Skip to content
Commits on Source (4)
mkgmap (0.0.0+svn4214-1) unstable; urgency=medium
* New upstream SVN snapshot.
-- Bas Couwenberg <sebastic@debian.org> Thu, 02 Aug 2018 07:31:48 +0200
mkgmap (0.0.0+svn4193-2) unstable; urgency=medium
* Bump Standards-Version to 4.1.5, no changes.
......
svn.version: 4193
build.timestamp: 2018-05-31T07:29:23+0100
svn.version: 4214
build.timestamp: 2018-07-28T09:29:55+0100
......@@ -218,6 +218,7 @@ man_made=tower|man_made=mast|landmark=chimney [0x6411 resolution 24]
# Edge 705 displays 0x650a,0x6511,0x6512,0x6513,0x6603,0x6614 as hollow white circles, no menu
natural=cave_entrance [0x6601 resolution 24]
natural=cape [0x6606 resolution 24]
natural=cliff [0x6607 resolution 24]
natural=peak {name '${name|def:}${ele|height:m=>ft|def:}' } [0x6616 resolution 24]
natural=rock [0x6614 resolution 24]
......
......@@ -529,8 +529,10 @@ public class ShapeMergeFilter{
* (c1.getHighPrecLat() - c2.getHighPrecLat());
}
if (Math.abs(signedAreaSize) < SINGLE_POINT_AREA){
if (log.isDebugEnabled()) {
log.debug("very small shape near", points.get(0).toOSMURL(), "signed area in high prec map units:", signedAreaSize );
}
}
return signedAreaSize;
}
......
......@@ -962,22 +962,6 @@ public class HousenumberGenerator {
}
}
private static void checkSegment(HousenumberMatch house, MapRoad road, int seg){
Coord cx = house.getLocation();
Coord c0 = road.getPoints().get(seg);
Coord c1 = road.getPoints().get(seg + 1);
double frac = getFrac(c0, c1, cx);
double dist = distanceToSegment(c0,c1,cx,frac);
if (dist < house.getDistance()){
house.setDistance(dist);
house.setRoad(road);
house.setSegment(seg);
house.setSegmentFrac(frac);
}
}
/**
* process option --x-name-service-roads=n
* The program identifies unnamed roads which are only connected to one
......@@ -1700,6 +1684,20 @@ public class HousenumberGenerator {
}
/**
* A performance critical part:
* Index all road segments to be able to find all road segments within a given range
* around a point.
* @author Gerd Petermann
*
*/
private static class RoadSegmentIndex {
private final KdTree<RoadPoint> kdTree = new KdTree<>();
private final Int2ObjectOpenHashMap<Set<RoadPoint>> nodeId2RoadPointMap = new Int2ObjectOpenHashMap<>();
private final double range;
private final double maxSegmentLength;
private final double kdSearchRange;
private static class RoadPoint implements Locatable{
final Coord p;
final MapRoad r;
......@@ -1722,20 +1720,6 @@ public class HousenumberGenerator {
}
}
/**
* A performance critical part:
* Index all road segments to be able to find all road segments within a given range
* around a point.
* @author Gerd Petermann
*
*/
class RoadSegmentIndex {
private final KdTree<RoadPoint> kdTree = new KdTree<>();
private final Int2ObjectOpenHashMap<Set<RoadPoint>> nodeId2RoadPointMap = new Int2ObjectOpenHashMap<>();
private final double range;
private final double maxSegmentLength;
private final double kdSearchRange;
public RoadSegmentIndex(List<MapRoad> roads, double rangeInMeter) {
this.range = rangeInMeter;
this.maxSegmentLength = range * 2 / 3;
......@@ -1931,6 +1915,20 @@ public class HousenumberGenerator {
}
private static void checkSegment(HousenumberMatch house, MapRoad road, int seg){
Coord cx = house.getLocation();
Coord c0 = road.getPoints().get(seg);
Coord c1 = road.getPoints().get(seg + 1);
double frac = getFrac(c0, c1, cx);
double dist = distanceToSegment(c0,c1,cx,frac);
if (dist < house.getDistance()){
house.setDistance(dist);
house.setRoad(road);
house.setSegment(seg);
house.setSegmentFrac(frac);
}
}
}
......@@ -108,7 +108,7 @@ public class ElementSaver {
}
/**
* Add the given node and save it. The node should have tags.
* Add the given node and save it. The node should have tags, if not it should be a member of a relation.
*
* @param node The osm node.
*/
......
......@@ -180,7 +180,13 @@ public class LocationHook extends OsmReadingHooksAdaptor {
Way way = (Way) elem;
// try the mid point of the way first
int middle = way.getPoints().size() / 2;
tags = search(way.getPoints().get(middle));
Coord midPoint;
if (way.getPoints().size() == 2) {
midPoint = way.getPoints().get(0).makeBetweenPoint(way.getPoints().get(1), 0.5);
} else {
midPoint = way.getPoints().get(middle);
}
tags = search(midPoint);
if (tags == null){
// try 1st point next
tags = search(way.getPoints().get(0));
......
......@@ -61,6 +61,8 @@ public class OsmMapDataSource extends MapperBasedMapDataSource implements Loadab
private static final Logger log = Logger.getLogger(OsmMapDataSource.class);
private Style style;
// attention, the order of the hooks is important!
private final OsmReadingHooks[] POSSIBLE_HOOKS = {
new SeaGenerator(),
new MultiPolygonFinishHook(),
......
......@@ -15,11 +15,8 @@ package uk.me.parabola.mkgmap.reader.osm;
import java.awt.Rectangle;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
import java.util.List;
import java.util.Map.Entry;
import java.util.Set;
import uk.me.parabola.imgfmt.app.Area;
import uk.me.parabola.imgfmt.app.Coord;
......@@ -28,7 +25,7 @@ import uk.me.parabola.util.EnhancedProperties;
/**
* The hook removes all elements that will not be included in the map and can therefore
* be safely removed. This improves the performance because the elements does not have
* be safely removed. This improves the performance because the elements do not have
* to go through the style system.
*
* @author WanMil
......@@ -39,7 +36,7 @@ public class UnusedElementsRemoverHook extends OsmReadingHooksAdaptor {
private ElementSaver saver;
/** node with tags of this list must not be removed */
private Collection<String> nodeTagBlacklist;
private List<Entry<String,String>> areasToPoiNodeTags;
public UnusedElementsRemoverHook() {
}
......@@ -51,12 +48,10 @@ public class UnusedElementsRemoverHook extends OsmReadingHooksAdaptor {
// where the POI is placed in polygons. They must not be removed if the polygon
// is not removed. Checking if the polygon is not removed is too costly therefore
// all nodes with these tags are kept.
nodeTagBlacklist = new HashSet<String>();
List<Entry<String,String>> areasToPoiNodeTags = POIGeneratorHook.getPoiPlacementTags(props);
for (Entry<String,String> nodeTags : areasToPoiNodeTags) {
nodeTagBlacklist.add(nodeTags.getKey());
}
if (props.containsKey("add-pois-to-areas"))
areasToPoiNodeTags = POIGeneratorHook.getPoiPlacementTags(props);
else
areasToPoiNodeTags = new ArrayList<>();
return true;
}
......@@ -81,11 +76,13 @@ public class UnusedElementsRemoverHook extends OsmReadingHooksAdaptor {
if (bbox.contains(node.getLocation()) == false) {
boolean removeNode = true;
// check if the node has no tag of the blacklist
if (nodeTagBlacklist.isEmpty() == false) {
for (String tag : nodeTagBlacklist ) {
if (node.getTag(tag) != null) {
// the node contains one tag that might be interesting for the POIGeneratorHook
for (Entry<String, String> tag : areasToPoiNodeTags) {
// check if the node has a tag used by the POIGeneratorHook
String val = node.getTag(tag.getKey());
if (val != null) {
if (tag.getValue() == null || val.equals(tag.getValue())) {
// the node contains one tag that might be
// interesting for the POIGeneratorHook
// do not remove it
removeNode = false;
break;
......@@ -100,22 +97,7 @@ public class UnusedElementsRemoverHook extends OsmReadingHooksAdaptor {
}
}
long tr1 = System.currentTimeMillis();
// store all way ids that are referenced by a relation
// all tags without a tag must not be removed if they are referenced by a relation
Set<Long> relationWays = new HashSet<Long>();
for (Relation rel : saver.getRelations().values()) {
for (Entry<String, Element> relEntry : rel.getElements()) {
if (relEntry.getValue() instanceof Way) {
relationWays.add(relEntry.getValue().getId());
}
}
}
log.debug("Collecting way ids from relations took", (System.currentTimeMillis()-tr1), "ms");
Rectangle bboxRect = new Rectangle(bbox.getMinLong(), bbox.getMinLat(), bbox.getWidth(), bbox.getHeight());
long relWays = 0;
long ways = saver.getWays().size();
for (Way way : new ArrayList<Way>(saver.getWays().values())) {
if (way.getPoints().isEmpty()) {
......@@ -124,16 +106,12 @@ public class UnusedElementsRemoverHook extends OsmReadingHooksAdaptor {
continue;
}
// check if a way has no tags and is not a member of a relation
// a relation might be used to add tags to the way using the style file
// check if a way has no tags
// it is presumed that the RelationStyleHook was already executed
if (way.getTagCount() == 0) {
if (relationWays.contains(way.getId())) {
relWays++;
} else {
saver.getWays().remove(way.getId());
continue;
}
}
// check if the way is completely outside the tile bounding box
boolean coordInBbox = false;
......@@ -183,15 +161,14 @@ public class UnusedElementsRemoverHook extends OsmReadingHooksAdaptor {
// no coord of the way is within the bounding box
// check if the way possibly covers the bounding box completely
Area wayBbox = new Area(minLat, minLong, maxLat, maxLong);
if (wayBbox.intersects(saver.getBoundingBox())) {
log.debug(way, "possibly covers the bbox completely. Keep it.", way.toTagString());
if (wayBbox.contains(saver.getBoundingBox())) {
log.debug(way, "possibly covers the bbox completely. Keep it.");
} else {
saver.getWays().remove(way.getId());
}
}
}
log.info("Relation referenced ways:", relationWays.size(), "Used:", relWays);
log.info("Nodes: before:", nodes, "after:", saver.getNodes().size());
log.info("Ways: before:", ways, "after:", saver.getWays().size());
log.info("Removing unused elements took", (System.currentTimeMillis()-t1), "ms");
......