1
1
//
2
2
// Copyright (c) ShuYu Wang <andelf@gmail.com>, Feather Workshop and Pirmin Kalberer. All rights reserved.
3
3
//
4
+ //! Read and write geometries in [OGC WKB](http://www.opengeospatial.org/standards/sfa) format.
5
+ //!
6
+ //! Support for SRID information according to [PostGIS EWKB extensions](https://svn.osgeo.org/postgis/trunk/doc/ZMSgeoms.txt)
4
7
5
8
use types as postgis;
6
9
use std;
@@ -12,10 +15,6 @@ use std::iter::FromIterator;
12
15
use byteorder:: { ReadBytesExt , WriteBytesExt , BigEndian , LittleEndian } ;
13
16
use error:: Error ;
14
17
15
- // OGC WKB specification: http://www.opengeospatial.org/standards/sfa
16
- // PostGIS EWKB extensions: https://svn.osgeo.org/postgis/trunk/doc/ZMSgeoms.txt
17
-
18
-
19
18
// --- Structs for reading PostGIS geometries into
20
19
21
20
#[ derive( PartialEq , Clone , Debug ) ]
@@ -78,6 +77,7 @@ pub trait EwkbRead: fmt::Debug + Sized {
78
77
Self :: read_ewkb_body ( raw, is_be, srid)
79
78
}
80
79
80
+ #[ doc( hidden) ]
81
81
fn read_ewkb_body < R : Read > ( raw : & mut R , is_be : bool , srid : Option < i32 > ) -> Result < Self , Error > ;
82
82
}
83
83
@@ -114,6 +114,7 @@ pub trait EwkbWrite: fmt::Debug + Sized {
114
114
self . write_ewkb_body ( w) ?;
115
115
Ok ( ( ) )
116
116
}
117
+ #[ doc( hidden) ]
117
118
fn write_ewkb_body < W : Write +?Sized > ( & self , w : & mut W ) -> Result < ( ) , Error > ;
118
119
119
120
fn to_hex_ewkb ( & self ) -> String {
@@ -720,9 +721,13 @@ point_container_write!(LineString and AsEwkbLineString for LineStringT
720
721
to EwkbLineString with type code 0x02 ,
721
722
command write_ewkb_body) ;
722
723
724
+ /// OGC LineString type
723
725
pub type LineString = LineStringT < Point > ;
726
+ /// OGC LineStringZ type
724
727
pub type LineStringZ = LineStringT < PointZ > ;
728
+ /// OGC LineStringM type
725
729
pub type LineStringM = LineStringT < PointM > ;
730
+ /// OGC LineStringZM type
726
731
pub type LineStringZM = LineStringT < PointZM > ;
727
732
728
733
/// Polygon
@@ -733,9 +738,13 @@ geometry_container_write!(Polygon and AsEwkbPolygon for PolygonT
733
738
contains EwkbLineString , LineStringT as LineString named rings,
734
739
command write_ewkb_body) ;
735
740
741
+ /// OGC Polygon type
736
742
pub type Polygon = PolygonT < Point > ;
743
+ /// OGC PolygonZ type
737
744
pub type PolygonZ = PolygonT < PointZ > ;
745
+ /// OGC PolygonM type
738
746
pub type PolygonM = PolygonT < PointM > ;
747
+ /// OGC PolygonZM type
739
748
pub type PolygonZM = PolygonT < PointZM > ;
740
749
741
750
/// MultiPoint
@@ -745,9 +754,13 @@ point_container_write!(MultiPoint and AsEwkbMultiPoint for MultiPointT
745
754
to EwkbMultiPoint with type code 0x04 ,
746
755
command write_ewkb) ;
747
756
757
+ /// OGC MultiPoint type
748
758
pub type MultiPoint = MultiPointT < Point > ;
759
+ /// OGC MultiPointZ type
749
760
pub type MultiPointZ = MultiPointT < PointZ > ;
761
+ /// OGC MultiPointM type
750
762
pub type MultiPointM = MultiPointT < PointM > ;
763
+ /// OGC MultiPointZM type
751
764
pub type MultiPointZM = MultiPointT < PointZM > ;
752
765
753
766
/// MultiLineString
@@ -758,9 +771,13 @@ geometry_container_write!(MultiLineString and AsEwkbMultiLineString for MultiLin
758
771
contains EwkbLineString , LineStringT as LineString named lines,
759
772
command write_ewkb) ;
760
773
774
+ /// OGC MultiLineString type
761
775
pub type MultiLineString = MultiLineStringT < Point > ;
776
+ /// OGC MultiLineStringZ type
762
777
pub type MultiLineStringZ = MultiLineStringT < PointZ > ;
778
+ /// OGC MultiLineStringM type
763
779
pub type MultiLineStringM = MultiLineStringT < PointM > ;
780
+ /// OGC MultiLineStringZM type
764
781
pub type MultiLineStringZM = MultiLineStringT < PointZM > ;
765
782
766
783
@@ -772,9 +789,13 @@ geometry_container_write!(multipoly MultiPolygon and AsEwkbMultiPolygon for Mult
772
789
contains EwkbPolygon , PolygonT as Polygon named polygons,
773
790
command write_ewkb) ;
774
791
792
+ /// OGC MultiPolygon type
775
793
pub type MultiPolygon = MultiPolygonT < Point > ;
794
+ /// OGC MultiPolygonZ type
776
795
pub type MultiPolygonZ = MultiPolygonT < PointZ > ;
796
+ /// OGC MultiPolygonM type
777
797
pub type MultiPolygonM = MultiPolygonT < PointM > ;
798
+ /// OGC MultiPolygonZM type
778
799
pub type MultiPolygonZM = MultiPolygonT < PointZM > ;
779
800
780
801
@@ -824,13 +845,16 @@ impl<P> EwkbRead for GeometryT<P>
824
845
}
825
846
}
826
847
848
+ /// OGC Geometry type
827
849
pub type Geometry = GeometryT < Point > ;
850
+ /// OGC GeometryZ type
828
851
pub type GeometryZ = GeometryT < PointZ > ;
852
+ /// OGC GeometryM type
829
853
pub type GeometryM = GeometryT < PointM > ;
854
+ /// OGC GeometryZM type
830
855
pub type GeometryZM = GeometryT < PointZM > ;
831
856
832
857
833
- /// GeometryCollection
834
858
#[ derive( Debug ) ]
835
859
pub struct GeometryCollectionT < P : postgis:: Point + EwkbRead > {
836
860
pub geometries : Vec < GeometryT < P > >
@@ -877,9 +901,13 @@ impl<P> EwkbRead for GeometryCollectionT<P>
877
901
}
878
902
}
879
903
904
+ /// OGC GeometryCollection type
880
905
pub type GeometryCollection = GeometryCollectionT < Point > ;
906
+ /// OGC GeometryCollectionZ type
881
907
pub type GeometryCollectionZ = GeometryCollectionT < PointZ > ;
908
+ /// OGC GeometryCollectionM type
882
909
pub type GeometryCollectionM = GeometryCollectionT < PointM > ;
910
+ /// OGC GeometryCollectionZM type
883
911
pub type GeometryCollectionZM = GeometryCollectionT < PointZM > ;
884
912
885
913
0 commit comments