@@ -19,55 +19,67 @@ GeoInterface.geomtrait(::MultiPolygon) = MultiPolygonTrait()
19
19
GeoInterface. geomtrait (:: GeometryCollection ) = GeometryCollectionTrait ()
20
20
GeoInterface. geomtrait (geom:: PreparedGeometry ) = GeoInterface. geomtrait (geom. ownedby)
21
21
22
- GeoInterface. ngeom (:: AbstractGeometryTrait , geom:: AbstractGeometry ) =
23
- isEmpty (geom) ? 0 : numGeometries (geom)
24
- GeoInterface. ngeom (:: AbstractPointTrait , geom:: AbstractGeometry ) = 0
22
+ GeoInterface. ngeom (:: AbstractGeometryCollectionTrait , geom:: AbstractMultiGeometry ) =
23
+ isEmpty (geom) ? 0 : Int (numGeometries (geom))
24
+ GeoInterface. ngeom (:: LineStringTrait , geom:: LineString ) = Int (numPoints (geom))
25
+ GeoInterface. ngeom (:: LinearRingTrait , geom:: LinearRing ) = Int (numPoints (geom))
26
+ GeoInterface. ngeom (:: PolygonTrait , geom:: Polygon ) = Int (numInteriorRings (geom)) + 1
27
+ GeoInterface. ngeom (t:: AbstractGeometryTrait , geom:: PreparedGeometry ) =
28
+ GeoInterface. ngeom (t, geom. ownedby)
29
+ GeoInterface. ngeom (:: AbstractPointTrait , geom:: Point ) = 0
30
+ GeoInterface. ngeom (:: AbstractPointTrait , geom:: PreparedGeometry ) = 0
25
31
26
- function GeoInterface. getgeom (:: AbstractGeometryTrait , geom:: AbstractGeometry , i)
32
+ function GeoInterface. getgeom (
33
+ :: AbstractGeometryCollectionTrait ,
34
+ geom:: AbstractMultiGeometry ,
35
+ i,
36
+ )
27
37
getGeometry (geom, i)
28
38
end
29
-
30
- GeoInterface. getgeom (:: AbstractPointTrait , geom:: AbstractGeometry , i) = nothing
31
- GeoInterface . ngeom ( :: AbstractGeometryTrait , geom :: Union{ LineString,LinearRing} ) =
32
- numPoints ( geom)
33
- GeoInterface . ngeom (t :: AbstractPointTrait , geom :: Union{LineString,LinearRing} ) = 0
34
- GeoInterface. getgeom (:: AbstractGeometryTrait , geom :: Union{LineString,LinearRing} , i) =
35
- Point ( getPoint (geom, i))
36
- GeoInterface . getgeom ( :: AbstractPointTrait , geom:: Union{LineString,LinearRing} , i) = nothing
37
-
38
- GeoInterface . ngeom ( :: AbstractGeometryTrait , geom :: Polygon ) = numInteriorRings ( geom) + 1
39
- GeoInterface. ngeom ( :: AbstractPointTrait , geom:: Polygon ) = 0
40
- function GeoInterface. getgeom (:: AbstractGeometryTrait , geom:: Polygon , i)
39
+ GeoInterface . getgeom ( :: MultiPointTrait , geom :: MultiPoint , i) = getGeometry (geom, i) :: Point
40
+ GeoInterface. getgeom (:: MultiLineStringTrait , geom:: MultiLineString , i) =
41
+ getGeometry (geom, i) :: LineString
42
+ GeoInterface . getgeom ( :: MultiPolygonTrait , geom:: MultiPolygon , i) =
43
+ getGeometry (geom, i) :: Polygon
44
+ GeoInterface. getgeom (
45
+ :: Union{LineStringTrait,LinearRingTrait} ,
46
+ geom:: Union{LineString,LinearRing} ,
47
+ i,
48
+ ) = Point ( getPoint ( geom, i))
49
+ GeoInterface. getgeom (t :: AbstractPointTrait , geom:: PreparedGeometry ) = nothing
50
+ function GeoInterface. getgeom (:: PolygonTrait , geom:: Polygon , i:: Int )
41
51
if i == 1
42
52
LinearRing (exteriorRing (geom))
43
53
else
44
54
LinearRing (interiorRing (geom, i - 1 ))
45
55
end
46
56
end
47
- GeoInterface. getgeom (:: AbstractPointTrait , geom:: Polygon , i) = nothing
48
-
49
- GeoInterface. ngeom (t:: AbstractGeometryTrait , geom:: PreparedGeometry ) =
50
- GeoInterface. ngeom (t, geom. ownedby)
51
- GeoInterface. ngeom (t:: AbstractPointTrait , geom:: PreparedGeometry ) = 0
52
57
GeoInterface. getgeom (t:: AbstractGeometryTrait , geom:: PreparedGeometry , i) =
53
58
GeoInterface. getgeom (t, geom. ownedby, i)
54
59
GeoInterface. getgeom (t:: AbstractPointTrait , geom:: PreparedGeometry , i) = 0
55
60
56
- GeoInterface. ncoord (:: AbstractGeometryTrait , geom:: AbstractGeometry ) =
57
- isEmpty (geom) ? 0 : getCoordinateDimension (geom)
58
- GeoInterface. getcoord (:: AbstractGeometryTrait , geom:: AbstractGeometry , i) =
59
- getCoordinates (getCoordSeq (geom), 1 )[i]
61
+ GeoInterface. coordinates (t:: AbstractPointTrait , geom:: Point ) = collect (getcoord (t, geom))
62
+ GeoInterface. coordinates (t:: AbstractPointTrait , geom:: AbstractGeometry ) = nothing
63
+ GeoInterface. coordinates (t:: AbstractGeometryTrait , geom:: AbstractGeometry ) =
64
+ [GeoInterface. coordinates (x) for x in getgeom (t, geom)]
65
+ GeoInterface. coordinates (t:: AbstractGeometryCollectionTrait , geom:: AbstractMultiGeometry ) =
66
+ [GeoInterface. coordinates (x) for x in getgeom (t, geom)]
60
67
68
+ GeoInterface. ncoord (:: AbstractGeometryTrait , geom:: AbstractGeometry ) =
69
+ isEmpty (geom) ? 0 : Int (getCoordinateDimension (geom))
61
70
GeoInterface. ncoord (t:: AbstractGeometryTrait , geom:: PreparedGeometry ) =
62
71
GeoInterface. ncoord (t, geom. ownedby)
72
+
73
+ GeoInterface. getcoord (:: AbstractGeometryTrait , geom:: AbstractGeometry , i) =
74
+ getCoordinates (getCoordSeq (geom), 1 )[i]
63
75
GeoInterface. getcoord (t:: AbstractGeometryTrait , geom:: PreparedGeometry , i) =
64
76
GeoInterface. getcoord (t, geom. ownedby, i)
65
77
66
78
# FIXME this doesn't work for 3d geoms, Z is missing
67
79
function GeoInterface. extent (:: AbstractGeometryTrait , geom:: AbstractGeometry )
68
80
# minx, miny, maxx, maxy = getExtent(geom)
69
81
env = envelope (geom)
70
- return Extent (X = (getXMin (env), getXMax (env)), Y = (getYMin (env), getYMax (env)))
82
+ return Extent (; X = (getXMin (env), getXMax (env)), Y = (getYMin (env), getYMax (env)))
71
83
end
72
84
73
85
GI. convert (:: Type{Point} , :: PointTrait , geom:: Point ; context = nothing ) = geom
@@ -180,7 +192,6 @@ function _geom_to_coord_seq(geom, context)
180
192
return seq
181
193
end
182
194
183
-
184
195
GeoInterface. distance (
185
196
:: AbstractGeometryTrait ,
186
197
:: AbstractGeometryTrait ,
@@ -268,7 +279,6 @@ GeoInterface.union(
268
279
269
280
GeoInterfaceRecipes. @enable_geo_plots AbstractGeometry
270
281
271
-
272
282
# -----
273
283
# LibGeos operations for any GeoInterface.jl compatible geometries
274
284
# -----
0 commit comments