Skip to content

Commit d0c7394

Browse files
committed
apply fixes iteratively, not by trait
this is worse for performance, better for predictability and correctness (the most complex trait will be chosen for the application rather than the least complex)
1 parent ec33788 commit d0c7394

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/transformations/correction/geometry_correction.jl

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,16 @@ application_level(gc::GeometryCorrection) = error("Not implemented yet for $(gc)
5252

5353
(gc::GeometryCorrection)(trait::GI.AbstractGeometryTrait, geometry) = error("Not implemented yet for $(gc) and $(trait).")
5454

55-
function fix(geometry; corrections = GeometryCorrection[ClosedRing(), CutAtAntimeridianAndPoles()], kwargs...)
55+
function fix(geometry; corrections = GeometryCorrection[CutAtAntimeridianAndPoles(), ClosedRing()], kwargs...)
56+
final_geoms = geometry
57+
# Iterate through the corrections and apply them to the input.
58+
# This allocates a _lot_, especially when reconstructing tables,
59+
# but it's the only fully general way to do this that I can think of.
60+
for correction in corrections
61+
final_geoms = apply(correction, application_level(correction), final_geoms; kwargs...)
62+
end
63+
#=
64+
# This was the old implementation
5665
application_levels = application_level.(corrections)
5766
final_geometry = geometry
5867
for trait in (GI.PointTrait(), GI.MultiPointTrait(), GI.LineStringTrait(), GI.LinearRingTrait(), GI.MultiLineStringTrait(), GI.PolygonTrait(), GI.MultiPolygonTrait())
@@ -65,6 +74,8 @@ function fix(geometry; corrections = GeometryCorrection[ClosedRing(), CutAtAntim
6574
final_geometry = apply(net_function, trait, final_geometry; kwargs...)
6675
end
6776
return final_geometry
77+
=#
78+
return final_geoms
6879
end
6980

7081
# ## Available corrections

0 commit comments

Comments
 (0)