logo separator

[mkgmap-dev] patched polish file charset and multipolygon handling

From Kolesár András mkgmap at kolesar.hu on Mon Feb 21 12:22:00 GMT 2011

Dear developers,

I'm new to mkgmap, just replacing cgpsmapper because it's slow, buggy and closed source. I have tried to compile from an .mp file. The resulting .img file had two huge problems:

1. Wrong character encoding.

I used an .mp source file in code page ISO-8859-2 (or Windows-1250). I was unable to fix encoding of Hungarian accented characters (áéíóúöőüű), tried all possible variations of --charset and --code-page options. I even tried to iconv .mp file to UTF-8 but it was also wrong way, img file had UTF-8 labels.

Finally, I have modified READING_CHARSET in mkgmap/reader/polish/PolishMapDataSource.java from "UTF-8" to "ISO-8859-2" and accented characters started to work. The used config was --charset=cp1252 --code-page=1252. The same worked when I specified ISO-8859-1, because the listed Hungarian characters are on the same place in two charsets. I think READING_CHARSET should be a new option or linked to --charset option.

2. Multipolygon errors.

Polygons with holes looked bizarre, long triangles appeared between endpoints of parts with alternating (negative/positive) rendering. Test showed detailed problems:

a. parts of multipart polygons were not closed at the last point
b. parts of multipart polygons were appended to each other, not stored as separated parts
c. multipolygon splitter treated "new" holes as areas, not holes

Investigating problem "b" showed that mkgmap stores polygons as a single List<Coord>. Garmin img also doesn't support holes or multipolygons.

For a working solution, I have created a workaround model for multipart polygons: first point of first part stands as a global starting point. Second part (hole or area, doesn't mind) is connected to this starting point with a zero-width capillary on the start and on the end as well. Every other parts are connected on the same way. Every parts should be closed (first node = last node), this was not checked before (problem "a"). Problem "b" became the spine of the solution, parts are appended. The connection between parts are only visible if polygon border is rendered.

Old cgpsmapper did the same way for holes, only difference is that cgpsmapper looked up the closest nodes for connection. I did not want to implement such a power-hungry algorithm, it's indifferent theoretically where holes are connected to areas. Another difference from cgpsmapper: multipolygons of disjoint areas were published to img as two independent polygons, resulting two labels on map.

I have implemented this model in two polygon processing class. Resulting .img file is now correct, even islands appear in holes. Modified files:


QUESTION: Where can I post my patch? Can I use SVN? Which branch? Attached patch against r1846.

András Kolesár
-------------- next part --------------
A non-text attachment was scrubbed...
Name: mkgmap-mpencoding-multipolygon.patch
Type: text/x-patch
Size: 4602 bytes
Desc: not available
Url : http://lists.mkgmap.org.uk/pipermail/mkgmap-dev/attachments/20110221/332edb48/attachment.bin 

More information about the mkgmap-dev mailing list