[OSM-dev] Area center calculation

Tom Hughes tom at compton.nu
Tue Oct 5 17:34:39 BST 2010

On 05/10/10 17:26, Csongor Nemes wrote:

> 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?

You'd be better off asking on the mapnik-dev list but I believe that the 
calculation comes from geos and is a very simple centre-of-mass type 

Note that there was some discussion at the recent mapnik code sprint of 
making this more intelligent, so I wouldn't count on it staying the 
same. Equally it is quite likely that at some point mapnik may get the 
ability to move the icon/label around a bit to try and find free space - 
if that happens then there won't be the sort of algorithm that you're 
looking for at all.


Tom Hughes (tom at compton.nu)

More information about the dev mailing list