[Tile-serving] [osm2pgsql] Add area reprojection facility (#454)
Paul Norman
notifications at github.com
Fri Oct 9 11:02:10 UTC 2015
> + * \return the area in projected units, or in EPSG 3857 if area reprojection is enabled
> + */
> +double geometry_builder::getArea(const geos::geom::Geometry *geom) const
> +{
> + // reprojection is not necessary, or has not been asked for.
> + if (!reprojection) {
> + return geom->getArea();
> + }
> +
> + // MultiPolygon - return sum of individual areas
> + if (const geos::geom::MultiPolygon* multi = dynamic_cast<const geos::geom::MultiPolygon *>(geom)) {
> + double area = 0.0;
> + for (std::size_t i=0; i<multi->getNumGeometries(); i++) {
> + area += getArea(multi->getGeometryN(i));
> + }
> + return area;
@lonvia we don't currently have any usage of `std::accumulate` or lambdas, but do you think this should be
```c++
return std::accumulate(multi->begin(), multi->end(), 0.0,
[=](double a, const geos::geom::Geometry *geom) { return a + getArea(geom); });
```
---
Reply to this email directly or view it on GitHub:
https://github.com/openstreetmap/osm2pgsql/pull/454/files#r41619111
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/tile-serving/attachments/20151009/35349b0e/attachment.html>
More information about the Tile-serving
mailing list