From cd363a97d0ee31fcd2b81a1b110b63c77e750716 Mon Sep 17 00:00:00 2001 From: Anshul Singhvi Date: Sat, 26 Jul 2025 00:09:06 -0400 Subject: [PATCH 1/2] Collect all LinearRingTrant to LineStringTrait --- ext/GeometryBasicsGeoInterfaceExt.jl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ext/GeometryBasicsGeoInterfaceExt.jl b/ext/GeometryBasicsGeoInterfaceExt.jl index ed5da70b..c77c46d0 100644 --- a/ext/GeometryBasicsGeoInterfaceExt.jl +++ b/ext/GeometryBasicsGeoInterfaceExt.jl @@ -34,6 +34,7 @@ geointerface_geomtype(::GeoInterface.PointTrait) = Point geointerface_geomtype(::GeoInterface.MultiPointTrait) = MultiPoint geointerface_geomtype(::GeoInterface.LineTrait) = Line geointerface_geomtype(::GeoInterface.LineStringTrait) = LineString +geointerface_geomtype(::GeoInterface.LinearRingTrait) = LineString geointerface_geomtype(::GeoInterface.MultiLineStringTrait) = MultiLineString geointerface_geomtype(::GeoInterface.PolygonTrait) = Polygon geointerface_geomtype(::GeoInterface.MultiPolygonTrait) = MultiPolygon @@ -111,7 +112,7 @@ function GeoInterface.convert(::Type{Point}, type::PointTrait, geom) return Point{2,T}(x, y) end end -function GeoInterface.convert(::Type{LineString}, type::LineStringTrait, geom) +function GeoInterface.convert(::Type{LineString}, type::Union{LineStringTrait, LinearRingTrait}, geom) g1 = getgeom(geom, 1) x, y = GeoInterface.x(g1), GeoInterface.y(g1) if GeoInterface.is3d(geom) From 773ff33eea204a6d147e850f7cfc7136c0ff7991 Mon Sep 17 00:00:00 2001 From: Anshul Singhvi Date: Sat, 26 Jul 2025 01:22:34 -0400 Subject: [PATCH 2/2] Add Line convert method --- ext/GeometryBasicsGeoInterfaceExt.jl | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/ext/GeometryBasicsGeoInterfaceExt.jl b/ext/GeometryBasicsGeoInterfaceExt.jl index c77c46d0..38d83aef 100644 --- a/ext/GeometryBasicsGeoInterfaceExt.jl +++ b/ext/GeometryBasicsGeoInterfaceExt.jl @@ -112,6 +112,18 @@ function GeoInterface.convert(::Type{Point}, type::PointTrait, geom) return Point{2,T}(x, y) end end +function GeoInterface.convert(::Type{Line}, type::LineTrait, geom) + g1, g2 = GeoInterface.getgeom(geom) + x, y = GeoInterface.x(g1), GeoInterface.y(g1) + if GeoInterface.is3d(geom) + z = GeoInterface.z(g1) + T = promote_type(typeof(x), typeof(y), typeof(z)) + return Line{3,T}(Point{3,T}(x, y, z), Point{3,T}(GeoInterface.x(g2), GeoInterface.y(g2), GeoInterface.z(g2))) + else + T = promote_type(typeof(x), typeof(y)) + return Line{2,T}(Point{2,T}(x, y), Point{2,T}(GeoInterface.x(g2), GeoInterface.y(g2))) + end +end function GeoInterface.convert(::Type{LineString}, type::Union{LineStringTrait, LinearRingTrait}, geom) g1 = getgeom(geom, 1) x, y = GeoInterface.x(g1), GeoInterface.y(g1)