diff --git a/DataExtractionOSM/src/net/osmand/ToDoConstants.java b/DataExtractionOSM/src/net/osmand/ToDoConstants.java index d18a09ddce..ba8f771f7a 100644 --- a/DataExtractionOSM/src/net/osmand/ToDoConstants.java +++ b/DataExtractionOSM/src/net/osmand/ToDoConstants.java @@ -12,17 +12,15 @@ public class ToDoConstants { // Map QuadTree (skip small areas!!!) // POI index exclude building hno from categories!!! - // Routing index + // Routing index !! // Identify coastline areas and pure ocean areas !!! - // Polish UI with new builiding style + + + // Polish UI with new builiding address search ...(Better completely new address search) // Test images in the map - // TODO - // Ref and other names are not provided as additional types (on level < 15)! - - // == Osmand application (TODO 127) == // TODO prepare C++ version of routing algorithm diff --git a/DataExtractionOSM/src/net/osmand/binary/BinaryMapDataObject.java b/DataExtractionOSM/src/net/osmand/binary/BinaryMapDataObject.java index 464d43e346..4002711ee6 100644 --- a/DataExtractionOSM/src/net/osmand/binary/BinaryMapDataObject.java +++ b/DataExtractionOSM/src/net/osmand/binary/BinaryMapDataObject.java @@ -26,9 +26,20 @@ public class BinaryMapDataObject { public String getName(){ if(objectNames == null){ - return null; + return ""; } - return objectNames.get(mapIndex.nameEncodingType); + String name = objectNames.get(mapIndex.nameEncodingType); + if(name == null){ + return ""; + } + return name; + } + + public String getRef(){ + if(mapIndex.refEncodingType != -1 && objectNames != null) { + return objectNames.get(mapIndex.refEncodingType); + } + return null; } public TIntObjectHashMap getObjectNames() { diff --git a/DataExtractionOSM/src/net/osmand/binary/BinaryMapIndexReader.java b/DataExtractionOSM/src/net/osmand/binary/BinaryMapIndexReader.java index 7856b001b4..608f53cbc6 100644 --- a/DataExtractionOSM/src/net/osmand/binary/BinaryMapIndexReader.java +++ b/DataExtractionOSM/src/net/osmand/binary/BinaryMapIndexReader.java @@ -566,6 +566,10 @@ public class BinaryMapIndexReader { index.encodingRules.get(tag).put(val, id); if("name".equals(tag)){ index.nameEncodingType = id; + } else if("natural".equals(tag) && "coastline".equals(val)){ + index.coastlineEncodingType = id; + } else if("ref".equals(tag)){ + index.refEncodingType = id; } if(!index.decodingRules.containsKey(id)){ index.decodingRules.put(id, new TagValuePair(tag, val, type)); @@ -1316,6 +1320,8 @@ public class BinaryMapIndexReader { Map> encodingRules = new LinkedHashMap>(); TIntObjectMap decodingRules = new TIntObjectHashMap(); int nameEncodingType = 0; + int refEncodingType = -1; + int coastlineEncodingType = 0; public List getRoots() { return roots; diff --git a/DataExtractionOSM/src/net/osmand/router/BinaryRoutePlanner.java b/DataExtractionOSM/src/net/osmand/router/BinaryRoutePlanner.java index b419cfbfe7..f4c9097df5 100644 --- a/DataExtractionOSM/src/net/osmand/router/BinaryRoutePlanner.java +++ b/DataExtractionOSM/src/net/osmand/router/BinaryRoutePlanner.java @@ -440,6 +440,7 @@ public class BinaryRoutePlanner { return null; } + private RouteSegment processIntersectionsWithWays(RoutingContext ctx, PriorityQueue graphSegments, @@ -487,25 +488,25 @@ public class BinaryRoutePlanner { if ((!alreadyVisited && processRoad) || oppositeConnectionFound) { int type = -1; if (!reverseWay) { - for (int i = 0; i < road.getRestrictionCount(); i++) { - if (road.getRestriction(i) == next.road.getId()) { - type = road.getRestrictionType(i); + for (int i = 0; i < getRestrictionCount(road); i++) { + if (getRestriction(road, i) == next.road.getId()) { + type = getRestrictionType(road, i); break; } } } else { - for (int i = 0; i < next.road.getRestrictionCount(); i++) { - if (next.road.getRestriction(i) == road.getId()) { - type = next.road.getRestrictionType(i); + for (int i = 0; i < getRestrictionCount(next.road); i++) { + if (getRestriction(next.road, i) == road.getId()) { + type = getRestrictionType(next.road, i); break; } // Check if there is restriction only to the current road - if (next.road.getRestrictionType(i) == MapRenderingTypes.RESTRICTION_ONLY_RIGHT_TURN - || next.road.getRestrictionType(i) == MapRenderingTypes.RESTRICTION_ONLY_LEFT_TURN - || next.road.getRestrictionType(i) == MapRenderingTypes.RESTRICTION_ONLY_STRAIGHT_ON) { + if (getRestrictionType(next.road, i) == MapRenderingTypes.RESTRICTION_ONLY_RIGHT_TURN + || getRestrictionType(next.road, i) == MapRenderingTypes.RESTRICTION_ONLY_LEFT_TURN + || getRestrictionType(next.road, i) == MapRenderingTypes.RESTRICTION_ONLY_STRAIGHT_ON) { // check if that restriction applies to considered junk RouteSegment foundNext = inputNext; - while(foundNext != null && foundNext.getRoad().getId() != next.road.getRestriction(i)){ + while(foundNext != null && foundNext.getRoad().getId() != getRestriction(next.road, i)){ foundNext = foundNext.next; } if(foundNext != null) { @@ -618,6 +619,21 @@ public class BinaryRoutePlanner { + private int getRestrictionType(BinaryMapDataObject road, int i) { + throw new UnsupportedOperationException(); + } + + + private long getRestriction(BinaryMapDataObject road, int i) { + throw new UnsupportedOperationException(); + } + + + private int getRestrictionCount(BinaryMapDataObject road) { + throw new UnsupportedOperationException(); + } + + private List prepareResult(RoutingContext ctx, RouteSegment start, RouteSegment end, long startNanoTime, RouteSegment finalDirectRoute, RouteSegment finalReverseRoute) { List result = new ArrayList(); @@ -681,9 +697,13 @@ public class BinaryRoutePlanner { " start_lat=\"{0}\" start_lon=\"{1}\" target_lat=\"{2}\" target_lon=\"{3}\">", startLat+"", startLon+"", endLat+"", endLon+"")); for (RouteSegmentResult res : result) { + String name = res.object.getName(); + if(res.object.getRef() != null) { + name += " " + res.object.getRef(); + } // (res.object.getId() >> 1) System.out.println(MessageFormat.format("\t", - (res.object.getId() >> 1)+"", res.startPointIndex, res.endPointIndex, (res.object.getName()+"").replace(MapRenderingTypes.REF_CHAR, ' '))); + (res.object.getId() >> 1)+"", res.startPointIndex, res.endPointIndex, name)); } System.out.println(""); } diff --git a/DataExtractionOSM/src/net/osmand/router/CarRouter.java b/DataExtractionOSM/src/net/osmand/router/CarRouter.java index 7515bdb056..0368ab6efd 100644 --- a/DataExtractionOSM/src/net/osmand/router/CarRouter.java +++ b/DataExtractionOSM/src/net/osmand/router/CarRouter.java @@ -142,7 +142,7 @@ public class CarRouter extends VehicleRouter { @Override public double defineSpeed(BinaryMapDataObject road) { TagValuePair pair = road.getTagValue(0); - double speed = MapRenderingTypes.getMaxSpeedIfDefined(road.getHighwayAttributes()) / 3.6d; + double speed = MapRenderingTypes.getMaxSpeedIfDefined(getHighwayAttributes(road)) / 3.6d; boolean highway = "highway".equals(pair.tag); double priority = highway && autoPriorityValues.containsKey(pair.value) ? autoPriorityValues.get(pair.value) : 0.5d; if (speed == 0 && highway) { diff --git a/DataExtractionOSM/src/net/osmand/router/VehicleRouter.java b/DataExtractionOSM/src/net/osmand/router/VehicleRouter.java index 04deff5adc..adfd1f341c 100644 --- a/DataExtractionOSM/src/net/osmand/router/VehicleRouter.java +++ b/DataExtractionOSM/src/net/osmand/router/VehicleRouter.java @@ -24,8 +24,12 @@ public abstract class VehicleRouter { public abstract boolean acceptPoint(TagValuePair pair); + public int getHighwayAttributes(BinaryMapDataObject road){ + throw new UnsupportedOperationException(); + } + public boolean isOneWay(BinaryMapDataObject road) { - int attributes = road.getHighwayAttributes(); + int attributes = getHighwayAttributes(road); return MapRenderingTypes.isOneWayWay(attributes) || MapRenderingTypes.isRoundabout(attributes); }