Skip to content

Commit dc16731

Browse files
committed
fix geointerface conversion performance
1 parent e6e4a87 commit dc16731

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

src/geointerface.jl

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,7 @@ GeoInterface.getgeom(::MultiPointTrait, g::MultiPoint, i::Int) = g[i]
6060
function GeoInterface.ngeom(::MultiLineStringTrait, g::MultiLineString)
6161
return length(g)
6262
end
63-
function GeoInterface.getgeom(::MultiLineStringTrait, g::MultiLineString,
64-
i::Int)
63+
function GeoInterface.getgeom(::MultiLineStringTrait, g::MultiLineString, i::Int)
6564
return g[i]
6665
end
6766
GeoInterface.ncoord(::MultiLineStringTrait, g::MultiLineString{Dim}) where {Dim} = Dim
@@ -123,7 +122,7 @@ function GeoInterface.convert(::Type{Polygon}, type::PolygonTrait, geom)
123122
if GeoInterface.nhole(geom) == 0
124123
return Polygon(exterior)
125124
else
126-
interiors = GeoInterface.convert.(LineString, Ref(t), GeoInterface.gethole(geom))
125+
interiors = map(h -> GeoInterface.convert(LineString, t, h), GeoInterface.gethole(geom))
127126
return Polygon(exterior, interiors)
128127
end
129128
end
@@ -143,10 +142,10 @@ end
143142

144143
function GeoInterface.convert(::Type{MultiLineString}, type::MultiLineStringTrait, geom)
145144
t = LineStringTrait()
146-
return MultiLineString([GeoInterface.convert(LineString, t, l) for l in getgeom(geom)])
145+
return MultiLineString(map(l -> GeoInterface.convert(LineString, t, l), getgeom(geom)))
147146
end
148147

149148
function GeoInterface.convert(::Type{MultiPolygon}, type::MultiPolygonTrait, geom)
150149
t = PolygonTrait()
151-
return MultiPolygon([GeoInterface.convert(Polygon, t, poly) for poly in getgeom(geom)])
150+
return MultiPolygon(map(poly -> GeoInterface.convert(Polygon, t, poly), getgeom(geom)))
152151
end

0 commit comments

Comments
 (0)