Basic routing support

This commit is contained in:
Victor Shcherb 2012-06-09 00:34:13 +02:00
parent 04e45d0199
commit 4a8ff5ba10
20 changed files with 944 additions and 1286 deletions

View file

@ -49,7 +49,7 @@ public class BinaryInspector {
// test cases show info
// inspector(new String[]{/*"-vmap", "-bbox=-121.785,37.35,-121.744,37.33", */"/home/victor/projects/OsmAnd/data/osm-gen/Ru-spe.obf"});
inspector(new String[]{/*"-vmap", "-bbox=-121.785,37.35,-121.744,37.33", */"/home/victor/projects/OsmAnd/data/osm-gen/Ru-spe.obf"});
// test case extract parts
// test case
}

View file

@ -29,7 +29,9 @@ import net.osmand.CollatorStringMatcher.StringMatcherMode;
import net.osmand.binary.BinaryMapAddressReaderAdapter.AddressRegion;
import net.osmand.binary.BinaryMapAddressReaderAdapter.CitiesBlock;
import net.osmand.binary.BinaryMapPoiReaderAdapter.PoiRegion;
import net.osmand.binary.BinaryMapRouteReaderAdapter.RouteDataObject;
import net.osmand.binary.BinaryMapRouteReaderAdapter.RouteRegion;
import net.osmand.binary.BinaryMapRouteReaderAdapter.RouteSubregion;
import net.osmand.binary.BinaryMapTransportReaderAdapter.TransportIndex;
import net.osmand.binary.OsmandOdb.MapDataBlock;
import net.osmand.binary.OsmandOdb.OsmAndMapIndex.MapDataBox;
@ -74,7 +76,7 @@ public class BinaryMapIndexReader {
private final BinaryMapTransportReaderAdapter transportAdapter;
private final BinaryMapPoiReaderAdapter poiAdapter;
private final BinaryMapAddressReaderAdapter addressAdapter;
private BinaryMapRouteReaderAdapter routeAdapter;
private final BinaryMapRouteReaderAdapter routeAdapter;
private static String BASEMAP_NAME = "basemap";
@ -114,6 +116,7 @@ public class BinaryMapIndexReader {
transportAdapter = null;
addressAdapter = null;
poiAdapter = null;
routeAdapter = null;
}
init();
}
@ -243,6 +246,10 @@ public class BinaryMapIndexReader {
return mapIndexes;
}
public List<RouteRegion> getRoutingIndexes() {
return routingIndexes;
}
public boolean isBasemap() {
return basemap;
}
@ -1141,7 +1148,7 @@ public class BinaryMapIndexReader {
return req.getSearchResults();
}
private List<String> readStringTable() throws IOException{
protected List<String> readStringTable() throws IOException{
List<String> list = new ArrayList<String>();
while(true){
int t = codedIS.readTag();
@ -1216,6 +1223,18 @@ public class BinaryMapIndexReader {
return request;
}
public static SearchRequest<RouteDataObject> buildSearchRouteRequest(int sleft, int sright, int stop, int sbottom,
ResultMatcher<RouteDataObject> matcher){
SearchRequest<RouteDataObject> request = new SearchRequest<RouteDataObject>();
request.left = sleft;
request.right = sright;
request.top = stop;
request.bottom = sbottom;
request.resultMatcher = matcher;
return request;
}
public static SearchRequest<Amenity> buildSearchPoiRequest(int x, int y, String nameFilter, ResultMatcher<Amenity> resultMatcher){
SearchRequest<Amenity> request = new SearchRequest<Amenity>();
@ -1350,6 +1369,14 @@ public class BinaryMapIndexReader {
return land;
}
public boolean intersects(int l, int t, int r, int b){
return r >= left && l <= right && t <= bottom && b >= top;
}
public boolean contains(int l, int t, int r, int b){
return r <= right && l >= left && b <= bottom && t >= top;
}
public void clearSearchResults(){
// recreate whole list to allow GC collect old data
searchResults = new ArrayList<T>();
@ -1872,5 +1899,15 @@ public class BinaryMapIndexReader {
}
}));
}
public void searchRouteIndex(SearchRequest<RouteDataObject> req, List<RouteSubregion> list) throws IOException {
req.numberOfVisitedObjects = 0;
req.numberOfAcceptedObjects = 0;
req.numberOfAcceptedSubtrees = 0;
req.numberOfReadSubtrees = 0;
if(routeAdapter != null){
routeAdapter.searchRouteRegion(req, list);
}
}
}

View file

