Skip to content

Commit c187e37

Browse files
committed
Eagerly compute extents in NaturalIndexing.prepare_naturally.
1 parent dea7093 commit c187e37

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/utils/NaturalIndexing.jl

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -237,8 +237,11 @@ GI.isgeometry(::Type{<: NaturallyIndexedRing}) = true
237237
GI.geomtrait(::NaturallyIndexedRing) = GI.LinearRingTrait()
238238

239239
function prepare_naturally(geom)
240-
return GO.apply(GI.PolygonTrait(), geom) do poly
241-
return GI.Polygon([GI.convert(NaturallyIndexedRing, GI.LinearRingTrait(), ring) for ring in GI.getring(poly)])
240+
crs = GI.crs(geom)
241+
return GO.apply(GI.PolygonTrait(), geom; calc_extent = true) do poly
242+
rings = [GI.convert(NaturallyIndexedRing, GI.LinearRingTrait(), ring) for ring in GI.getring(poly)]
243+
extent = mapreduce(GI.extent, Extents.union, rings)
244+
return GI.Polygon(rings; extent, crs)
242245
end
243246
end
244247

0 commit comments

Comments
 (0)