[Tile-serving] [osm2pgsql] Add area reprojection facility (#454)

Sarah Hoffmann notifications at github.com
Sun Oct 25 07:52:36 UTC 2015


> +        return std::accumulate(multi->begin(), multi->end(), 0.0,
> +                               [=](double a, const geos::geom::Geometry *geom) { return a + getArea(geom); });
> +    }
> +
> +    const auto *poly = dynamic_cast<const geos::geom::Polygon *>(geom);
> +    if (!poly) {
> +        return 0.0;
> +    }
> +
> +    // standard polygon - reproject rings individually, then assemble polygon and
> +    // compute area.
> +
> +    const auto *ext = poly->getExteriorRing();
> +    auto *projectedExt = reproject_linearring(ext);
> +    auto nholes = poly->getNumInteriorRing();
> +    std::vector<geos::geom::Geometry *> *projectedHoles = new std::vector<geos::geom::Geometry *>(nholes);

Wrap in std::unique_ptr<> and use release() below in createPolygon() to ensure memory gets clean up when an exception is thrown.

---
Reply to this email directly or view it on GitHub:
https://github.com/openstreetmap/osm2pgsql/pull/454/files#r42942335
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/tile-serving/attachments/20151025/1276541a/attachment.html>


More information about the Tile-serving mailing list