[OSM-dev] Area center calculation

Igor Brejc igor.brejc at gmail.com
Tue Oct 5 20:50:29 BST 2010


  Hi,

You could take a look at Kosmos's code 
(http://downloads.igorbrejc.net/osm/kosmos/  BSD license), I've 
implemented an algorithm for finding a point in the area which should be 
a good enough approximation of the center. I use it for Maperitive, too. 
But it's definitively not the same as that of Mapnik.

A simple centroid will not work since the point can be outside of the 
polygon for concave polygons.

As for tapping POIs based on static bitmaps like tiles, I think you'll 
need to find another approach for this - probably by having to download 
the vector data for a limited area and then calculating (and rendering 
symbol overlays) yourselves.

Regards,
Igor

On 5.10.2010 18:26, Csongor Nemes wrote:
> Hi,
>
> I am contacting you regarding the calculation of centers of areas in OSM.
>
> Our product, OpenMaps (currently available on the iPhone and the iPod 
> touch), is the only one which lets you tap on POIs on the map. We use 
> the default OSM map as the default map type in our app, but the user 
> can change to OpenCycleMap and OpenPisteMap as well; also the user can 
> add custom map types (e.g. OSM Osmarender). We need to know the exact 
> location of the symbol inside an area (currently we use an algorithm 
> which doesn't always match the rendered symbol's location). The best 
> solution (from our perspective) would be to request the calculated 
> center from OSM, but I'm not sure that it's possible. Otherwise we 
> will implement the algorithm. If I'm not mistaken slightly different 
> algorithms are implemented in different renderers. We are interested 
> in the Mapnik version for now. Point me in the right direction, 
> please; where can I find a description of the algorithm and which 
> source files contain the implementation?
>
> Thank you,
> Csongor Nemes,
> IZE, Ltd.
>
>
> _______________________________________________
> dev mailing list
> dev at openstreetmap.org
> http://lists.openstreetmap.org/listinfo/dev


-- 
http://igorbrejc.net




More information about the dev mailing list