support binary transport indexes
git-svn-id: https://osmand.googlecode.com/svn/trunk@638 e29c36b1-1cfa-d876-8d93-3434fc2bb7b8
This commit is contained in:
parent
a32daf7a6e
commit
82f3d9bb15
10 changed files with 695 additions and 166 deletions
|
@ -340,10 +340,13 @@ public class BinaryMapIndexReader {
|
|||
// left, ... already initialized
|
||||
length = readInt();
|
||||
int filePointer = codedIS.getTotalBytesRead();
|
||||
oldLimit = codedIS.pushLimit(length);
|
||||
searchTransportTreeBounds(cleft, cright, ctop, cbottom, req);
|
||||
codedIS.popLimit(oldLimit);
|
||||
if (req.limit == -1 || req.limit >= req.searchResults.size()) {
|
||||
oldLimit = codedIS.pushLimit(length);
|
||||
searchTransportTreeBounds(cleft, cright, ctop, cbottom, req);
|
||||
codedIS.popLimit(oldLimit);
|
||||
}
|
||||
codedIS.seek(filePointer + length);
|
||||
|
||||
if(lastIndexResult >= 0){
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
|
@ -364,7 +367,11 @@ public class BinaryMapIndexReader {
|
|||
}
|
||||
}
|
||||
|
||||
public net.osmand.data.TransportRoute getTransportRoute(int filePointer) throws IOException {
|
||||
public boolean transportStopBelongsTo(TransportStop s){
|
||||
return getTransportIndex(s.getFileOffset()) != null;
|
||||
}
|
||||
|
||||
private TransportIndex getTransportIndex(int filePointer) {
|
||||
TransportIndex ind = null;
|
||||
for(TransportIndex i : transportIndexes){
|
||||
if(i.fileOffset <= filePointer && (filePointer - i.fileOffset) < i.length){
|
||||
|
@ -372,6 +379,35 @@ public class BinaryMapIndexReader {
|
|||
break;
|
||||
}
|
||||
}
|
||||
return ind;
|
||||
}
|
||||
|
||||
public boolean containTransportData(double latitude, double longitude) {
|
||||
double x = MapUtils.getTileNumberX(TRANSPORT_STOP_ZOOM, longitude);
|
||||
double y = MapUtils.getTileNumberY(TRANSPORT_STOP_ZOOM, latitude);
|
||||
for (TransportIndex index : transportIndexes) {
|
||||
if (index.right >= x && index.left <= x && index.top <= y && index.bottom >= y) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean containTransportData(double topLatitude, double leftLongitude, double bottomLatitude, double rightLongitude){
|
||||
double leftX = MapUtils.getTileNumberX(TRANSPORT_STOP_ZOOM, leftLongitude);
|
||||
double topY = MapUtils.getTileNumberY(TRANSPORT_STOP_ZOOM, topLatitude);
|
||||
double rightX = MapUtils.getTileNumberX(TRANSPORT_STOP_ZOOM, rightLongitude);
|
||||
double bottomY = MapUtils.getTileNumberY(TRANSPORT_STOP_ZOOM, bottomLatitude);
|
||||
for (TransportIndex index : transportIndexes) {
|
||||
if (index.right >= leftX && index.left <= rightX && index.top <= bottomY && index.bottom >= topY) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public net.osmand.data.TransportRoute getTransportRoute(int filePointer) throws IOException {
|
||||
TransportIndex ind = getTransportIndex(filePointer);
|
||||
if(ind == null){
|
||||
return null;
|
||||
}
|
||||
|
@ -383,6 +419,7 @@ public class BinaryMapIndexReader {
|
|||
int name = -1;
|
||||
int nameEn = -1;
|
||||
int operator = -1;
|
||||
int type = -1;
|
||||
long rid = 0;
|
||||
int rx = 0;
|
||||
int ry = 0;
|
||||
|
@ -405,6 +442,9 @@ public class BinaryMapIndexReader {
|
|||
case OsmandOdb.TransportRoute.REF_FIELD_NUMBER :
|
||||
dataObject.setRef(codedIS.readString());
|
||||
break;
|
||||
case OsmandOdb.TransportRoute.TYPE_FIELD_NUMBER :
|
||||
type = codedIS.readUInt32();
|
||||
break;
|
||||
case OsmandOdb.TransportRoute.NAME_EN_FIELD_NUMBER :
|
||||
nameEn = codedIS.readUInt32();
|
||||
break;
|
||||
|
@ -452,24 +492,29 @@ public class BinaryMapIndexReader {
|
|||
if(operator != -1){
|
||||
dataObject.setOperator(getStringFromStringTable(ind.stringTable, operator));
|
||||
}
|
||||
for(int i=0; i< 2; i++){
|
||||
if(type != -1){
|
||||
dataObject.setType(getStringFromStringTable(ind.stringTable, type));
|
||||
}
|
||||
for (int i = 0; i < 2; i++) {
|
||||
List<TransportStop> stops = i == 0 ? dataObject.getForwardStops() : dataObject.getBackwardStops();
|
||||
for(TransportStop s : stops){
|
||||
if(s.getName().length() > 0){
|
||||
for (TransportStop s : stops) {
|
||||
if (s.getName().length() > 0) {
|
||||
s.setName(getStringFromStringTable(ind.stringTable, s.getName().charAt(0)));
|
||||
}
|
||||
if(s.getEnName().length() > 0){
|
||||
if (s.getEnName().length() > 0) {
|
||||
s.setEnName(getStringFromStringTable(ind.stringTable, s.getEnName().charAt(0)));
|
||||
} else {
|
||||
s.setEnName(Junidecode.unidecode(s.getName()));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return dataObject;
|
||||
}
|
||||
|
||||
|
||||
|
||||
private TransportStop readTransportRouteStop(int dx, int dy, long did) throws IOException {
|
||||
TransportStop dataObject = new TransportStop();
|
||||
|
@ -528,7 +573,7 @@ public class BinaryMapIndexReader {
|
|||
|
||||
TransportStop dataObject = new TransportStop();
|
||||
dataObject.setLocation(MapUtils.getLatitudeFromTile(TRANSPORT_STOP_ZOOM, y), MapUtils.getLongitudeFromTile(TRANSPORT_STOP_ZOOM, x));
|
||||
|
||||
dataObject.setFileOffset(shift);
|
||||
while(true){
|
||||
int t = codedIS.readTag();
|
||||
tag = WireFormat.getTagFieldNumber(t);
|
||||
|
@ -703,6 +748,10 @@ public class BinaryMapIndexReader {
|
|||
|
||||
|
||||
public List<BinaryMapDataObject> searchMapIndex(SearchRequest<BinaryMapDataObject> req) throws IOException {
|
||||
req.numberOfVisitedObjects = 0;
|
||||
req.numberOfAcceptedObjects = 0;
|
||||
req.numberOfAcceptedSubtrees = 0;
|
||||
req.numberOfReadSubtrees = 0;
|
||||
for (MapRoot index : mapIndexes) {
|
||||
if (index.minZoom <= req.zoom && index.maxZoom >= req.zoom) {
|
||||
if(index.right < req.left || index.left > req.right || index.top > req.bottom || index.bottom < req.top){
|
||||
|
@ -753,6 +802,10 @@ public class BinaryMapIndexReader {
|
|||
return req.getSearchResults();
|
||||
}
|
||||
|
||||
public boolean hasTransportData(){
|
||||
return transportIndexes.size() > 0;
|
||||
}
|
||||
|
||||
public List<String> getRegionNames(){
|
||||
List<String> names = new ArrayList<String>();
|
||||
for(AddressRegion r : addressIndexes){
|
||||
|
@ -1364,6 +1417,7 @@ public class BinaryMapIndexReader {
|
|||
}
|
||||
break;
|
||||
case OsmandOdb.MapTree.BASEID_FIELD_NUMBER :
|
||||
case OsmandOdb.MapTree.OLDBASEID_FIELD_NUMBER :
|
||||
long baseId = codedIS.readUInt64();
|
||||
|
||||
if (lastIndexResult != -1) {
|
||||
|
@ -1379,6 +1433,7 @@ public class BinaryMapIndexReader {
|
|||
}
|
||||
break;
|
||||
case OsmandOdb.MapTree.STRINGTABLE_FIELD_NUMBER :
|
||||
case OsmandOdb.MapTree.OLDSTRINGTABLE_FIELD_NUMBER :
|
||||
length = codedIS.readRawVarint32();
|
||||
oldLimit = codedIS.pushLimit(length);
|
||||
List<String> stringTable = readStringTable();
|
||||
|
@ -1569,13 +1624,16 @@ public class BinaryMapIndexReader {
|
|||
return request;
|
||||
}
|
||||
|
||||
public static SearchRequest<TransportStop> buildSearchTransportRequest(int sleft, int sright, int stop, int sbottom, int zoom){
|
||||
public static SearchRequest<TransportStop> buildSearchTransportRequest(int sleft, int sright, int stop, int sbottom, int limit, List<TransportStop> stops){
|
||||
SearchRequest<TransportStop> request = new SearchRequest<TransportStop>();
|
||||
if (stops != null) {
|
||||
request.searchResults = stops;
|
||||
}
|
||||
request.left = sleft >> (31 - TRANSPORT_STOP_ZOOM);
|
||||
request.right = sright >> (31 - TRANSPORT_STOP_ZOOM);
|
||||
request.top = stop >> (31 - TRANSPORT_STOP_ZOOM);
|
||||
request.bottom = sbottom >> (31 - TRANSPORT_STOP_ZOOM);
|
||||
request.zoom = zoom;
|
||||
request.limit = limit;
|
||||
return request;
|
||||
}
|
||||
|
||||
|
@ -1601,6 +1659,7 @@ public class BinaryMapIndexReader {
|
|||
int top = 0;
|
||||
int bottom = 0;
|
||||
int zoom = 15;
|
||||
int limit = -1;
|
||||
List<T> searchResults = new ArrayList<T>();
|
||||
TIntArrayList cacheCoordinates = new TIntArrayList();
|
||||
TIntArrayList cacheTypes = new TIntArrayList();
|
||||
|
@ -1756,18 +1815,35 @@ public class BinaryMapIndexReader {
|
|||
System.out.println(i.stringTable.offsets);
|
||||
System.out.println(i.stringTable.window);
|
||||
}
|
||||
int sleft = MapUtils.get31TileNumberX(27.573);
|
||||
int sright = MapUtils.get31TileNumberX(27.581);
|
||||
int stop = MapUtils.get31TileNumberY(53.912);
|
||||
int sbottom = MapUtils.get31TileNumberY(53.908);
|
||||
for(TransportStop s : reader.searchTransportIndex(buildSearchTransportRequest(sleft, sright, stop, sbottom, 15))){
|
||||
System.out.println(s.getName());
|
||||
for (int i : s.getReferencesToRoutes()) {
|
||||
TransportRoute route = reader.getTransportRoute(i);
|
||||
System.out.println(" " + route.getRef() + " " + route.getName() + " " + route.getDistance() + " " + route.getAvgBothDistance());
|
||||
{
|
||||
int sleft = MapUtils.get31TileNumberX(27.573);
|
||||
int sright = MapUtils.get31TileNumberX(27.581);
|
||||
int stop = MapUtils.get31TileNumberY(53.912);
|
||||
int sbottom = MapUtils.get31TileNumberY(53.908);
|
||||
for (TransportStop s : reader.searchTransportIndex(buildSearchTransportRequest(sleft, sright, stop, sbottom, 15, null))) {
|
||||
System.out.println(s.getName());
|
||||
for (int i : s.getReferencesToRoutes()) {
|
||||
TransportRoute route = reader.getTransportRoute(i);
|
||||
System.out.println(" " + route.getRef() + " " + route.getName() + " " + route.getDistance() + " "
|
||||
+ route.getAvgBothDistance());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
int sleft = MapUtils.get31TileNumberX(27.473);
|
||||
int sright = MapUtils.get31TileNumberX(27.681);
|
||||
int stop = MapUtils.get31TileNumberY(53.912);
|
||||
int sbottom = MapUtils.get31TileNumberY(53.708);
|
||||
for (TransportStop s : reader.searchTransportIndex(buildSearchTransportRequest(sleft, sright, stop, sbottom, 16, null))) {
|
||||
System.out.println(s.getName());
|
||||
for (int i : s.getReferencesToRoutes()) {
|
||||
TransportRoute route = reader.getTransportRoute(i);
|
||||
System.out.println(" " + route.getRef() + " " + route.getName() + " " + route.getDistance() + " "
|
||||
+ route.getAvgBothDistance());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
System.out.println("MEMORY " + (Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory()));
|
||||
System.out.println("Time " + (System.currentTimeMillis() - time));
|
||||
}
|
||||
|
|
|
@ -125,10 +125,13 @@ public class BinaryMapIndexWriter {
|
|||
return length;
|
||||
}
|
||||
|
||||
public void startWriteMapIndex() throws IOException{
|
||||
public void startWriteMapIndex(String name) throws IOException{
|
||||
pushState(MAP_INDEX_INIT, OSMAND_STRUCTURE_INIT);
|
||||
codedOutStream.writeTag(OsmandOdb.OsmAndStructure.MAPINDEX_FIELD_NUMBER, WireFormat.WIRETYPE_FIXED32_LENGTH_DELIMITED);
|
||||
preserveInt32Size();
|
||||
if(name != null){
|
||||
codedOutStream.writeString(OsmandOdb.OsmAndMapIndex.NAME_FIELD_NUMBER, name);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -552,11 +555,14 @@ public class BinaryMapIndexWriter {
|
|||
return size;
|
||||
}
|
||||
|
||||
public void startWriteTransportIndex() throws IOException {
|
||||
public void startWriteTransportIndex(String name) throws IOException {
|
||||
pushState(TRANSPORT_INDEX_INIT, OSMAND_STRUCTURE_INIT);
|
||||
codedOutStream.writeTag(OsmandOdb.OsmAndStructure.TRANSPORTINDEX_FIELD_NUMBER, WireFormat.WIRETYPE_FIXED32_LENGTH_DELIMITED);
|
||||
stackBounds.push(new Bounds(0, 0, 0, 0)); // for transport stops tree
|
||||
preserveInt32Size();
|
||||
if(name != null){
|
||||
codedOutStream.writeString(OsmandOdb.OsmAndTransportIndex.NAME_FIELD_NUMBER, name);
|
||||
}
|
||||
}
|
||||
|
||||
public void endWriteTransportIndex() throws IOException {
|
||||
|
|
|
@ -962,6 +962,13 @@ public final class OsmandOdb {
|
|||
return levels_.get(index);
|
||||
}
|
||||
|
||||
// optional string name = 3;
|
||||
public static final int NAME_FIELD_NUMBER = 3;
|
||||
private boolean hasName;
|
||||
private java.lang.String name_ = "";
|
||||
public boolean hasName() { return hasName; }
|
||||
public java.lang.String getName() { return name_; }
|
||||
|
||||
private void initFields() {
|
||||
}
|
||||
public final boolean isInitialized() {
|
||||
|
@ -977,6 +984,9 @@ public final class OsmandOdb {
|
|||
for (net.osmand.binary.OsmandOdb.MapRootLevel element : getLevelsList()) {
|
||||
output.writeMessage(1, element);
|
||||
}
|
||||
if (hasName()) {
|
||||
output.writeString(3, getName());
|
||||
}
|
||||
getUnknownFields().writeTo(output);
|
||||
}
|
||||
|
||||
|
@ -990,6 +1000,10 @@ public final class OsmandOdb {
|
|||
size += com.google.protobuf.CodedOutputStream
|
||||
.computeMessageSize(1, element);
|
||||
}
|
||||
if (hasName()) {
|
||||
size += com.google.protobuf.CodedOutputStream
|
||||
.computeStringSize(3, getName());
|
||||
}
|
||||
size += getUnknownFields().getSerializedSize();
|
||||
memoizedSerializedSize = size;
|
||||
return size;
|
||||
|
@ -1158,6 +1172,9 @@ public final class OsmandOdb {
|
|||
}
|
||||
result.levels_.addAll(other.levels_);
|
||||
}
|
||||
if (other.hasName()) {
|
||||
setName(other.getName());
|
||||
}
|
||||
this.mergeUnknownFields(other.getUnknownFields());
|
||||
return this;
|
||||
}
|
||||
|
@ -1189,6 +1206,10 @@ public final class OsmandOdb {
|
|||
addLevels(subBuilder.buildPartial());
|
||||
break;
|
||||
}
|
||||
case 26: {
|
||||
setName(input.readString());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1245,6 +1266,27 @@ public final class OsmandOdb {
|
|||
return this;
|
||||
}
|
||||
|
||||
// optional string name = 3;
|
||||
public boolean hasName() {
|
||||
return result.hasName();
|
||||
}
|
||||
public java.lang.String getName() {
|
||||
return result.getName();
|
||||
}
|
||||
public Builder setName(java.lang.String value) {
|
||||
if (value == null) {
|
||||
throw new NullPointerException();
|
||||
}
|
||||
result.hasName = true;
|
||||
result.name_ = value;
|
||||
return this;
|
||||
}
|
||||
public Builder clearName() {
|
||||
result.hasName = false;
|
||||
result.name_ = getDefaultInstance().getName();
|
||||
return this;
|
||||
}
|
||||
|
||||
// @@protoc_insertion_point(builder_scope:OsmAndMapIndex)
|
||||
}
|
||||
|
||||
|
@ -1886,19 +1928,19 @@ public final class OsmandOdb {
|
|||
public boolean hasBottom() { return hasBottom; }
|
||||
public int getBottom() { return bottom_; }
|
||||
|
||||
// optional .StringTable stringTable = 5;
|
||||
public static final int STRINGTABLE_FIELD_NUMBER = 5;
|
||||
private boolean hasStringTable;
|
||||
private net.osmand.binary.OsmandOdb.StringTable stringTable_;
|
||||
public boolean hasStringTable() { return hasStringTable; }
|
||||
public net.osmand.binary.OsmandOdb.StringTable getStringTable() { return stringTable_; }
|
||||
// optional .StringTable oldstringTable = 5;
|
||||
public static final int OLDSTRINGTABLE_FIELD_NUMBER = 5;
|
||||
private boolean hasOldstringTable;
|
||||
private net.osmand.binary.OsmandOdb.StringTable oldstringTable_;
|
||||
public boolean hasOldstringTable() { return hasOldstringTable; }
|
||||
public net.osmand.binary.OsmandOdb.StringTable getOldstringTable() { return oldstringTable_; }
|
||||
|
||||
// optional uint64 baseId = 6;
|
||||
public static final int BASEID_FIELD_NUMBER = 6;
|
||||
private boolean hasBaseId;
|
||||
private long baseId_ = 0L;
|
||||
public boolean hasBaseId() { return hasBaseId; }
|
||||
public long getBaseId() { return baseId_; }
|
||||
// optional uint64 oldbaseId = 6;
|
||||
public static final int OLDBASEID_FIELD_NUMBER = 6;
|
||||
private boolean hasOldbaseId;
|
||||
private long oldbaseId_ = 0L;
|
||||
public boolean hasOldbaseId() { return hasOldbaseId; }
|
||||
public long getOldbaseId() { return oldbaseId_; }
|
||||
|
||||
// repeated .MapTree subtrees = 7;
|
||||
public static final int SUBTREES_FIELD_NUMBER = 7;
|
||||
|
@ -1924,7 +1966,22 @@ public final class OsmandOdb {
|
|||
return leafs_.get(index);
|
||||
}
|
||||
|
||||
// optional uint64 baseId = 10;
|
||||
public static final int BASEID_FIELD_NUMBER = 10;
|
||||
private boolean hasBaseId;
|
||||
private long baseId_ = 0L;
|
||||
public boolean hasBaseId() { return hasBaseId; }
|
||||
public long getBaseId() { return baseId_; }
|
||||
|
||||
// optional .StringTable stringTable = 11;
|
||||
public static final int STRINGTABLE_FIELD_NUMBER = 11;
|
||||
private boolean hasStringTable;
|
||||
private net.osmand.binary.OsmandOdb.StringTable stringTable_;
|
||||
public boolean hasStringTable() { return hasStringTable; }
|
||||
public net.osmand.binary.OsmandOdb.StringTable getStringTable() { return stringTable_; }
|
||||
|
||||
private void initFields() {
|
||||
oldstringTable_ = net.osmand.binary.OsmandOdb.StringTable.getDefaultInstance();
|
||||
stringTable_ = net.osmand.binary.OsmandOdb.StringTable.getDefaultInstance();
|
||||
}
|
||||
public final boolean isInitialized() {
|
||||
|
@ -1956,11 +2013,11 @@ public final class OsmandOdb {
|
|||
if (hasBottom()) {
|
||||
output.writeSInt32(4, getBottom());
|
||||
}
|
||||
if (hasStringTable()) {
|
||||
output.writeMessage(5, getStringTable());
|
||||
if (hasOldstringTable()) {
|
||||
output.writeMessage(5, getOldstringTable());
|
||||
}
|
||||
if (hasBaseId()) {
|
||||
output.writeUInt64(6, getBaseId());
|
||||
if (hasOldbaseId()) {
|
||||
output.writeUInt64(6, getOldbaseId());
|
||||
}
|
||||
for (net.osmand.binary.OsmandOdb.MapTree element : getSubtreesList()) {
|
||||
output.writeMessage(7, element);
|
||||
|
@ -1968,6 +2025,12 @@ public final class OsmandOdb {
|
|||
for (net.osmand.binary.OsmandOdb.MapData element : getLeafsList()) {
|
||||
output.writeMessage(8, element);
|
||||
}
|
||||
if (hasBaseId()) {
|
||||
output.writeUInt64(10, getBaseId());
|
||||
}
|
||||
if (hasStringTable()) {
|
||||
output.writeMessage(11, getStringTable());
|
||||
}
|
||||
getUnknownFields().writeTo(output);
|
||||
}
|
||||
|
||||
|
@ -1993,13 +2056,13 @@ public final class OsmandOdb {
|
|||
size += com.google.protobuf.CodedOutputStream
|
||||
.computeSInt32Size(4, getBottom());
|
||||
}
|
||||
if (hasStringTable()) {
|
||||
if (hasOldstringTable()) {
|
||||
size += com.google.protobuf.CodedOutputStream
|
||||
.computeMessageSize(5, getStringTable());
|
||||
.computeMessageSize(5, getOldstringTable());
|
||||
}
|
||||
if (hasBaseId()) {
|
||||
if (hasOldbaseId()) {
|
||||
size += com.google.protobuf.CodedOutputStream
|
||||
.computeUInt64Size(6, getBaseId());
|
||||
.computeUInt64Size(6, getOldbaseId());
|
||||
}
|
||||
for (net.osmand.binary.OsmandOdb.MapTree element : getSubtreesList()) {
|
||||
size += com.google.protobuf.CodedOutputStream
|
||||
|
@ -2009,6 +2072,14 @@ public final class OsmandOdb {
|
|||
size += com.google.protobuf.CodedOutputStream
|
||||
.computeMessageSize(8, element);
|
||||
}
|
||||
if (hasBaseId()) {
|
||||
size += com.google.protobuf.CodedOutputStream
|
||||
.computeUInt64Size(10, getBaseId());
|
||||
}
|
||||
if (hasStringTable()) {
|
||||
size += com.google.protobuf.CodedOutputStream
|
||||
.computeMessageSize(11, getStringTable());
|
||||
}
|
||||
size += getUnknownFields().getSerializedSize();
|
||||
memoizedSerializedSize = size;
|
||||
return size;
|
||||
|
@ -2187,11 +2258,11 @@ public final class OsmandOdb {
|
|||
if (other.hasBottom()) {
|
||||
setBottom(other.getBottom());
|
||||
}
|
||||
if (other.hasStringTable()) {
|
||||
mergeStringTable(other.getStringTable());
|
||||
if (other.hasOldstringTable()) {
|
||||
mergeOldstringTable(other.getOldstringTable());
|
||||
}
|
||||
if (other.hasBaseId()) {
|
||||
setBaseId(other.getBaseId());
|
||||
if (other.hasOldbaseId()) {
|
||||
setOldbaseId(other.getOldbaseId());
|
||||
}
|
||||
if (!other.subtrees_.isEmpty()) {
|
||||
if (result.subtrees_.isEmpty()) {
|
||||
|
@ -2205,6 +2276,12 @@ public final class OsmandOdb {
|
|||
}
|
||||
result.leafs_.addAll(other.leafs_);
|
||||
}
|
||||
if (other.hasBaseId()) {
|
||||
setBaseId(other.getBaseId());
|
||||
}
|
||||
if (other.hasStringTable()) {
|
||||
mergeStringTable(other.getStringTable());
|
||||
}
|
||||
this.mergeUnknownFields(other.getUnknownFields());
|
||||
return this;
|
||||
}
|
||||
|
@ -2248,15 +2325,15 @@ public final class OsmandOdb {
|
|||
}
|
||||
case 42: {
|
||||
net.osmand.binary.OsmandOdb.StringTable.Builder subBuilder = net.osmand.binary.OsmandOdb.StringTable.newBuilder();
|
||||
if (hasStringTable()) {
|
||||
subBuilder.mergeFrom(getStringTable());
|
||||
if (hasOldstringTable()) {
|
||||
subBuilder.mergeFrom(getOldstringTable());
|
||||
}
|
||||
input.readMessage(subBuilder, extensionRegistry);
|
||||
setStringTable(subBuilder.buildPartial());
|
||||
setOldstringTable(subBuilder.buildPartial());
|
||||
break;
|
||||
}
|
||||
case 48: {
|
||||
setBaseId(input.readUInt64());
|
||||
setOldbaseId(input.readUInt64());
|
||||
break;
|
||||
}
|
||||
case 58: {
|
||||
|
@ -2271,6 +2348,19 @@ public final class OsmandOdb {
|
|||
addLeafs(subBuilder.buildPartial());
|
||||
break;
|
||||
}
|
||||
case 80: {
|
||||
setBaseId(input.readUInt64());
|
||||
break;
|
||||
}
|
||||
case 90: {
|
||||
net.osmand.binary.OsmandOdb.StringTable.Builder subBuilder = net.osmand.binary.OsmandOdb.StringTable.newBuilder();
|
||||
if (hasStringTable()) {
|
||||
subBuilder.mergeFrom(getStringTable());
|
||||
}
|
||||
input.readMessage(subBuilder, extensionRegistry);
|
||||
setStringTable(subBuilder.buildPartial());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2348,58 +2438,58 @@ public final class OsmandOdb {
|
|||
return this;
|
||||
}
|
||||
|
||||
// optional .StringTable stringTable = 5;
|
||||
public boolean hasStringTable() {
|
||||
return result.hasStringTable();
|
||||
// optional .StringTable oldstringTable = 5;
|
||||
public boolean hasOldstringTable() {
|
||||
return result.hasOldstringTable();
|
||||
}
|
||||
public net.osmand.binary.OsmandOdb.StringTable getStringTable() {
|
||||
return result.getStringTable();
|
||||
public net.osmand.binary.OsmandOdb.StringTable getOldstringTable() {
|
||||
return result.getOldstringTable();
|
||||
}
|
||||
public Builder setStringTable(net.osmand.binary.OsmandOdb.StringTable value) {
|
||||
public Builder setOldstringTable(net.osmand.binary.OsmandOdb.StringTable value) {
|
||||
if (value == null) {
|
||||
throw new NullPointerException();
|
||||
}
|
||||
result.hasStringTable = true;
|
||||
result.stringTable_ = value;
|
||||
result.hasOldstringTable = true;
|
||||
result.oldstringTable_ = value;
|
||||
return this;
|
||||
}
|
||||
public Builder setStringTable(net.osmand.binary.OsmandOdb.StringTable.Builder builderForValue) {
|
||||
result.hasStringTable = true;
|
||||
result.stringTable_ = builderForValue.build();
|
||||
public Builder setOldstringTable(net.osmand.binary.OsmandOdb.StringTable.Builder builderForValue) {
|
||||
result.hasOldstringTable = true;
|
||||
result.oldstringTable_ = builderForValue.build();
|
||||
return this;
|
||||
}
|
||||
public Builder mergeStringTable(net.osmand.binary.OsmandOdb.StringTable value) {
|
||||
if (result.hasStringTable() &&
|
||||
result.stringTable_ != net.osmand.binary.OsmandOdb.StringTable.getDefaultInstance()) {
|
||||
result.stringTable_ =
|
||||
net.osmand.binary.OsmandOdb.StringTable.newBuilder(result.stringTable_).mergeFrom(value).buildPartial();
|
||||
public Builder mergeOldstringTable(net.osmand.binary.OsmandOdb.StringTable value) {
|
||||
if (result.hasOldstringTable() &&
|
||||
result.oldstringTable_ != net.osmand.binary.OsmandOdb.StringTable.getDefaultInstance()) {
|
||||
result.oldstringTable_ =
|
||||
net.osmand.binary.OsmandOdb.StringTable.newBuilder(result.oldstringTable_).mergeFrom(value).buildPartial();
|
||||
} else {
|
||||
result.stringTable_ = value;
|
||||
result.oldstringTable_ = value;
|
||||
}
|
||||
result.hasStringTable = true;
|
||||
result.hasOldstringTable = true;
|
||||
return this;
|
||||
}
|
||||
public Builder clearStringTable() {
|
||||
result.hasStringTable = false;
|
||||
result.stringTable_ = net.osmand.binary.OsmandOdb.StringTable.getDefaultInstance();
|
||||
public Builder clearOldstringTable() {
|
||||
result.hasOldstringTable = false;
|
||||
result.oldstringTable_ = net.osmand.binary.OsmandOdb.StringTable.getDefaultInstance();
|
||||
return this;
|
||||
}
|
||||
|
||||
// optional uint64 baseId = 6;
|
||||
public boolean hasBaseId() {
|
||||
return result.hasBaseId();
|
||||
// optional uint64 oldbaseId = 6;
|
||||
public boolean hasOldbaseId() {
|
||||
return result.hasOldbaseId();
|
||||
}
|
||||
public long getBaseId() {
|
||||
return result.getBaseId();
|
||||
public long getOldbaseId() {
|
||||
return result.getOldbaseId();
|
||||
}
|
||||
public Builder setBaseId(long value) {
|
||||
result.hasBaseId = true;
|
||||
result.baseId_ = value;
|
||||
public Builder setOldbaseId(long value) {
|
||||
result.hasOldbaseId = true;
|
||||
result.oldbaseId_ = value;
|
||||
return this;
|
||||
}
|
||||
public Builder clearBaseId() {
|
||||
result.hasBaseId = false;
|
||||
result.baseId_ = 0L;
|
||||
public Builder clearOldbaseId() {
|
||||
result.hasOldbaseId = false;
|
||||
result.oldbaseId_ = 0L;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -2505,6 +2595,61 @@ public final class OsmandOdb {
|
|||
return this;
|
||||
}
|
||||
|
||||
// optional uint64 baseId = 10;
|
||||
public boolean hasBaseId() {
|
||||
return result.hasBaseId();
|
||||
}
|
||||
public long getBaseId() {
|
||||
return result.getBaseId();
|
||||
}
|
||||
public Builder setBaseId(long value) {
|
||||
result.hasBaseId = true;
|
||||
result.baseId_ = value;
|
||||
return this;
|
||||
}
|
||||
public Builder clearBaseId() {
|
||||
result.hasBaseId = false;
|
||||
result.baseId_ = 0L;
|
||||
return this;
|
||||
}
|
||||
|
||||
// optional .StringTable stringTable = 11;
|
||||
public boolean hasStringTable() {
|
||||
return result.hasStringTable();
|
||||
}
|
||||
public net.osmand.binary.OsmandOdb.StringTable getStringTable() {
|
||||
return result.getStringTable();
|
||||
}
|
||||
public Builder setStringTable(net.osmand.binary.OsmandOdb.StringTable value) {
|
||||
if (value == null) {
|
||||
throw new NullPointerException();
|
||||
}
|
||||
result.hasStringTable = true;
|
||||
result.stringTable_ = value;
|
||||
return this;
|
||||
}
|
||||
public Builder setStringTable(net.osmand.binary.OsmandOdb.StringTable.Builder builderForValue) {
|
||||
result.hasStringTable = true;
|
||||
result.stringTable_ = builderForValue.build();
|
||||
return this;
|
||||
}
|
||||
public Builder mergeStringTable(net.osmand.binary.OsmandOdb.StringTable value) {
|
||||
if (result.hasStringTable() &&
|
||||
result.stringTable_ != net.osmand.binary.OsmandOdb.StringTable.getDefaultInstance()) {
|
||||
result.stringTable_ =
|
||||
net.osmand.binary.OsmandOdb.StringTable.newBuilder(result.stringTable_).mergeFrom(value).buildPartial();
|
||||
} else {
|
||||
result.stringTable_ = value;
|
||||
}
|
||||
result.hasStringTable = true;
|
||||
return this;
|
||||
}
|
||||
public Builder clearStringTable() {
|
||||
result.hasStringTable = false;
|
||||
result.stringTable_ = net.osmand.binary.OsmandOdb.StringTable.getDefaultInstance();
|
||||
return this;
|
||||
}
|
||||
|
||||
// @@protoc_insertion_point(builder_scope:MapTree)
|
||||
}
|
||||
|
||||
|
@ -9729,6 +9874,13 @@ public final class OsmandOdb {
|
|||
return net.osmand.binary.OsmandOdb.internal_static_OsmAndTransportIndex_fieldAccessorTable;
|
||||
}
|
||||
|
||||
// optional string name = 1;
|
||||
public static final int NAME_FIELD_NUMBER = 1;
|
||||
private boolean hasName;
|
||||
private java.lang.String name_ = "";
|
||||
public boolean hasName() { return hasName; }
|
||||
public java.lang.String getName() { return name_; }
|
||||
|
||||
// optional .TransportRoutes routes = 3;
|
||||
public static final int ROUTES_FIELD_NUMBER = 3;
|
||||
private boolean hasRoutes;
|
||||
|
@ -9769,6 +9921,9 @@ public final class OsmandOdb {
|
|||
public void writeTo(com.google.protobuf.CodedOutputStream output)
|
||||
throws java.io.IOException {
|
||||
getSerializedSize();
|
||||
if (hasName()) {
|
||||
output.writeString(1, getName());
|
||||
}
|
||||
if (hasRoutes()) {
|
||||
output.writeMessage(3, getRoutes());
|
||||
}
|
||||
|
@ -9787,6 +9942,10 @@ public final class OsmandOdb {
|
|||
if (size != -1) return size;
|
||||
|
||||
size = 0;
|
||||
if (hasName()) {
|
||||
size += com.google.protobuf.CodedOutputStream
|
||||
.computeStringSize(1, getName());
|
||||
}
|
||||
if (hasRoutes()) {
|
||||
size += com.google.protobuf.CodedOutputStream
|
||||
.computeMessageSize(3, getRoutes());
|
||||
|
@ -9957,6 +10116,9 @@ public final class OsmandOdb {
|
|||
|
||||
public Builder mergeFrom(net.osmand.binary.OsmandOdb.OsmAndTransportIndex other) {
|
||||
if (other == net.osmand.binary.OsmandOdb.OsmAndTransportIndex.getDefaultInstance()) return this;
|
||||
if (other.hasName()) {
|
||||
setName(other.getName());
|
||||
}
|
||||
if (other.hasRoutes()) {
|
||||
mergeRoutes(other.getRoutes());
|
||||
}
|
||||
|
@ -9991,6 +10153,10 @@ public final class OsmandOdb {
|
|||
}
|
||||
break;
|
||||
}
|
||||
case 10: {
|
||||
setName(input.readString());
|
||||
break;
|
||||
}
|
||||
case 26: {
|
||||
net.osmand.binary.OsmandOdb.TransportRoutes.Builder subBuilder = net.osmand.binary.OsmandOdb.TransportRoutes.newBuilder();
|
||||
if (hasRoutes()) {
|
||||
|
@ -10023,6 +10189,27 @@ public final class OsmandOdb {
|
|||
}
|
||||
|
||||
|
||||
// optional string name = 1;
|
||||
public boolean hasName() {
|
||||
return result.hasName();
|
||||
}
|
||||
public java.lang.String getName() {
|
||||
return result.getName();
|
||||
}
|
||||
public Builder setName(java.lang.String value) {
|
||||
if (value == null) {
|
||||
throw new NullPointerException();
|
||||
}
|
||||
result.hasName = true;
|
||||
result.name_ = value;
|
||||
return this;
|
||||
}
|
||||
public Builder clearName() {
|
||||
result.hasName = false;
|
||||
result.name_ = getDefaultInstance().getName();
|
||||
return this;
|
||||
}
|
||||
|
||||
// optional .TransportRoutes routes = 3;
|
||||
public boolean hasRoutes() {
|
||||
return result.hasRoutes();
|
||||
|
@ -10265,61 +10452,63 @@ public final class OsmandOdb {
|
|||
"OsmAndMapIndex\022)\n\014addressIndex\030\003 \003(\0132\023.O" +
|
||||
"smAndAddressIndex\022-\n\016transportIndex\030\004 \003(" +
|
||||
"\0132\025.OsmAndTransportIndex\022\026\n\016versionConfi" +
|
||||
"rm\030 \002(\r\"\030\n\013StringTable\022\t\n\001s\030\001 \003(\t\"/\n\016Os" +
|
||||
"rm\030 \002(\r\"\030\n\013StringTable\022\t\n\001s\030\001 \003(\t\"=\n\016Os" +
|
||||
"mAndMapIndex\022\035\n\006levels\030\001 \003(\0132\r.MapRootLe" +
|
||||
"vel\"\202\001\n\014MapRootLevel\022\017\n\007maxZoom\030\001 \002(\005\022\017\n" +
|
||||
"\007minZoom\030\002 \002(\005\022\014\n\004left\030\003 \002(\005\022\r\n\005right\030\004 " +
|
||||
"\002(\005\022\013\n\003top\030\005 \002(\005\022\016\n\006bottom\030\006 \002(\005\022\026\n\004root",
|
||||
"\030\007 \003(\0132\010.MapTree\"\253\001\n\007MapTree\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!\n\013stringTable\030\005 \001(\0132\014.StringTabl" +
|
||||
"e\022\016\n\006baseId\030\006 \001(\004\022\032\n\010subtrees\030\007 \003(\0132\010.Ma" +
|
||||
"pTree\022\027\n\005leafs\030\010 \003(\0132\010.MapData\"v\n\007MapDat" +
|
||||
"a\022\023\n\013coordinates\030\001 \002(\014\022\r\n\005types\030\002 \002(\014\022\n\n" +
|
||||
"\002id\030\003 \002(\022\022\020\n\010stringId\030\004 \001(\r\022\024\n\014restricti" +
|
||||
"ons\030\005 \001(\014\022\023\n\013highwayMeta\030\006 \001(\005\"\225\001\n\022OsmAn" +
|
||||
"dAddressIndex\022\014\n\004name\030\001 \002(\t\022\017\n\007name_en\030\002" +
|
||||
" \001(\t\022\034\n\006cities\030\005 \001(\0132\014.CitiesIndex\022\"\n\tpo",
|
||||
"stcodes\030\006 \001(\0132\017.PostcodesIndex\022\036\n\010villag" +
|
||||
"es\030\007 \001(\0132\014.CitiesIndex\")\n\013CitiesIndex\022\032\n" +
|
||||
"\006cities\030\001 \003(\0132\n.CityIndex\"3\n\016PostcodesIn" +
|
||||
"dex\022!\n\tpostcodes\030\001 \003(\0132\016.PostcodeIndex\"\253" +
|
||||
"\001\n\tCityIndex\022\021\n\tcity_type\030\001 \002(\r\022\014\n\004name\030" +
|
||||
"\002 \002(\t\022\017\n\007name_en\030\003 \001(\t\022\n\n\002id\030\004 \001(\004\022\t\n\001x\030" +
|
||||
"\005 \002(\007\022\t\n\001y\030\006 \002(\007\022+\n\rintersections\030\016 \001(\0132" +
|
||||
"\024.InteresectedStreets\022\035\n\007streets\030\022 \003(\0132\014" +
|
||||
".StreetIndex\"A\n\023InteresectedStreets\022*\n\ri" +
|
||||
"ntersections\030\005 \003(\0132\023.StreetIntersection\"",
|
||||
"x\n\022StreetIntersection\022\032\n\022intersectedStre" +
|
||||
"et1\030\002 \002(\r\022\032\n\022intersectedStreet2\030\003 \002(\r\022\024\n" +
|
||||
"\014intersectedX\030\004 \002(\021\022\024\n\014intersectedY\030\005 \002(" +
|
||||
"\021\"V\n\rPostcodeIndex\022\020\n\010postcode\030\001 \002(\t\022\t\n\001" +
|
||||
"x\030\002 \002(\007\022\t\n\001y\030\003 \002(\007\022\035\n\007streets\030\005 \003(\0132\014.St" +
|
||||
"reetIndex\"q\n\013StreetIndex\022\014\n\004name\030\001 \002(\t\022\017" +
|
||||
"\n\007name_en\030\002 \001(\t\022\t\n\001x\030\003 \002(\021\022\t\n\001y\030\004 \002(\021\022\n\n" +
|
||||
"\002id\030\006 \001(\004\022!\n\tbuildings\030\022 \003(\0132\016.BuildingI" +
|
||||
"ndex\"b\n\rBuildingIndex\022\014\n\004name\030\001 \002(\t\022\017\n\007n" +
|
||||
"ame_en\030\002 \001(\t\022\n\n\002id\030\005 \001(\004\022\020\n\010postcode\030\006 \001",
|
||||
"(\t\022\t\n\001x\030\003 \002(\021\022\t\n\001y\030\004 \002(\021\"2\n\017TransportRou" +
|
||||
"tes\022\037\n\006routes\030\006 \003(\0132\017.TransportRoute\"\317\001\n" +
|
||||
"\016TransportRoute\022\n\n\002id\030\001 \002(\004\022\014\n\004type\030\003 \001(" +
|
||||
"\r\022\020\n\010operator\030\004 \001(\r\022\013\n\003ref\030\005 \001(\t\022\014\n\004name" +
|
||||
"\030\006 \001(\r\022\017\n\007name_en\030\007 \001(\r\022\020\n\010distance\030\010 \001(" +
|
||||
"\r\022(\n\013directStops\030\017 \003(\0132\023.TransportRouteS" +
|
||||
"top\022)\n\014reverseStops\030\020 \003(\0132\023.TransportRou" +
|
||||
"teStop\"W\n\022TransportRouteStop\022\n\n\002id\030\001 \002(\022" +
|
||||
"\022\n\n\002dx\030\002 \002(\021\022\n\n\002dy\030\003 \002(\021\022\014\n\004name\030\006 \002(\r\022\017" +
|
||||
"\n\007name_en\030\007 \001(\r\"b\n\rTransportStop\022\n\n\002dx\030\001",
|
||||
" \002(\021\022\n\n\002dy\030\002 \002(\021\022\n\n\002id\030\005 \002(\022\022\014\n\004name\030\006 \002" +
|
||||
"(\r\022\017\n\007name_en\030\007 \001(\r\022\016\n\006routes\030\020 \003(\r\"\244\001\n\022" +
|
||||
"TransportStopsTree\022\014\n\004left\030\001 \002(\021\022\r\n\005righ" +
|
||||
"t\030\002 \002(\021\022\013\n\003top\030\003 \002(\021\022\016\n\006bottom\030\004 \002(\021\022%\n\010" +
|
||||
"subtrees\030\007 \003(\0132\023.TransportStopsTree\022\035\n\005l" +
|
||||
"eafs\030\010 \003(\0132\016.TransportStop\022\016\n\006baseId\030\020 \001" +
|
||||
"(\004\"\177\n\024OsmAndTransportIndex\022 \n\006routes\030\003 \001" +
|
||||
"(\0132\020.TransportRoutes\022\"\n\005stops\030\006 \001(\0132\023.Tr" +
|
||||
"ansportStopsTree\022!\n\013stringTable\030\t \002(\0132\014." +
|
||||
"StringTableB\023\n\021net.osmand.binary"
|
||||
"vel\022\014\n\004name\030\003 \001(\t\"\202\001\n\014MapRootLevel\022\017\n\007ma" +
|
||||
"xZoom\030\001 \002(\005\022\017\n\007minZoom\030\002 \002(\005\022\014\n\004left\030\003 \002" +
|
||||
"(\005\022\r\n\005right\030\004 \002(\005\022\013\n\003top\030\005 \002(\005\022\016\n\006bottom",
|
||||
"\030\006 \002(\005\022\026\n\004root\030\007 \003(\0132\010.MapTree\"\344\001\n\007MapTr" +
|
||||
"ee\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$\n\016oldstringTable\030\005" +
|
||||
" \001(\0132\014.StringTable\022\021\n\toldbaseId\030\006 \001(\004\022\032\n" +
|
||||
"\010subtrees\030\007 \003(\0132\010.MapTree\022\027\n\005leafs\030\010 \003(\013" +
|
||||
"2\010.MapData\022\016\n\006baseId\030\n \001(\004\022!\n\013stringTabl" +
|
||||
"e\030\013 \001(\0132\014.StringTable\"v\n\007MapData\022\023\n\013coor" +
|
||||
"dinates\030\001 \002(\014\022\r\n\005types\030\002 \002(\014\022\n\n\002id\030\003 \002(\022" +
|
||||
"\022\020\n\010stringId\030\004 \001(\r\022\024\n\014restrictions\030\005 \001(\014" +
|
||||
"\022\023\n\013highwayMeta\030\006 \001(\005\"\225\001\n\022OsmAndAddressI",
|
||||
"ndex\022\014\n\004name\030\001 \002(\t\022\017\n\007name_en\030\002 \001(\t\022\034\n\006c" +
|
||||
"ities\030\005 \001(\0132\014.CitiesIndex\022\"\n\tpostcodes\030\006" +
|
||||
" \001(\0132\017.PostcodesIndex\022\036\n\010villages\030\007 \001(\0132" +
|
||||
"\014.CitiesIndex\")\n\013CitiesIndex\022\032\n\006cities\030\001" +
|
||||
" \003(\0132\n.CityIndex\"3\n\016PostcodesIndex\022!\n\tpo" +
|
||||
"stcodes\030\001 \003(\0132\016.PostcodeIndex\"\253\001\n\tCityIn" +
|
||||
"dex\022\021\n\tcity_type\030\001 \002(\r\022\014\n\004name\030\002 \002(\t\022\017\n\007" +
|
||||
"name_en\030\003 \001(\t\022\n\n\002id\030\004 \001(\004\022\t\n\001x\030\005 \002(\007\022\t\n\001" +
|
||||
"y\030\006 \002(\007\022+\n\rintersections\030\016 \001(\0132\024.Interes" +
|
||||
"ectedStreets\022\035\n\007streets\030\022 \003(\0132\014.StreetIn",
|
||||
"dex\"A\n\023InteresectedStreets\022*\n\rintersecti" +
|
||||
"ons\030\005 \003(\0132\023.StreetIntersection\"x\n\022Street" +
|
||||
"Intersection\022\032\n\022intersectedStreet1\030\002 \002(\r" +
|
||||
"\022\032\n\022intersectedStreet2\030\003 \002(\r\022\024\n\014intersec" +
|
||||
"tedX\030\004 \002(\021\022\024\n\014intersectedY\030\005 \002(\021\"V\n\rPost" +
|
||||
"codeIndex\022\020\n\010postcode\030\001 \002(\t\022\t\n\001x\030\002 \002(\007\022\t" +
|
||||
"\n\001y\030\003 \002(\007\022\035\n\007streets\030\005 \003(\0132\014.StreetIndex" +
|
||||
"\"q\n\013StreetIndex\022\014\n\004name\030\001 \002(\t\022\017\n\007name_en" +
|
||||
"\030\002 \001(\t\022\t\n\001x\030\003 \002(\021\022\t\n\001y\030\004 \002(\021\022\n\n\002id\030\006 \001(\004" +
|
||||
"\022!\n\tbuildings\030\022 \003(\0132\016.BuildingIndex\"b\n\rB",
|
||||
"uildingIndex\022\014\n\004name\030\001 \002(\t\022\017\n\007name_en\030\002 " +
|
||||
"\001(\t\022\n\n\002id\030\005 \001(\004\022\020\n\010postcode\030\006 \001(\t\022\t\n\001x\030\003" +
|
||||
" \002(\021\022\t\n\001y\030\004 \002(\021\"2\n\017TransportRoutes\022\037\n\006ro" +
|
||||
"utes\030\006 \003(\0132\017.TransportRoute\"\317\001\n\016Transpor" +
|
||||
"tRoute\022\n\n\002id\030\001 \002(\004\022\014\n\004type\030\003 \001(\r\022\020\n\010oper" +
|
||||
"ator\030\004 \001(\r\022\013\n\003ref\030\005 \001(\t\022\014\n\004name\030\006 \001(\r\022\017\n" +
|
||||
"\007name_en\030\007 \001(\r\022\020\n\010distance\030\010 \001(\r\022(\n\013dire" +
|
||||
"ctStops\030\017 \003(\0132\023.TransportRouteStop\022)\n\014re" +
|
||||
"verseStops\030\020 \003(\0132\023.TransportRouteStop\"W\n" +
|
||||
"\022TransportRouteStop\022\n\n\002id\030\001 \002(\022\022\n\n\002dx\030\002 ",
|
||||
"\002(\021\022\n\n\002dy\030\003 \002(\021\022\014\n\004name\030\006 \002(\r\022\017\n\007name_en" +
|
||||
"\030\007 \001(\r\"b\n\rTransportStop\022\n\n\002dx\030\001 \002(\021\022\n\n\002d" +
|
||||
"y\030\002 \002(\021\022\n\n\002id\030\005 \002(\022\022\014\n\004name\030\006 \002(\r\022\017\n\007nam" +
|
||||
"e_en\030\007 \001(\r\022\016\n\006routes\030\020 \003(\r\"\244\001\n\022Transport" +
|
||||
"StopsTree\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%\n\010subtrees\030" +
|
||||
"\007 \003(\0132\023.TransportStopsTree\022\035\n\005leafs\030\010 \003(" +
|
||||
"\0132\016.TransportStop\022\016\n\006baseId\030\020 \001(\004\"\215\001\n\024Os" +
|
||||
"mAndTransportIndex\022\014\n\004name\030\001 \001(\t\022 \n\006rout" +
|
||||
"es\030\003 \001(\0132\020.TransportRoutes\022\"\n\005stops\030\006 \001(",
|
||||
"\0132\023.TransportStopsTree\022!\n\013stringTable\030\t " +
|
||||
"\002(\0132\014.StringTableB\023\n\021net.osmand.binary"
|
||||
};
|
||||
com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner =
|
||||
new com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner() {
|
||||
|
@ -10347,7 +10536,7 @@ public final class OsmandOdb {
|
|||
internal_static_OsmAndMapIndex_fieldAccessorTable = new
|
||||
com.google.protobuf.GeneratedMessage.FieldAccessorTable(
|
||||
internal_static_OsmAndMapIndex_descriptor,
|
||||
new java.lang.String[] { "Levels", },
|
||||
new java.lang.String[] { "Levels", "Name", },
|
||||
net.osmand.binary.OsmandOdb.OsmAndMapIndex.class,
|
||||
net.osmand.binary.OsmandOdb.OsmAndMapIndex.Builder.class);
|
||||
internal_static_MapRootLevel_descriptor =
|
||||
|
@ -10363,7 +10552,7 @@ public final class OsmandOdb {
|
|||
internal_static_MapTree_fieldAccessorTable = new
|
||||
com.google.protobuf.GeneratedMessage.FieldAccessorTable(
|
||||
internal_static_MapTree_descriptor,
|
||||
new java.lang.String[] { "Left", "Right", "Top", "Bottom", "StringTable", "BaseId", "Subtrees", "Leafs", },
|
||||
new java.lang.String[] { "Left", "Right", "Top", "Bottom", "OldstringTable", "OldbaseId", "Subtrees", "Leafs", "BaseId", "StringTable", },
|
||||
net.osmand.binary.OsmandOdb.MapTree.class,
|
||||
net.osmand.binary.OsmandOdb.MapTree.Builder.class);
|
||||
internal_static_MapData_descriptor =
|
||||
|
@ -10491,7 +10680,7 @@ public final class OsmandOdb {
|
|||
internal_static_OsmAndTransportIndex_fieldAccessorTable = new
|
||||
com.google.protobuf.GeneratedMessage.FieldAccessorTable(
|
||||
internal_static_OsmAndTransportIndex_descriptor,
|
||||
new java.lang.String[] { "Routes", "Stops", "StringTable", },
|
||||
new java.lang.String[] { "Name", "Routes", "Stops", "StringTable", },
|
||||
net.osmand.binary.OsmandOdb.OsmAndTransportIndex.class,
|
||||
net.osmand.binary.OsmandOdb.OsmAndTransportIndex.Builder.class);
|
||||
return null;
|
||||
|
|
|
@ -1553,7 +1553,7 @@ public class IndexCreator {
|
|||
assert IndexConstants.IndexBinaryMapRenderObject.values().length == 6;
|
||||
PreparedStatement selectData = mapConnection.prepareStatement("SELECT * FROM " + IndexBinaryMapRenderObject.getTable() + " WHERE id = ?");
|
||||
|
||||
writer.startWriteMapIndex();
|
||||
writer.startWriteMapIndex(regionName);
|
||||
|
||||
for (int i = 0; i < MAP_ZOOMS.length - 1; i++) {
|
||||
RTree rtree = mapTree[i];
|
||||
|
@ -1643,7 +1643,7 @@ public class IndexCreator {
|
|||
" A.latitude, A.longitude, A.name, A.name_en " +
|
||||
"FROM transport_route_stop S INNER JOIN transport_stop A ON A.id = S.stop WHERE S.route = ? ORDER BY S.ord asc");
|
||||
|
||||
writer.startWriteTransportIndex();
|
||||
writer.startWriteTransportIndex(regionName);
|
||||
|
||||
writer.startWriteTransportRoutes();
|
||||
|
||||
|
@ -1942,12 +1942,14 @@ public class IndexCreator {
|
|||
}
|
||||
|
||||
// 3.3 MAIN iterate over all entities
|
||||
progress.setGeneralProgress("[50 of 100]");
|
||||
progress.startTask("Processing osm nodes...", allNodes);
|
||||
iterateOverEntities(progress, EntityType.NODE, allNodes, STEP_MAIN);
|
||||
progress.setGeneralProgress("[70 of 100]");
|
||||
progress.startTask("Processing osm ways...", allWays);
|
||||
iterateOverEntities(progress, EntityType.WAY, allWays, STEP_MAIN);
|
||||
if (indexPOI || indexAddress || indexMap) {
|
||||
progress.setGeneralProgress("[50 of 100]");
|
||||
progress.startTask("Processing osm nodes...", allNodes);
|
||||
iterateOverEntities(progress, EntityType.NODE, allNodes, STEP_MAIN);
|
||||
progress.setGeneralProgress("[70 of 100]");
|
||||
progress.startTask("Processing osm ways...", allWays);
|
||||
iterateOverEntities(progress, EntityType.WAY, allWays, STEP_MAIN);
|
||||
}
|
||||
progress.setGeneralProgress("[85 of 100]");
|
||||
progress.startTask("Processing osm relations...", allRelations);
|
||||
iterateOverEntities(progress, EntityType.RELATION, allRelations, STEP_MAIN);
|
||||
|
@ -2335,11 +2337,11 @@ public class IndexCreator {
|
|||
// creator.setIndexPOI(true);
|
||||
creator.setIndexTransport(true);
|
||||
|
||||
creator.recreateOnlyBinaryFile = true;
|
||||
creator.recreateOnlyBinaryFile = false;
|
||||
creator.deleteDatabaseIndexes = false;
|
||||
|
||||
creator.setNodesDBFile(new File("e:/Information/OSM maps/osmand/minsk.tmp.odb"));
|
||||
creator.generateIndexes(new File("e:/Information/OSM maps/belarus osm/minsk.osm"), new ConsoleProgressImplementation(3), null);
|
||||
// creator.setNodesDBFile(new File("e:/Information/OSM maps/osmand/minsk.tmp.odb"));
|
||||
// creator.generateIndexes(new File("e:/Information/OSM maps/belarus osm/minsk.osm"), new ConsoleProgressImplementation(3), null);
|
||||
|
||||
// creator.setNodesDBFile(new File("e:/Information/OSM maps/osmand/belarus_nodes.tmp.odb"));
|
||||
// creator.generateIndexes(new File("e:/Information/OSM maps/belarus osm/belarus.osm.bz2"), new ConsoleProgressImplementation(3), null);
|
||||
|
@ -2354,8 +2356,8 @@ public class IndexCreator {
|
|||
// creator.setNodesDBFile(new File("e:/Information/OSM maps/osmand/den_haag.tmp.odb"));
|
||||
// creator.generateIndexes(new File("e:/Information/OSM maps/osm_map/den_haag.osm"), new ConsoleProgressImplementation(3), null);
|
||||
|
||||
// creator.setNodesDBFile(new File("e:/Information/OSM maps/osmand/netherlands.tmp.odb"));
|
||||
// creator.generateIndexes(new File("e:/Information/OSM maps/osm_map/netherlands.osm.bz2"), new ConsoleProgressImplementation(1), null);
|
||||
creator.setNodesDBFile(new File("e:/Information/OSM maps/osmand/netherlands.tmp.odb"));
|
||||
creator.generateIndexes(new File("e:/Information/OSM maps/osm_map/netherlands.osm.bz2"), new ConsoleProgressImplementation(1), null);
|
||||
|
||||
// creator.generateIndexes(new File("e:/Information/OSM maps/osm_map/forest_complex.osm"), new ConsoleProgressImplementation(25), null);
|
||||
|
||||
|
|
|
@ -31,7 +31,9 @@ message StringTable {
|
|||
|
||||
message OsmAndMapIndex {
|
||||
// encoded as fixed32 length delimited
|
||||
repeated MapRootLevel levels = 1;
|
||||
repeated MapRootLevel levels = 1;
|
||||
|
||||
optional string name = 3;
|
||||
}
|
||||
|
||||
message MapRootLevel {
|
||||
|
@ -53,13 +55,18 @@ message MapTree {
|
|||
required sint32 top = 3; // delta encoded
|
||||
required sint32 bottom = 4; // delta encoded
|
||||
|
||||
optional StringTable stringTable = 5;
|
||||
optional uint64 baseId = 6;
|
||||
// deprecated fields used as base id (should be removed, when all maps be regenerated)
|
||||
// leave for backward compatibility
|
||||
optional StringTable oldstringTable = 5;
|
||||
optional uint64 oldbaseId = 6;
|
||||
|
||||
// encoded as fixed32 length delimited
|
||||
repeated MapTree subtrees = 7;
|
||||
|
||||
repeated MapData leafs = 8;
|
||||
|
||||
optional uint64 baseId = 10;
|
||||
optional StringTable stringTable = 11;
|
||||
}
|
||||
|
||||
|
||||
|
@ -226,7 +233,8 @@ message TransportStopsTree {
|
|||
}
|
||||
|
||||
message OsmAndTransportIndex {
|
||||
|
||||
optional string name = 1;
|
||||
|
||||
// encoded as fixed32 length delimited
|
||||
optional TransportRoutes routes = 3; // routes
|
||||
|
||||
|
@ -235,4 +243,5 @@ message OsmAndTransportIndex {
|
|||
|
||||
|
||||
required StringTable stringTable = 9;
|
||||
|
||||
}
|
|
@ -85,7 +85,7 @@ public class ResourceManager {
|
|||
|
||||
protected final Map<String, AmenityIndexRepository> amenityRepositories = new LinkedHashMap<String, AmenityIndexRepository>();
|
||||
|
||||
protected final Map<String, TransportIndexRepository> transportRepositories = new LinkedHashMap<String, TransportIndexRepository>();
|
||||
protected final List<TransportIndexRepository> transportRepositories = new ArrayList<TransportIndexRepository>();
|
||||
|
||||
protected final MapRenderRepositories renderer;
|
||||
|
||||
|
@ -377,6 +377,9 @@ public class ResourceManager {
|
|||
RegionAddressRepositoryBinary rarb = new RegionAddressRepositoryBinary(index, rName);
|
||||
addressMap.put(rName, rarb);
|
||||
}
|
||||
if(index.hasTransportData()){
|
||||
transportRepositories.add(new TransportIndexRepositoryBinary(index));
|
||||
}
|
||||
}
|
||||
} catch (SQLiteException e) {
|
||||
log.error("Exception reading " + f.getAbsolutePath(), e); //$NON-NLS-1$
|
||||
|
@ -473,7 +476,7 @@ public class ResourceManager {
|
|||
try {
|
||||
boolean initialized = repository.initialize(progress, f);
|
||||
if (initialized) {
|
||||
transportRepositories.put(repository.getName(), repository);
|
||||
transportRepositories.add(repository);
|
||||
} else {
|
||||
warnings.add(MessageFormat.format(Messages.getMessage("version_index_is_not_supported"), f.getName())); //$NON-NLS-1$
|
||||
}
|
||||
|
@ -551,7 +554,7 @@ public class ResourceManager {
|
|||
////////////////////////////////////////////// Working with transport ////////////////////////////////////////////////
|
||||
public List<TransportIndexRepository> searchTransportRepositories(double latitude, double longitude) {
|
||||
List<TransportIndexRepository> repos = new ArrayList<TransportIndexRepository>();
|
||||
for (TransportIndexRepository index : transportRepositories.values()) {
|
||||
for (TransportIndexRepository index : transportRepositories) {
|
||||
if (index.checkContains(latitude,longitude)) {
|
||||
repos.add(index);
|
||||
}
|
||||
|
@ -561,7 +564,7 @@ public class ResourceManager {
|
|||
|
||||
|
||||
public void searchTransportAsync(double topLatitude, double leftLongitude, double bottomLatitude, double rightLongitude, int zoom, List<TransportStop> toFill){
|
||||
for(TransportIndexRepository index : transportRepositories.values()){
|
||||
for(TransportIndexRepository index : transportRepositories){
|
||||
if(index.checkContains(topLatitude, leftLongitude, bottomLatitude, rightLongitude)){
|
||||
if(!index.checkCachedObjects(topLatitude, leftLongitude, bottomLatitude, rightLongitude, zoom, toFill, true)){
|
||||
asyncLoadingTiles.requestToLoadTransport(
|
||||
|
@ -607,7 +610,7 @@ public class ResourceManager {
|
|||
}
|
||||
|
||||
public void closeTransport(){
|
||||
for(TransportIndexRepository r : transportRepositories.values()){
|
||||
for(TransportIndexRepository r : transportRepositories){
|
||||
r.close();
|
||||
}
|
||||
transportRepositories.clear();
|
||||
|
|
|
@ -16,8 +16,7 @@ public interface TransportIndexRepository {
|
|||
|
||||
public boolean checkCachedObjects(double topLatitude, double leftLongitude, double bottomLatitude, double rightLongitude, int zoom, List<TransportStop> toFill, boolean fillFound);
|
||||
|
||||
|
||||
public List<TransportStop> searchTransportStops(double topLatitude, double leftLongitude, double bottomLatitude, double rightLongitude, int limit, List<TransportStop> stops);
|
||||
public boolean acceptTransportStop(TransportStop stop);
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
232
OsmAnd/src/net/osmand/TransportIndexRepositoryBinary.java
Normal file
232
OsmAnd/src/net/osmand/TransportIndexRepositoryBinary.java
Normal file
|
@ -0,0 +1,232 @@
|
|||
package net.osmand;
|
||||
|
||||
import java.io.IOException;
|
||||
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 net.osmand.binary.BinaryMapIndexReader;
|
||||
import net.osmand.binary.BinaryMapIndexReader.SearchRequest;
|
||||
import net.osmand.data.TransportRoute;
|
||||
import net.osmand.data.TransportStop;
|
||||
import net.osmand.osm.LatLon;
|
||||
import net.osmand.osm.MapUtils;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
|
||||
public class TransportIndexRepositoryBinary implements TransportIndexRepository {
|
||||
private static final Log log = LogUtil.getLog(TransportIndexRepositoryBinary.class);
|
||||
private final BinaryMapIndexReader file;
|
||||
|
||||
protected List<TransportStop> cachedObjects = new ArrayList<TransportStop>();
|
||||
protected double cTopLatitude;
|
||||
protected double cBottomLatitude;
|
||||
protected double cLeftLongitude;
|
||||
protected double cRightLongitude;
|
||||
private int cZoom;
|
||||
|
||||
public TransportIndexRepositoryBinary(BinaryMapIndexReader file) {
|
||||
this.file = file;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkContains(double latitude, double longitude) {
|
||||
return file.containTransportData(latitude, longitude);
|
||||
}
|
||||
@Override
|
||||
public boolean checkContains(double topLatitude, double leftLongitude, double bottomLatitude, double rightLongitude) {
|
||||
return file.containTransportData(topLatitude, leftLongitude, bottomLatitude, rightLongitude);
|
||||
}
|
||||
|
||||
public boolean checkCachedObjects(double topLatitude, double leftLongitude, double bottomLatitude, double rightLongitude, int zoom, List<TransportStop> toFill){
|
||||
return checkCachedObjects(topLatitude, leftLongitude, bottomLatitude, rightLongitude, zoom, toFill, false);
|
||||
}
|
||||
|
||||
public synchronized boolean checkCachedObjects(double topLatitude, double leftLongitude, double bottomLatitude, double rightLongitude, int zoom, List<TransportStop> toFill, boolean fillFound){
|
||||
boolean inside = cTopLatitude >= topLatitude && cLeftLongitude <= leftLongitude && cRightLongitude >= rightLongitude
|
||||
&& cBottomLatitude <= bottomLatitude && cZoom == zoom;
|
||||
boolean noNeedToSearch = inside;
|
||||
if((inside || fillFound) && toFill != null){
|
||||
for(TransportStop a : cachedObjects){
|
||||
LatLon location = a.getLocation();
|
||||
if (location.getLatitude() <= topLatitude && location.getLongitude() >= leftLongitude && location.getLongitude() <= rightLongitude
|
||||
&& location.getLatitude() >= bottomLatitude) {
|
||||
toFill.add(a);
|
||||
}
|
||||
}
|
||||
}
|
||||
return noNeedToSearch;
|
||||
}
|
||||
|
||||
public List<TransportStop> searchTransportStops(double topLatitude, double leftLongitude, double bottomLatitude, double rightLongitude,
|
||||
int limit, List<TransportStop> stops) {
|
||||
long now = System.currentTimeMillis();
|
||||
try {
|
||||
file.searchTransportIndex(BinaryMapIndexReader.buildSearchTransportRequest(MapUtils.get31TileNumberX(leftLongitude),
|
||||
MapUtils.get31TileNumberX(rightLongitude), MapUtils.get31TileNumberY(topLatitude),
|
||||
MapUtils.get31TileNumberY(bottomLatitude), limit, stops));
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug(String.format("Search for %s done in %s ms found %s.", //$NON-NLS-1$
|
||||
topLatitude + " " + leftLongitude, System.currentTimeMillis() - now, stops.size())); //$NON-NLS-1$
|
||||
}
|
||||
} catch (IOException e) {
|
||||
log.error("Disk error ", e); //$NON-NLS-1$
|
||||
}
|
||||
return stops;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @param stop
|
||||
* @param format
|
||||
* 0} - ref, {1} - type, {2} - name, {3} - name_en
|
||||
* @return
|
||||
*/
|
||||
public List<String> getRouteDescriptionsForStop(TransportStop stop, String format) {
|
||||
assert acceptTransportStop(stop);
|
||||
long now = System.currentTimeMillis();
|
||||
List<String> res = new ArrayList<String>();
|
||||
MessageFormat f = new MessageFormat(format);
|
||||
|
||||
for(int r : stop.getReferencesToRoutes()) {
|
||||
try {
|
||||
TransportRoute route = file.getTransportRoute(r);
|
||||
res.add(f.format(new String[] { route.getRef(), route.getType(), route.getName(), route.getEnName()}));
|
||||
} catch (IOException e) {
|
||||
log.error("Disk error ", e); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug(String.format("Search for stop %s done in %s ms found %s.", //$NON-NLS-1$
|
||||
stop.getId() + "", System.currentTimeMillis() - now, res.size())); //$NON-NLS-1$
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
public void evaluateCachedTransportStops(double topLatitude, double leftLongitude, double bottomLatitude, double rightLongitude,
|
||||
int zoom, int limit, List<TransportStop> toFill) {
|
||||
cTopLatitude = topLatitude + (topLatitude - bottomLatitude);
|
||||
cBottomLatitude = bottomLatitude - (topLatitude - bottomLatitude);
|
||||
cLeftLongitude = leftLongitude - (rightLongitude - leftLongitude);
|
||||
cRightLongitude = rightLongitude + (rightLongitude - leftLongitude);
|
||||
cZoom = zoom;
|
||||
// first of all put all entities in temp list in order to not freeze other read threads
|
||||
ArrayList<TransportStop> tempList = new ArrayList<TransportStop>();
|
||||
searchTransportStops(cTopLatitude, cLeftLongitude, cBottomLatitude, cRightLongitude, limit, tempList);
|
||||
synchronized (this) {
|
||||
cachedObjects.clear();
|
||||
cachedObjects.addAll(tempList);
|
||||
}
|
||||
|
||||
checkCachedObjects(topLatitude, leftLongitude, bottomLatitude, rightLongitude, cZoom, toFill);
|
||||
}
|
||||
|
||||
|
||||
public List<RouteInfoLocation> searchTransportRouteStops(double latitude, double longitude, LatLon locationToGo, int zoom) {
|
||||
long now = System.currentTimeMillis();
|
||||
final LatLon loc = new LatLon(latitude, longitude);
|
||||
double tileNumberX = MapUtils.getTileNumberX(zoom, longitude);
|
||||
double tileNumberY = MapUtils.getTileNumberY(zoom, latitude);
|
||||
double topLatitude = MapUtils.getLatitudeFromTile(zoom, tileNumberY - 0.5);
|
||||
double bottomLatitude = MapUtils.getLatitudeFromTile(zoom, tileNumberY + 0.5);
|
||||
double leftLongitude = MapUtils.getLongitudeFromTile(zoom, tileNumberX - 0.5);
|
||||
double rightLongitude = MapUtils.getLongitudeFromTile(zoom, tileNumberX + 0.5);
|
||||
SearchRequest<TransportStop> req = BinaryMapIndexReader.buildSearchTransportRequest(MapUtils.get31TileNumberX(leftLongitude),
|
||||
MapUtils.get31TileNumberX(rightLongitude), MapUtils.get31TileNumberY(topLatitude),
|
||||
MapUtils.get31TileNumberY(bottomLatitude), -1, null);
|
||||
|
||||
List<RouteInfoLocation> listRoutes = new ArrayList<RouteInfoLocation>();
|
||||
try {
|
||||
List<TransportStop> stops = file.searchTransportIndex(req);
|
||||
|
||||
Map<Long, RouteInfoLocation> registeredRoutes = new LinkedHashMap<Long, RouteInfoLocation>();
|
||||
for (TransportStop s : stops) {
|
||||
for (int ref : s.getReferencesToRoutes()) {
|
||||
TransportRoute route = file.getTransportRoute(ref);
|
||||
for (int i = 0; i < 2; i++) {
|
||||
boolean direction = i == 0;
|
||||
List<TransportStop> stps = direction ? route.getForwardStops() : route.getBackwardStops();
|
||||
// load only part
|
||||
while (!stps.isEmpty() && (stps.get(0).getId().longValue() != s.getId().longValue())) {
|
||||
stps.remove(0);
|
||||
}
|
||||
if (!stps.isEmpty()) {
|
||||
long idToPut = route.getId() << 1 + (direction ? 1 : 0);
|
||||
if (registeredRoutes.containsKey(idToPut)) {
|
||||
TransportStop st = registeredRoutes.get(idToPut).getStart();
|
||||
if (MapUtils.getDistance(loc, st.getLocation()) < MapUtils.getDistance(loc, s.getLocation())) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
RouteInfoLocation r = new RouteInfoLocation();
|
||||
r.setRoute(route);
|
||||
r.setStart(stps.get(0));
|
||||
r.setDirection(direction);
|
||||
if (locationToGo != null) {
|
||||
int distToLoc = Integer.MAX_VALUE;
|
||||
for (TransportStop st : stps) {
|
||||
double ndist = MapUtils.getDistance(locationToGo, st.getLocation());
|
||||
if (ndist < distToLoc) {
|
||||
distToLoc = (int) ndist;
|
||||
r.setStop(st);
|
||||
r.setDistToLocation(distToLoc);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
registeredRoutes.put(idToPut, r);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug(String.format("Search for routes done in %s ms found %s.", //$NON-NLS-1$
|
||||
System.currentTimeMillis() - now, registeredRoutes.size()));
|
||||
}
|
||||
|
||||
listRoutes = new ArrayList<RouteInfoLocation>(registeredRoutes.values());
|
||||
if (locationToGo != null) {
|
||||
Collections.sort(listRoutes, new Comparator<RouteInfoLocation>() {
|
||||
@Override
|
||||
public int compare(RouteInfoLocation object1, RouteInfoLocation object2) {
|
||||
int x = (int) (MapUtils.getDistance(loc, object1.getStart().getLocation()) + object1.getDistToLocation());
|
||||
int y = (int) (MapUtils.getDistance(loc, object2.getStart().getLocation()) + object2.getDistToLocation());
|
||||
return x - y;
|
||||
}
|
||||
|
||||
});
|
||||
} else {
|
||||
Collections.sort(listRoutes, new Comparator<RouteInfoLocation>() {
|
||||
@Override
|
||||
public int compare(RouteInfoLocation object1, RouteInfoLocation object2) {
|
||||
return Double.compare(MapUtils.getDistance(loc, object1.getStart().getLocation()), MapUtils.getDistance(loc, object2
|
||||
.getStart().getLocation()));
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
} catch (IOException e) {
|
||||
log.error("Disk error", e); //$NON-NLS-1$
|
||||
}
|
||||
return listRoutes;
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean acceptTransportStop(TransportStop stop) {
|
||||
return file.transportStopBelongsTo(stop);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
}
|
||||
|
||||
}
|
|
@ -214,6 +214,11 @@ public class TransportIndexRepositoryOdb extends BaseLocationIndexRepository<Tra
|
|||
return list;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean acceptTransportStop(TransportStop stop) {
|
||||
return checkContains(stop.getLocation().getLatitude(), stop.getLocation().getLongitude());
|
||||
}
|
||||
|
||||
protected List<RouteInfoLocation> preloadRouteStopsAndCalculateDistance(final LatLon loc, LatLon locationToGo,
|
||||
Map<Long, RouteInfoLocation> registeredRoutes) {
|
||||
|
|
|
@ -83,7 +83,15 @@ public class TransportStopsLayer implements OsmandMapLayer, ContextMenuLayer.ICo
|
|||
text.append(view.getContext().getString(R.string.transport_Stop)).append(" : ").append(n.getName(OsmandSettings.usingEnglishNames(view.getSettings()))); //$NON-NLS-1$
|
||||
text.append("\n").append(view.getContext().getString(R.string.transport_Routes)).append(" : "); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
List<TransportIndexRepository> reps = view.getApplication().getResourceManager().searchTransportRepositories(n.getLocation().getLatitude(), n.getLocation().getLongitude());
|
||||
if(!reps.isEmpty()){
|
||||
|
||||
TransportIndexRepository tir = null;
|
||||
for(TransportIndexRepository t : reps){
|
||||
if(t.acceptTransportStop(n)){
|
||||
tir = t;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(tir != null){
|
||||
List<String> l;
|
||||
if(!useName){
|
||||
l = reps.get(0).getRouteDescriptionsForStop(n, "{1} {0}"); //$NON-NLS-1$
|
||||
|
|
Loading…
Reference in a new issue