@@ -10,6 +10,14 @@ function Base.show(io::IO, geo::AbstractGeometry)
1010 end
1111end
1212
13+ function open_issue_if_conversion_makes_sense (T:: Type , id)
14+ msg = """ LibGEOS: Can't convert a pointer to an element with a GeomType ID id = $id (GEOSGeomType = $(GEOSGeomTypes (id)) )
15+ to a geometry of type $T (yet).
16+ Please open an issue if you think this conversion makes sense.")
17+ """
18+ error (msg)
19+ end
20+
1321mutable struct Point <: AbstractGeometry
1422 ptr:: GEOSGeom
1523 context:: GEOSContext
@@ -19,8 +27,7 @@ mutable struct Point <: AbstractGeometry
1927 point = if id == GEOS_POINT
2028 point = new (cloneGeom (obj, context), context)
2129 else
22- error (" LibGEOS: Can't convert a pointer to an element with a GeomType ID of $id to a point (yet).
23- Please open an issue if you think this conversion makes sense." )
30+ open_issue_if_conversion_makes_sense (Point, id)
2431 end
2532 finalizer (destroyGeom, point)
2633 point
@@ -50,8 +57,7 @@ mutable struct MultiPoint <: AbstractGeometry
5057 context
5158 )
5259 else
53- error (" LibGEOS: Can't convert a pointer to an element with a GeomType ID of $id to a multipoint (yet).
54- Please open an issue if you think this conversion makes sense." )
60+ open_issue_if_conversion_makes_sense (MultiPoint, id)
5561 end
5662 finalizer (destroyGeom, multipoint)
5763 multipoint
@@ -83,8 +89,7 @@ mutable struct LineString <: AbstractGeometry
8389 line = if id == GEOS_LINESTRING
8490 new (cloneGeom (obj, context), context)
8591 else
86- error (" LibGEOS: Can't convert a pointer to an element with a GeomType ID of $id to a linestring (yet).
87- Please open an issue if you think this conversion makes sense." )
92+ open_issue_if_conversion_makes_sense (LineString, id)
8893 end
8994 finalizer (destroyGeom, line)
9095 line
@@ -115,8 +120,7 @@ mutable struct MultiLineString <: AbstractGeometry
115120 [cloneGeom (obj, context)],
116121 context), context)
117122 else
118- error (" LibGEOS: Can't convert a pointer to an element with a GeomType ID of $id to a multi-linestring (yet).
119- Please open an issue if you think this conversion makes sense." )
123+ open_issue_if_conversion_makes_sense (MultiLineString, id)
120124 end
121125 finalizer (destroyGeom, multiline)
122126 multiline
@@ -147,8 +151,7 @@ mutable struct LinearRing <: AbstractGeometry
147151 ring = if id == GEOS_LINEARRING
148152 new (cloneGeom (obj, context), context)
149153 else
150- error (" LibGEOS: Can't convert a pointer to an element with a GeomType ID of $id to a linear ring (yet).
151- Please open an issue if you think this conversion makes sense." )
154+ open_issue_if_conversion_makes_sense (LinearRing, id)
152155 end
153156 finalizer (destroyGeom, ring)
154157 ring
@@ -174,8 +177,7 @@ mutable struct Polygon <: AbstractGeometry
174177 elseif id == GEOS_LINEARRING
175178 new (cloneGeom (createPolygon (obj, context), context), context)
176179 else
177- error (" LibGEOS: Can't convert a pointer to an element with a GeomType ID of $id to a polygon (yet).
178- Please open an issue if you think this conversion makes sense." )
180+ open_issue_if_conversion_makes_sense (Polygon, id)
179181 end
180182 finalizer (destroyGeom, polygon)
181183 polygon
@@ -214,8 +216,7 @@ mutable struct MultiPolygon <: AbstractGeometry
214216 context
215217 )
216218 else
217- error (" LibGEOS: Can't convert a pointer to an element with a GeomType ID of $id to a multi-polygon (yet).
218- Please open an issue if you think this conversion makes sense." )
219+ open_issue_if_conversion_makes_sense (MultiPolygon, id)
219220 end
220221 finalizer (destroyGeom, multipolygon)
221222 multipolygon
@@ -254,8 +255,7 @@ mutable struct GeometryCollection <: AbstractGeometry
254255 geometrycollection = if id == GEOS_GEOMETRYCOLLECTION
255256 new (cloneGeom (obj, context), context)
256257 else
257- error (" LibGEOS: Can't convert a pointer to an element with a GeomType ID of $id to a geometry collection (yet).
258- Please open an issue if you think this conversion makes sense." )
258+ open_issue_if_conversion_makes_sense (GeometryCollection, id)
259259 end
260260 finalizer (destroyGeom, geometrycollection)
261261 geometrycollection
0 commit comments