[PATCH] POI Branch empty-duplicated city area poi problem

Hi, the attached patch fixes the following problems of the --add-pois-to-areas option in the poi branch: - Prevent creation of unnamed city pois out of polygons - Prevent duplicated city pois creation Berni. Index: src/uk/me/parabola/mkgmap/main/MapMaker.java =================================================================== --- src/uk/me/parabola/mkgmap/main/MapMaker.java (revision 967) +++ src/uk/me/parabola/mkgmap/main/MapMaker.java (working copy) @@ -143,7 +143,7 @@ if (s != null) { MapPointFastFindMap poiMap = new MapPointFastFindMap(); - + for (MapPoint point : src.getPoints()) { if(point.isRoadNamePOI() == false) // Don't put road pois in this list @@ -158,10 +158,15 @@ // only make a point if the shape has a name and we know what type of point to make if (pointType == 0) continue; - + + + // We don't want to add unnamed cities !! + if(MapPoint.isCityType(pointType) && shapeName == null) + continue; + // check if there is not already a poi in that shape - if(poiMap.findPointInShape(shape, pointType) == null) + if(poiMap.findPointInShape(shape, pointType, shapeName) == null) { MapPoint newPoint = new MapPoint(); newPoint.setName(shapeName); Index: src/uk/me/parabola/mkgmap/general/MapPointFastFindMap.java =================================================================== --- src/uk/me/parabola/mkgmap/general/MapPointFastFindMap.java (revision 967) +++ src/uk/me/parabola/mkgmap/general/MapPointFastFindMap.java (working copy) @@ -185,7 +185,7 @@ return nextPoint; } - public MapPoint findPointInShape(MapShape shape, int pointType) + public MapPoint findPointInShape(MapShape shape, int pointType, String poiName) { ArrayList<MapPoint> list; List<Coord> points = shape.getPoints(); @@ -208,14 +208,27 @@ if (list != null) { for (MapPoint actPoint : list) { - if (pointType == 0 || actPoint.getType() == pointType) { - if (shape.contains(actPoint.getLocation())) - return actPoint; + boolean checkThisPoint = false; + + if (pointType == 0 || actPoint.getType() == pointType) + checkThisPoint = true; + + if(MapPoint.isCityType(pointType) && actPoint.isCity() && + actPoint.getName() != null && poiName != null) + { + // Check for city name pois in that shape + // Since the types might not be exactly the same we + // check for all places pois with the same name + + checkThisPoint = actPoint.getName().equalsIgnoreCase(poiName); } + + if (checkThisPoint && shape.contains(actPoint.getLocation())) + return actPoint; } } } - + return null; } Index: src/uk/me/parabola/mkgmap/general/MapPoint.java =================================================================== --- src/uk/me/parabola/mkgmap/general/MapPoint.java (revision 967) +++ src/uk/me/parabola/mkgmap/general/MapPoint.java (working copy) @@ -59,8 +59,7 @@ } public boolean isCity() { - int type = getType(); - return type >= 0x0100 && type <= 0x1100; + return MapPoint.isCityType(getType()); } public void setRoadNamePOI(boolean isRoadNamePoi) { @@ -70,4 +69,9 @@ public boolean isRoadNamePOI() { return this.isRoadNamePoi; } + + public static boolean isCityType(int type) + { + return type >= 0x0100 && type <= 0x1100; + } }
participants (1)
-
Bernhard Heibler