1+ ``` @meta
2+ CurrentModule = GeoInterface
3+ ```
4+
15# Implementing GeoInterface
26GeoInterface requires six functions to be defined for a custom geometry. On top of that
37it could be useful to also implement some optional methods if they apply or are faster than the fallbacks.
@@ -9,7 +13,7 @@ also implement those interfaces where applicable.
913
1014``` julia
1115GeoInterface. isgeometry (geom:: customgeom ):: Bool = true
12- GeoInterface. geomtype (geom:: customgeom ):: DataType = GeoInterface. XTrait () # <: AbstractGeometryTrait
16+ GeoInterface. geomtype (geom:: customgeom ):: DataType = GeoInterface. XTraitTrait () # <: AbstractGeometryTrait
1317GeoInterface. ncoord (geomtype (geom), geom:: customgeom ):: Integer
1418GeoInterface. getcoord (geomtype (geom), geom:: customgeom , i):: Real # only for PointTraits
1519GeoInterface. ngeom (geomtype (geom), geom:: customgeom ):: Integer
@@ -82,7 +86,7 @@ GeoInterface.isgeometry(geom::customgeom)::Bool = true
8286
8387A ` geom::customgeom ` with "Point"-like traits implements
8488``` julia
85- GeoInterface. geomtype (geom:: customgeom ):: DataType = GeoInterface. Point ()
89+ GeoInterface. geomtype (geom:: customgeom ):: DataType = GeoInterface. PointTrait ()
8690GeoInterface. ncoord (:: GeoInterface.PointTrait , geom:: customgeom ):: Integer
8791GeoInterface. getcoord (:: GeoInterface.PointTrait , geom:: customgeom , i):: Real
8892
@@ -93,7 +97,7 @@ GeoInterface.getgeom(::GeoInterface.PointTrait, geom::customgeom, i) = nothing
9397
9498A ` geom::customgeom ` with "LineString"-like traits implements the following methods:
9599``` julia
96- GeoInterface. geomtype (geom:: customgeom ):: DataType = GeoInterface. LineString ()
100+ GeoInterface. geomtype (geom:: customgeom ):: DataType = GeoInterface. LineStringTrait ()
97101GeoInterface. ncoord (:: GeoInterface.LineStringTrait , geom:: customgeom ):: Integer
98102
99103# These alias for npoint and getpoint
@@ -107,7 +111,7 @@ GeoInterface.length(::GeoInterface.LineStringTrait, geom::customgeom)::Real
107111```
108112A ` geom::customgeom ` with "Polygon"-like traits can implement the following methods:
109113``` julia
110- GeoInterface. geomtype (geom:: customgeom ):: DataType = GeoInterface. Polygon ()
114+ GeoInterface. geomtype (geom:: customgeom ):: DataType = GeoInterface. PolygonTrait ()
111115GeoInterface. ncoord (:: GeoInterface.PolygonTrait , geom:: customgeom ):: Integer
112116
113117# These alias for nring and getring
@@ -123,15 +127,15 @@ GeoInterface.boundary(::GeoInterface.PolygonTrait, geom::customgeom)::"LineStrin
123127
124128A ` geom::customgeom ` with "GeometryCollection"-like traits has to implement the following methods:
125129``` julia
126- GeoInterface. geomtype (geom:: customgeom ) = GeoInterface. GeometryCollection ()
130+ GeoInterface. geomtype (geom:: customgeom ) = GeoInterface. GeometryCollectionTrait ()
127131GeoInterface. ncoord (:: GeoInterface.GeometryCollectionTrait , geom:: customgeom ):: Integer
128132GeoInterface. ngeom (:: GeoInterface.GeometryCollectionTrait , geom:: customgeom ):: Integer
129133GeoInterface. getgeom (:: GeoInterface.GeometryCollectionTrait ,geom:: customgeomm , i): :" GeometryTrait"
130134```
131135
132136A ` geom::customgeom ` with "MultiPoint"-like traits has to implement the following methods:
133137``` julia
134- GeoInterface. geomtype (geom:: customgeom ) = GeoInterface. MultiPoint ()
138+ GeoInterface. geomtype (geom:: customgeom ) = GeoInterface. MultiPointTrait ()
135139GeoInterface. ncoord (:: GeoInterface.MultiPointTrait , geom:: customgeom ):: Integer
136140
137141# These alias for npoint and getpoint
@@ -141,7 +145,7 @@ GeoInterface.getgeom(::GeoInterface.MultiPointTrait, geom::customgeom, i)::"Poin
141145
142146A ` geom::customgeom ` with "MultiLineString"-like traits has to implement the following methods:
143147``` julia
144- GeoInterface. geomtype (geom:: customgeom ) = GeoInterface. MultiLineString ()
148+ GeoInterface. geomtype (geom:: customgeom ) = GeoInterface. MultiLineStringTrait ()
145149GeoInterface. ncoord (:: GeoInterface.MultiLineStringTrait , geom:: customgeom ):: Integer
146150
147151# These alias for nlinestring and getlinestring
@@ -151,7 +155,7 @@ GeoInterface.getgeom(::GeoInterface.MultiLineStringTrait,geom::customgeomm, i)::
151155
152156A ` geom::customgeom ` with "MultiPolygon"-like traits has to implement the following methods:
153157``` julia
154- GeoInterface. geomtype (geom:: customgeom ) = GeoInterface. MultiPolygon ()
158+ GeoInterface. geomtype (geom:: customgeom ) = GeoInterface. MultiPolygonTrait ()
155159GeoInterface. ncoord (:: GeoInterface.MultiPolygonTrait , geom:: customgeom ):: Integer
156160
157161# These alias for npolygon and getpolygon
0 commit comments