Skip to content
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

Check the dimensions of child geoms when rebuilding #239

Open
wants to merge 2 commits into
base: as/usecore
Choose a base branch
from
Open
Show file tree
Hide file tree
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
21 changes: 16 additions & 5 deletions GeometryOpsCore/src/other_primitives.jl
Original file line number Diff line number Diff line change
Expand Up @@ -159,10 +159,21 @@ on geometries from other packages and specify how to rebuild them.
rebuild(geom, child_geoms; kw...) = rebuild(GI.trait(geom), geom, child_geoms; kw...)
function rebuild(trait::GI.AbstractTrait, geom, child_geoms; crs=GI.crs(geom), extent=nothing)
T = GI.geointerface_geomtype(trait)
if GI.is3d(geom)
# The Boolean type parameters here indicate "3d-ness" and "measure" coordinate, respectively.
return T{true,false}(child_geoms; crs, extent)
else
return T{false,false}(child_geoms; crs, extent)
haveZ = (GI.is3d(child) for child in child_geoms)
haveM = (GI.ismeasured(child) for child in child_geoms)

consistentZ = length(child_geoms) == 1 ? true : all(==(first(haveZ)), haveZ)
consistentM = length(child_geoms) == 1 ? true : all(==(first(haveM)), haveM)

if !consistentZ || !consistentM
@show consistentZ consistentM
@show GI.is3d.(child_geoms)
@show GI.ismeasured.(child_geoms)
throw(ArgumentError("child geometries do not have consistent 3d or measure attributes."))
end

hasZ = first(haveZ)
hasM = first(haveM)

return T{hasZ,hasM}(child_geoms; crs, extent)
end
5 changes: 5 additions & 0 deletions src/transformations/forcedims.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
function forcexy(geom)
return GO.apply(GO.GI.PointTrait(), geom) do point
(GI.x(point), GI.y(point))

Check warning on line 3 in src/transformations/forcedims.jl

View check run for this annotation

Codecov / codecov/patch

src/transformations/forcedims.jl#L1-L3

Added lines #L1 - L3 were not covered by tests
end
end
Loading