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

Frederik Ramm notifications at github.com
Thu Oct 8 09:02:24 UTC 2015


> +    {
> +        double area = 0.0;
> +        for (std::size_t i=0; i<multi->getNumGeometries(); i++)
> +        {
> +            area += getArea(multi->getGeometryN(i));
> +        }
> +        return area;
> +    }
> +
> +    const geos::geom::Polygon *poly = dynamic_cast<const geos::geom::Polygon *>(geom);
> +    if (!poly) {
> +        return 0.0;
> +    }
> +
> +    // standard polygon - reproject rings individually, then assemble polygon and
> +    // compute area.

Thing is we can only reproject individual coordinate pairs, and the wrapper I built will dissect a polygon into rings, the rings into coordinate pairs, reproject them, and reassemble rings and a polygon from that. The wrapper does not have the capability to reproject a multipolygon; this would require iterating through the getGeometryNs of the multipolygon, reprojecting the individual members, and then calling the GEOS factory to build a multipolygon from all that in the end. It would then be possible to call getArea on the multipolygon. But the building of the multipolygon would IMHO be unnecessary extra code and extra memory allocation/release.

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


More information about the Tile-serving mailing list