Skip to content

Commit 32a0ef4

Browse files
committed
Reuse the same reprojection
Instead of creating a new one each time we have to compute the area.
1 parent 3d4bb81 commit 32a0ef4

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/output-pgsql.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,11 @@ static double calculate_area(bool reproject_area,
4848
geom::geometry_t const &geom4326,
4949
geom::geometry_t const &geom)
5050
{
51+
static thread_local auto const proj3857 =
52+
reprojection::create_projection(3857);
53+
5154
if (reproject_area) {
52-
// XXX there is some overhead here always dynamically
53-
// creating the same projection object. Needs refactoring.
54-
auto const ogeom =
55-
geom::transform(geom4326, *reprojection::create_projection(3857));
55+
auto const ogeom = geom::transform(geom4326, *proj3857);
5656
return geom::area(ogeom);
5757
}
5858
return geom::area(geom);

0 commit comments

Comments
 (0)