El 26/02/11 19:55, Clinton Gladstone escribió:
The attached patch is a highly alpha version of code which attempts to 
determine the ocean or sea name of generated sea polygons.

- The code uses a web service from geonames.org (see 
http://www.geonames.org/export/web-services.html#ocean)

- The results can sometimes be wildly inaccurate. :-)


What you need:

1. To use this, you must first create a free user account at geonames.org, and 
activate that account for the free web services. (http://www.geonames.org/login)

2. Then you must specify your user name with the "geonames-user" parameter in 
mkgmap's --generate-sea option. Example:

    
--generate-sea=multipolygon,extend-sea-sectors,close-gaps=1000,floodblocker,geonames-user=<your
 user name>

   (Replace "<your user name>" with your geonames.org user name.)

3. For the moment, this only works with multipolygon sea generation, although 
this can be changed later.


How it works:

For each sea polygon, the code makes one or more HTTP calls to 
http://api.geonames.org/oceanJSON and uses the first sea name found.

Example HTTP call:

   
http://api.geonames.org/oceanJSON?lat=51.08498811721802&lng=156.70072317123413&username=demo

The code attempts lookups for the following coordinates in the following order. 
:

1. The center of gravity of the first way in the multipolygon.

2. The first coordinate in the first way in the multipolygon.

3. - 6. The corners of the bounding box.

7. The center of the bounding box.

The code uses the first valid name found (and skips the other lookups).


The result:

If everything works nicely, and you are lucky, you'll get nice named sea 
polygons.

However, in most cases, you'll get semi-accurate results. Often only one sea 
(multi-)polygon is created per tile. Polygons which cross sea borders will only 
have the name of the first sea found. For example, in the attached screen shot 
of the coast of South Africa, you can see that the South Atlantic Ocean extends 
too far to the East.

As such, the results can be considered to be of entertainment value only. :-)

I would appreciate your feedback though, especially if you have ideas to 
improve this.
I attach screenshot of Morocco's map. Why are so many labels created? Why Canarias sea extends even to Mediterranean sea?

<<attachment: Pantallazo-1.png>>

_______________________________________________
mkgmap-dev mailing list
[email protected]
http://www.mkgmap.org.uk/mailman/listinfo/mkgmap-dev

Reply via email to