Skip to content

[WIP] GeoInterface improvements #264

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion ext/GeometryBasicsGeoInterfaceExt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -111,7 +112,19 @@ 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{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)
if GeoInterface.is3d(geom)
Expand Down
Loading