Introduce id and restrictions

This commit is contained in:
Victor Shcherb 2012-06-07 01:10:19 +02:00
parent c5f2156e4a
commit 2c8117f738
6 changed files with 205 additions and 171 deletions

View file

@ -18222,7 +18222,7 @@ public final class OsmandOdb {
return net.osmand.binary.OsmandOdb.internal_static_IdTable_fieldAccessorTable;
}
// repeated uint64 routeId = 1;
// repeated sint64 routeId = 1;
public static final int ROUTEID_FIELD_NUMBER = 1;
private java.util.List<java.lang.Long> routeId_ =
java.util.Collections.emptyList();
@ -18234,7 +18234,7 @@ public final class OsmandOdb {
return routeId_.get(index);
}
// repeated uint64 pointId = 2;
// repeated sint64 pointId = 2;
public static final int POINTID_FIELD_NUMBER = 2;
private java.util.List<java.lang.Long> pointId_ =
java.util.Collections.emptyList();
@ -18258,10 +18258,10 @@ public final class OsmandOdb {
throws java.io.IOException {
getSerializedSize();
for (long element : getRouteIdList()) {
output.writeUInt64(1, element);
output.writeSInt64(1, element);
}
for (long element : getPointIdList()) {
output.writeUInt64(2, element);
output.writeSInt64(2, element);
}
getUnknownFields().writeTo(output);
}
@ -18277,7 +18277,7 @@ public final class OsmandOdb {
int dataSize = 0;
for (long element : getRouteIdList()) {
dataSize += com.google.protobuf.CodedOutputStream
.computeUInt64SizeNoTag(element);
.computeSInt64SizeNoTag(element);
}
size += dataSize;
size += 1 * getRouteIdList().size();
@ -18286,7 +18286,7 @@ public final class OsmandOdb {
int dataSize = 0;
for (long element : getPointIdList()) {
dataSize += com.google.protobuf.CodedOutputStream
.computeUInt64SizeNoTag(element);
.computeSInt64SizeNoTag(element);
}
size += dataSize;
size += 1 * getPointIdList().size();
@ -18507,27 +18507,27 @@ public final class OsmandOdb {
break;
}
case 8: {
addRouteId(input.readUInt64());
addRouteId(input.readSInt64());
break;
}
case 10: {
int length = input.readRawVarint32();
int limit = input.pushLimit(length);
while (input.getBytesUntilLimit() > 0) {
addRouteId(input.readUInt64());
addRouteId(input.readSInt64());
}
input.popLimit(limit);
break;
}
case 16: {
addPointId(input.readUInt64());
addPointId(input.readSInt64());
break;
}
case 18: {
int length = input.readRawVarint32();
int limit = input.pushLimit(length);
while (input.getBytesUntilLimit() > 0) {
addPointId(input.readUInt64());
addPointId(input.readSInt64());
}
input.popLimit(limit);
break;
@ -18537,7 +18537,7 @@ public final class OsmandOdb {
}
// repeated uint64 routeId = 1;
// repeated sint64 routeId = 1;
public java.util.List<java.lang.Long> getRouteIdList() {
return java.util.Collections.unmodifiableList(result.routeId_);
}
@ -18571,7 +18571,7 @@ public final class OsmandOdb {
return this;
}
// repeated uint64 pointId = 2;
// repeated sint64 pointId = 2;
public java.util.List<java.lang.Long> getPointIdList() {
return java.util.Collections.unmodifiableList(result.pointId_);
}
@ -20902,6 +20902,13 @@ public final class OsmandOdb {
public boolean hasIdTable() { return hasIdTable; }
public net.osmand.binary.OsmandOdb.IdTable getIdTable() { return idTable_; }
// optional .StringTable stringTable = 8;
public static final int STRINGTABLE_FIELD_NUMBER = 8;
private boolean hasStringTable;
private net.osmand.binary.OsmandOdb.StringTable stringTable_;
public boolean hasStringTable() { return hasStringTable; }
public net.osmand.binary.OsmandOdb.StringTable getStringTable() { return stringTable_; }
// repeated .RouteData dataObjects = 6;
public static final int DATAOBJECTS_FIELD_NUMBER = 6;
private java.util.List<net.osmand.binary.OsmandOdb.RouteData> dataObjects_ =
@ -20926,13 +20933,6 @@ public final class OsmandOdb {
return restrictions_.get(index);
}
// optional .StringTable stringTable = 8;
public static final int STRINGTABLE_FIELD_NUMBER = 8;
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() {
idTable_ = net.osmand.binary.OsmandOdb.IdTable.getDefaultInstance();
stringTable_ = net.osmand.binary.OsmandOdb.StringTable.getDefaultInstance();
@ -21170,6 +21170,9 @@ public final class OsmandOdb {
if (other.hasIdTable()) {
mergeIdTable(other.getIdTable());
}
if (other.hasStringTable()) {
mergeStringTable(other.getStringTable());
}
if (!other.dataObjects_.isEmpty()) {
if (result.dataObjects_.isEmpty()) {
result.dataObjects_ = new java.util.ArrayList<net.osmand.binary.OsmandOdb.RouteData>();
@ -21182,9 +21185,6 @@ public final class OsmandOdb {
}
result.restrictions_.addAll(other.restrictions_);
}
if (other.hasStringTable()) {
mergeStringTable(other.getStringTable());
}
this.mergeUnknownFields(other.getUnknownFields());
return this;
}
@ -21283,6 +21283,43 @@ public final class OsmandOdb {
return this;
}
// optional .StringTable stringTable = 8;
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;
}
// repeated .RouteData dataObjects = 6;
public java.util.List<net.osmand.binary.OsmandOdb.RouteData> getDataObjectsList() {
return java.util.Collections.unmodifiableList(result.dataObjects_);
@ -21385,43 +21422,6 @@ public final class OsmandOdb {
return this;
}
// optional .StringTable stringTable = 8;
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:OsmAndRoutingIndex.RouteDataBlock)
}
@ -22311,8 +22311,8 @@ 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(\004\022\017\n\007po" +
"intId\030\002 \003(\004\"F\n\017RestrictionData\022\014\n\004type\030\001" +
"\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" +
@ -22329,9 +22329,9 @@ public final class OsmandOdb {
"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\037\n\013dataObjects\030\006 \003(\0132\n.RouteData" +
"\022&\n\014restrictions\030\007 \003(\0132\020.RestrictionData",
"\022!\n\013stringTable\030\010 \001(\0132\014.StringTableB\023\n\021n" +
"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"
};
com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner =
@ -22681,7 +22681,7 @@ public final class OsmandOdb {
internal_static_OsmAndRoutingIndex_RouteDataBlock_fieldAccessorTable = new
com.google.protobuf.GeneratedMessage.FieldAccessorTable(
internal_static_OsmAndRoutingIndex_RouteDataBlock_descriptor,
new java.lang.String[] { "IdTable", "DataObjects", "Restrictions", "StringTable", },
new java.lang.String[] { "IdTable", "StringTable", "DataObjects", "Restrictions", },
net.osmand.binary.OsmandOdb.OsmAndRoutingIndex.RouteDataBlock.class,
net.osmand.binary.OsmandOdb.OsmAndRoutingIndex.RouteDataBlock.Builder.class);
return null;

View file

@ -208,9 +208,11 @@ public class BinaryMapIndexWriter {
int len = writeInt32Size();
log.info("- ROUTE TYPE SIZE SIZE " + BinaryMapIndexWriter.ROUTE_TYPES_SIZE ); //$NON-NLS-1$
log.info("- ROUTE COORDINATES SIZE " + BinaryMapIndexWriter.ROUTE_COORDINATES_SIZE + " COUNT " + BinaryMapIndexWriter.ROUTE_COORDINATES_COUNT); //$NON-NLS-1$
log.info("- ROUTE POINTS SIZE " + BinaryMapIndexWriter.ROUTE_POINTS_SIZE);
log.info("- ROUTE ID SIZE " + BinaryMapIndexWriter.ROUTE_ID_SIZE); //$NON-NLS-1$
log.info("-- ROUTE_DATA " + BinaryMapIndexWriter.ROUTE_DATA_SIZE); //$NON-NLS-1$
ROUTE_TYPES_SIZE = ROUTE_DATA_SIZE = ROUTE_ID_SIZE = ROUTE_COORDINATES_COUNT = ROUTE_COORDINATES_SIZE = 0;
ROUTE_TYPES_SIZE = ROUTE_DATA_SIZE = ROUTE_POINTS_SIZE = ROUTE_ID_SIZE =
ROUTE_COORDINATES_COUNT = ROUTE_COORDINATES_SIZE = 0;
log.info("ROUTE INDEX SIZE : " + len);
}
@ -396,6 +398,7 @@ public class BinaryMapIndexWriter {
public static int ROUTE_TYPES_SIZE = 0;
public static int ROUTE_COORDINATES_SIZE = 0;
public static int ROUTE_COORDINATES_COUNT = 0;
public static int ROUTE_POINTS_SIZE = 0;
public static int ROUTE_DATA_SIZE = 0;
public MapDataBlock.Builder createWriteMapDataBlock(long baseid) throws IOException {
@ -408,17 +411,15 @@ public class BinaryMapIndexWriter {
throws IOException {
checkPeekState(ROUTE_INDEX_INIT);
StringTable.Builder bs = OsmandOdb.StringTable.newBuilder();
if (stringTable != null) {
for (String s : stringTable.keySet()) {
bs.addS(s);
}
if (stringTable != null && stringTable.size() > 0) {
StringTable.Builder bs = OsmandOdb.StringTable.newBuilder();
StringTable st = bs.build();
builder.setStringTable(st);
int size = st.getSerializedSize();
STRING_TABLE_SIZE += CodedOutputStream.computeTagSize(OsmandOdb.MapDataBlock.STRINGTABLE_FIELD_NUMBER)
+ CodedOutputStream.computeRawVarint32Size(size) + size;
}
StringTable st = bs.build();
builder.setStringTable(st);
int size = st.getSerializedSize();
STRING_TABLE_SIZE += CodedOutputStream.computeTagSize(OsmandOdb.MapDataBlock.STRINGTABLE_FIELD_NUMBER)
+ CodedOutputStream.computeRawVarint32Size(size) + size;
codedOutStream.writeTag(OsmAndMapIndex.MapRootLevel.BLOCKS_FIELD_NUMBER, FieldType.MESSAGE.getWireType());
@ -451,7 +452,7 @@ public class BinaryMapIndexWriter {
public RouteData writeRouteData(int diffId, int pleft, int ptop, int[] types, RoutePointToWrite[] points,
Map<MapRouteType, String> names, Map<String, Integer> stringTable, RouteDataBlock.Builder dataBlock,
boolean allowCoordinateSimplification)
boolean allowCoordinateSimplification, boolean writePointId)
throws IOException {
RouteData.Builder builder = RouteData.newBuilder();
builder.setRouteId(diffId);
@ -468,8 +469,9 @@ public class BinaryMapIndexWriter {
for(int k=0; k<points.length; k++) {
ROUTE_COORDINATES_COUNT++;
RoutePoint.Builder point = RoutePoint.newBuilder();
// not implemented correctly
// point.setPointId(points[j].id);
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;
@ -487,22 +489,27 @@ public class BinaryMapIndexWriter {
point.setTypes(ByteString.copyFrom(mapDataBuf.toArray()));
ROUTE_TYPES_SIZE += CodedOutputStream.computeTagSize(RoutePoint.TYPES_FIELD_NUMBER)
+ CodedOutputStream.computeRawVarint32Size(mapDataBuf.size()) + mapDataBuf.size();
builder.addPoints(point.build());
RoutePoint p = point.build();
ROUTE_POINTS_SIZE += p.getSerializedSize() + CodedOutputStream.computeTagSize(RouteData.POINTS_FIELD_NUMBER)
+CodedOutputStream.computeRawVarint32Size(p.getSerializedSize());
builder.addPoints(p);
}
mapDataBuf.clear();
if (names != null) {
for (Entry<MapRouteType, String> s : names.entrySet()) {
writeRawVarint32(mapDataBuf, s.getKey().getTargetId());
Integer ls = stringTable.get(s.getValue());
if (ls == null) {
ls = stringTable.size();
stringTable.put(s.getValue(), ls);
if (names.size() > 0) {
mapDataBuf.clear();
if (names != null) {
for (Entry<MapRouteType, String> s : names.entrySet()) {
writeRawVarint32(mapDataBuf, s.getKey().getTargetId());
Integer ls = stringTable.get(s.getValue());
if (ls == null) {
ls = stringTable.size();
stringTable.put(s.getValue(), ls);
}
writeRawVarint32(mapDataBuf, ls);
}
writeRawVarint32(mapDataBuf, ls);
}
STRING_TABLE_SIZE += mapDataBuf.size();
builder.setStringNames(ByteString.copyFrom(mapDataBuf.toArray()));
}
STRING_TABLE_SIZE += mapDataBuf.size();
builder.setStringNames(ByteString.copyFrom(mapDataBuf.toArray()));
return builder.build();
}
@ -638,7 +645,7 @@ public class BinaryMapIndexWriter {
public static class RoutePointToWrite {
public TIntArrayList types = new TIntArrayList();
public long id;
public int id;
public int x;
public int y;
}

View file

@ -329,15 +329,13 @@ public class IndexCreator {
private void createDatabaseIndexesStructure() throws SQLException, IOException {
// 2.1 create temporary sqlite database to put temporary results to it
if (indexMap || indexAddress || indexTransport || indexPOI) {
mapFile = new File(workingDir, getMapFileName());
// to save space
mapFile.getParentFile().mkdirs();
File tempDBMapFile = new File(workingDir, getTempMapDBFileName());
mapDBDialect.removeDatabase(tempDBMapFile);
mapConnection = (Connection) getDatabaseConnection(tempDBMapFile.getAbsolutePath(), mapDBDialect);
mapConnection.setAutoCommit(false);
}
mapFile = new File(workingDir, getMapFileName());
// to save space
mapFile.getParentFile().mkdirs();
File tempDBMapFile = new File(workingDir, getTempMapDBFileName());
mapDBDialect.removeDatabase(tempDBMapFile);
mapConnection = (Connection) getDatabaseConnection(tempDBMapFile.getAbsolutePath(), mapDBDialect);
mapConnection.setAutoCommit(false);
// 2.2 create rtree map
if (indexMap) {
@ -572,7 +570,6 @@ public class IndexCreator {
}
// 3.3 MAIN iterate over all entities
if (indexPOI || indexAddress || indexMap) {
progress.setGeneralProgress("[50 / 100]");
progress.startTask(Messages.getString("IndexCreator.PROCESS_OSM_NODES"), accessor.getAllNodes());
accessor.iterateOverEntities(progress, EntityType.NODE, new OsmDbVisitor() {
@ -589,7 +586,6 @@ public class IndexCreator {
iterateMainEntity(e, ctx);
}
});
}
progress.setGeneralProgress("[85 / 100]");
progress.startTask(Messages.getString("IndexCreator.PROCESS_OSM_REL"), accessor.getAllRelations());
accessor.iterateOverEntities(progress, EntityType.RELATION, new OsmDbVisitor() {
@ -631,7 +627,7 @@ public class IndexCreator {
}
// 5. Writing binary file
if (indexMap || indexAddress || indexTransport || indexPOI) {
if (indexMap || indexAddress || indexTransport || indexPOI || indexRouting) {
if (mapFile.exists()) {
mapFile.delete();
}
@ -737,9 +733,9 @@ public class IndexCreator {
public static void main(String[] args) throws IOException, SAXException, SQLException, InterruptedException {
long time = System.currentTimeMillis();
IndexCreator creator = new IndexCreator(new File("/home/victor/projects/OsmAnd/data/osm-gen/")); //$NON-NLS-1$
creator.setIndexMap(true);
creator.setIndexAddress(true);
creator.setIndexPOI(true);
creator.setIndexMap(false);
creator.setIndexAddress(false);
creator.setIndexPOI(false);
creator.setIndexTransport(false);
creator.setIndexRouting(true);

View file

@ -22,6 +22,7 @@ import java.util.Map;
import net.osmand.Algoritms;
import net.osmand.IProgress;
import net.osmand.binary.OsmandOdb.IdTable;
import net.osmand.binary.OsmandOdb.MapData;
import net.osmand.binary.OsmandOdb.MapDataBlock;
import net.osmand.binary.OsmandOdb.OsmAndRoutingIndex.RouteDataBlock;
@ -59,9 +60,10 @@ public class IndexRouteCreator extends AbstractIndexPartCreator {
private Connection mapConnection;
private final Log logMapDataWarn;
private final static boolean WRITE_POINT_ID = false;
private RTree routeTree = null;
private MapRoutingTypes routeTypes;
private TLongObjectHashMap<TLongArrayList> highwayRestrictions = new TLongObjectHashMap<TLongArrayList>();
// local purpose to speed up processing cache allocation
@ -332,6 +334,15 @@ public class IndexRouteCreator extends AbstractIndexPartCreator {
}
private int registerId(TLongArrayList ids, long id) {
for (int i = 0; i < ids.size(); i++) {
if (ids.getQuick(i) == id) {
return i;
}
}
ids.add(id);
return ids.size() - 1;
}
public void writeBinaryMapBlock(rtree.Node parent, Rect parentBounds, RTree r, BinaryMapIndexWriter writer, PreparedStatement selectData,
TLongObjectHashMap<BinaryFileReference> bounds, Map<String, Integer> tempStringTable, Map<MapRouteType, String> tempNames)
@ -340,6 +351,8 @@ public class IndexRouteCreator extends AbstractIndexPartCreator {
RouteDataBlock.Builder dataBlock = null;
BinaryFileReference ref = bounds.get(parent.getNodeIndex());
TLongArrayList wayMapIds = new TLongArrayList();
TLongArrayList pointMapIds = new TLongArrayList();
for (int i = 0; i < parent.getTotalElements(); i++) {
if (e[i].getElementType() == rtree.Node.LEAF_NODE) {
long id = ((LeafElement) e[i]).getPtr();
@ -349,11 +362,13 @@ public class IndexRouteCreator extends AbstractIndexPartCreator {
ResultSet rs = selectData.executeQuery();
if (rs.next()) {
long cid = id;
if (dataBlock == null) {
dataBlock = RouteDataBlock.newBuilder();
tempStringTable.clear();
wayMapIds.clear();
pointMapIds.clear();
}
int cid = registerId(wayMapIds, id);
tempNames.clear();
decodeNames(rs.getString(5), tempNames);
byte[] types = rs.getBytes(1);
@ -367,13 +382,13 @@ public class IndexRouteCreator extends AbstractIndexPartCreator {
byte[] pointCoordinates = rs.getBytes(4);
int typeInd = 0;
RoutePointToWrite[] points = new RoutePointToWrite[pointCoordinates.length / 8];
TLongArrayList restrictions = highwayRestrictions.get(cid);
TLongArrayList restrictions = highwayRestrictions.get(id);
if(restrictions != null){
Builder restriction = RestrictionData.newBuilder();
// TODO ids
for(int li = 0; li<restrictions.size(); li++){
restriction.setFrom((int) cid);
restriction.setTo((int) (restrictions.get(li) >> 3));
Builder restriction = RestrictionData.newBuilder();
restriction.setFrom(cid);
int toId = registerId(wayMapIds, restrictions.get(li) >> 3);
restriction.setTo(toId);
restriction.setType((int) (restrictions.get(li) & 0x7));
dataBlock.addRestrictions(restriction.build());
}
@ -382,7 +397,9 @@ public class IndexRouteCreator extends AbstractIndexPartCreator {
points[j] = new RoutePointToWrite();
points[j].x = Algoritms.parseIntFromBytes(pointCoordinates, j * 8);
points[j].y = Algoritms.parseIntFromBytes(pointCoordinates, j * 8 + 4);
points[j].id = Algoritms.parseLongFromBytes(pointIds, j * 8);
if(WRITE_POINT_ID) {
points[j].id = registerId(pointMapIds, Algoritms.parseLongFromBytes(pointIds, j * 8));
}
int type = 0;
do {
type = Algoritms.parseSmallIntFromBytes(pointTypes, typeInd);
@ -393,8 +410,8 @@ public class IndexRouteCreator extends AbstractIndexPartCreator {
} while (type != 0);
}
RouteData routeData = writer.writeRouteData((int) cid, parentBounds.getMinX(), parentBounds.getMinY(), typeUse, points,
names, tempStringTable, dataBlock, true);
RouteData routeData = writer.writeRouteData(cid, parentBounds.getMinX(), parentBounds.getMinY(), typeUse, points,
names, tempStringTable, dataBlock, true, WRITE_POINT_ID);
if (routeData != null) {
dataBlock.addDataObjects(routeData);
}
@ -404,6 +421,20 @@ public class IndexRouteCreator extends AbstractIndexPartCreator {
}
}
if (dataBlock != null) {
IdTable.Builder idTable = IdTable.newBuilder();
long prev = 0;
for (int i = 0; i < wayMapIds.size(); i++) {
idTable.addRouteId(wayMapIds.getQuick(i) - prev);
prev = wayMapIds.getQuick(i);
}
if (WRITE_POINT_ID) {
prev = 0;
for (int i = 0; i < pointMapIds.size(); i++) {
idTable.addPointId(pointMapIds.getQuick(i) - prev);
prev = pointMapIds.getQuick(i);
}
}
dataBlock.setIdTable(idTable.build());
writer.writeRouteDataBlock(dataBlock, tempStringTable, ref);
}
for (int i = 0; i < parent.getTotalElements(); i++) {

View file

@ -459,13 +459,13 @@ message OsmAndPoiBoxDataAtom {
/**
* Id table 1-based. Map of sequential ids to real ids
* [1,2,3....n] -> [a1, ... an]
* a1,.. an - sorted set of longs
* a1,.. an - (ideally sorted) set of longs
*/
message IdTable {
// diff between 2 ids
repeated uint64 routeId = 1;
repeated sint64 routeId = 1;
// diff between 2 ids
repeated uint64 pointId = 2;
repeated sint64 pointId = 2;
}
message RestrictionData {

View file

@ -4682,28 +4682,28 @@ class IdTable : public ::google::protobuf::Message {
// accessors -------------------------------------------------------
// repeated uint64 routeId = 1;
// repeated sint64 routeId = 1;
inline int routeid_size() const;
inline void clear_routeid();
static const int kRouteIdFieldNumber = 1;
inline ::google::protobuf::uint64 routeid(int index) const;
inline void set_routeid(int index, ::google::protobuf::uint64 value);
inline void add_routeid(::google::protobuf::uint64 value);
inline const ::google::protobuf::RepeatedField< ::google::protobuf::uint64 >&
inline ::google::protobuf::int64 routeid(int index) const;
inline void set_routeid(int index, ::google::protobuf::int64 value);
inline void add_routeid(::google::protobuf::int64 value);
inline const ::google::protobuf::RepeatedField< ::google::protobuf::int64 >&
routeid() const;
inline ::google::protobuf::RepeatedField< ::google::protobuf::uint64 >*
inline ::google::protobuf::RepeatedField< ::google::protobuf::int64 >*
mutable_routeid();
// repeated uint64 pointId = 2;
// repeated sint64 pointId = 2;
inline int pointid_size() const;
inline void clear_pointid();
static const int kPointIdFieldNumber = 2;
inline ::google::protobuf::uint64 pointid(int index) const;
inline void set_pointid(int index, ::google::protobuf::uint64 value);
inline void add_pointid(::google::protobuf::uint64 value);
inline const ::google::protobuf::RepeatedField< ::google::protobuf::uint64 >&
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::uint64 >*
inline ::google::protobuf::RepeatedField< ::google::protobuf::int64 >*
mutable_pointid();
// @@protoc_insertion_point(class_scope:IdTable)
@ -4711,8 +4711,8 @@ class IdTable : public ::google::protobuf::Message {
::google::protobuf::UnknownFieldSet _unknown_fields_;
mutable int _cached_size_;
::google::protobuf::RepeatedField< ::google::protobuf::uint64 > routeid_;
::google::protobuf::RepeatedField< ::google::protobuf::uint64 > pointid_;
::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();
@ -5395,6 +5395,13 @@ class OsmAndRoutingIndex_RouteDataBlock : public ::google::protobuf::Message {
inline const ::IdTable& idtable() const;
inline ::IdTable* mutable_idtable();
// optional .StringTable stringTable = 8;
inline bool has_stringtable() const;
inline void clear_stringtable();
static const int kStringTableFieldNumber = 8;
inline const ::StringTable& stringtable() const;
inline ::StringTable* mutable_stringtable();
// repeated .RouteData dataObjects = 6;
inline int dataobjects_size() const;
inline void clear_dataobjects();
@ -5419,22 +5426,15 @@ class OsmAndRoutingIndex_RouteDataBlock : public ::google::protobuf::Message {
inline ::google::protobuf::RepeatedPtrField< ::RestrictionData >*
mutable_restrictions();
// optional .StringTable stringTable = 8;
inline bool has_stringtable() const;
inline void clear_stringtable();
static const int kStringTableFieldNumber = 8;
inline const ::StringTable& stringtable() const;
inline ::StringTable* mutable_stringtable();
// @@protoc_insertion_point(class_scope:OsmAndRoutingIndex.RouteDataBlock)
private:
::google::protobuf::UnknownFieldSet _unknown_fields_;
mutable int _cached_size_;
::IdTable* idtable_;
::StringTable* stringtable_;
::google::protobuf::RepeatedPtrField< ::RouteData > dataobjects_;
::google::protobuf::RepeatedPtrField< ::RestrictionData > restrictions_;
::StringTable* stringtable_;
friend void protobuf_AddDesc_src_2fosmand_5fodb_2eproto();
friend void protobuf_AssignDesc_src_2fosmand_5fodb_2eproto();
friend void protobuf_ShutdownFile_src_2fosmand_5fodb_2eproto();
@ -9794,52 +9794,52 @@ inline ::std::string* OsmAndPoiBoxDataAtom::mutable_note() {
// IdTable
// repeated uint64 routeId = 1;
// repeated sint64 routeId = 1;
inline int IdTable::routeid_size() const {
return routeid_.size();
}
inline void IdTable::clear_routeid() {
routeid_.Clear();
}
inline ::google::protobuf::uint64 IdTable::routeid(int index) const {
inline ::google::protobuf::int64 IdTable::routeid(int index) const {
return routeid_.Get(index);
}
inline void IdTable::set_routeid(int index, ::google::protobuf::uint64 value) {
inline void IdTable::set_routeid(int index, ::google::protobuf::int64 value) {
routeid_.Set(index, value);
}
inline void IdTable::add_routeid(::google::protobuf::uint64 value) {
inline void IdTable::add_routeid(::google::protobuf::int64 value) {
routeid_.Add(value);
}
inline const ::google::protobuf::RepeatedField< ::google::protobuf::uint64 >&
inline const ::google::protobuf::RepeatedField< ::google::protobuf::int64 >&
IdTable::routeid() const {
return routeid_;
}
inline ::google::protobuf::RepeatedField< ::google::protobuf::uint64 >*
inline ::google::protobuf::RepeatedField< ::google::protobuf::int64 >*
IdTable::mutable_routeid() {
return &routeid_;
}
// repeated uint64 pointId = 2;
// repeated sint64 pointId = 2;
inline int IdTable::pointid_size() const {
return pointid_.size();
}
inline void IdTable::clear_pointid() {
pointid_.Clear();
}
inline ::google::protobuf::uint64 IdTable::pointid(int index) const {
inline ::google::protobuf::int64 IdTable::pointid(int index) const {
return pointid_.Get(index);
}
inline void IdTable::set_pointid(int index, ::google::protobuf::uint64 value) {
inline void IdTable::set_pointid(int index, ::google::protobuf::int64 value) {
pointid_.Set(index, value);
}
inline void IdTable::add_pointid(::google::protobuf::uint64 value) {
inline void IdTable::add_pointid(::google::protobuf::int64 value) {
pointid_.Add(value);
}
inline const ::google::protobuf::RepeatedField< ::google::protobuf::uint64 >&
inline const ::google::protobuf::RepeatedField< ::google::protobuf::int64 >&
IdTable::pointid() const {
return pointid_;
}
inline ::google::protobuf::RepeatedField< ::google::protobuf::uint64 >*
inline ::google::protobuf::RepeatedField< ::google::protobuf::int64 >*
IdTable::mutable_pointid() {
return &pointid_;
}
@ -10379,6 +10379,23 @@ inline ::IdTable* OsmAndRoutingIndex_RouteDataBlock::mutable_idtable() {
return idtable_;
}
// optional .StringTable stringTable = 8;
inline bool OsmAndRoutingIndex_RouteDataBlock::has_stringtable() const {
return _has_bit(1);
}
inline void OsmAndRoutingIndex_RouteDataBlock::clear_stringtable() {
if (stringtable_ != NULL) stringtable_->::StringTable::Clear();
_clear_bit(1);
}
inline const ::StringTable& OsmAndRoutingIndex_RouteDataBlock::stringtable() const {
return stringtable_ != NULL ? *stringtable_ : *default_instance_->stringtable_;
}
inline ::StringTable* OsmAndRoutingIndex_RouteDataBlock::mutable_stringtable() {
_set_bit(1);
if (stringtable_ == NULL) stringtable_ = new ::StringTable;
return stringtable_;
}
// repeated .RouteData dataObjects = 6;
inline int OsmAndRoutingIndex_RouteDataBlock::dataobjects_size() const {
return dataobjects_.size();
@ -10429,23 +10446,6 @@ OsmAndRoutingIndex_RouteDataBlock::mutable_restrictions() {
return &restrictions_;
}
// optional .StringTable stringTable = 8;
inline bool OsmAndRoutingIndex_RouteDataBlock::has_stringtable() const {
return _has_bit(3);
}
inline void OsmAndRoutingIndex_RouteDataBlock::clear_stringtable() {
if (stringtable_ != NULL) stringtable_->::StringTable::Clear();
_clear_bit(3);
}
inline const ::StringTable& OsmAndRoutingIndex_RouteDataBlock::stringtable() const {
return stringtable_ != NULL ? *stringtable_ : *default_instance_->stringtable_;
}
inline ::StringTable* OsmAndRoutingIndex_RouteDataBlock::mutable_stringtable() {
_set_bit(3);
if (stringtable_ == NULL) stringtable_ = new ::StringTable;
return stringtable_;
}
// -------------------------------------------------------------------
// OsmAndRoutingIndex