[OSM-dev] country boundary polygons
Andy Deakin
andy.deakin at pcmend.net
Tue Mar 31 14:43:12 BST 2009
Hi Marcus,
(Sent off list - I don't like clogging up the dev list)
Thanks for your comments. What I have is a rough first approximation.
I did have a look at your code, but there are some countries (e.g.
Russia, US) for which the MBR is huge, (so they appear in the results
for lots of countries) and I didn't really want the overhead of loading
the whole polygon. From what I can see you have a limited number of
countries on there which will make it a lot faster.
Perhaps I will look at splitting up the country polygons along lat/long
boundaries, so that the number of verticies of e.g. Russia which appear
in the mbr for e.g. Latvia are fewer. This will reduce the loading time
and computation time. This has the downside of having multiple polygons
for each country, but I think this is ok, as it would only need a few
extra points (e.g. at corners) to define sub-polygons.
I would like to implement more accurate checking for borders, and will
revisit this when I have time.
Kind regards,
Andy
marcus.wolschon at googlemail.com wrote:
> Hello Andy.
>
> Have you looked at how I did this in:
> http://travelingsales.svn.sourceforge.net/viewvc/travelingsales/trunk/osmnavigation/src/org/openstreetmap/travelingsalesman/navigation/traffic/
>
> it is documented here:
> http://apps.sourceforge.net/mediawiki/travelingsales/index.php?title=TrafficRuleManager
>
> "
> For each country this test involves first to check with the bounding-box of
> the country. If we are not within the bounding-box, we cannot be inside
> that country.
>
> Next we test if the node or way is tagged with "is_in:country" or "is_in"
> and contains either the country-name (case insensitite) or the uppercase
> ISO3166 -code of the country.
>
> Next we load the prepared border-polygon of the country and cache it.
> Loading the polygon take a lot of time but checks with it are fast.
> "
>
> I'll add a fourth step to be taken if the distance to the simple polygon
> is below it's simplification-threshold and use the OSM-ways that make up
> the
> border in that section then.
>
> It never compares against the full OSM border of the country.
>
> Marcus
>
> On Tue, 31 Mar 2009 13:48:27 +0100, Andy Deakin <andy.deakin at pcmend.net>
> wrote:
>
>> Hi,
>>
>> No major breakthrough here, but if anyone is interested in a quick and
>> dirty 'what country is lat,lon in' I have created a simple method.
>>
>> Lookups have been taking about 0.00002 seconds, and it involves a binary
>> lookup file (25MB) at 1/20th of a degree resolution. Boundaries need
>> further processing for an exact result. If you were only interested in a
>> smaller area (e.g. Europe) then it could be made much smaller.
>>
>> Details available here:
>> http://www.handyandy.org.uk/blog/2009/03/31/what-country-are-you-in/
>>
>> Andy
>>
More information about the dev
mailing list