@ -1,12 +1,22 @@
package net.osmand.binary;
import gnu.trove.list.array.TIntArrayList;
import gnu.trove.list.array.TLongArrayList;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import net.osmand.LogUtil;
import net.osmand.binary.BinaryMapIndexReader.SearchRequest;
import net.osmand.binary.OsmandOdb.IdTable;
import net.osmand.binary.OsmandOdb.RestrictionData;
import net.osmand.binary.OsmandOdb.OsmAndRoutingIndex.RouteDataBlock;
import net.osmand.binary.OsmandOdb.OsmAndRoutingIndex.RouteDataBox;
import net.osmand.binary.OsmandOdb.OsmAndRoutingIndex.RouteEncodingRule;
import net.osmand.binary.OsmandOdb.RouteData;
import org.apache.commons.logging.Log;
@ -14,13 +24,17 @@ import com.google.protobuf.CodedInputStreamRAF;
import com.google.protobuf.WireFormat;
public class BinaryMapRouteReaderAdapter {
private static final Log LOG = LogUtil.getLog(BinaryMapRouteReaderAdapter.class);
protected static final Log LOG = LogUtil.getLog(BinaryMapRouteReaderAdapter.class);
private static final int SHIFT_COORDINATES = 5;
public static class RouteTypeRule {
private final static int ACCESS = 1;
private final static int ONEWAY = 2;
private final static int HIGHWAY_TYPE = 3;
private final static int MAXSPEED = 4;
private final static int ROUNDABOUT = 5;
public final static int TRAFFIC_SIGNALS = 6;
public final static int RAILWAY_CROSSING = 6;
private final String t;
private final String v;
private int intValue;
@ -33,6 +47,14 @@ public class BinaryMapRouteReaderAdapter {
analyze();
}
public boolean roundabout(){
return type == ROUNDABOUT;
}
public int getType() {
return type;
}
public int onewayDirection(){
if(type == ONEWAY){
return intValue;
@ -61,8 +83,15 @@ public class BinaryMapRouteReaderAdapter {
intValue = -1;
} else if("1".equals(v) || "yes".equals(v)) {
intValue = 1;
} else {
intValue = 0;
}
intValue = 0;
} else if(t.equalsIgnoreCase("highway") && "traffic_signals".equals(v)){
type = TRAFFIC_SIGNALS;
} else if(t.equalsIgnoreCase("railway") && ("crossing".equals(v) || "level_crossing".equals(v))){
type = RAILWAY_CROSSING;
} else if(t.equalsIgnoreCase("roundabout") && v != null){
type = ROUNDABOUT;
} else if(t.equalsIgnoreCase("highway") && v != null){
type = HIGHWAY_TYPE;
} else if(t.startsWith("access") && v != null){
@ -75,7 +104,7 @@ public class BinaryMapRouteReaderAdapter {
}
if(i > 0) {
floatValue = Integer.parseInt(v.substring(0, i));
floatValue *= 3.6; // km/h -> m/s
floatValue /= 3.6; // km/h -> m/s
if(v.contains("mph")) {
floatValue *= 1.6;
}
@ -86,6 +115,62 @@ public class BinaryMapRouteReaderAdapter {
}
}
public static class RouteDataObject {
public final RouteRegion region;
public RouteDataObject(RouteRegion region) {
this.region = region;
}
public TIntArrayList types = new TIntArrayList();
public TIntArrayList pointsX = new TIntArrayList();
public TIntArrayList pointsY = new TIntArrayList();
public TLongArrayList restrictions = new TLongArrayList();
public List<TIntArrayList> pointTypes = new ArrayList<TIntArrayList>();
public long id;
public long getId() {
return id;
}
public int getPoint31XTile(int i) {
return pointsX.getQuick(i);
}
public int getPoint31YTile(int i) {
return pointsY.getQuick(i);
}
public int getPointsLength() {
return pointsX.size();
}
public TIntArrayList getPointTypes(int ind) {
if(ind >= pointTypes.size()){
return null;
}
return pointTypes.get(ind);
}
public void setPointTypes(int ind, TIntArrayList l) {
while(ind >= pointTypes.size()){
pointTypes.add(null);
}
pointTypes.set(ind, l);
}
public String getHighway() {
String highway = null;
int sz = types.size();
for (int i = 0; i < sz; i++) {
RouteTypeRule r = region.quickGetEncodingRule(types.getQuick(i));
highway = r.highwayRoad();
if (highway != null) {
break;
}
}
return highway;
}
}
public static class RouteRegion extends BinaryIndexPart {
double leftLongitude;
@ -132,17 +217,19 @@ public class BinaryMapRouteReaderAdapter {
public static class RouteSubregion {
private final static int INT_SIZE = 4;
public final RouteRegion routeReg;
public RouteSubregion(RouteSubregion copy) {
this.routeReg = copy.routeReg;
this.left = copy.left;
this.right = copy.right;
this.top = copy.top;
this.bottom = copy.bottom;
this.filePointer = copy.filePointer;
this.length = copy.length;
}
public RouteSubregion(RouteRegion routeReg) {
this.routeReg = routeReg;
}
public RouteSubregion(RouteSubregion parentReg) {
this.routeReg = parentReg.routeReg;
this.left = parentReg.left;
this.right = parentReg.right;
this.top = parentReg.top;
this.bottom = parentReg.bottom;
}
public int length;
public int filePointer;
public int left;
@ -151,9 +238,10 @@ public class BinaryMapRouteReaderAdapter {
public int bottom;
public int shiftToData;
public List<RouteSubregion> subregions = null;
public List<RouteDataObject> dataObjects = null;
public int getEstimatedSize(){
int shallow = 7 * INT_SIZE + 4 + 4/*list*/;
int shallow = 7 * INT_SIZE + 4*3;
if (subregions != null) {
shallow += 8;
for (RouteSubregion s : subregions) {
@ -204,7 +292,7 @@ public class BinaryMapRouteReaderAdapter {
subregion.length = readInt();
subregion.filePointer = codedIS.getTotalBytesRead();
int oldLimit = codedIS.pushLimit(subregion.length);
readRouteTree(subregion, true);
readRouteTree(subregion, null, 0, true);
region.getSubregions().add(subregion);
codedIS.popLimit(oldLimit);
codedIS.seek(subregion.filePointer + subregion.length);
@ -217,45 +305,158 @@ public class BinaryMapRouteReaderAdapter {
}
}
private RouteSubregion readRouteTree(RouteSubregion routeTree, boolean readChildren) throws IOException {
if(readChildren) {
routeTree.subregions = new ArrayList<BinaryMapRouteReaderAdapter.RouteSubregion>();
private RouteDataObject readRouteDataObject(RouteRegion reg, int pleftx, int ptopy) throws IOException {
RouteDataObject o = new RouteDataObject(reg);
while (true) {
int ts = codedIS.readTag();
int tags = WireFormat.getTagFieldNumber(ts);
switch (tags) {
case 0:
return o;
case RouteData.TYPES_FIELD_NUMBER:
int len = codedIS.readRawVarint32();
int oldLimit = codedIS.pushLimit(len);
while(codedIS.getBytesUntilLimit() > 0) {
o.types.add(codedIS.readRawVarint32());
}
codedIS.popLimit(oldLimit);
break;
case RouteData.POINTS_FIELD_NUMBER:
len = codedIS.readRawVarint32();
oldLimit = codedIS.pushLimit(len);
int px = pleftx >> SHIFT_COORDINATES;
int py = ptopy >> SHIFT_COORDINATES;
while(codedIS.getBytesUntilLimit() > 0){
int x = (codedIS.readSInt32() ) + px;
int y = (codedIS.readSInt32() ) + py;
o.pointsX.add(x << SHIFT_COORDINATES);
o.pointsY.add(y << SHIFT_COORDINATES);
px = x;
py = y;
}
codedIS.popLimit(oldLimit);
break;
case RouteData.POINTTYPES_FIELD_NUMBER:
len = codedIS.readRawVarint32();
oldLimit = codedIS.pushLimit(len);
while(codedIS.getBytesUntilLimit() > 0){
int pointInd = codedIS.readRawVarint32();
TIntArrayList pointTypes = new TIntArrayList();
int lens = codedIS.readRawVarint32();
int oldLimits = codedIS.pushLimit(lens);
while(codedIS.getBytesUntilLimit() > 0){
pointTypes.add(codedIS.readRawVarint32());
}
o.setPointTypes(pointInd, pointTypes);
codedIS.popLimit(oldLimits);
}
codedIS.popLimit(oldLimit);
break;
case RouteData.ROUTEID_FIELD_NUMBER:
o.id = codedIS.readInt32();
break;
default:
skipUnknownField(ts);
break;
}
}
routeTree.routeReg.regionsRead++;
}
private static final int RESTRICTION_SHIFT = 20;
private static final long RESTRICTION_MASK = (1l << RESTRICTION_SHIFT) - 1;
private void readRouteTreeData(RouteSubregion routeTree, TLongArrayList idTables,
TLongArrayList restrictions) throws IOException {
routeTree.dataObjects = new ArrayList<RouteDataObject>();
idTables.clear();
restrictions.clear();
while(true){
int t = codedIS.readTag();
int tag = WireFormat.getTagFieldNumber(t);
switch (tag) {
case 0:
return routeTree;
case RouteDataBox.LEFT_FIELD_NUMBER :
routeTree.left += codedIS.readSInt32();
break;
case RouteDataBox.RIGHT_FIELD_NUMBER :
routeTree.right += codedIS.readSInt32();
break;
case RouteDataBox.TOP_FIELD_NUMBER :
routeTree.top += codedIS.readSInt32();
break;
case RouteDataBox.BOTTOM_FIELD_NUMBER :
routeTree.bottom += codedIS.readSInt32();
break;
case RouteDataBox.SHIFTTODATA_FIELD_NUMBER :
routeTree.shiftToData = readInt();
break;
case RouteDataBox.BOXES_FIELD_NUMBER :
if(readChildren){
RouteSubregion subregion = new RouteSubregion(routeTree);
subregion.length = readInt();
subregion.filePointer = codedIS.getTotalBytesRead();
int oldLimit = codedIS.pushLimit(subregion.length);
readRouteTree(subregion, readChildren);
routeTree.subregions.add(subregion);
codedIS.popLimit(oldLimit);
codedIS.seek(subregion.filePointer + subregion.length);
} else {
skipUnknownField(t);
for (int k = 0; k < restrictions.size(); k++) {
long r = restrictions.get(k);
int from = (int) (r >> (RESTRICTION_SHIFT+RESTRICTION_SHIFT));
int to = (int) ((r >> RESTRICTION_SHIFT) & RESTRICTION_MASK);
int type = (int) (r & RESTRICTION_SHIFT);
RouteDataObject i = routeTree.dataObjects.get(from);
long val = (idTables.get(to) << 3) | ((long)type);
i.restrictions.add(val);
}
for (RouteDataObject o : routeTree.dataObjects) {
if (o != null) {
if (o.id < idTables.size()) {
o.id = idTables.get((int) o.id);
}
}
}
return;
case RouteDataBlock.DATAOBJECTS_FIELD_NUMBER :
int length = codedIS.readRawVarint32();
int oldLimit = codedIS.pushLimit(length);
RouteDataObject obj = readRouteDataObject(routeTree.routeReg, routeTree.left, routeTree.top);
while(obj.id >= routeTree.dataObjects.size()) {
routeTree.dataObjects.add(null);
}
routeTree.dataObjects.set((int) obj.id,obj);
codedIS.popLimit(oldLimit);
break;
case RouteDataBlock.IDTABLE_FIELD_NUMBER :
long routeId = 0;
length = codedIS.readRawVarint32();
oldLimit = codedIS.pushLimit(length);
idLoop : while(true){
int ts = codedIS.readTag();
int tags = WireFormat.getTagFieldNumber(ts);
switch (tags) {
case 0:
break idLoop;
case IdTable.ROUTEID_FIELD_NUMBER :
routeId += codedIS.readSInt64();
idTables.add(routeId);
break;
default:
skipUnknownField(ts);
break;
}
}
codedIS.popLimit(oldLimit);
break;
case RouteDataBlock.RESTRICTIONS_FIELD_NUMBER :
length = codedIS.readRawVarint32();
oldLimit = codedIS.pushLimit(length);
long restriction = 0;
idLoop : while(true){
int ts = codedIS.readTag();
int tags = WireFormat.getTagFieldNumber(ts);
switch (tags) {
case 0:
break idLoop;
case RestrictionData.FROM_FIELD_NUMBER :
long from = codedIS.readInt32();
restriction |= (from << (RESTRICTION_SHIFT+RESTRICTION_SHIFT));
break;
case RestrictionData.TO_FIELD_NUMBER :
long to = codedIS.readInt32();
restriction |= (to << RESTRICTION_SHIFT);
break;
case RestrictionData.TYPE_FIELD_NUMBER :
int type = codedIS.readInt32();
restriction |= type;
break;
default:
skipUnknownField(ts);
break;
}
}
restrictions.add(restriction);
codedIS.popLimit(oldLimit);
break;
case RouteDataBlock.STRINGTABLE_FIELD_NUMBER :
length = codedIS.readRawVarint32();
oldLimit = codedIS.pushLimit(length);
// map.readStringTable();
codedIS.skipRawBytes(codedIS.getBytesUntilLimit());
codedIS.popLimit(oldLimit);
break;
default:
skipUnknownField(t);
@ -264,6 +465,8 @@ public class BinaryMapRouteReaderAdapter {
}
}
private void readRouteEncodingRule(RouteRegion index, int id) throws IOException {
String tags = null;
String val = null;
@ -290,4 +493,112 @@ public class BinaryMapRouteReaderAdapter {
}
}
private RouteSubregion readRouteTree(RouteSubregion thisTree, RouteSubregion parentTree, int depth,
boolean readCoordinates) throws IOException {
boolean readChildren = depth != 0;
if(readChildren) {
thisTree.subregions = new ArrayList<BinaryMapRouteReaderAdapter.RouteSubregion>();
}
thisTree.routeReg.regionsRead++;
while(true){
int t = codedIS.readTag();
int tag = WireFormat.getTagFieldNumber(t);
switch (tag) {
case 0:
return thisTree;
case RouteDataBox.LEFT_FIELD_NUMBER :
int i = codedIS.readSInt32();
if (readCoordinates) {
thisTree.left = i + (parentTree != null ? parentTree.left : 0);
}
break;
case RouteDataBox.RIGHT_FIELD_NUMBER :
i = codedIS.readSInt32();
if (readCoordinates) {
thisTree.right = i + (parentTree != null ? parentTree.right : 0);
}
break;
case RouteDataBox.TOP_FIELD_NUMBER :
i = codedIS.readSInt32();
if (readCoordinates) {
thisTree.top = i + (parentTree != null ? parentTree.top : 0);
}
break;
case RouteDataBox.BOTTOM_FIELD_NUMBER :
i = codedIS.readSInt32();
if (readCoordinates) {
thisTree.bottom = i + (parentTree != null ? parentTree.bottom : 0);
}
break;
case RouteDataBox.SHIFTTODATA_FIELD_NUMBER :
thisTree.shiftToData = readInt();
break;
case RouteDataBox.BOXES_FIELD_NUMBER :
if(readChildren){
RouteSubregion subregion = new RouteSubregion(thisTree.routeReg);
subregion.length = readInt();
subregion.filePointer = codedIS.getTotalBytesRead();
int oldLimit = codedIS.pushLimit(subregion.length);
readRouteTree(subregion, thisTree, depth - 1, true);
thisTree.subregions.add(subregion);
codedIS.popLimit(oldLimit);
codedIS.seek(subregion.filePointer + subregion.length);
} else {
skipUnknownField(t);
}
break;
default:
skipUnknownField(t);
break;
}
}
}
public void searchRouteRegion(SearchRequest<RouteDataObject> req, List<RouteSubregion> list) throws IOException {
List<RouteSubregion> toLoad = new ArrayList<BinaryMapRouteReaderAdapter.RouteSubregion>();
searchRouteRegion(req, list, toLoad);
Collections.sort(toLoad, new Comparator<RouteSubregion>() {
@Override
public int compare(RouteSubregion o1, RouteSubregion o2) {
int p1 = o1.filePointer + o1.shiftToData;
int p2 = o2.filePointer + o2.shiftToData;
return p1 == p2 ? 0 : (p1 < p2 ? -1 : 1);
}
});
TLongArrayList idMap = new TLongArrayList();
TLongArrayList restrictionMap = new TLongArrayList();
for (RouteSubregion rs : toLoad) {
if (rs.dataObjects == null) {
codedIS.seek(rs.filePointer + rs.shiftToData);
int limit = codedIS.readRawVarint32();
int oldLimit = codedIS.pushLimit(limit);
readRouteTreeData(rs, idMap, restrictionMap);
codedIS.popLimit(oldLimit);
}
for (RouteDataObject ro : rs.dataObjects) {
if (ro != null) {
req.publish(ro);
}
}
}
}
private void searchRouteRegion(SearchRequest<RouteDataObject> req, List<RouteSubregion> list, List<RouteSubregion> toLoad) throws IOException {
for(RouteSubregion rs : list){
if (req.intersects(rs.left, rs.top, rs.right, rs.bottom)) {
if (rs.subregions == null) {
codedIS.seek(rs.filePointer);
int old = codedIS.pushLimit(rs.length);
readRouteTree(rs, null, req.contains(rs.left, rs.top, rs.right, rs.bottom) ? -1 : 1, false);
codedIS.popLimit(old);
}
searchRouteRegion(req, rs.subregions, toLoad);
if (rs.shiftToData != 0) {
toLoad.add(rs);
}
}
}
}
}

View file

@ -18234,18 +18234,6 @@ public final class OsmandOdb {
return routeId_.get(index);
}
// repeated sint64 pointId = 2;
public static final int POINTID_FIELD_NUMBER = 2;
private java.util.List<java.lang.Long> pointId_ =
java.util.Collections.emptyList();
public java.util.List<java.lang.Long> getPointIdList() {
return pointId_;
}
public int getPointIdCount() { return pointId_.size(); }
public long getPointId(int index) {
return pointId_.get(index);
}
private void initFields() {
}
@Override
@ -18260,9 +18248,6 @@ public final class OsmandOdb {
for (long element : getRouteIdList()) {
output.writeSInt64(1, element);
}
for (long element : getPointIdList()) {
output.writeSInt64(2, element);
}
getUnknownFields().writeTo(output);
}
@ -18282,15 +18267,6 @@ public final class OsmandOdb {
size += dataSize;
size += 1 * getRouteIdList().size();
}
{
int dataSize = 0;
for (long element : getPointIdList()) {
dataSize += com.google.protobuf.CodedOutputStream
.computeSInt64SizeNoTag(element);
}
size += dataSize;
size += 1 * getPointIdList().size();
}
size += getUnknownFields().getSerializedSize();
memoizedSerializedSize = size;
return size;
@ -18447,10 +18423,6 @@ public final class OsmandOdb {
result.routeId_ =
java.util.Collections.unmodifiableList(result.routeId_);
}
if (result.pointId_ != java.util.Collections.EMPTY_LIST) {
result.pointId_ =
java.util.Collections.unmodifiableList(result.pointId_);
}
net.osmand.binary.OsmandOdb.IdTable returnMe = result;
result = null;
return returnMe;
@ -18474,12 +18446,6 @@ public final class OsmandOdb {
}
result.routeId_.addAll(other.routeId_);
}
if (!other.pointId_.isEmpty()) {
if (result.pointId_.isEmpty()) {
result.pointId_ = new java.util.ArrayList<java.lang.Long>();
}
result.pointId_.addAll(other.pointId_);
}
this.mergeUnknownFields(other.getUnknownFields());
return this;
}
@ -18519,19 +18485,6 @@ public final class OsmandOdb {
input.popLimit(limit);
break;
}
case 16: {
addPointId(input.readSInt64());
break;
}
case 18: {
int length = input.readRawVarint32();
int limit = input.pushLimit(length);
while (input.getBytesUntilLimit() > 0) {
addPointId(input.readSInt64());
}
input.popLimit(limit);
break;
}
}
}
}
@ -18571,40 +18524,6 @@ public final class OsmandOdb {
return this;
}
// repeated sint64 pointId = 2;
public java.util.List<java.lang.Long> getPointIdList() {
return java.util.Collections.unmodifiableList(result.pointId_);
}
public int getPointIdCount() {
return result.getPointIdCount();
}
public long getPointId(int index) {
return result.getPointId(index);
}
public Builder setPointId(int index, long value) {
result.pointId_.set(index, value);
return this;
}
public Builder addPointId(long value) {
if (result.pointId_.isEmpty()) {
result.pointId_ = new java.util.ArrayList<java.lang.Long>();
}
result.pointId_.add(value);
return this;
}
public Builder addAllPointId(
java.lang.Iterable<? extends java.lang.Long> values) {
if (result.pointId_.isEmpty()) {
result.pointId_ = new java.util.ArrayList<java.lang.Long>();
}
super.addAll(values, result.pointId_);
return this;
}
public Builder clearPointId() {
result.pointId_ = java.util.Collections.emptyList();
return this;
}
// @@protoc_insertion_point(builder_scope:IdTable)
}
@ -19038,392 +18957,6 @@ public final class OsmandOdb {
// @@protoc_insertion_point(class_scope:RestrictionData)
}
public static final class RoutePoint extends
com.google.protobuf.GeneratedMessage {
// Use RoutePoint.newBuilder() to construct.
private RoutePoint() {
initFields();
}
private RoutePoint(boolean noInit) {}
private static final RoutePoint defaultInstance;
public static RoutePoint getDefaultInstance() {
return defaultInstance;
}
@Override
public RoutePoint getDefaultInstanceForType() {
return defaultInstance;
}
public static final com.google.protobuf.Descriptors.Descriptor
getDescriptor() {
return net.osmand.binary.OsmandOdb.internal_static_RoutePoint_descriptor;
}
@Override
protected com.google.protobuf.GeneratedMessage.FieldAccessorTable
internalGetFieldAccessorTable() {
return net.osmand.binary.OsmandOdb.internal_static_RoutePoint_fieldAccessorTable;
}
// required bytes point = 1;
public static final int POINT_FIELD_NUMBER = 1;
private boolean hasPoint;
private com.google.protobuf.ByteString point_ = com.google.protobuf.ByteString.EMPTY;
public boolean hasPoint() { return hasPoint; }
public com.google.protobuf.ByteString getPoint() { return point_; }
// optional uint32 pointId = 2;
public static final int POINTID_FIELD_NUMBER = 2;
private boolean hasPointId;
private int pointId_ = 0;
public boolean hasPointId() { return hasPointId; }
public int getPointId() { return pointId_; }
// optional bytes types = 4;
public static final int TYPES_FIELD_NUMBER = 4;
private boolean hasTypes;
private com.google.protobuf.ByteString types_ = com.google.protobuf.ByteString.EMPTY;
public boolean hasTypes() { return hasTypes; }
public com.google.protobuf.ByteString getTypes() { return types_; }
private void initFields() {
}
@Override
public final boolean isInitialized() {
if (!hasPoint) return false;
return true;
}
@Override
public void writeTo(com.google.protobuf.CodedOutputStream output)
throws java.io.IOException {
getSerializedSize();
if (hasPoint()) {
output.writeBytes(1, getPoint());
}
if (hasPointId()) {
output.writeUInt32(2, getPointId());
}
if (hasTypes()) {
output.writeBytes(4, getTypes());
}
getUnknownFields().writeTo(output);
}
private int memoizedSerializedSize = -1;
@Override
public int getSerializedSize() {
int size = memoizedSerializedSize;
if (size != -1) return size;
size = 0;
if (hasPoint()) {
size += com.google.protobuf.CodedOutputStream
.computeBytesSize(1, getPoint());
}
if (hasPointId()) {
size += com.google.protobuf.CodedOutputStream
.computeUInt32Size(2, getPointId());
}
if (hasTypes()) {
size += com.google.protobuf.CodedOutputStream
.computeBytesSize(4, getTypes());
}
size += getUnknownFields().getSerializedSize();
memoizedSerializedSize = size;
return size;
}
public static net.osmand.binary.OsmandOdb.RoutePoint parseFrom(
com.google.protobuf.ByteString data)
throws com.google.protobuf.InvalidProtocolBufferException {
return newBuilder().mergeFrom(data).buildParsed();
}
public static net.osmand.binary.OsmandOdb.RoutePoint parseFrom(
com.google.protobuf.ByteString data,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws com.google.protobuf.InvalidProtocolBufferException {
return newBuilder().mergeFrom(data, extensionRegistry)
.buildParsed();
}
public static net.osmand.binary.OsmandOdb.RoutePoint parseFrom(byte[] data)
throws com.google.protobuf.InvalidProtocolBufferException {
return newBuilder().mergeFrom(data).buildParsed();
}
public static net.osmand.binary.OsmandOdb.RoutePoint parseFrom(
byte[] data,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws com.google.protobuf.InvalidProtocolBufferException {
return newBuilder().mergeFrom(data, extensionRegistry)
.buildParsed();
}
public static net.osmand.binary.OsmandOdb.RoutePoint parseFrom(java.io.InputStream input)
throws java.io.IOException {
return newBuilder().mergeFrom(input).buildParsed();
}
public static net.osmand.binary.OsmandOdb.RoutePoint parseFrom(
java.io.InputStream input,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws java.io.IOException {
return newBuilder().mergeFrom(input, extensionRegistry)
.buildParsed();
}
public static net.osmand.binary.OsmandOdb.RoutePoint parseDelimitedFrom(java.io.InputStream input)
throws java.io.IOException {
Builder builder = newBuilder();
if (builder.mergeDelimitedFrom(input)) {
return builder.buildParsed();
} else {
return null;
}
}
public static net.osmand.binary.OsmandOdb.RoutePoint parseDelimitedFrom(
java.io.InputStream input,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws java.io.IOException {
Builder builder = newBuilder();
if (builder.mergeDelimitedFrom(input, extensionRegistry)) {
return builder.buildParsed();
} else {
return null;
}
}
public static net.osmand.binary.OsmandOdb.RoutePoint parseFrom(
com.google.protobuf.CodedInputStream input)
throws java.io.IOException {
return newBuilder().mergeFrom(input).buildParsed();
}
public static net.osmand.binary.OsmandOdb.RoutePoint parseFrom(
com.google.protobuf.CodedInputStream input,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws java.io.IOException {
return newBuilder().mergeFrom(input, extensionRegistry)
.buildParsed();
}
public static Builder newBuilder() { return Builder.create(); }
@Override
public Builder newBuilderForType() { return newBuilder(); }
public static Builder newBuilder(net.osmand.binary.OsmandOdb.RoutePoint prototype) {
return newBuilder().mergeFrom(prototype);
}
@Override
public Builder toBuilder() { return newBuilder(this); }
public static final class Builder extends
com.google.protobuf.GeneratedMessage.Builder<Builder> {
private net.osmand.binary.OsmandOdb.RoutePoint result;
// Construct using net.osmand.binary.OsmandOdb.RoutePoint.newBuilder()
private Builder() {}
private static Builder create() {
Builder builder = new Builder();
builder.result = new net.osmand.binary.OsmandOdb.RoutePoint();
return builder;
}
@Override
protected net.osmand.binary.OsmandOdb.RoutePoint internalGetResult() {
return result;
}
@Override
public Builder clear() {
if (result == null) {
throw new IllegalStateException(
"Cannot call clear() after build().");
}
result = new net.osmand.binary.OsmandOdb.RoutePoint();
return this;
}
@Override
public Builder clone() {
return create().mergeFrom(result);
}
@Override
public com.google.protobuf.Descriptors.Descriptor
getDescriptorForType() {
return net.osmand.binary.OsmandOdb.RoutePoint.getDescriptor();
}
@Override
public net.osmand.binary.OsmandOdb.RoutePoint getDefaultInstanceForType() {
return net.osmand.binary.OsmandOdb.RoutePoint.getDefaultInstance();
}
@Override
public boolean isInitialized() {
return result.isInitialized();
}
@Override
public net.osmand.binary.OsmandOdb.RoutePoint build() {
if (result != null && !isInitialized()) {
throw newUninitializedMessageException(result);
}
return buildPartial();
}
private net.osmand.binary.OsmandOdb.RoutePoint buildParsed()
throws com.google.protobuf.InvalidProtocolBufferException {
if (!isInitialized()) {
throw newUninitializedMessageException(
result).asInvalidProtocolBufferException();
}
return buildPartial();
}
@Override
public net.osmand.binary.OsmandOdb.RoutePoint buildPartial() {
if (result == null) {
throw new IllegalStateException(
"build() has already been called on this Builder.");
}
net.osmand.binary.OsmandOdb.RoutePoint returnMe = result;
result = null;
return returnMe;
}
@Override
public Builder mergeFrom(com.google.protobuf.Message other) {
if (other instanceof net.osmand.binary.OsmandOdb.RoutePoint) {
return mergeFrom((net.osmand.binary.OsmandOdb.RoutePoint)other);
} else {
super.mergeFrom(other);
return this;
}
}
public Builder mergeFrom(net.osmand.binary.OsmandOdb.RoutePoint other) {
if (other == net.osmand.binary.OsmandOdb.RoutePoint.getDefaultInstance()) return this;
if (other.hasPoint()) {
setPoint(other.getPoint());
}
if (other.hasPointId()) {
setPointId(other.getPointId());
}
if (other.hasTypes()) {
setTypes(other.getTypes());
}
this.mergeUnknownFields(other.getUnknownFields());
return this;
}
@Override
public Builder mergeFrom(
com.google.protobuf.CodedInputStream input,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws java.io.IOException {
com.google.protobuf.UnknownFieldSet.Builder unknownFields =
com.google.protobuf.UnknownFieldSet.newBuilder(
this.getUnknownFields());
while (true) {
int tag = input.readTag();
switch (tag) {
case 0:
this.setUnknownFields(unknownFields.build());
return this;
default: {
if (!parseUnknownField(input, unknownFields,
extensionRegistry, tag)) {
this.setUnknownFields(unknownFields.build());
return this;
}
break;
}
case 10: {
setPoint(input.readBytes());
break;
}
case 16: {
setPointId(input.readUInt32());
break;
}
case 34: {
setTypes(input.readBytes());
break;
}
}
}
}
// required bytes point = 1;
public boolean hasPoint() {
return result.hasPoint();
}
public com.google.protobuf.ByteString getPoint() {
return result.getPoint();
}
public Builder setPoint(com.google.protobuf.ByteString value) {
if (value == null) {
throw new NullPointerException();
}
result.hasPoint = true;
result.point_ = value;
return this;
}
public Builder clearPoint() {
result.hasPoint = false;
result.point_ = getDefaultInstance().getPoint();
return this;
}
// optional uint32 pointId = 2;
public boolean hasPointId() {
return result.hasPointId();
}
public int getPointId() {
return result.getPointId();
}
public Builder setPointId(int value) {
result.hasPointId = true;
result.pointId_ = value;
return this;
}
public Builder clearPointId() {
result.hasPointId = false;
result.pointId_ = 0;
return this;
}
// optional bytes types = 4;
public boolean hasTypes() {
return result.hasTypes();
}
public com.google.protobuf.ByteString getTypes() {
return result.getTypes();
}
public Builder setTypes(com.google.protobuf.ByteString value) {
if (value == null) {
throw new NullPointerException();
}
result.hasTypes = true;
result.types_ = value;
return this;
}
public Builder clearTypes() {
result.hasTypes = false;
result.types_ = getDefaultInstance().getTypes();
return this;
}
// @@protoc_insertion_point(builder_scope:RoutePoint)
}
static {
defaultInstance = new RoutePoint(true);
net.osmand.binary.OsmandOdb.internalForceInit();
defaultInstance.initFields();
}
// @@protoc_insertion_point(class_scope:RoutePoint)
}
public static final class RouteData extends
com.google.protobuf.GeneratedMessage {
// Use RouteData.newBuilder() to construct.
@ -19453,17 +18986,19 @@ public final class OsmandOdb {
return net.osmand.binary.OsmandOdb.internal_static_RouteData_fieldAccessorTable;
}
// repeated .RoutePoint points = 1;
// required bytes points = 1;
public static final int POINTS_FIELD_NUMBER = 1;
private java.util.List<net.osmand.binary.OsmandOdb.RoutePoint> points_ =
java.util.Collections.emptyList();
public java.util.List<net.osmand.binary.OsmandOdb.RoutePoint> getPointsList() {
return points_;
}
public int getPointsCount() { return points_.size(); }
public net.osmand.binary.OsmandOdb.RoutePoint getPoints(int index) {
return points_.get(index);
}
private boolean hasPoints;
private com.google.protobuf.ByteString points_ = com.google.protobuf.ByteString.EMPTY;
public boolean hasPoints() { return hasPoints; }
public com.google.protobuf.ByteString getPoints() { return points_; }
// optional bytes pointTypes = 4;
public static final int POINTTYPES_FIELD_NUMBER = 4;
private boolean hasPointTypes;
private com.google.protobuf.ByteString pointTypes_ = com.google.protobuf.ByteString.EMPTY;
public boolean hasPointTypes() { return hasPointTypes; }
public com.google.protobuf.ByteString getPointTypes() { return pointTypes_; }
// required bytes types = 7;
public static final int TYPES_FIELD_NUMBER = 7;
@ -19490,11 +19025,9 @@ public final class OsmandOdb {
}
@Override
public final boolean isInitialized() {
if (!hasPoints) return false;
if (!hasTypes) return false;
if (!hasRouteId) return false;
for (net.osmand.binary.OsmandOdb.RoutePoint element : getPointsList()) {
if (!element.isInitialized()) return false;
}
return true;
}
@ -19502,8 +19035,11 @@ public final class OsmandOdb {
public void writeTo(com.google.protobuf.CodedOutputStream output)
throws java.io.IOException {
getSerializedSize();
for (net.osmand.binary.OsmandOdb.RoutePoint element : getPointsList()) {
output.writeMessage(1, element);
if (hasPoints()) {
output.writeBytes(1, getPoints());
}
if (hasPointTypes()) {
output.writeBytes(4, getPointTypes());
}
if (hasTypes()) {
output.writeBytes(7, getTypes());
@ -19524,9 +19060,13 @@ public final class OsmandOdb {
if (size != -1) return size;
size = 0;
for (net.osmand.binary.OsmandOdb.RoutePoint element : getPointsList()) {
if (hasPoints()) {
size += com.google.protobuf.CodedOutputStream
.computeMessageSize(1, element);
.computeBytesSize(1, getPoints());
}
if (hasPointTypes()) {
size += com.google.protobuf.CodedOutputStream
.computeBytesSize(4, getPointTypes());
}
if (hasTypes()) {
size += com.google.protobuf.CodedOutputStream
@ -19692,10 +19232,6 @@ public final class OsmandOdb {
throw new IllegalStateException(
"build() has already been called on this Builder.");
}
if (result.points_ != java.util.Collections.EMPTY_LIST) {
result.points_ =
java.util.Collections.unmodifiableList(result.points_);
}
net.osmand.binary.OsmandOdb.RouteData returnMe = result;
result = null;
return returnMe;
@ -19713,11 +19249,11 @@ public final class OsmandOdb {
public Builder mergeFrom(net.osmand.binary.OsmandOdb.RouteData other) {
if (other == net.osmand.binary.OsmandOdb.RouteData.getDefaultInstance()) return this;
if (!other.points_.isEmpty()) {
if (result.points_.isEmpty()) {
result.points_ = new java.util.ArrayList<net.osmand.binary.OsmandOdb.RoutePoint>();
}
result.points_.addAll(other.points_);
if (other.hasPoints()) {
setPoints(other.getPoints());
}
if (other.hasPointTypes()) {
setPointTypes(other.getPointTypes());
}
if (other.hasTypes()) {
setTypes(other.getTypes());
@ -19755,9 +19291,11 @@ public final class OsmandOdb {
break;
}
case 10: {
net.osmand.binary.OsmandOdb.RoutePoint.Builder subBuilder = net.osmand.binary.OsmandOdb.RoutePoint.newBuilder();
input.readMessage(subBuilder, extensionRegistry);
addPoints(subBuilder.buildPartial());
setPoints(input.readBytes());
break;
}
case 34: {
setPointTypes(input.readBytes());
break;
}
case 58: {
@ -19777,54 +19315,45 @@ public final class OsmandOdb {
}
// repeated .RoutePoint points = 1;
public java.util.List<net.osmand.binary.OsmandOdb.RoutePoint> getPointsList() {
return java.util.Collections.unmodifiableList(result.points_);
// required bytes points = 1;
public boolean hasPoints() {
return result.hasPoints();
}
public int getPointsCount() {
return result.getPointsCount();
public com.google.protobuf.ByteString getPoints() {
return result.getPoints();
}
public net.osmand.binary.OsmandOdb.RoutePoint getPoints(int index) {
return result.getPoints(index);
}
public Builder setPoints(int index, net.osmand.binary.OsmandOdb.RoutePoint value) {
public Builder setPoints(com.google.protobuf.ByteString value) {
if (value == null) {
throw new NullPointerException();
}
result.points_.set(index, value);
return this;
}
public Builder setPoints(int index, net.osmand.binary.OsmandOdb.RoutePoint.Builder builderForValue) {
result.points_.set(index, builderForValue.build());
return this;
}
public Builder addPoints(net.osmand.binary.OsmandOdb.RoutePoint value) {
if (value == null) {
throw new NullPointerException();
}
if (result.points_.isEmpty()) {
result.points_ = new java.util.ArrayList<net.osmand.binary.OsmandOdb.RoutePoint>();
}
result.points_.add(value);
return this;
}
public Builder addPoints(net.osmand.binary.OsmandOdb.RoutePoint.Builder builderForValue) {
if (result.points_.isEmpty()) {
result.points_ = new java.util.ArrayList<net.osmand.binary.OsmandOdb.RoutePoint>();
}
result.points_.add(builderForValue.build());
return this;
}
public Builder addAllPoints(
java.lang.Iterable<? extends net.osmand.binary.OsmandOdb.RoutePoint> values) {
if (result.points_.isEmpty()) {
result.points_ = new java.util.ArrayList<net.osmand.binary.OsmandOdb.RoutePoint>();
}
super.addAll(values, result.points_);
throw new NullPointerException();
}
result.hasPoints = true;
result.points_ = value;
return this;
}
public Builder clearPoints() {
result.points_ = java.util.Collections.emptyList();
result.hasPoints = false;
result.points_ = getDefaultInstance().getPoints();
return this;
}
// optional bytes pointTypes = 4;
public boolean hasPointTypes() {
return result.hasPointTypes();
}
public com.google.protobuf.ByteString getPointTypes() {
return result.getPointTypes();
}
public Builder setPointTypes(com.google.protobuf.ByteString value) {
if (value == null) {
throw new NullPointerException();
}
result.hasPointTypes = true;
result.pointTypes_ = value;
return this;
}
public Builder clearPointTypes() {
result.hasPointTypes = false;
result.pointTypes_ = getDefaultInstance().getPointTypes();
return this;
}
@ -22162,11 +21691,6 @@ public final class OsmandOdb {
private static
com.google.protobuf.GeneratedMessage.FieldAccessorTable
internal_static_RestrictionData_fieldAccessorTable;
private static com.google.protobuf.Descriptors.Descriptor
internal_static_RoutePoint_descriptor;
private static
com.google.protobuf.GeneratedMessage.FieldAccessorTable
internal_static_RoutePoint_fieldAccessorTable;
private static com.google.protobuf.Descriptors.Descriptor
internal_static_RouteData_descriptor;
private static
@ -22311,28 +21835,26 @@ public final class OsmandOdb {
"\022\n\ncategories\030\004 \003(\r\022\014\n\004name\030\006 \001(\t\022\016\n\006nam" +
"eEn\030\007 \001(\t\022\n\n\002id\030\010 \001(\004\022\024\n\014openingHours\030\n " +
"\001(\t\022\014\n\004site\030\013 \001(\t\022\r\n\005phone\030\014 \001(\t\022\014\n\004note",
"\030\r \001(\t\"+\n\007IdTable\022\017\n\007routeId\030\001 \003(\022\022\017\n\007po" +
"intId\030\002 \003(\022\"F\n\017RestrictionData\022\014\n\004type\030\001" +
" \002(\005\022\014\n\004from\030\002 \002(\005\022\n\n\002to\030\003 \002(\005\022\013\n\003via\030\004 " +
"\001(\005\";\n\nRoutePoint\022\r\n\005point\030\001 \002(\014\022\017\n\007poin" +
"tId\030\002 \001(\r\022\r\n\005types\030\004 \001(\014\"]\n\tRouteData\022\033\n" +
"\006points\030\001 \003(\0132\013.RoutePoint\022\r\n\005types\030\007 \002(" +
"\014\022\017\n\007routeId\030\014 \002(\005\022\023\n\013stringNames\030\016 \001(\014\"" +
"\251\004\n\022OsmAndRoutingIndex\022\014\n\004name\030\001 \002(\t\0224\n\005" +
"rules\030\002 \003(\0132%.OsmAndRoutingIndex.RouteEn" +
"codingRule\0223\n\trootBoxes\030\003 \003(\0132 .OsmAndRo",
"utingIndex.RouteDataBox\0222\n\006blocks\030\005 \003(\0132" +
"\".OsmAndRoutingIndex.RouteDataBlock\032;\n\021R" +
"outeEncodingRule\022\013\n\003tag\030\003 \002(\t\022\r\n\005value\030\005" +
" \002(\t\022\n\n\002id\030\007 \001(\r\032\216\001\n\014RouteDataBox\022\014\n\004lef" +
"t\030\001 \002(\021\022\r\n\005right\030\002 \002(\021\022\013\n\003top\030\003 \002(\021\022\016\n\006b" +
"ottom\030\004 \002(\021\022\023\n\013shiftToData\030\005 \001(\007\022/\n\005boxe" +
"s\030\007 \003(\0132 .OsmAndRoutingIndex.RouteDataBo" +
"x\032\227\001\n\016RouteDataBlock\022\031\n\007idTable\030\005 \001(\0132\010." +
"IdTable\022!\n\013stringTable\030\010 \001(\0132\014.StringTab" +
"le\022\037\n\013dataObjects\030\006 \003(\0132\n.RouteData\022&\n\014r",
"estrictions\030\007 \003(\0132\020.RestrictionDataB\023\n\021n" +
"et.osmand.binary"
"\030\r \001(\t\"\032\n\007IdTable\022\017\n\007routeId\030\001 \003(\022\"F\n\017Re" +
"strictionData\022\014\n\004type\030\001 \002(\005\022\014\n\004from\030\002 \002(" +
"\005\022\n\n\002to\030\003 \002(\005\022\013\n\003via\030\004 \001(\005\"d\n\tRouteData\022" +
"\016\n\006points\030\001 \002(\014\022\022\n\npointTypes\030\004 \001(\014\022\r\n\005t" +
"ypes\030\007 \002(\014\022\017\n\007routeId\030\014 \002(\005\022\023\n\013stringNam" +
"es\030\016 \001(\014\"\251\004\n\022OsmAndRoutingIndex\022\014\n\004name\030" +
"\001 \002(\t\0224\n\005rules\030\002 \003(\0132%.OsmAndRoutingInde" +
"x.RouteEncodingRule\0223\n\trootBoxes\030\003 \003(\0132 " +
".OsmAndRoutingIndex.RouteDataBox\0222\n\006bloc" +
"ks\030\005 \003(\0132\".OsmAndRoutingIndex.RouteDataB",
"lock\032;\n\021RouteEncodingRule\022\013\n\003tag\030\003 \002(\t\022\r" +
"\n\005value\030\005 \002(\t\022\n\n\002id\030\007 \001(\r\032\216\001\n\014RouteDataB" +
"ox\022\014\n\004left\030\001 \002(\021\022\r\n\005right\030\002 \002(\021\022\013\n\003top\030\003" +
" \002(\021\022\016\n\006bottom\030\004 \002(\021\022\023\n\013shiftToData\030\005 \001(" +
"\007\022/\n\005boxes\030\007 \003(\0132 .OsmAndRoutingIndex.Ro" +
"uteDataBox\032\227\001\n\016RouteDataBlock\022\031\n\007idTable" +
"\030\005 \001(\0132\010.IdTable\022!\n\013stringTable\030\010 \001(\0132\014." +
"StringTable\022\037\n\013dataObjects\030\006 \003(\0132\n.Route" +
"Data\022&\n\014restrictions\030\007 \003(\0132\020.Restriction" +
"DataB\023\n\021net.osmand.binary"
};
com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner =
new com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner() {
@ -22625,7 +22147,7 @@ public final class OsmandOdb {
internal_static_IdTable_fieldAccessorTable = new
com.google.protobuf.GeneratedMessage.FieldAccessorTable(
internal_static_IdTable_descriptor,
new java.lang.String[] { "RouteId", "PointId", },
new java.lang.String[] { "RouteId", },
net.osmand.binary.OsmandOdb.IdTable.class,
net.osmand.binary.OsmandOdb.IdTable.Builder.class);
internal_static_RestrictionData_descriptor =
@ -22636,24 +22158,16 @@ public final class OsmandOdb {
new java.lang.String[] { "Type", "From", "To", "Via", },
net.osmand.binary.OsmandOdb.RestrictionData.class,
net.osmand.binary.OsmandOdb.RestrictionData.Builder.class);
internal_static_RoutePoint_descriptor =
getDescriptor().getMessageTypes().get(31);
internal_static_RoutePoint_fieldAccessorTable = new
com.google.protobuf.GeneratedMessage.FieldAccessorTable(
internal_static_RoutePoint_descriptor,
new java.lang.String[] { "Point", "PointId", "Types", },
net.osmand.binary.OsmandOdb.RoutePoint.class,
net.osmand.binary.OsmandOdb.RoutePoint.Builder.class);
internal_static_RouteData_descriptor =
getDescriptor().getMessageTypes().get(32);
getDescriptor().getMessageTypes().get(31);
internal_static_RouteData_fieldAccessorTable = new
com.google.protobuf.GeneratedMessage.FieldAccessorTable(
internal_static_RouteData_descriptor,
new java.lang.String[] { "Points", "Types", "RouteId", "StringNames", },
new java.lang.String[] { "Points", "PointTypes", "Types", "RouteId", "StringNames", },
net.osmand.binary.OsmandOdb.RouteData.class,
net.osmand.binary.OsmandOdb.RouteData.Builder.class);
internal_static_OsmAndRoutingIndex_descriptor =
getDescriptor().getMessageTypes().get(33);
getDescriptor().getMessageTypes().get(32);
internal_static_OsmAndRoutingIndex_fieldAccessorTable = new
com.google.protobuf.GeneratedMessage.FieldAccessorTable(
internal_static_OsmAndRoutingIndex_descriptor,

View file

@ -47,7 +47,6 @@ import net.osmand.binary.OsmandOdb.OsmAndRoutingIndex.RouteDataBlock;
import net.osmand.binary.OsmandOdb.OsmAndRoutingIndex.RouteDataBox;
import net.osmand.binary.OsmandOdb.OsmAndRoutingIndex.RouteEncodingRule;
import net.osmand.binary.OsmandOdb.OsmAndTransportIndex;
import net.osmand.binary.OsmandOdb.RoutePoint;
import net.osmand.binary.OsmandOdb.StreetIndex;
import net.osmand.binary.OsmandOdb.StreetIntersection;
import net.osmand.binary.OsmandOdb.StringTable;
@ -457,6 +456,7 @@ public class BinaryMapIndexWriter {
RouteData.Builder builder = RouteData.newBuilder();
builder.setRouteId(diffId);
ROUTE_ID_SIZE += CodedOutputStream.computeInt64Size(RouteData.ROUTEID_FIELD_NUMBER, diffId);
// types
mapDataBuf.clear();
for (int i = 0; i < types.length; i++) {
writeRawVarint32(mapDataBuf, types[i]);
@ -464,36 +464,37 @@ public class BinaryMapIndexWriter {
builder.setTypes(ByteString.copyFrom(mapDataBuf.toArray()));
ROUTE_TYPES_SIZE += CodedOutputStream.computeTagSize(RouteData.TYPES_FIELD_NUMBER)
+ CodedOutputStream.computeRawVarint32Size(mapDataBuf.size()) + mapDataBuf.size();
// coordinates and point types
int pcalcx = pleft >> SHIFT_COORDINATES;
int pcalcy = ptop >> SHIFT_COORDINATES;
mapDataBuf.clear();
typesDataBuf.clear();
for(int k=0; k<points.length; k++) {
ROUTE_COORDINATES_COUNT++;
RoutePoint.Builder point = RoutePoint.newBuilder();
if(writePointId) {
point.setPointId(points[k].id);
}
mapDataBuf.clear();
int tx = (points[k].x >> SHIFT_COORDINATES) - pcalcx;
int ty = (points[k].y >> SHIFT_COORDINATES) - pcalcy;
writeRawVarint32(mapDataBuf, CodedOutputStream.encodeZigZag32(tx));
writeRawVarint32(mapDataBuf, CodedOutputStream.encodeZigZag32(ty));
pcalcx = pcalcx + tx ;
pcalcy = pcalcy + ty ;
point.setPoint(ByteString.copyFrom(mapDataBuf.toArray()));
ROUTE_COORDINATES_SIZE += CodedOutputStream.computeTagSize(RoutePoint.POINT_FIELD_NUMBER)
+ CodedOutputStream.computeRawVarint32Size(mapDataBuf.size()) + mapDataBuf.size();
mapDataBuf.clear();
for(int ij =0; ij < points[k].types.size(); ij++){
writeRawVarint32(mapDataBuf, points[k].types.get(ij));
if(points[k].types.size() >0) {
typesAddDataBuf.clear();
for(int ij =0; ij < points[k].types.size(); ij++){
writeRawVarint32(typesAddDataBuf, points[k].types.get(ij));
}
writeRawVarint32(typesDataBuf, k);
writeRawVarint32(typesDataBuf, typesAddDataBuf.size());
typesDataBuf.add(typesAddDataBuf.toArray());
}
point.setTypes(ByteString.copyFrom(mapDataBuf.toArray()));
ROUTE_TYPES_SIZE += CodedOutputStream.computeTagSize(RoutePoint.TYPES_FIELD_NUMBER)
+ CodedOutputStream.computeRawVarint32Size(mapDataBuf.size()) + mapDataBuf.size();
RoutePoint p = point.build();
ROUTE_POINTS_SIZE += p.getSerializedSize() + CodedOutputStream.computeTagSize(RouteData.POINTS_FIELD_NUMBER)
+CodedOutputStream.computeRawVarint32Size(p.getSerializedSize());
builder.addPoints(p);
}
builder.setPoints(ByteString.copyFrom(mapDataBuf.toArray()));
ROUTE_COORDINATES_SIZE += CodedOutputStream.computeTagSize(RouteData.POINTS_FIELD_NUMBER)
+ CodedOutputStream.computeRawVarint32Size(mapDataBuf.size()) + mapDataBuf.size();
builder.setPointTypes(ByteString.copyFrom(typesDataBuf.toArray()));
ROUTE_TYPES_SIZE += CodedOutputStream.computeTagSize(RouteData.POINTTYPES_FIELD_NUMBER)
+ CodedOutputStream.computeRawVarint32Size(typesDataBuf.size()) + typesDataBuf.size();
if (names.size() > 0) {
mapDataBuf.clear();
if (names != null) {
@ -540,6 +541,8 @@ public class BinaryMapIndexWriter {
}
private TByteArrayList mapDataBuf = new TByteArrayList();
private TByteArrayList typesDataBuf = new TByteArrayList();
private TByteArrayList typesAddDataBuf = new TByteArrayList();
public MapData writeMapData(long diffId, int pleft, int ptop, boolean area, byte[] coordinates, byte[] innerPolygonTypes, int[] typeUse,
int[] addtypeUse, Map<MapRulType, String> names, Map<String, Integer> stringTable, MapDataBlock.Builder dataBlock,

View file

@ -422,7 +422,6 @@ public class IndexRouteCreator extends AbstractIndexPartCreator {
if (WRITE_POINT_ID) {
prev = 0;
for (int i = 0; i < pointMapIds.size(); i++) {
idTable.addPointId(pointMapIds.getQuick(i) - prev);
prev = pointMapIds.getQuick(i);
}
}

View file

@ -35,6 +35,7 @@ public class MapRoutingTypes {
TAGS_TO_SAVE.add("goods");
TAGS_TO_SAVE.add("toll");
TAGS_TO_SAVE.add("tracktype");
TAGS_TO_SAVE.add("railway");
}
private Map<String, MapRouteType> types = new LinkedHashMap<String, MapRoutingTypes.MapRouteType>();

View file

@ -1,11 +1,14 @@
package net.osmand.router;
import gnu.trove.list.array.TIntArrayList;
import java.util.LinkedHashMap;
import java.util.Map;
import net.osmand.binary.BinaryMapDataObject;
import net.osmand.binary.BinaryMapIndexReader.TagValuePair;
import net.osmand.osm.MapRenderingTypes;
import net.osmand.binary.BinaryMapRouteReaderAdapter.RouteDataObject;
import net.osmand.binary.BinaryMapRouteReaderAdapter.RouteRegion;
import net.osmand.binary.BinaryMapRouteReaderAdapter.RouteTypeRule;
import net.osmand.router.BinaryRoutePlanner.RouteSegment;
public class BicycleRouter extends VehicleRouter {
@ -68,56 +71,37 @@ public class BicycleRouter extends VehicleRouter {
}
@Override
public boolean acceptLine(TagValuePair pair) {
if (pair.tag.equals("highway")) {
return bicycleNotDefinedValues.containsKey(pair.value);
}
return false;
public boolean acceptLine(RouteDataObject way) {
return bicycleNotDefinedValues.containsKey(way.getHighway());
}
@Override
public boolean acceptPoint(TagValuePair pair) {
if (pair.tag.equals("highway") && pair.value.equals("traffic_signals")) {
return true;
} else if (pair.tag.equals("railway") && pair.value.equals("crossing")) {
return true;
} else if (pair.tag.equals("railway") && pair.value.equals("level_crossing")) {
return true;
}
return false;
}
public boolean isOneWay(int highwayAttributes) {
return MapRenderingTypes.isOneWayWay(highwayAttributes) || MapRenderingTypes.isRoundabout(highwayAttributes);
}
/**
* return delay in seconds
*/
@Override
public double defineObstacle(BinaryMapDataObject road, int point) {
if ((road.getTypes()[0] & 3) == MapRenderingTypes.POINT_TYPE) {
// possibly not only first type needed ?
TagValuePair pair = road.getTagValue(0);
if (pair != null) {
if (pair.tag.equals("highway") && pair.value.equals("traffic_signals")) {
return 30;
} else if (pair.tag.equals("railway") && pair.value.equals("crossing")) {
return 15;
} else if (pair.tag.equals("railway") && pair.value.equals("level_crossing")) {
return 15;
}
public double defineObstacle(RouteDataObject road, int point) {
TIntArrayList pointTypes = road.getPointTypes(point);
if(pointTypes == null) {
return 0;
}
RouteRegion reg = road.region;
int sz = pointTypes.size();
for(int i=0; i<sz; i++) {
RouteTypeRule r = reg.quickGetEncodingRule(pointTypes.getQuick(i));
if(r.getType() == RouteTypeRule.TRAFFIC_SIGNALS) {
return 30;
} else if(r.getType() == RouteTypeRule.RAILWAY_CROSSING) {
return 15;
}
}
return 0;
}
@Override
public double getRoadPriorityToCalculateRoute(BinaryMapDataObject road) {
TagValuePair pair = road.getTagValue(0);
boolean highway = "highway".equals(pair.tag);
double priority = highway && bicyclePriorityValues.containsKey(pair.value) ? bicyclePriorityValues.get(pair.value) : 1d;
public double getRoadPriorityToCalculateRoute(RouteDataObject road) {
String highway = getHighway(road);
double priority = highway != null && bicyclePriorityValues.containsKey(highway) ? bicyclePriorityValues.get(highway) : 1d;
return priority;
}
@ -125,20 +109,17 @@ public class BicycleRouter extends VehicleRouter {
* return speed in m/s
*/
@Override
public double defineSpeed(BinaryMapDataObject road) {
TagValuePair pair = road.getTagValue(0);
double speed = 4d;
boolean highway = "highway".equals(pair.tag);
double priority = highway && bicyclePriorityValues.containsKey(pair.value) ? bicyclePriorityValues.get(pair.value) : 1d;
if (speed == 0 && highway) {
Double value = bicycleNotDefinedValues.get(pair.value);
if (value != null) {
speed = value;
}
public double defineSpeed(RouteDataObject road) {
String highway = getHighway(road);
double priority = highway != null && bicyclePriorityValues.containsKey(highway) ? bicyclePriorityValues.get(highway) : 0.5d;
Double value = bicycleNotDefinedValues.get(highway);
if (value == null) {
value = 4d;
}
return speed * priority;
return value / 3.6d * priority;
}
/**
* Used for A* routing to calculate g(x)
*

View file

@ -1,6 +1,5 @@
package net.osmand.router;
import gnu.trove.list.array.TIntArrayList;
import gnu.trove.map.hash.TLongObjectHashMap;
import gnu.trove.procedure.TObjectProcedure;
@ -9,16 +8,20 @@ import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.PriorityQueue;
import net.osmand.LogUtil;
import net.osmand.binary.BinaryMapDataObject;
import net.osmand.ResultMatcher;
import net.osmand.binary.BinaryMapIndexReader;
import net.osmand.binary.BinaryMapIndexReader.MapIndex;
import net.osmand.binary.BinaryMapIndexReader.SearchFilter;
import net.osmand.binary.BinaryMapIndexReader.SearchRequest;
import net.osmand.binary.BinaryMapIndexReader.TagValuePair;
import net.osmand.binary.BinaryMapRouteReaderAdapter;
import net.osmand.binary.BinaryMapRouteReaderAdapter.RouteDataObject;
import net.osmand.binary.BinaryMapRouteReaderAdapter.RouteRegion;
import net.osmand.binary.BinaryMapRouteReaderAdapter.RouteSubregion;
import net.osmand.osm.LatLon;
import net.osmand.osm.MapRenderingTypes;
import net.osmand.osm.MapUtils;
@ -29,14 +32,23 @@ public class BinaryRoutePlanner {
private final static boolean PRINT_TO_CONSOLE_ROUTE_INFORMATION_TO_TEST = true;
private final int REVERSE_WAY_RESTRICTION_ONLY = 1024;
private final BinaryMapIndexReader[] map;
private final Map<BinaryMapIndexReader, List<RouteSubregion>> map = new LinkedHashMap<BinaryMapIndexReader, List<RouteSubregion>>();
private static final Log log = LogUtil.getLog(BinaryRoutePlanner.class);
public BinaryRoutePlanner(BinaryMapIndexReader... map){
this.map = map;
public BinaryRoutePlanner(BinaryMapIndexReader... map) {
for (BinaryMapIndexReader mr : map) {
List<RouteRegion> rr = mr.getRoutingIndexes();
List<RouteSubregion> subregions = new ArrayList<BinaryMapRouteReaderAdapter.RouteSubregion>();
for (RouteRegion r : rr) {
for (RouteSubregion rs : r.getSubregions()) {
subregions.add(new RouteSubregion(rs));
}
}
this.map.put(mr, subregions);
}
}
@ -63,68 +75,7 @@ public class BinaryRoutePlanner {
// translate into meters
return (x1 - x2) * 0.011d;
}
public void loadRoutes(final RoutingContext ctx, int tileX, int tileY) throws IOException {
int tileC = (tileX << ctx.getZoomToLoadTileWithRoads()) + tileY;
if(ctx.loadedTiles.contains(tileC)){
return;
}
long now = System.nanoTime();
int zoomToLoad = 31 - ctx.getZoomToLoadTileWithRoads();
SearchFilter searchFilter = new BinaryMapIndexReader.SearchFilter(){
@Override
public boolean accept(TIntArrayList types, MapIndex index) {
for (int j = 0; j < types.size(); j++) {
int wholeType = types.get(j);
TagValuePair pair = index.decodeType(wholeType);
if (pair != null) {
int t = wholeType & 3;
if(t == MapRenderingTypes.POINT_TYPE){
if(ctx.getRouter().acceptPoint(pair)){
return true;
}
} else if(t == MapRenderingTypes.POLYLINE_TYPE){
if(ctx.getRouter().acceptLine(pair)){
return true;
}
}
}
}
return false;
}
};
SearchRequest<BinaryMapDataObject> request = BinaryMapIndexReader.buildSearchRequest(tileX << zoomToLoad,
(tileX + 1) << zoomToLoad, tileY << zoomToLoad,
(tileY + 1) << zoomToLoad, 15, searchFilter);
for (BinaryMapIndexReader r : map) {
r.searchMapIndex(request);
for (BinaryMapDataObject o : request.getSearchResults()) {
BinaryMapDataObject old = ctx.idObjects.get(o.getId());
// sometimes way are presented only partially in one index
if (old != null && old.getPointsLength() >= o.getPointsLength()) {
continue;
}
ctx.idObjects.put(o.getId(), o);
for (int j = 0; j < o.getPointsLength(); j++) {
long l = (((long) o.getPoint31XTile(j)) << 31) + (long) o.getPoint31YTile(j);
RouteSegment segment = new RouteSegment();
segment.road = o;
segment.segmentEnd = segment.segmentStart = j;
if (ctx.routes.get(l) != null) {
segment.next = ctx.routes.get(l);
}
ctx.routes.put(l, segment);
}
}
ctx.loadedTiles.add(tileC);
ctx.timeToLoad += (System.nanoTime() - now);
}
}
// calculate distance from C to AB (distnace doesn't calculate
private static double calculateDistance(int xA, int yA, int xB, int yB, int xC, int yC, double distAB){
// Scalar multiplication between (AB', AC)
@ -146,30 +97,31 @@ public class BinaryRoutePlanner {
}
public RouteSegment findRouteSegment(double lat, double lon, RoutingContext ctx) throws IOException {
double tileX = MapUtils.getTileNumberX(ctx.getZoomToLoadTileWithRoads(), lon);
double tileY = MapUtils.getTileNumberY(ctx.getZoomToLoadTileWithRoads(), lat);
loadRoutes(ctx, (int) tileX , (int) tileY);
int px = MapUtils.get31TileNumberX(lon);
int py = MapUtils.get31TileNumberY(lat);
List<RouteDataObject> dataObjects = new ArrayList<RouteDataObject>();
loadRoutes(ctx, px,py, dataObjects);
RouteSegment road = null;
double sdist = 0;
int px = MapUtils.get31TileNumberX(lon);
int py = MapUtils.get31TileNumberY(lat);
for(BinaryMapDataObject r : ctx.values()){
for(RouteDataObject r : dataObjects){
if(r.getPointsLength() > 1){
double priority = ctx.getRouter().getRoadPriorityToCalculateRoute(r);
// double priority = ctx.getRouter().getRoadPriorityToCalculateRoute(r);
for (int j = 1; j < r.getPointsLength(); j++) {
double mDist = squareRootDist(r.getPoint31XTile(j), r.getPoint31YTile(j), r.getPoint31XTile(j - 1), r.getPoint31YTile(j - 1));
double projection = calculateProjection(r.getPoint31XTile(j - 1), r.getPoint31YTile(j - 1), r.getPoint31XTile(j), r.getPoint31YTile(j),
px, py, mDist);
double currentsDist;
if(projection < 0){//TODO: first 2 and last 2 points of a route should be only near and not based on road priority (I.E. a motorway road node unreachable near my house)
currentsDist = squareDist(r.getPoint31XTile(j - 1), r.getPoint31YTile(j - 1), px, py) / (priority * priority);
currentsDist = squareDist(r.getPoint31XTile(j - 1), r.getPoint31YTile(j - 1), px, py);// / (priority * priority);
} else if(projection > mDist){
currentsDist = squareDist(r.getPoint31XTile(j), r.getPoint31YTile(j), px, py) / (priority * priority);
currentsDist = squareDist(r.getPoint31XTile(j), r.getPoint31YTile(j), px, py);// / (priority * priority);
} else {
currentsDist = calculatesquareDistance(r.getPoint31XTile(j - 1), r.getPoint31YTile(j - 1), r.getPoint31XTile(j), r.getPoint31YTile(j),
px, py, mDist) / (priority * priority);
px, py, mDist);// / (priority * priority);
}
if (road == null || currentsDist < sdist) {
@ -188,6 +140,8 @@ public class BinaryRoutePlanner {
// TODO write unit tests
// TODO add information about turns (?) - probably calculate additional information to show on map
// TODO think about u-turn
@ -327,6 +281,60 @@ public class BinaryRoutePlanner {
result += obstaclesTime;
return result;
}
public void loadRoutes(final RoutingContext ctx, int tile31X, int tile31Y, final List<RouteDataObject> toFillIn) {
int zoomToLoad = 31 - ctx.getZoomToLoadTileWithRoads();
int tileX = tile31X >> zoomToLoad;
int tileY = tile31Y >> zoomToLoad;
int tileC = (tileX << ctx.getZoomToLoadTileWithRoads()) + tileY;
if (ctx.loadedTiles.contains(tileC) && toFillIn == null) {
return;
}
long now = System.nanoTime();
ResultMatcher<RouteDataObject> matcher = new ResultMatcher<RouteDataObject>() {
@Override
public boolean publish(RouteDataObject o) {
if (toFillIn != null) {
if (ctx.getRouter().acceptLine(o)) {
toFillIn.add(o);
}
}
RouteDataObject old = ctx.idObjects.get(o.id);
// sometimes way are presented only partially in one index
if ((old != null && old.pointsX.size() >= o.pointsX.size()) || (!ctx.getRouter().acceptLine(o))) {
return false;
}
ctx.idObjects.put(o.id, o);
for (int j = 0; j < o.pointsX.size(); j++) {
long l = (((long) o.pointsX.getQuick(j)) << 31) + (long) o.pointsY.getQuick(j);
RouteSegment segment = new RouteSegment();
segment.road = o;
segment.segmentEnd = segment.segmentStart = j;
if (ctx.routes.get(l) != null) {
segment.next = ctx.routes.get(l);
}
ctx.routes.put(l, segment);
}
return false;
}
@Override
public boolean isCancelled() {
return false;
}
};
SearchRequest<RouteDataObject> request = BinaryMapIndexReader.buildSearchRouteRequest(tileX << zoomToLoad,
(tileX + 1) << zoomToLoad, tileY << zoomToLoad, (tileY + 1) << zoomToLoad, matcher);
for (Entry<BinaryMapIndexReader,List<RouteSubregion>> r : map.entrySet()) {
try {
r.getKey().searchRouteIndex(request, r.getValue());
} catch (IOException e) {
throw new RuntimeException("Loading data exception", e);
}
}
ctx.loadedTiles.add(tileC);
ctx.timeToLoad += (System.nanoTime() - now);
}
private void visitAllStartSegments(final RoutingContext ctx, RouteSegment start, PriorityQueue<RouteSegment> graphDirectSegments,
TLongObjectHashMap<RouteSegment> visitedSegments, int startX, int startY) throws IOException {
@ -335,7 +343,7 @@ public class BinaryRoutePlanner {
visitedSegments.put(nt, start);
graphDirectSegments.add(start);
loadRoutes(ctx, (startX >> (31 - ctx.getZoomToLoadTileWithRoads())), (startY >> (31 - ctx.getZoomToLoadTileWithRoads())));
loadRoutes(ctx, startX , startY,null);
long ls = (((long) startX) << 31) + (long) startY;
RouteSegment startNbs = ctx.routes.get(ls);
while(startNbs != null) { // startNbs.road.id >> 1, start.road.id >> 1
@ -359,7 +367,7 @@ public class BinaryRoutePlanner {
// Always start from segmentStart (!), not from segmentEnd
// It makes difference only for the first start segment
// Middle point will always be skipped from observation considering already visited
final BinaryMapDataObject road = segment.road;
final RouteDataObject road = segment.road;
final int middle = segment.segmentStart;
int middlex = road.getPoint31XTile(middle);
int middley = road.getPoint31YTile(middle);
@ -375,9 +383,16 @@ public class BinaryRoutePlanner {
return new RoutePair(segment, opposite);
}
boolean oneway = ctx.getRouter().isOneWay(road);
boolean minusAllowed = !oneway || reverseWaySearch;
boolean plusAllowed = !oneway || !reverseWaySearch;
int oneway = ctx.getRouter().isOneWay(road);
boolean minusAllowed;
boolean plusAllowed;
if (!reverseWaySearch) {
minusAllowed = oneway <= 0;
plusAllowed = oneway >= 0;
} else {
minusAllowed = oneway >= 0;
plusAllowed = oneway <= 0;
}
// +/- diff from middle point
int d = plusAllowed ? 1 : -1;
@ -420,7 +435,7 @@ public class BinaryRoutePlanner {
// 2. calculate point and try to load neighbor ways if they are not loaded
int x = road.getPoint31XTile(segmentEnd);
int y = road.getPoint31YTile(segmentEnd);
loadRoutes(ctx, (x >> (31 - ctx.getZoomToLoadTileWithRoads())), (y >> (31 - ctx.getZoomToLoadTileWithRoads())));
loadRoutes(ctx, x, y, null);
long l = (((long) x) << 31) + (long) y;
RouteSegment next = ctx.routes.get(l);
@ -446,7 +461,7 @@ public class BinaryRoutePlanner {
private RouteSegment processIntersectionsWithWays(RoutingContext ctx, PriorityQueue<RouteSegment> graphSegments,
TLongObjectHashMap<RouteSegment> visitedSegments, TLongObjectHashMap<RouteSegment> oppositeSegments,
double distOnRoadToPass, double distToFinalPoint,
RouteSegment segment, BinaryMapDataObject road, boolean firstOfSegment, int segmentEnd, RouteSegment inputNext,
RouteSegment segment, RouteDataObject road, boolean firstOfSegment, int segmentEnd, RouteSegment inputNext,
boolean reverseWay) {
// This variables can be in routing context
@ -488,25 +503,27 @@ public class BinaryRoutePlanner {
if ((!alreadyVisited && processRoad) || oppositeConnectionFound) {
int type = -1;
if (!reverseWay) {
for (int i = 0; i < getRestrictionCount(road); i++) {
if (getRestriction(road, i) == next.road.getId()) {
type = getRestrictionType(road, i);
for (int i = 0; i < road.restrictions.size(); i++) {
if (road.restrictions.getQuick(i) >> 3 == next.road.id) {
type = (int) (road.restrictions.getQuick(i) & 7);
break;
}
}
} else {
for (int i = 0; i < getRestrictionCount(next.road); i++) {
if (getRestriction(next.road, i) == road.getId()) {
type = getRestrictionType(next.road, i);
for (int i = 0; i < next.road.restrictions.size(); i++) {
int rt = (int) (next.road.restrictions.getQuick(i) & 7);
if (next.road.restrictions.getQuick(i) >> 3 == road.id) {
type = rt;
break;
}
// Check if there is restriction only to the current road
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) {
if (rt == MapRenderingTypes.RESTRICTION_ONLY_RIGHT_TURN
|| rt == MapRenderingTypes.RESTRICTION_ONLY_LEFT_TURN
|| rt == MapRenderingTypes.RESTRICTION_ONLY_STRAIGHT_ON) {
// check if that restriction applies to considered junk
RouteSegment foundNext = inputNext;
while(foundNext != null && foundNext.getRoad().getId() != getRestriction(next.road, i)){
while(foundNext != null && foundNext.getRoad().id != rt){
foundNext = foundNext.next;
}
if(foundNext != null) {
@ -619,20 +636,6 @@ 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<RouteSegmentResult> prepareResult(RoutingContext ctx, RouteSegment start, RouteSegment end, long startNanoTime,
RouteSegment finalDirectRoute, RouteSegment finalReverseRoute) {
@ -697,8 +700,8 @@ 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();
String ref = res.object.getNameByType(res.object.getMapIndex().refEncodingType);
String name = "Uknown";//res.object.getName();
String ref = "";//res.object.getNameByType(res.object.getMapIndex().refEncodingType);
if(ref != null) {
name += " " + ref;
}
@ -715,7 +718,7 @@ public class BinaryRoutePlanner {
return result;
}
private LatLon convertPoint(BinaryMapDataObject o, int ind){
private LatLon convertPoint(RouteDataObject o, int ind){
return new LatLon(MapUtils.get31LatitudeY(o.getPoint31YTile(ind)), MapUtils.get31LongitudeX(o.getPoint31XTile(ind)));
}
@ -738,7 +741,7 @@ public class BinaryRoutePlanner {
public static class RouteSegment {
int segmentStart = 0;
int segmentEnd = 0;
BinaryMapDataObject road;
RouteDataObject road;
// needed to store intersection of routes
RouteSegment next = null;
@ -759,7 +762,7 @@ public class BinaryRoutePlanner {
return segmentStart;
}
public BinaryMapDataObject getRoad() {
public RouteDataObject getRoad() {
return road;
}
}

View file

@ -1,11 +1,13 @@
package net.osmand.router;
import gnu.trove.list.array.TIntArrayList;
import java.util.LinkedHashMap;
import java.util.Map;
import net.osmand.binary.BinaryMapDataObject;
import net.osmand.binary.BinaryMapIndexReader.TagValuePair;
import net.osmand.osm.MapRenderingTypes;
import net.osmand.binary.BinaryMapRouteReaderAdapter.RouteDataObject;
import net.osmand.binary.BinaryMapRouteReaderAdapter.RouteRegion;
import net.osmand.binary.BinaryMapRouteReaderAdapter.RouteTypeRule;
import net.osmand.router.BinaryRoutePlanner.RouteSegment;
public class CarRouter extends VehicleRouter {
@ -52,59 +54,38 @@ public class CarRouter extends VehicleRouter {
}
@Override
public boolean acceptLine(TagValuePair pair) {
if (pair.tag.equals("highway")) {
return autoNotDefinedValues.containsKey(pair.value);
}
return false;
public boolean acceptLine(RouteDataObject way) {
return autoNotDefinedValues.containsKey(way.getHighway());
}
@Override
public boolean acceptPoint(TagValuePair pair) {
if (pair.tag.equals("traffic_calming")) {
return true;
} else if (pair.tag.equals("highway") && pair.value.equals("traffic_signals")) {
return true;
} else if (pair.tag.equals("highway") && pair.value.equals("speed_camera")) {
return true;
} else if (pair.tag.equals("railway") && pair.value.equals("crossing")) {
return true;
} else if (pair.tag.equals("railway") && pair.value.equals("level_crossing")) {
return true;
}
return false;
}
public boolean isOneWay(int highwayAttributes) {
return MapRenderingTypes.isOneWayWay(highwayAttributes) || MapRenderingTypes.isRoundabout(highwayAttributes);
}
/**
* return delay in seconds
*/
@Override
public double defineObstacle(BinaryMapDataObject road, int point) {
if ((road.getTypes()[0] & 3) == MapRenderingTypes.POINT_TYPE) {
// possibly not only first type needed ?
TagValuePair pair = road.getTagValue(0);
if (pair != null) {
if (pair.tag.equals("highway") && pair.value.equals("traffic_signals")) {
return 20;
} else if (pair.tag.equals("railway") && pair.value.equals("crossing")) {
return 25;
} else if (pair.tag.equals("railway") && pair.value.equals("level_crossing")) {
return 25;
}
public double defineObstacle(RouteDataObject road, int point) {
TIntArrayList pointTypes = road.getPointTypes(point);
if(pointTypes == null) {
return 0;
}
RouteRegion reg = road.region;
int sz = pointTypes.size();
for(int i=0; i<sz; i++) {
RouteTypeRule r = reg.quickGetEncodingRule(pointTypes.getQuick(i));
if(r.getType() == RouteTypeRule.TRAFFIC_SIGNALS) {
return 20;
} else if(r.getType() == RouteTypeRule.RAILWAY_CROSSING) {
return 25;
}
}
return 0;
}
@Override
public double getRoadPriorityHeuristicToIncrease(BinaryMapDataObject road) {
TagValuePair pair = road.getTagValue(0);
boolean highway = "highway".equals(pair.tag);
double priority = highway && autoPriorityValues.containsKey(pair.value) ? autoPriorityValues.get(pair.value) : 0.5d;
public double getRoadPriorityHeuristicToIncrease(RouteDataObject road) {
String highway = getHighway(road);
double priority = highway !=null && autoPriorityValues.containsKey(highway) ? autoPriorityValues.get(highway) : 0.5d;
// allow to get out from motorway to primary roads
// if("motorway_link".equals(pair.value) || "trunk".equals(pair.value) ||
// "trunk_link".equals(pair.value) || "motorway".equals(pair.value)) {
@ -122,15 +103,14 @@ public class CarRouter extends VehicleRouter {
}
@Override
public double getRoadPriorityToCalculateRoute(BinaryMapDataObject road) {
TagValuePair pair = road.getTagValue(0);
boolean highway = "highway".equals(pair.tag);
double priority = highway && autoPriorityValues.containsKey(pair.value) ? autoPriorityValues.get(pair.value) : 0.5d;
// keep it in boundaries otherwise
// (it will use first founded exist for trunk even if it in another city and make Uturn there)
if(priority > 1.4){
public double getRoadPriorityToCalculateRoute(RouteDataObject road) {
String highway = getHighway(road);
double priority = highway != null && autoPriorityValues.containsKey(highway) ? autoPriorityValues.get(highway) : 0.5d;
// keep it in boundaries otherwise
// (it will use first founded exist for trunk even if it in another city and make Uturn there)
if (priority > 1.4) {
return 1.4d;
} else if(priority < 0.5d) {
} else if (priority < 0.5d) {
return 0.5d;
}
return priority;
@ -140,19 +120,25 @@ public class CarRouter extends VehicleRouter {
* return speed in m/s
*/
@Override
public double defineSpeed(BinaryMapDataObject road) {
TagValuePair pair = road.getTagValue(0);
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) {
Double value = autoNotDefinedValues.get(pair.value);
if (value == null) {
value = 50d;
public double defineSpeed(RouteDataObject road) {
String highway = null;
RouteRegion reg = road.region;
int sz = road.types.size();
for (int i = 0; i < sz; i++) {
RouteTypeRule r = reg.quickGetEncodingRule(road.types.getQuick(i));
float maxSpeed = r.maxSpeed();
if (maxSpeed > 0) {
return maxSpeed;
} else if (highway == null) {
highway = r.highwayRoad();
}
speed = value / 3.6d;
}
return speed * priority;
double priority = highway != null && autoPriorityValues.containsKey(highway) ? autoPriorityValues.get(highway) : 0.5d;
Double value = autoNotDefinedValues.get(highway);
if (value == null) {
value = 50d;
}
return value / 3.6d * priority;
}
/**

View file

@ -1,10 +1,14 @@
package net.osmand.router;
import gnu.trove.list.array.TIntArrayList;
import java.util.LinkedHashMap;
import java.util.Map;
import net.osmand.binary.BinaryMapDataObject;
import net.osmand.binary.BinaryMapIndexReader.TagValuePair;
import net.osmand.binary.BinaryMapRouteReaderAdapter.RouteDataObject;
import net.osmand.binary.BinaryMapRouteReaderAdapter.RouteRegion;
import net.osmand.binary.BinaryMapRouteReaderAdapter.RouteTypeRule;
import net.osmand.osm.MapRenderingTypes;
import net.osmand.router.BinaryRoutePlanner.RouteSegment;
@ -68,38 +72,22 @@ public class PedestrianRouter extends VehicleRouter {
}
@Override
public double getRoadPriorityToCalculateRoute(BinaryMapDataObject road) {
TagValuePair pair = road.getTagValue(0);
boolean highway = "highway".equals(pair.tag);
double priority = highway && pedestrianPriorityValues.containsKey(pair.value) ? pedestrianPriorityValues.get(pair.value) : 1d;
public double getRoadPriorityToCalculateRoute(RouteDataObject road) {
String highway = getHighway(road);
double priority = highway!= null && pedestrianPriorityValues.containsKey(highway) ? pedestrianPriorityValues.get(highway) : 1d;
return priority;
}
@Override
public boolean isOneWay(BinaryMapDataObject road) {
// for now all ways are bidirectional
return false;
public int isOneWay(RouteDataObject road) {
return 0;
}
@Override
public boolean acceptLine(TagValuePair pair) {
if (pair.tag.equals("highway")) {
return pedestrianNotDefinedValues.containsKey(pair.value);
}
return false;
public boolean acceptLine(RouteDataObject way) {
return pedestrianNotDefinedValues.containsKey(way.getHighway());
}
@Override
public boolean acceptPoint(TagValuePair pair) {
if (pair.tag.equals("highway") && pair.value.equals("traffic_signals")) {
return true;
} else if (pair.tag.equals("railway") && pair.value.equals("crossing")) {
return true;
} else if (pair.tag.equals("railway") && pair.value.equals("level_crossing")) {
return true;
}
return false;
}
public boolean isOneWay(int highwayAttributes) {
return MapRenderingTypes.isOneWayWay(highwayAttributes) || MapRenderingTypes.isRoundabout(highwayAttributes);
@ -109,18 +97,19 @@ public class PedestrianRouter extends VehicleRouter {
* return delay in seconds
*/
@Override
public double defineObstacle(BinaryMapDataObject road, int point) {
if ((road.getTypes()[0] & 3) == MapRenderingTypes.POINT_TYPE) {
// possibly not only first type needed ?
TagValuePair pair = road.getTagValue(0);
if (pair != null) {
if (pair.tag.equals("highway") && pair.value.equals("traffic_signals")) {
return 20;
} else if (pair.tag.equals("railway") && pair.value.equals("crossing")) {
return 15;
} else if (pair.tag.equals("railway") && pair.value.equals("level_crossing")) {
return 15;
}
public double defineObstacle(RouteDataObject road, int point) {
TIntArrayList pointTypes = road.getPointTypes(point);
if(pointTypes == null) {
return 0;
}
RouteRegion reg = road.region;
int sz = pointTypes.size();
for(int i=0; i<sz; i++) {
RouteTypeRule r = reg.quickGetEncodingRule(pointTypes.getQuick(i));
if(r.getType() == RouteTypeRule.TRAFFIC_SIGNALS) {
return 20;
} else if(r.getType() == RouteTypeRule.RAILWAY_CROSSING) {
return 15;
}
}
return 0;
@ -130,13 +119,12 @@ public class PedestrianRouter extends VehicleRouter {
* return speed in m/s
*/
@Override
public double defineSpeed(BinaryMapDataObject road) {
TagValuePair pair = road.getTagValue(0);
public double defineSpeed(RouteDataObject road) {
double speed = 1.5d;
boolean highway = "highway".equals(pair.tag);
double priority = highway && pedestrianPriorityValues.containsKey(pair.value) ? pedestrianPriorityValues.get(pair.value) : 1d;
if (speed == 0 && highway) {
Double value = pedestrianNotDefinedValues.get(pair.value);
String highway = getHighway(road);
double priority = highway != null && pedestrianPriorityValues.containsKey(highway) ? pedestrianPriorityValues.get(highway) : 1d;
if (highway != null) {
Double value = pedestrianNotDefinedValues.get(highway);
if (value != null) {
speed = value;
}

View file

@ -1,13 +1,13 @@
package net.osmand.router;
import net.osmand.binary.BinaryMapDataObject;
import net.osmand.binary.BinaryMapRouteReaderAdapter.RouteDataObject;
import net.osmand.osm.LatLon;
public class RouteSegmentResult {
public LatLon startPoint;
public LatLon endPoint;
public BinaryMapDataObject object;
public RouteDataObject object;
public int startPointIndex;
public int endPointIndex;
}

View file

@ -5,9 +5,7 @@ import gnu.trove.map.hash.TLongObjectHashMap;
import gnu.trove.set.TIntSet;
import gnu.trove.set.hash.TIntHashSet;
import java.util.Collection;
import net.osmand.binary.BinaryMapDataObject;
import net.osmand.binary.BinaryMapRouteReaderAdapter.RouteDataObject;
import net.osmand.router.BinaryRoutePlanner.RouteSegment;
import net.osmand.router.BinaryRoutePlanner.RouteSegmentVisitor;
@ -30,7 +28,6 @@ public class RoutingContext {
// 2. Routing memory cache
TLongObjectMap<BinaryMapDataObject> idObjects = new TLongObjectHashMap<BinaryMapDataObject>();
TLongObjectMap<RouteSegment> routes = new TLongObjectHashMap<RouteSegment>();
TIntSet loadedTiles = new TIntHashSet();
@ -40,6 +37,8 @@ public class RoutingContext {
int visitedSegments = 0;
// callback of processing segments
RouteSegmentVisitor visitor = null;
// TODO delete this object ?
TLongObjectHashMap<RouteDataObject> idObjects = new TLongObjectHashMap<RouteDataObject>();
public RouteSegmentVisitor getVisitor() {
@ -110,10 +109,6 @@ public class RoutingContext {
this.useStrategyOfIncreasingRoadPriorities = useStrategyOfIncreasingRoadPriorities;
}
public Collection<BinaryMapDataObject> values() {
return idObjects.valueCollection();
}
public int roadPriorityComparator(double o1DistanceFromStart, double o1DistanceToEnd, double o2DistanceFromStart, double o2DistanceToEnd) {
return BinaryRoutePlanner.roadPriorityComparator(o1DistanceFromStart, o1DistanceToEnd, o2DistanceFromStart, o2DistanceToEnd,
heuristicCoefficient);

View file

@ -1,8 +1,8 @@
package net.osmand.router;
import net.osmand.binary.BinaryMapDataObject;
import net.osmand.binary.BinaryMapIndexReader.TagValuePair;
import net.osmand.osm.MapRenderingTypes;
import net.osmand.binary.BinaryMapRouteReaderAdapter.RouteDataObject;
import net.osmand.binary.BinaryMapRouteReaderAdapter.RouteRegion;
import net.osmand.binary.BinaryMapRouteReaderAdapter.RouteTypeRule;
import net.osmand.router.BinaryRoutePlanner.RouteSegment;
public abstract class VehicleRouter {
@ -10,27 +10,28 @@ public abstract class VehicleRouter {
/**
* Accepts line to use it for routing
*
* @param pair
* @param way
* @return
*/
public abstract boolean acceptLine(TagValuePair pair);
/**
* Accepts point to use it for routing
*
* @param pair
* @return
*/
public abstract boolean acceptPoint(TagValuePair pair);
public abstract boolean acceptLine(RouteDataObject way);
public int getHighwayAttributes(BinaryMapDataObject road){
throw new UnsupportedOperationException();
public int isOneWay(RouteDataObject road) {
RouteRegion reg = road.region;
int sz = road.types.size();
for(int i=0; i<sz; i++) {
RouteTypeRule r = reg.quickGetEncodingRule(road.types.getQuick(i));
if(r.onewayDirection() != 0) {
return r.onewayDirection();
} else if(r.roundabout()) {
return 1;
}
}
return 0;
}
public boolean isOneWay(BinaryMapDataObject road) {
int attributes = getHighwayAttributes(road);
return MapRenderingTypes.isOneWayWay(attributes) || MapRenderingTypes.isRoundabout(attributes);
public String getHighway(RouteDataObject road) {
return road.getHighway();
}
/**
@ -39,7 +40,7 @@ public abstract class VehicleRouter {
* @param road
* @return
*/
public double getRoadPriorityHeuristicToIncrease(BinaryMapDataObject road) {
public double getRoadPriorityHeuristicToIncrease(RouteDataObject road) {
return 1;
}
@ -49,14 +50,14 @@ public abstract class VehicleRouter {
* @param road
* @return
*/
public double getRoadPriorityToCalculateRoute(BinaryMapDataObject road) {
public double getRoadPriorityToCalculateRoute(RouteDataObject road) {
return 1;
}
/**
* return delay in seconds
*/
public double defineObstacle(BinaryMapDataObject road, int point) {
public double defineObstacle(RouteDataObject road, int point) {
// no obstacles
return 0;
}
@ -64,7 +65,7 @@ public abstract class VehicleRouter {
/**
* return speed in m/s for vehicle
*/
public abstract double defineSpeed(BinaryMapDataObject road);
public abstract double defineSpeed(RouteDataObject road);
/**
* Used for A* routing to calculate g(x)

View file

@ -54,7 +54,7 @@ public class RouterTestsSuite {
if (!properties.containsKey(reg)) {
throw new IllegalArgumentException("Region " + reg + " is not found in the source.properties file");
}
BinaryMapIndexReader r = new BinaryMapIndexReader(new RandomAccessFile((String) properties.get(reg), "r"), true);
BinaryMapIndexReader r = new BinaryMapIndexReader(new RandomAccessFile((String) properties.get(reg), "r"), false);
readers[i++] = r;
}

View file

@ -48,11 +48,32 @@ public class DataExtractionSettings {
return new LatLon(lat, lon);
}
public LatLon getStartLocation(){
double lat = preferences.getDouble("start_lat", 53.9);
double lon = preferences.getDouble("start_lon", 27.56);
return new LatLon(lat, lon);
}
public LatLon getEndLocation(){
double lat = preferences.getDouble("end_lat", 53.9);
double lon = preferences.getDouble("end_lon", 27.56);
return new LatLon(lat, lon);
}
public void saveDefaultLocation(double lat, double lon){
preferences.putDouble("default_lat", lat);
preferences.putDouble("default_lon", lon);
}
public void saveStartLocation(double lat, double lon){
preferences.putDouble("start_lat", lat);
preferences.putDouble("start_lon", lon);
}
public void saveEndLocation(double lat, double lon){
preferences.putDouble("end_lat", lat);
preferences.putDouble("end_lon", lon);
}
public MapZooms getMapZooms(){
String value = preferences.get("map_zooms", MapZooms.MAP_ZOOMS_DEFAULT);
return MapZooms.parseZooms(value);

View file

@ -25,9 +25,10 @@ import javax.swing.SwingUtilities;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import net.osmand.binary.BinaryMapDataObject;
import net.osmand.binary.BinaryMapIndexReader;
import net.osmand.binary.BinaryMapIndexReader.TagValuePair;
import net.osmand.binary.BinaryMapRouteReaderAdapter.RouteDataObject;
import net.osmand.binary.BinaryMapRouteReaderAdapter.RouteRegion;
import net.osmand.binary.BinaryMapRouteReaderAdapter.RouteTypeRule;
import net.osmand.data.DataTileManager;
import net.osmand.osm.LatLon;
import net.osmand.osm.MapUtils;
@ -128,7 +129,7 @@ public class MapClusterLayer implements MapPanelLayer {
BinaryMapIndexReader[] rs = new BinaryMapIndexReader[files.length];
for(int i=0; i<files.length; i++){
RandomAccessFile raf = new RandomAccessFile(files[i], "r"); //$NON-NLS-1$ //$NON-NLS-2$
rs[i] = new BinaryMapIndexReader(raf, true);
rs[i] = new BinaryMapIndexReader(raf, false);
}
@ -138,10 +139,10 @@ public class MapClusterLayer implements MapPanelLayer {
// find closest way
RouteSegment st = router.findRouteSegment(lat, lon, ctx);
if (st != null) {
BinaryMapDataObject road = st.getRoad();
TagValuePair pair = road.getTagValue(0);
log.info("ROAD TO START " + pair.tag + " " + pair.value + " " + road.getName() + " "
+ (road.getId() >> 3));
RouteDataObject road = st.getRoad();
String highway = getHighway(road);
log.info("ROAD TO START " + highway + " " + //road.getName() + " "
+ road.id);
}
@ -208,7 +209,7 @@ public class MapClusterLayer implements MapPanelLayer {
Queue<RouteSegment> queue = new LinkedList<RouteSegment>();
TLongHashSet visitedIds = new TLongHashSet();
queue.add(st);
BinaryMapDataObject startRoad = st.getRoad();
RouteDataObject startRoad = st.getRoad();
long lstart = (((long) startRoad.getPoint31XTile(st.getSegmentStart())) << 31) +
(long) startRoad.getPoint31YTile(st.getSegmentStart());
RouteSegment next = ctx.getLoadedRoutes().get(lstart);
@ -221,7 +222,7 @@ public class MapClusterLayer implements MapPanelLayer {
nextSegment : while(!queue.isEmpty()){
RouteSegment segment = queue.poll();
BinaryMapDataObject road = segment.getRoad();
RouteDataObject road = segment.getRoad();
ctx.getVisitor().visitSegment(segment);
if(visitedIds.contains(calculateId(segment, segment.getSegmentStart()))){
continue;
@ -278,14 +279,13 @@ public class MapClusterLayer implements MapPanelLayer {
w.addNode(new Node(MapUtils.get31LatitudeY(y), MapUtils.get31LongitudeX(x), -1), 0);
}
router.loadRoutes(ctx, (x >> (31 - ctx.getZoomToLoadTileWithRoads())),
(y >> (31 - ctx.getZoomToLoadTileWithRoads())));
router.loadRoutes(ctx, x ,y , null);
long l = (((long) x) << 31) + (long) y;
next = ctx.getLoadedRoutes().get(l);
boolean addToQueue = true;;
while (next != null) {
TagValuePair pair = next.getRoad().getTagValue(0);
if (pair.tag.equals("highway") && roads.contains(pair.value)) {
String h = getHighway(next.getRoad());
if (roads.contains(h)) {
if(currentD > 0){
plusAllowed = false;
} else {
@ -325,5 +325,7 @@ public class MapClusterLayer implements MapPanelLayer {
public static String getHighway(RouteDataObject road) {
return road.getHighway();
}
}

View file

@ -25,16 +25,16 @@ import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import net.osmand.binary.BinaryMapDataObject;
import net.osmand.binary.BinaryMapIndexReader;
import net.osmand.binary.BinaryMapIndexReader.TagValuePair;
import net.osmand.data.DataTileManager;
import net.osmand.osm.LatLon;
import net.osmand.osm.MapUtils;
import net.osmand.osm.Way;
import net.osmand.router.BinaryRoutePlanner;
import net.osmand.router.CarRouter;
import net.osmand.router.RouteSegmentResult;
import net.osmand.router.RoutingContext;
import net.osmand.router.VehicleRouter;
import net.osmand.router.BinaryRoutePlanner.RouteSegment;
import net.osmand.router.BinaryRoutePlanner.RouteSegmentVisitor;
@ -53,15 +53,13 @@ import org.json.JSONTokener;
public class MapRouterLayer implements MapPanelLayer {
private /*final */ static boolean ANIMATE_CALCULATING_ROUTE = true;
private /*final */ static int SIZE_OF_ROUTES_TO_ANIMATE = 1;
private /*final */ static int SIZE_OF_ROUTES_TO_ANIMATE = 10;
private MapPanel map;
// private LatLon startRoute;
// private LatLon endRoute;
// test route purpose
private LatLon startRoute = new LatLon(53.9113, 27.5795);
private LatLon endRoute = new LatLon(53.95386, 27.68131);
private LatLon startRoute ;
private LatLon endRoute ;
private VehicleRouter routerMode = new CarRouter();
@Override
@ -73,6 +71,8 @@ public class MapRouterLayer implements MapPanelLayer {
public void initLayer(MapPanel map) {
this.map = map;
fillPopupMenuWithActions(map.getPopupMenu());
startRoute = DataExtractionSettings.getSettings().getStartLocation();
endRoute = DataExtractionSettings.getSettings().getEndLocation();
}
public void fillPopupMenuWithActions(JPopupMenu menu) {
@ -87,6 +87,7 @@ public class MapRouterLayer implements MapPanelLayer {
double latitude = MapUtils.getLatitudeFromTile(map.getZoom(), map.getYTile() + fy);
double longitude = MapUtils.getLongitudeFromTile(map.getZoom(), map.getXTile() + fx);
startRoute = new LatLon(latitude, longitude);
DataExtractionSettings.getSettings().saveStartLocation(latitude, longitude);
map.repaint();
}
};
@ -102,6 +103,7 @@ public class MapRouterLayer implements MapPanelLayer {
double latitude = MapUtils.getLatitudeFromTile(map.getZoom(), map.getYTile() + fy);
double longitude = MapUtils.getLongitudeFromTile(map.getZoom(), map.getXTile() + fx);
endRoute = new LatLon(latitude, longitude);
DataExtractionSettings.getSettings().saveEndLocation(latitude, longitude);
map.repaint();
}
};
@ -473,8 +475,13 @@ public class MapRouterLayer implements MapPanelLayer {
public List<Way> selfRoute(LatLon start, LatLon end) {
List<Way> res = new ArrayList<Way>();
long time = System.currentTimeMillis();
// TODO DataExtractionSettings.getSettings().getBinaryFilesDir()
File[] files = new File[0];
List<File> files = new ArrayList<File>();
for(File f :new File(DataExtractionSettings.getSettings().getBinaryFilesDir()).listFiles()){
if(f.getName().endsWith(".obf")){
files.add(f);
}
}
if(files == null){
JOptionPane.showMessageDialog(OsmExtractionUI.MAIN_APP.getFrame(), "Please specify obf file in settings", "Obf file not found",
JOptionPane.ERROR_MESSAGE);
@ -483,33 +490,30 @@ public class MapRouterLayer implements MapPanelLayer {
System.out.println("Self made route from " + start + " to " + end);
if (start != null && end != null) {
try {
BinaryMapIndexReader[] rs = new BinaryMapIndexReader[files.length];
for(int i=0; i<files.length; i++){
RandomAccessFile raf = new RandomAccessFile(files[i], "r"); //$NON-NLS-1$ //$NON-NLS-2$
rs[i] = new BinaryMapIndexReader(raf, true);
BinaryMapIndexReader[] rs = new BinaryMapIndexReader[files.size()];
int it = 0;
for (File f : files) {
RandomAccessFile raf = new RandomAccessFile(f, "r"); //$NON-NLS-1$ //$NON-NLS-2$
rs[it++] = new BinaryMapIndexReader(raf, false);
}
BinaryRoutePlanner router = new BinaryRoutePlanner(rs);
RoutingContext ctx = new RoutingContext();
// ctx.setPlanRoadDirection(true);
ctx.setRouter(this.routerMode);
ctx.setPlanRoadDirection(true);
// find closest way
RouteSegment st = router.findRouteSegment(start.getLatitude(), start.getLongitude(), ctx);
if (st != null) {
BinaryMapDataObject road = st.getRoad();
TagValuePair pair = road.getTagValue(0);
System.out.println("ROAD TO START " + pair.tag + " " + pair.value + " " + road.getName() + " "
+ (road.getId() >> 3));
if (st == null) {
throw new RuntimeException("Start point to calculate route was not found");
}
System.out.println("ROAD TO START " + st.getRoad().getHighway() + " " + st.getRoad().id);
RouteSegment e = router.findRouteSegment(end.getLatitude(), end.getLongitude(), ctx);
if ( e != null) {
BinaryMapDataObject road = e.getRoad();
TagValuePair pair = road.getTagValue(0);
System.out.println("ROAD TO END " + pair.tag + " " + pair.value + " " + road.getName()+ " " +
+ (road.getId() >> 3));
if (e == null) {
throw new RuntimeException("End point to calculate route was not found");
}
System.out.println("ROAD TO END " + e.getRoad().getHighway() + " " + e.getRoad().id);
final DataTileManager<Way> points = new DataTileManager<Way>();
points.setZoom(11);
@ -571,7 +575,7 @@ public class MapRouterLayer implements MapPanelLayer {
.get31LongitudeX(s.object.getPoint31XTile(i)), -1);
if (prevWayNode != null) {
if (MapUtils.getDistance(prevWayNode, n) > 0) {
System.out.println("Warning not connected road " + " " + s.object.getName() + " dist "
System.out.println("Warning not connected road " + " " + s.object.getHighway() + " dist "
+ MapUtils.getDistance(prevWayNode, n));
}
prevWayNode = null;

View file

@ -464,8 +464,6 @@ message OsmAndPoiBoxDataAtom {
message IdTable {
// diff between 2 ids
repeated sint64 routeId = 1;
// diff between 2 ids
repeated sint64 pointId = 2;
}
message RestrictionData {
@ -475,17 +473,17 @@ message RestrictionData {
optional int32 via = 4;
}
message RoutePoint {
// array of delta x,y sint32 (CodedIinputStream) >> 5
// first x delta to Tree.left, y to delta Tree.top (next delta to previous)
required bytes point = 1;
optional uint32 pointId = 2;
// array of raw var int types
optional bytes types = 4;
}
message RouteData {
repeated RoutePoint points = 1;
// array of delta x,y sint32 (CodedIinputStream) >> 5
// first x delta to Tree.left, y to delta Tree.top (next delta to previous)
required bytes points = 1;
// continuous array of pairs
// [pointIndex - int32, pointTypes - bytes]
// bytes - array of raw var int types
optional bytes pointTypes = 4;
// array of raw var int types
required bytes types = 7;

View file

@ -67,7 +67,6 @@ class OsmAndPoiBoxData;
class OsmAndPoiBoxDataAtom;
class IdTable;
class RestrictionData;
class RoutePoint;
class RouteData;
class OsmAndRoutingIndex;
class OsmAndRoutingIndex_RouteEncodingRule;
@ -4694,30 +4693,17 @@ class IdTable : public ::google::protobuf::Message {
inline ::google::protobuf::RepeatedField< ::google::protobuf::int64 >*
mutable_routeid();
// repeated sint64 pointId = 2;
inline int pointid_size() const;
inline void clear_pointid();
static const int kPointIdFieldNumber = 2;
inline ::google::protobuf::int64 pointid(int index) const;
inline void set_pointid(int index, ::google::protobuf::int64 value);
inline void add_pointid(::google::protobuf::int64 value);
inline const ::google::protobuf::RepeatedField< ::google::protobuf::int64 >&
pointid() const;
inline ::google::protobuf::RepeatedField< ::google::protobuf::int64 >*
mutable_pointid();
// @@protoc_insertion_point(class_scope:IdTable)
private:
::google::protobuf::UnknownFieldSet _unknown_fields_;
mutable int _cached_size_;
::google::protobuf::RepeatedField< ::google::protobuf::int64 > routeid_;
::google::protobuf::RepeatedField< ::google::protobuf::int64 > pointid_;
friend void protobuf_AddDesc_src_2fosmand_5fodb_2eproto();
friend void protobuf_AssignDesc_src_2fosmand_5fodb_2eproto();
friend void protobuf_ShutdownFile_src_2fosmand_5fodb_2eproto();
::google::protobuf::uint32 _has_bits_[(2 + 31) / 32];
::google::protobuf::uint32 _has_bits_[(1 + 31) / 32];
// WHY DOES & HAVE LOWER PRECEDENCE THAN != !?
inline bool _has_bit(int index) const {
@ -4848,119 +4834,6 @@ class RestrictionData : public ::google::protobuf::Message {
};
// -------------------------------------------------------------------
class RoutePoint : public ::google::protobuf::Message {
public:
RoutePoint();
virtual ~RoutePoint();
RoutePoint(const RoutePoint& from);
inline RoutePoint& operator=(const RoutePoint& from) {
CopyFrom(from);
return *this;
}
inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
return _unknown_fields_;
}
inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
return &_unknown_fields_;
}
static const ::google::protobuf::Descriptor* descriptor();
static const RoutePoint& default_instance();
void Swap(RoutePoint* other);
// implements Message ----------------------------------------------
RoutePoint* New() const;
void CopyFrom(const ::google::protobuf::Message& from);
void MergeFrom(const ::google::protobuf::Message& from);
void CopyFrom(const RoutePoint& from);
void MergeFrom(const RoutePoint& from);
void Clear();
bool IsInitialized() const;
int ByteSize() const;
bool MergePartialFromCodedStream(
::google::protobuf::io::CodedInputStream* input);
void SerializeWithCachedSizes(
::google::protobuf::io::CodedOutputStream* output) const;
::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const;
int GetCachedSize() const { return _cached_size_; }
private:
void SharedCtor();
void SharedDtor();
void SetCachedSize(int size) const;
public:
::google::protobuf::Metadata GetMetadata() const;
// nested types ----------------------------------------------------
// accessors -------------------------------------------------------
// required bytes point = 1;
inline bool has_point() const;
inline void clear_point();
static const int kPointFieldNumber = 1;
inline const ::std::string& point() const;
inline void set_point(const ::std::string& value);
inline void set_point(const char* value);
inline void set_point(const void* value, size_t size);
inline ::std::string* mutable_point();
// optional uint32 pointId = 2;
inline bool has_pointid() const;
inline void clear_pointid();
static const int kPointIdFieldNumber = 2;
inline ::google::protobuf::uint32 pointid() const;
inline void set_pointid(::google::protobuf::uint32 value);
// optional bytes types = 4;
inline bool has_types() const;
inline void clear_types();
static const int kTypesFieldNumber = 4;
inline const ::std::string& types() const;
inline void set_types(const ::std::string& value);
inline void set_types(const char* value);
inline void set_types(const void* value, size_t size);
inline ::std::string* mutable_types();
// @@protoc_insertion_point(class_scope:RoutePoint)
private:
::google::protobuf::UnknownFieldSet _unknown_fields_;
mutable int _cached_size_;
::std::string* point_;
static const ::std::string _default_point_;
::google::protobuf::uint32 pointid_;
::std::string* types_;
static const ::std::string _default_types_;
friend void protobuf_AddDesc_src_2fosmand_5fodb_2eproto();
friend void protobuf_AssignDesc_src_2fosmand_5fodb_2eproto();
friend void protobuf_ShutdownFile_src_2fosmand_5fodb_2eproto();
::google::protobuf::uint32 _has_bits_[(3 + 31) / 32];
// WHY DOES & HAVE LOWER PRECEDENCE THAN != !?
inline bool _has_bit(int index) const {
return (_has_bits_[index / 32] & (1u << (index % 32))) != 0;
}
inline void _set_bit(int index) {
_has_bits_[index / 32] |= (1u << (index % 32));
}
inline void _clear_bit(int index) {
_has_bits_[index / 32] &= ~(1u << (index % 32));
}
void InitAsDefaultInstance();
static RoutePoint* default_instance_;
};
// -------------------------------------------------------------------
class RouteData : public ::google::protobuf::Message {
public:
RouteData();
@ -5015,17 +4888,25 @@ class RouteData : public ::google::protobuf::Message {
// accessors -------------------------------------------------------
// repeated .RoutePoint points = 1;
inline int points_size() const;
// required bytes points = 1;
inline bool has_points() const;
inline void clear_points();
static const int kPointsFieldNumber = 1;
inline const ::RoutePoint& points(int index) const;
inline ::RoutePoint* mutable_points(int index);
inline ::RoutePoint* add_points();
inline const ::google::protobuf::RepeatedPtrField< ::RoutePoint >&
points() const;
inline ::google::protobuf::RepeatedPtrField< ::RoutePoint >*
mutable_points();
inline const ::std::string& points() const;
inline void set_points(const ::std::string& value);
inline void set_points(const char* value);
inline void set_points(const void* value, size_t size);
inline ::std::string* mutable_points();
// optional bytes pointTypes = 4;
inline bool has_pointtypes() const;
inline void clear_pointtypes();
static const int kPointTypesFieldNumber = 4;
inline const ::std::string& pointtypes() const;
inline void set_pointtypes(const ::std::string& value);
inline void set_pointtypes(const char* value);
inline void set_pointtypes(const void* value, size_t size);
inline ::std::string* mutable_pointtypes();
// required bytes types = 7;
inline bool has_types() const;
@ -5059,7 +4940,10 @@ class RouteData : public ::google::protobuf::Message {
::google::protobuf::UnknownFieldSet _unknown_fields_;
mutable int _cached_size_;
::google::protobuf::RepeatedPtrField< ::RoutePoint > points_;
::std::string* points_;
static const ::std::string _default_points_;
::std::string* pointtypes_;
static const ::std::string _default_pointtypes_;
::std::string* types_;
static const ::std::string _default_types_;
::google::protobuf::int32 routeid_;
@ -5069,7 +4953,7 @@ class RouteData : public ::google::protobuf::Message {
friend void protobuf_AssignDesc_src_2fosmand_5fodb_2eproto();
friend void protobuf_ShutdownFile_src_2fosmand_5fodb_2eproto();
::google::protobuf::uint32 _has_bits_[(4 + 31) / 32];
::google::protobuf::uint32 _has_bits_[(5 + 31) / 32];
// WHY DOES & HAVE LOWER PRECEDENCE THAN != !?
inline bool _has_bit(int index) const {
@ -9819,31 +9703,6 @@ IdTable::mutable_routeid() {
return &routeid_;
}
// repeated sint64 pointId = 2;
inline int IdTable::pointid_size() const {
return pointid_.size();
}
inline void IdTable::clear_pointid() {
pointid_.Clear();
}
inline ::google::protobuf::int64 IdTable::pointid(int index) const {
return pointid_.Get(index);
}
inline void IdTable::set_pointid(int index, ::google::protobuf::int64 value) {
pointid_.Set(index, value);
}
inline void IdTable::add_pointid(::google::protobuf::int64 value) {
pointid_.Add(value);
}
inline const ::google::protobuf::RepeatedField< ::google::protobuf::int64 >&
IdTable::pointid() const {
return pointid_;
}
inline ::google::protobuf::RepeatedField< ::google::protobuf::int64 >*
IdTable::mutable_pointid() {
return &pointid_;
}
// -------------------------------------------------------------------
// RestrictionData
@ -9914,173 +9773,128 @@ inline void RestrictionData::set_via(::google::protobuf::int32 value) {
// -------------------------------------------------------------------
// RoutePoint
// RouteData
// required bytes point = 1;
inline bool RoutePoint::has_point() const {
// required bytes points = 1;
inline bool RouteData::has_points() const {
return _has_bit(0);
}
inline void RoutePoint::clear_point() {
if (point_ != &_default_point_) {
point_->clear();
inline void RouteData::clear_points() {
if (points_ != &_default_points_) {
points_->clear();
}
_clear_bit(0);
}
inline const ::std::string& RoutePoint::point() const {
return *point_;
inline const ::std::string& RouteData::points() const {
return *points_;
}
inline void RoutePoint::set_point(const ::std::string& value) {
inline void RouteData::set_points(const ::std::string& value) {
_set_bit(0);
if (point_ == &_default_point_) {
point_ = new ::std::string;
if (points_ == &_default_points_) {
points_ = new ::std::string;
}
point_->assign(value);
points_->assign(value);
}
inline void RoutePoint::set_point(const char* value) {
inline void RouteData::set_points(const char* value) {
_set_bit(0);
if (point_ == &_default_point_) {
point_ = new ::std::string;
if (points_ == &_default_points_) {
points_ = new ::std::string;
}
point_->assign(value);
points_->assign(value);
}
inline void RoutePoint::set_point(const void* value, size_t size) {
inline void RouteData::set_points(const void* value, size_t size) {
_set_bit(0);
if (point_ == &_default_point_) {
point_ = new ::std::string;
if (points_ == &_default_points_) {
points_ = new ::std::string;
}
point_->assign(reinterpret_cast<const char*>(value), size);
points_->assign(reinterpret_cast<const char*>(value), size);
}
inline ::std::string* RoutePoint::mutable_point() {
inline ::std::string* RouteData::mutable_points() {
_set_bit(0);
if (point_ == &_default_point_) {
point_ = new ::std::string;
if (points_ == &_default_points_) {
points_ = new ::std::string;
}
return point_;
}
// optional uint32 pointId = 2;
inline bool RoutePoint::has_pointid() const {
return _has_bit(1);
}
inline void RoutePoint::clear_pointid() {
pointid_ = 0u;
_clear_bit(1);
}
inline ::google::protobuf::uint32 RoutePoint::pointid() const {
return pointid_;
}
inline void RoutePoint::set_pointid(::google::protobuf::uint32 value) {
_set_bit(1);
pointid_ = value;
}
// optional bytes types = 4;
inline bool RoutePoint::has_types() const {
return _has_bit(2);
}
inline void RoutePoint::clear_types() {
if (types_ != &_default_types_) {
types_->clear();
}
_clear_bit(2);
}
inline const ::std::string& RoutePoint::types() const {
return *types_;
}
inline void RoutePoint::set_types(const ::std::string& value) {
_set_bit(2);
if (types_ == &_default_types_) {
types_ = new ::std::string;
}
types_->assign(value);
}
inline void RoutePoint::set_types(const char* value) {
_set_bit(2);
if (types_ == &_default_types_) {
types_ = new ::std::string;
}
types_->assign(value);
}
inline void RoutePoint::set_types(const void* value, size_t size) {
_set_bit(2);
if (types_ == &_default_types_) {
types_ = new ::std::string;
}
types_->assign(reinterpret_cast<const char*>(value), size);
}
inline ::std::string* RoutePoint::mutable_types() {
_set_bit(2);
if (types_ == &_default_types_) {
types_ = new ::std::string;
}
return types_;
}
// -------------------------------------------------------------------
// RouteData
// repeated .RoutePoint points = 1;
inline int RouteData::points_size() const {
return points_.size();
}
inline void RouteData::clear_points() {
points_.Clear();
}
inline const ::RoutePoint& RouteData::points(int index) const {
return points_.Get(index);
}
inline ::RoutePoint* RouteData::mutable_points(int index) {
return points_.Mutable(index);
}
inline ::RoutePoint* RouteData::add_points() {
return points_.Add();
}
inline const ::google::protobuf::RepeatedPtrField< ::RoutePoint >&
RouteData::points() const {
return points_;
}
inline ::google::protobuf::RepeatedPtrField< ::RoutePoint >*
RouteData::mutable_points() {
return &points_;
// optional bytes pointTypes = 4;
inline bool RouteData::has_pointtypes() const {
return _has_bit(1);
}
inline void RouteData::clear_pointtypes() {
if (pointtypes_ != &_default_pointtypes_) {
pointtypes_->clear();
}
_clear_bit(1);
}
inline const ::std::string& RouteData::pointtypes() const {
return *pointtypes_;
}
inline void RouteData::set_pointtypes(const ::std::string& value) {
_set_bit(1);
if (pointtypes_ == &_default_pointtypes_) {
pointtypes_ = new ::std::string;
}
pointtypes_->assign(value);
}
inline void RouteData::set_pointtypes(const char* value) {
_set_bit(1);
if (pointtypes_ == &_default_pointtypes_) {
pointtypes_ = new ::std::string;
}
pointtypes_->assign(value);
}
inline void RouteData::set_pointtypes(const void* value, size_t size) {
_set_bit(1);
if (pointtypes_ == &_default_pointtypes_) {
pointtypes_ = new ::std::string;
}
pointtypes_->assign(reinterpret_cast<const char*>(value), size);
}
inline ::std::string* RouteData::mutable_pointtypes() {
_set_bit(1);
if (pointtypes_ == &_default_pointtypes_) {
pointtypes_ = new ::std::string;
}
return pointtypes_;
}
// required bytes types = 7;
inline bool RouteData::has_types() const {
return _has_bit(1);
return _has_bit(2);
}
inline void RouteData::clear_types() {
if (types_ != &_default_types_) {
types_->clear();
}
_clear_bit(1);
_clear_bit(2);
}
inline const ::std::string& RouteData::types() const {
return *types_;
}
inline void RouteData::set_types(const ::std::string& value) {
_set_bit(1);
_set_bit(2);
if (types_ == &_default_types_) {
types_ = new ::std::string;
}
types_->assign(value);
}
inline void RouteData::set_types(const char* value) {
_set_bit(1);
_set_bit(2);
if (types_ == &_default_types_) {
types_ = new ::std::string;
}
types_->assign(value);
}
inline void RouteData::set_types(const void* value, size_t size) {
_set_bit(1);
_set_bit(2);
if (types_ == &_default_types_) {
types_ = new ::std::string;
}
types_->assign(reinterpret_cast<const char*>(value), size);
}
inline ::std::string* RouteData::mutable_types() {
_set_bit(1);
_set_bit(2);
if (types_ == &_default_types_) {
types_ = new ::std::string;
}
@ -10089,56 +9903,56 @@ inline ::std::string* RouteData::mutable_types() {
// required int32 routeId = 12;
inline bool RouteData::has_routeid() const {
return _has_bit(2);
return _has_bit(3);
}
inline void RouteData::clear_routeid() {
routeid_ = 0;
_clear_bit(2);
_clear_bit(3);
}
inline ::google::protobuf::int32 RouteData::routeid() const {
return routeid_;
}
inline void RouteData::set_routeid(::google::protobuf::int32 value) {
_set_bit(2);
_set_bit(3);
routeid_ = value;
}
// optional bytes stringNames = 14;
inline bool RouteData::has_stringnames() const {
return _has_bit(3);
return _has_bit(4);
}
inline void RouteData::clear_stringnames() {
if (stringnames_ != &_default_stringnames_) {
stringnames_->clear();
}
_clear_bit(3);
_clear_bit(4);
}
inline const ::std::string& RouteData::stringnames() const {
return *stringnames_;
}
inline void RouteData::set_stringnames(const ::std::string& value) {
_set_bit(3);
_set_bit(4);
if (stringnames_ == &_default_stringnames_) {
stringnames_ = new ::std::string;
}
stringnames_->assign(value);
}
inline void RouteData::set_stringnames(const char* value) {
_set_bit(3);
_set_bit(4);
if (stringnames_ == &_default_stringnames_) {
stringnames_ = new ::std::string;
}
stringnames_->assign(value);
}
inline void RouteData::set_stringnames(const void* value, size_t size) {
_set_bit(3);
_set_bit(4);
if (stringnames_ == &_default_stringnames_) {
stringnames_ = new ::std::string;
}
stringnames_->assign(reinterpret_cast<const char*>(value), size);
}
inline ::std::string* RouteData::mutable_stringnames() {
_set_bit(3);
_set_bit(4);
if (stringnames_ == &_default_stringnames_) {
stringnames_ = new ::std::string;
}