Hi,
I did some investigation on the LBL portion of imgfmt. I'm now able to
attach some address information to the POI records. Please see the
attached patch with the small corrections I made. The main changes are:
- Calculation of "local" POIFlag that is written into the POI dataset
fixed. Looks like we have to "cut out" all bits that are not set in the
LBL header. In other words the meaning of the local bits change
according to the global bits.
- Size of CityIndex and ZipIndex is now one or two bytes depending on
the number of records in the LBL
- Fixed wrong POINT_REF mask in City.java. I'm still struggling with the
POINT_REF stuff. I'm not sure how to compute the subdivision and
pointIndex.
poiAddressPatch.txt doesn't include the filling of the address
information for the POI's. This small patch should be save to be
integrated into the trunk.
I have also attached experimental code to use information out of the
"Karlsruhe Addressing" scheme or from the nearest city. To do so I had
to extend also osm2mp to provide the necessary information. I will try
to improve this search since sometimes the POI's end up in the wrong
city. Please also be aware that I use some openGeoDB tags which may not
be available everywhere. The search for nearest city is linear and slow.
I still have not figured out what data has to be provided to enable a
real address based destination selection. Maybe this has something to do
with the POINT_REF stuff ?
Patches are bases on rev 828 of nod branch. I tested my stuff with Nuvi
360 and GPSMapEdit.
Thanks
Berni.
Index: POIRecord.java
===================================================================
--- POIRecord.java (revision 104)
+++ POIRecord.java (working copy)
@@ -47,8 +47,8 @@
private Label streetName;
private Label streetNumberName; // Used for numbers such as 221b
- private char cityIndex;
- private char zipIndex;
+ private char cityIndex = 0;
+ private char zipIndex = 0;
private String phoneNumber;
@@ -59,8 +59,19 @@
public void setStreetName(Label label) {
this.streetName = label;
}
+
+ public void setZipIndex(int zipIndex)
+ {
+ this.zipIndex = (char) zipIndex;
+ }
+
+ public void setCityIndex(int cityIndex)
+ {
+ this.cityIndex = (char) cityIndex;
+ }
- void write(ImgFileWriter writer, byte POIGlobalFlags, int realofs) {
+ void write(ImgFileWriter writer, byte POIGlobalFlags, int realofs,
+ long numCities, long numZips) {
assert offset == realofs;
int ptr = poiName.getOffset();
@@ -69,31 +80,104 @@
writer.put3(ptr);
if (POIGlobalFlags != getPOIFlags())
- writer.put(getPOIFlags());
+ writer.put(getWrittenPOIFlags(POIGlobalFlags));
if (streetName != null)
writer.put3(streetName.getOffset());
+
+ if (cityIndex > 0)
+ {
+ if(numCities > 255)
+ writer.putChar(cityIndex);
+ else
+ writer.put((byte)cityIndex);
+ }
+
+ if (zipIndex > 0)
+ {
+ if(numZips > 255)
+ writer.putChar(zipIndex);
+ else
+ writer.put((byte)zipIndex);
+ }
}
byte getPOIFlags() {
byte b = 0;
if (streetName != null)
b |= HAS_STREET;
+ if (cityIndex > 0)
+ b |= HAS_CITY;
+ if (zipIndex > 0)
+ b |= HAS_ZIP;
return b;
}
+
+ byte getWrittenPOIFlags(byte POIGlobalFlags)
+ {
+ int mask;
+ int flag = 0;
+ int j = 0;
+
+ int usedFields = getPOIFlags();
+
+ /* the local POI flag is really tricky
+ if a bit is not set in the global mask
+ we have to skip this bit in the local mask.
+ In other words the meaning of the local bits
+ change influenced by the global bits */
+
+ for(byte i = 0; i < 6; i++)
+ {
+ mask = 1 << i;
+
+ if((mask & POIGlobalFlags) == mask)
+ {
+ if((mask & usedFields) == mask)
+ flag = flag | (1 << j);
+ j++;
+ }
+
+ }
+ return (byte) flag;
+ }
/**
* Sets the start offset of this POIRecord
*
* \return Number of bytes needed by this entry
*/
- int calcOffset(int ofs, byte POIGlobalFlags) {
+ int calcOffset(int ofs, byte POIGlobalFlags, long numCities, long numZips) {
offset = ofs;
int size = 3;
if (POIGlobalFlags != getPOIFlags())
size += 1;
if (streetName != null)
size += 3;
+ if (cityIndex > 0)
+ {
+ /*
+ depending on how many cities are in the LBL block we have
+ to write one or two bytes
+ */
+
+ if(numCities > 255)
+ size += 2;
+ else
+ size += 1;
+ }
+ if (zipIndex > 0)
+ {
+ /*
+ depending on how many zips are in the LBL block we have
+ to write one or two bytes
+ */
+
+ if(numZips > 255)
+ size += 2;
+ else
+ size += 1;
+ }
return size;
}
Index: PlacesFile.java
===================================================================
--- PlacesFile.java (revision 104)
+++ PlacesFile.java (working copy)
@@ -70,7 +70,7 @@
byte poiglobalflags = placeHeader.getPOIGlobalFlags();
for (POIRecord p : pois)
p.write(writer, poiglobalflags,
- writer.position() - poistart);
+ writer.position() - poistart, cities.size(), postalCodes.size());
placeHeader.endPOI(writer.position());
for (Zip z : postalCodes.values())
@@ -79,7 +79,7 @@
}
Country createCountry(String name, String abbr) {
- Country c = new Country(countries.size());
+ Country c = new Country(countries.size()+1);
String s = abbr != null ? name + 0x1d + abbr : name;
@@ -91,7 +91,7 @@
}
Region createRegion(Country country, String name) {
- Region r = new Region(country, regions.size());
+ Region r = new Region(country, regions.size()+1);
Label l = lblFile.newLabel(name);
r.setLabel(l);
@@ -101,7 +101,7 @@
}
City createCity(Region region, String name) {
- City c = new City(region, cities.size());
+ City c = new City(region, cities.size()+1);
Label l = lblFile.newLabel(name);
c.setLabel(l);
@@ -111,7 +111,7 @@
}
Zip createZip(String code) {
- Zip z = new Zip(postalCodes.size());
+ Zip z = new Zip(postalCodes.size()+1);
Label l = lblFile.newLabel(code);
z.setLabel(l);
@@ -143,6 +143,6 @@
int ofs = 0;
for (POIRecord p : pois)
- ofs += p.calcOffset(ofs, poiFlags);
+ ofs += p.calcOffset(ofs, poiFlags, cities.size(), postalCodes.size());
}
}
Index: City.java
===================================================================
--- City.java (revision 104)
+++ City.java (working copy)
@@ -26,7 +26,7 @@
* @author Steve Ratcliffe
*/
public class City {
- private static final int POINT_REF = 0x80;
+ private static final int POINT_REF = 0x8000;
private final int index;
Index: LBLFile.java
===================================================================
--- LBLFile.java (revision 104)
+++ LBLFile.java (working copy)
@@ -138,7 +138,24 @@
public POIRecord createPOI(String name) {
return places.createPOI(name);
}
+
+ public Country createCountry(String name, String abbr) {
+ return places.createCountry(name, abbr);
+ }
+
+ public Region createRegion(Country country, String region) {
+ return places.createRegion(country, region);
+ }
+
+ public City createCity(Region region, String city) {
+ return places.createCity(region, city);
+ }
+ public Zip createZip(String code) {
+ return places.createZip(code);
+ }
+
+
public void allPOIsDone() {
places.allPOIsDone();
}
Index: src/uk/me/parabola/imgfmt/app/lbl/POIRecord.java
===================================================================
--- src/uk/me/parabola/imgfmt/app/lbl/POIRecord.java (.../upstream/mkgmap) (revision 105)
+++ src/uk/me/parabola/imgfmt/app/lbl/POIRecord.java (.../work/mkgmap) (revision 105)
@@ -47,8 +47,8 @@
private Label streetName;
private Label streetNumberName; // Used for numbers such as 221b
- private char cityIndex;
- private char zipIndex;
+ private char cityIndex = 0;
+ private char zipIndex = 0;
private String phoneNumber;
@@ -59,8 +59,19 @@
public void setStreetName(Label label) {
this.streetName = label;
}
+
+ public void setZipIndex(int zipIndex)
+ {
+ this.zipIndex = (char) zipIndex;
+ }
+
+ public void setCityIndex(int cityIndex)
+ {
+ this.cityIndex = (char) cityIndex;
+ }
- void write(ImgFileWriter writer, byte POIGlobalFlags, int realofs) {
+ void write(ImgFileWriter writer, byte POIGlobalFlags, int realofs,
+ long numCities, long numZips) {
assert offset == realofs;
int ptr = poiName.getOffset();
@@ -69,31 +80,104 @@
writer.put3(ptr);
if (POIGlobalFlags != getPOIFlags())
- writer.put(getPOIFlags());
+ writer.put(getWrittenPOIFlags(POIGlobalFlags));
if (streetName != null)
writer.put3(streetName.getOffset());
+
+ if (cityIndex > 0)
+ {
+ if(numCities > 255)
+ writer.putChar(cityIndex);
+ else
+ writer.put((byte)cityIndex);
+ }
+
+ if (zipIndex > 0)
+ {
+ if(numZips > 255)
+ writer.putChar(zipIndex);
+ else
+ writer.put((byte)zipIndex);
+ }
}
byte getPOIFlags() {
byte b = 0;
if (streetName != null)
b |= HAS_STREET;
+ if (cityIndex > 0)
+ b |= HAS_CITY;
+ if (zipIndex > 0)
+ b |= HAS_ZIP;
return b;
}
+
+ byte getWrittenPOIFlags(byte POIGlobalFlags)
+ {
+ int mask;
+ int flag = 0;
+ int j = 0;
+
+ int usedFields = getPOIFlags();
+
+ /* the local POI flag is really tricky
+ if a bit is not set in the global mask
+ we have to skip this bit in the local mask.
+ In other words the meaning of the local bits
+ change influenced by the global bits */
+
+ for(byte i = 0; i < 6; i++)
+ {
+ mask = 1 << i;
+
+ if((mask & POIGlobalFlags) == mask)
+ {
+ if((mask & usedFields) == mask)
+ flag = flag | (1 << j);
+ j++;
+ }
+
+ }
+ return (byte) flag;
+ }
/**
* Sets the start offset of this POIRecord
*
* \return Number of bytes needed by this entry
*/
- int calcOffset(int ofs, byte POIGlobalFlags) {
+ int calcOffset(int ofs, byte POIGlobalFlags, long numCities, long numZips) {
offset = ofs;
int size = 3;
if (POIGlobalFlags != getPOIFlags())
size += 1;
if (streetName != null)
size += 3;
+ if (cityIndex > 0)
+ {
+ /*
+ depending on how many cities are in the LBL block we have
+ to write one or two bytes
+ */
+
+ if(numCities > 255)
+ size += 2;
+ else
+ size += 1;
+ }
+ if (zipIndex > 0)
+ {
+ /*
+ depending on how many zips are in the LBL block we have
+ to write one or two bytes
+ */
+
+ if(numZips > 255)
+ size += 2;
+ else
+ size += 1;
+ }
return size;
}
Index: src/uk/me/parabola/imgfmt/app/lbl/PlacesFile.java
===================================================================
--- src/uk/me/parabola/imgfmt/app/lbl/PlacesFile.java (.../upstream/mkgmap) (revision 105)
+++ src/uk/me/parabola/imgfmt/app/lbl/PlacesFile.java (.../work/mkgmap) (revision 105)
@@ -70,7 +70,7 @@
byte poiglobalflags = placeHeader.getPOIGlobalFlags();
for (POIRecord p : pois)
p.write(writer, poiglobalflags,
- writer.position() - poistart);
+ writer.position() - poistart, cities.size(), postalCodes.size());
placeHeader.endPOI(writer.position());
for (Zip z : postalCodes.values())
@@ -79,44 +79,65 @@
}
Country createCountry(String name, String abbr) {
- Country c = new Country(countries.size());
-
+
String s = abbr != null ? name + 0x1d + abbr : name;
+
+ Country c = countries.get(s);
+
+ if(c == null)
+ {
+ c = new Country(countries.size()+1);
- Label l = lblFile.newLabel(s);
- c.setLabel(l);
-
- countries.put(name, c);
+ Label l = lblFile.newLabel(s);
+ c.setLabel(l);
+ countries.put(name, c);
+ }
return c;
}
Region createRegion(Country country, String name) {
- Region r = new Region(country, regions.size());
-
- Label l = lblFile.newLabel(name);
- r.setLabel(l);
-
- regions.put(name, r);
+
+ Region r = regions.get(name);
+
+ if(r == null)
+ {
+ r = new Region(country, regions.size()+1);
+ Label l = lblFile.newLabel(name);
+ r.setLabel(l);
+ regions.put(name, r);
+ }
return r;
}
City createCity(Region region, String name) {
- City c = new City(region, cities.size());
+
+ City c = cities.get(name); // Fixme
+
+ if(c == null)
+ {
+ c = new City(region, cities.size()+1);
- Label l = lblFile.newLabel(name);
- c.setLabel(l);
+ Label l = lblFile.newLabel(name);
+ c.setLabel(l);
- cities.put(name, c);
+ cities.put(name, c);
+ }
return c;
}
Zip createZip(String code) {
- Zip z = new Zip(postalCodes.size());
+
+ Zip z = postalCodes.get(code);
+
+ if(z == null)
+ {
+ z = new Zip(postalCodes.size()+1);
- Label l = lblFile.newLabel(code);
- z.setLabel(l);
+ Label l = lblFile.newLabel(code);
+ z.setLabel(l);
- postalCodes.put(code, z);
+ postalCodes.put(code, z);
+ }
return z;
}
@@ -129,6 +150,7 @@
p.setLabel(l);
pois.add(p);
+
return p;
}
@@ -143,6 +165,6 @@
int ofs = 0;
for (POIRecord p : pois)
- ofs += p.calcOffset(ofs, poiFlags);
+ ofs += p.calcOffset(ofs, poiFlags, cities.size(), postalCodes.size());
}
}
Index: src/uk/me/parabola/imgfmt/app/lbl/City.java
===================================================================
--- src/uk/me/parabola/imgfmt/app/lbl/City.java (.../upstream/mkgmap) (revision 105)
+++ src/uk/me/parabola/imgfmt/app/lbl/City.java (.../work/mkgmap) (revision 105)
@@ -26,7 +26,7 @@
* @author Steve Ratcliffe
*/
public class City {
- private static final int POINT_REF = 0x80;
+ private static final int POINT_REF = 0x8000;
private final int index;
Index: src/uk/me/parabola/imgfmt/app/lbl/LBLFile.java
===================================================================
--- src/uk/me/parabola/imgfmt/app/lbl/LBLFile.java (.../upstream/mkgmap) (revision 105)
+++ src/uk/me/parabola/imgfmt/app/lbl/LBLFile.java (.../work/mkgmap) (revision 105)
@@ -138,7 +138,24 @@
public POIRecord createPOI(String name) {
return places.createPOI(name);
}
+
+ public Country createCountry(String name, String abbr) {
+ return places.createCountry(name, abbr);
+ }
+
+ public Region createRegion(Country country, String region) {
+ return places.createRegion(country, region);
+ }
+
+ public City createCity(Region region, String city) {
+ return places.createCity(region, city);
+ }
+ public Zip createZip(String code) {
+ return places.createZip(code);
+ }
+
+
public void allPOIsDone() {
places.allPOIsDone();
}
Index: src/uk/me/parabola/mkgmap/osmstyle/StyledConverter.java
===================================================================
--- src/uk/me/parabola/mkgmap/osmstyle/StyledConverter.java (.../upstream/mkgmap) (revision 105)
+++ src/uk/me/parabola/mkgmap/osmstyle/StyledConverter.java (.../work/mkgmap) (revision 105)
@@ -226,6 +226,31 @@
}
private void elementSetup(MapElement ms, GType gt, Element element) {
+
+ String city = element.getTag("addr:city");
+ String zip = element.getTag("addr:postcode");
+ String street = element.getTag("addr:street");
+ String houseNumber = element.getTag("addr:housenumber");
+ String isIn = element.getTag("is_in");
+
+ if(zip == null)
+ zip = element.getTag("openGeoDB:postal_codes");
+
+ if(city != null)
+ ms.setCity(city);
+
+ if(zip != null)
+ ms.setZip(zip);
+
+ if(street != null)
+ ms.setStreet(street);
+
+ if(houseNumber != null)
+ ms.setHouseNumber(houseNumber);
+
+ if(isIn != null)
+ ms.setHouseNumber(isIn);
+
ms.setName(element.getName());
ms.setType(gt.getType());
ms.setMinResolution(gt.getMinResolution());
Index: src/uk/me/parabola/mkgmap/build/Locator.java
===================================================================
--- src/uk/me/parabola/mkgmap/build/Locator.java (.../upstream/mkgmap) (revision 0)
+++ src/uk/me/parabola/mkgmap/build/Locator.java (.../work/mkgmap) (revision 105)
@@ -0,0 +1,218 @@
+/*
+ * Copyright (C) 2009 Bernhard Heibler
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ *
+ * Author: Bernhard Heibler
+ * Create date: 02-Jan-2009
+ */
+package uk.me.parabola.mkgmap.build;
+
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Vector;
+import uk.me.parabola.mkgmap.general.MapPoint;
+import uk.me.parabola.imgfmt.app.Coord;
+
+public class Locator {
+
+ class MapPointMultiMap{
+
+ private final java.util.Map<String,Vector<MapPoint>> map = new HashMap<String,Vector<MapPoint>>();
+ //private final java.util.Map<String,MapPoint> map = new HashMap<String,MapPoint>();
+ private final java.util.Vector<MapPoint> points = new Vector<MapPoint>();
+
+ public MapPoint put(String name, MapPoint p)
+ {
+ Vector<MapPoint> list;
+
+ list = map.get(name);
+
+ if(list == null)
+ {
+ list = new Vector<MapPoint>();
+ list.add(p);
+ map.put(name, list);
+ }
+ else
+ list.add(p);
+
+ points.add(p);
+
+ return p;
+ }
+
+ public MapPoint get(String name)
+ {
+ Vector<MapPoint> list;
+
+ list = map.get(name);
+
+ if(list != null)
+ return list.elementAt(0);
+ else
+ return null;
+ }
+
+ public Collection<MapPoint> getList(String name)
+ {
+ return map.get(name);
+ }
+
+ public long size()
+ {
+ return points.size();
+ }
+
+ public Collection<MapPoint> values()
+ {
+ return points;
+ }
+ }
+
+ private final MapPointMultiMap cityMap = new MapPointMultiMap();
+ private final MapPointMultiMap placesMap = new MapPointMultiMap();
+
+ public void addLocation(MapPoint p) {
+
+ if(p.getIsIn() != null)
+ {
+ String cityList[] = p.getIsIn().split(",");
+
+ if(cityList.length > 2 && cityList[cityList.length-1].equals("Europe"))
+ {
+ /*System.out.println(cityList[cityList.length-3] + ";" + cityList[cityList.length-2]);*/
+
+ String CountryStr = cityList[cityList.length-2].trim();
+
+ if(CountryStr.equals("Bundesrepublik Deutschland"))
+ CountryStr = "Deutschland";
+
+ p.setRegion(cityList[cityList.length-3].trim());
+ p.setCountry(CountryStr);
+ }
+
+ /*for(int i = 0; i < cityList.length; i++)
+ {
+ if(i > 0) System.out.print(";");
+ System.out.print(cityList[i]);
+ if(i == cityList.length -1) System.out.print("\n");
+ }*/
+ }
+
+ if(p.getCity() != null)
+ {
+ cityMap.put(p.getName(),p);
+ }
+ else
+ {
+ placesMap.put(p.getName(),p);
+ //System.out.println("Locator::addLocation " + p.getName());
+ }
+
+ }
+
+ public MapPoint findNextPoint(MapPoint p)
+ {
+ double minDist = Double.MAX_VALUE;
+ MapPoint nextPoint = null;
+
+ for (MapPoint loc: cityMap.values())
+ {
+ double distance = loc.getLocation().distance(p.getLocation());
+
+ if(distance < minDist)
+ {
+ nextPoint = loc;
+ minDist = distance;
+ }
+ }
+ return nextPoint;
+ }
+
+ public void stat() {
+ System.out.println("\nLocator City Map contains " + cityMap.size() + " entries");
+ System.out.println("Locator Places Map contains " + placesMap.size() + " entries");
+
+ for (MapPoint place: placesMap.values())
+ {
+ MapPoint near = null;
+ Double minDist = Double.MAX_VALUE;
+
+ String isIn = place.getIsIn();
+
+ if(isIn != null)
+ {
+ String cityList[] = isIn.split(",");
+
+ for(int i = 0; i < cityList.length; i++)
+ {
+ String biggerCityName=cityList[i].trim();
+
+ Collection <MapPoint> nextCityList = cityMap.getList(biggerCityName);
+
+ if(nextCityList != null)
+ for (MapPoint nextCity: nextCityList)
+ {
+ Double dist = place.getLocation().distance(nextCity.getLocation());
+
+ if(dist < minDist)
+ {
+ minDist = dist;
+ near = nextCity;
+ }
+ }
+ }
+
+ /*
+
+ // Check if the distance between the two is suspicious
+
+ if(near != null && minDist > 10000)
+ {
+ System.out.println(place.getName() + " -> "
+ + near.getName() + " " + (minDist/1000.0) + " km " +
+ place.getIsIn());
+ }*/
+
+ }
+ else
+ near = findNextPoint(place);
+
+ if(near != null)
+ {
+ //System.out.println(place.getName() + " belongs to " + near.getName());
+ place.setCity(near.getCity());
+ place.setZip(near.getZip());
+
+ if(place.getRegion() == null)
+ place.setRegion(near.getRegion());
+
+ if(place.getCountry() == null)
+ place.setCountry(near.getCountry());
+ }
+ }
+
+ for (MapPoint place: placesMap.values())
+ {
+ if (place.getCity() != null)
+ cityMap.put(place.getName(),place);
+ }
+
+ System.out.println("Locator City Map contains " + cityMap.size() + " entries after resolver");
+
+ }
+
+
+
+}
+
Index: src/uk/me/parabola/mkgmap/build/MapBuilder.java
===================================================================
--- src/uk/me/parabola/mkgmap/build/MapBuilder.java (.../upstream/mkgmap) (revision 105)
+++ src/uk/me/parabola/mkgmap/build/MapBuilder.java (.../work/mkgmap) (revision 105)
@@ -23,8 +23,13 @@
import java.util.List;
import uk.me.parabola.imgfmt.app.Coord;
+import uk.me.parabola.imgfmt.app.Label;
import uk.me.parabola.imgfmt.app.lbl.LBLFile;
import uk.me.parabola.imgfmt.app.lbl.POIRecord;
+import uk.me.parabola.imgfmt.app.lbl.Country;
+import uk.me.parabola.imgfmt.app.lbl.Region;
+import uk.me.parabola.imgfmt.app.lbl.City;
+import uk.me.parabola.imgfmt.app.lbl.Zip;
import uk.me.parabola.imgfmt.app.map.Map;
import uk.me.parabola.imgfmt.app.net.NETFile;
import uk.me.parabola.imgfmt.app.net.NODFile;
@@ -77,6 +82,8 @@
private final java.util.Map<MapPoint,POIRecord> poimap =
new HashMap<MapPoint,POIRecord>();
+
+ private Locator locator = new Locator();
/**
* Main method to create the map, just calls out to several routines
@@ -86,6 +93,7 @@
* @param src The map data.
*/
public void makeMap(Map map, LoadableMapDataSource src) {
+ processLocations(map, src);
processPOIs(map, src);
//preProcessRoads(map, src);
processOverviews(map, src);
@@ -138,12 +146,81 @@
*/
private void processPOIs(Map map, MapDataSource src) {
LBLFile lbl = map.getLblFile();
+
+
for (MapPoint p : src.getPoints()) {
- POIRecord r = lbl.createPOI(p.getName());
- poimap.put(p, r);
+ POIRecord r = lbl.createPOI(p.getName());
+
+ String CountryStr = p.getCountry();
+ String RegionStr = p.getRegion();
+ String ZipStr = p.getZip();
+ String CityStr = p.getCity();
+
+ if(CountryStr == null || RegionStr == null ||
+ (ZipStr == null && CityStr == null))
+ {
+ MapPoint nextCity = locator.findNextPoint(p);
+
+ if(nextCity != null)
+ {
+ if (CountryStr == null) CountryStr = nextCity.getCountry();
+ if (RegionStr == null) RegionStr = nextCity.getRegion();
+
+ if(p.getType() > 0x1100)
+ {
+ if(ZipStr == null) ZipStr = nextCity.getZip();
+ if(CityStr == null) CityStr = nextCity.getCity();
+ }
+ }
+ }
+
+ //System.out.println(ZipStr + ";" + CityStr + ";" + RegionStr + ";" + CountryStr);
+
+ if (CountryStr == null) CountryStr = "";
+ if (RegionStr == null) RegionStr = "";
+ //if (ZipStr == null) ZipStr = "";
+ //if (CityStr == null) CityStr = "";
+
+ if(CityStr != null)
+ {
+ Country d = lbl.createCountry(CountryStr, null);
+ Region b = lbl.createRegion(d,RegionStr);
+
+ City city = lbl.createCity(b, CityStr);
+ r.setCityIndex(city.getIndex());
+ }
+
+
+ if (ZipStr != null)
+ {
+ Zip zip = lbl.createZip(ZipStr);
+ r.setZipIndex(zip.getIndex());
+ }
+
+ if(p.getStreet() != null)
+ {
+ Label streetName = lbl.newLabel(p.getStreet());
+ r.setStreetName(streetName);
+ }
+
+ poimap.put(p, r);
}
lbl.allPOIsDone();
}
+
+ /**
+ *
+ * @param map The map.
+ * @param src The map data.
+ */
+ private void processLocations(Map map, MapDataSource src) {
+
+ for (MapPoint p : src.getPoints()) {
+ if(p.getType() <= 0x1100)
+ locator.addLocation(p);
+ }
+ locator.stat();
+ }
/**
* Process roads first to create RoadDefs
Index: src/uk/me/parabola/mkgmap/reader/polish/PolishMapDataSource.java
===================================================================
--- src/uk/me/parabola/mkgmap/reader/polish/PolishMapDataSource.java (.../upstream/mkgmap) (revision 105)
+++ src/uk/me/parabola/mkgmap/reader/polish/PolishMapDataSource.java (.../work/mkgmap) (revision 105)
@@ -346,6 +346,16 @@
} catch (NumberFormatException e) {
endLevel = 0;
}
+ } else if (name.equals("ZipCode")) {
+ elem.setZip(value);
+ } else if (name.equals("CityName")) {
+ elem.setCity(value);
+ } else if (name.equals("StreetDesc")) {
+ elem.setStreet(value);
+ } else if (name.equals("HouseNumber")) {
+ elem.setHouseNumber(value);
+ } else if (name.equals("is_in")) {
+ elem.setIsIn(value);
} else {
return false;
}
Index: src/uk/me/parabola/mkgmap/general/MapElement.java
===================================================================
--- src/uk/me/parabola/mkgmap/general/MapElement.java (.../upstream/mkgmap) (revision 105)
+++ src/uk/me/parabola/mkgmap/general/MapElement.java (.../work/mkgmap) (revision 105)
@@ -29,6 +29,14 @@
private int minResolution = 24;
private int maxResolution = 24;
+
+ private String zipCode;
+ private String city;
+ private String region;
+ private String country;
+ private String street;
+ private String houseNumber;
+ private String isIn;
protected MapElement() {
}
@@ -56,6 +64,63 @@
this.name = name;
}
+ public String getCity() {
+ return city;
+ }
+
+ public void setCity(String city) {
+ this.city = city;
+ }
+
+ public String getZip() {
+ return zipCode;
+ }
+
+ public void setZip(String zip) {
+ this.zipCode = zip;
+ }
+
+ public String getStreet() {
+ return street;
+ }
+
+ public void setStreet(String street) {
+ this.street = street;
+ }
+
+ public String getCountry() {
+ return country;
+ }
+
+ public void setCountry(String country) {
+ this.country = country;
+ }
+
+ public String getRegion() {
+ return region;
+ }
+
+ public void setRegion(String region) {
+ this.region = region;
+ }
+
+ public String getHouseNumber() {
+ return houseNumber;
+ }
+
+ public void setHouseNumber(String houseNumber) {
+ this.houseNumber = houseNumber;
+ }
+
+ public String getIsIn() {
+ return isIn;
+ }
+
+ public void setIsIn(String isIn) {
+ this.isIn = isIn;
+ }
+
+
/**
* This is the type code that goes in the .img file so that the GPS device
* knows what to display.
Index: osm2mp.pl
===================================================================
--- osm2mp.pl (.../upstream/osm2mp) (revision 106)
+++ osm2mp.pl (.../work/osm2mp) (revision 106)
@@ -196,7 +196,7 @@
my $id;
my $latlon;
-my ($poi, $poiname);
+my ($poi, $poiname, $ZipCode, $CityName, $StreetDesc, $HouseNumber, $isIn);
my $nameprio = 99;
while (<IN>) {
@@ -210,18 +210,34 @@
$poi = "";
$poiname = "";
+ $ZipCode = "";
+ $CityName = "";
+ $StreetDesc = "";
+ $HouseNumber = "";
+ $isIn = "";
$nameprio = 99;
next;
}
if ( /\<tag/ ) {
- /^.*k=["'](.*)["'].*v=["'](.*)["'].*$/;
+ /^.*k=["'](.*)["'].*v=["'](.*)["'].*$/;
$poi = "$1=$2" if ($poitype{"$1=$2"});
my $tagprio = indexof(\@nametagarray, $1);
if ($tagprio>=0 && $tagprio<$nameprio) {
$poiname = convert_string ($2);
$nameprio = $tagprio;
}
+
+ #printf STDERR "$1 $2\n" if ( "$1" ne "created_by");
+
+ $isIn = $2 if ( "$1" eq "is_in");
+ $ZipCode = $2 if ( "$1" eq "openGeoDB:postal_codes");
+ $ZipCode = $2 if ( "$1" eq "addr:postcode" );
+ $CityName = $2 if ( "$1" eq "addr:city" );
+ $CityName = $2 if ( "$1" eq "openGeoDB:sort_name" );
+ $StreetDesc = $2 if ( "$1" eq "addr:street" );
+ $HouseNumber = $2 if ( "$1" eq "addr:housenumber" );
+
next;
}
@@ -238,8 +254,14 @@
printf "Data%d=($latlon)\n", $type[1];
printf "EndLevel=%d\n", $type[2] if ($type[2] > $type[1]);
printf "City=Y\n", if ($type[3]);
- print "Label=$poiname\n" if ($poiname);
+ print "Label=$poiname\n" if ($poiname);
+ printf "ZipCode=$ZipCode\n", if ($ZipCode);
+ printf "CityName=$CityName\n", if ($CityName);
+ printf "StreetDesc=$StreetDesc\n", if ($StreetDesc);
+ printf "HouseNumber=$HouseNumber\n", if ($HouseNumber);
+ printf "is_in=$isIn\n", if ($isIn);
print "[END]\n\n";
+
}
}
}