diff --git a/GeometryOpsCore/src/other_primitives.jl b/GeometryOpsCore/src/other_primitives.jl index b0ac8c6b7..b51365e40 100644 --- a/GeometryOpsCore/src/other_primitives.jl +++ b/GeometryOpsCore/src/other_primitives.jl @@ -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 diff --git a/src/transformations/forcedims.jl b/src/transformations/forcedims.jl new file mode 100644 index 000000000..d0525e214 --- /dev/null +++ b/src/transformations/forcedims.jl @@ -0,0 +1,5 @@ +function forcexy(geom) + return GO.apply(GO.GI.PointTrait(), geom) do point + (GI.x(point), GI.y(point)) + end +end