Intermediate commit
This commit is contained in:
parent
ce564e82cf
commit
988604bf0c
3 changed files with 2244 additions and 34 deletions
File diff suppressed because it is too large
Load diff
|
@ -31,6 +31,9 @@ import net.osmand.binary.OsmandOdb.CityIndex;
|
|||
import net.osmand.binary.OsmandOdb.MapData;
|
||||
import net.osmand.binary.OsmandOdb.MapDataBlock;
|
||||
import net.osmand.binary.OsmandOdb.OsmAndAddressIndex;
|
||||
import net.osmand.binary.OsmandOdb.OsmAndRoutingIndex.RouteBorderBox;
|
||||
import net.osmand.binary.OsmandOdb.OsmAndRoutingIndex.RouteBorderPoint;
|
||||
import net.osmand.binary.OsmandOdb.OsmAndRoutingIndex.RouteBorderPointsBlock;
|
||||
import net.osmand.binary.OsmandOdb.RouteData;
|
||||
import net.osmand.binary.OsmandOdb.OsmAndAddressIndex.CitiesIndex;
|
||||
import net.osmand.binary.OsmandOdb.OsmAndAddressNameIndexData.AddressNameIndexData;
|
||||
|
@ -43,6 +46,7 @@ import net.osmand.binary.OsmandOdb.OsmAndPoiBoxDataAtom;
|
|||
import net.osmand.binary.OsmandOdb.OsmAndPoiNameIndex;
|
||||
import net.osmand.binary.OsmandOdb.OsmAndPoiNameIndexDataAtom;
|
||||
import net.osmand.binary.OsmandOdb.OsmAndRoutingIndex;
|
||||
import net.osmand.binary.OsmandOdb.OsmAndRoutingIndex.RouteBorderLine;
|
||||
import net.osmand.binary.OsmandOdb.OsmAndRoutingIndex.RouteDataBlock;
|
||||
import net.osmand.binary.OsmandOdb.OsmAndRoutingIndex.RouteDataBox;
|
||||
import net.osmand.binary.OsmandOdb.OsmAndRoutingIndex.RouteEncodingRule;
|
||||
|
@ -122,6 +126,7 @@ public class BinaryMapIndexWriter {
|
|||
|
||||
private final static int ROUTE_INDEX_INIT = 15;
|
||||
private final static int ROUTE_TREE = 16;
|
||||
private final static int ROUTE_BORDER_BOX = 17;
|
||||
|
||||
public BinaryMapIndexWriter(final RandomAccessFile raf) throws IOException {
|
||||
this.raf = raf;
|
||||
|
@ -203,6 +208,7 @@ public class BinaryMapIndexWriter {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
public void endWriteRouteIndex() throws IOException {
|
||||
popState(ROUTE_INDEX_INIT);
|
||||
int len = writeInt32Size();
|
||||
|
@ -310,6 +316,62 @@ public class BinaryMapIndexWriter {
|
|||
}
|
||||
}
|
||||
|
||||
public void startRouteBorderBox(int leftX, int rightX, int topY, int bottomY, int zoomToSplit, boolean basemap) throws IOException {
|
||||
pushState(ROUTE_BORDER_BOX, ROUTE_INDEX_INIT);
|
||||
if(basemap) {
|
||||
codedOutStream.writeTag(OsmAndRoutingIndex.BASEBORDERBOX_FIELD_NUMBER, WireFormat.WIRETYPE_FIXED32_LENGTH_DELIMITED);
|
||||
} else {
|
||||
codedOutStream.writeTag(OsmAndRoutingIndex.BORDERBOX_FIELD_NUMBER, WireFormat.WIRETYPE_FIXED32_LENGTH_DELIMITED);
|
||||
}
|
||||
preserveInt32Size();
|
||||
OsmandOdb.OsmAndTileBox.Builder builder = OsmandOdb.OsmAndTileBox.newBuilder();
|
||||
builder.setLeft(leftX);
|
||||
builder.setRight(rightX);
|
||||
builder.setTop(topY);
|
||||
builder.setBottom(bottomY);
|
||||
codedOutStream.writeMessage(RouteBorderBox.BOUNDARIES_FIELD_NUMBER, builder.build());
|
||||
codedOutStream.writeInt32(RouteBorderBox.TILEZOOMTOSPLIT_FIELD_NUMBER, zoomToSplit);
|
||||
stackBounds.push(new Bounds(leftX, rightX, topY, bottomY));
|
||||
}
|
||||
|
||||
public BinaryFileReference writeRouteBorderLine(int fromX, int fromY, int toX, int toY) throws IOException {
|
||||
codedOutStream.writeTag(RouteBorderBox.BORDERLINES_FIELD_NUMBER, FieldType.MESSAGE.getWireType());
|
||||
long startMessage = getFilePointer();
|
||||
RouteBorderLine.Builder builder = RouteBorderLine.newBuilder();
|
||||
Bounds p = stackBounds.peek();
|
||||
builder.setX(fromX - p.leftX);
|
||||
builder.setY(fromY - p.topY);
|
||||
if (toX != -1) {
|
||||
builder.setTox(toX - p.leftX);
|
||||
}
|
||||
if (toY != -1) {
|
||||
builder.setToy(toY - p.topY);
|
||||
}
|
||||
builder.setShiftToPointsBlock(0);
|
||||
codedOutStream.writeMessageNoTag(builder.build());
|
||||
return BinaryFileReference.createShiftReference(getFilePointer() - 4, startMessage);
|
||||
}
|
||||
|
||||
public void writeRouteBorderPointBlock(int x, int y, long baseId, List<RouteBorderPoint> points, BinaryFileReference ref) throws IOException {
|
||||
codedOutStream.writeTag(RouteBorderBox.BLOCKS_FIELD_NUMBER, FieldType.MESSAGE.getWireType());
|
||||
codedOutStream.flush();
|
||||
ref.writeReference(raf, getFilePointer());
|
||||
RouteBorderPointsBlock.Builder builder = RouteBorderPointsBlock.newBuilder();
|
||||
builder.setX(x);
|
||||
builder.setY(y);
|
||||
builder.setBaseId(baseId);
|
||||
for(RouteBorderPoint p : points) {
|
||||
builder.addPoints(p);
|
||||
}
|
||||
codedOutStream.writeMessageNoTag(builder.build());
|
||||
}
|
||||
|
||||
public void endRouteBorderBox() throws IOException {
|
||||
stackBounds.pop();
|
||||
popState(ROUTE_BORDER_BOX);
|
||||
writeInt32Size();
|
||||
}
|
||||
|
||||
public BinaryFileReference startRouteTreeElement(int leftX, int rightX, int topY, int bottomY, boolean containsObjects,
|
||||
boolean basemap) throws IOException {
|
||||
checkPeekState(ROUTE_TREE, ROUTE_INDEX_INIT);
|
||||
|
@ -418,9 +480,7 @@ public class BinaryMapIndexWriter {
|
|||
|
||||
public void writeRouteDataBlock(RouteDataBlock.Builder builder, Map<String, Integer> stringTable, BinaryFileReference ref)
|
||||
throws IOException {
|
||||
|
||||
checkPeekState(ROUTE_INDEX_INIT);
|
||||
|
||||
if (stringTable != null && stringTable.size() > 0) {
|
||||
StringTable.Builder bs = OsmandOdb.StringTable.newBuilder();
|
||||
for (String s : stringTable.keySet()) {
|
||||
|
@ -432,15 +492,15 @@ public class BinaryMapIndexWriter {
|
|||
ROUTE_STRING_DATA_SIZE += CodedOutputStream.computeTagSize(OsmandOdb.MapDataBlock.STRINGTABLE_FIELD_NUMBER)
|
||||
+ CodedOutputStream.computeRawVarint32Size(size) + size;
|
||||
}
|
||||
|
||||
codedOutStream.writeTag(OsmAndMapIndex.MapRootLevel.BLOCKS_FIELD_NUMBER, FieldType.MESSAGE.getWireType());
|
||||
|
||||
codedOutStream.flush();
|
||||
ref.writeReference(raf, getFilePointer());
|
||||
RouteDataBlock block = builder.build();
|
||||
ROUTE_DATA_SIZE += block.getSerializedSize();
|
||||
codedOutStream.writeMessageNoTag(block);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Encode and write a varint. {@code value} is treated as unsigned, so it won't be sign-extended if negative.
|
||||
|
|
|
@ -505,19 +505,18 @@ message OsmAndRoutingIndex {
|
|||
optional uint32 id = 7;
|
||||
}
|
||||
|
||||
// encoded as fixed32 length delimited
|
||||
optional RouteClusterBox clusterBox = 7;
|
||||
|
||||
// encoded as fixed32 length delimited
|
||||
optional RouteClusterBox baseClusterBox = 8;
|
||||
|
||||
|
||||
// encoded as fixed32 length delimited
|
||||
repeated RouteDataBox rootBoxes = 3;
|
||||
|
||||
// encoded as fixed32 length delimited
|
||||
repeated RouteDataBox basemapBoxes = 4;
|
||||
|
||||
// encoded as fixed32 length delimited
|
||||
optional RouteBorderBox borderBox = 7;
|
||||
|
||||
// encoded as fixed32 length delimited
|
||||
optional RouteBorderBox baseBorderBox = 8;
|
||||
|
||||
repeated RouteDataBlock blocks = 5;
|
||||
message RouteDataBox {
|
||||
// for root box is absolute coordinates
|
||||
|
@ -544,22 +543,39 @@ message OsmAndRoutingIndex {
|
|||
|
||||
}
|
||||
|
||||
message RouteClusterBox {
|
||||
optional int32 zoom = 1 ;
|
||||
optional int32 tileX = 2 ;
|
||||
optional int32 tileY = 3 ;
|
||||
message RouteBorderBox {
|
||||
required OsmAndTileBox boundaries = 1;
|
||||
optional uint32 tileZoomToSplit = 2;
|
||||
|
||||
repeated RouteClusterBox children = 5;
|
||||
repeated RouteBorderLine borderLines = 6;
|
||||
|
||||
repeated RouteClusterPoint parentCommonPoints = 7;
|
||||
repeated RouteClusterPoint neighboorPoints = 8;
|
||||
repeated RouteBorderPointsBlock blocks = 7;
|
||||
}
|
||||
|
||||
message RouteClusterPoint {
|
||||
message RouteBorderLine {
|
||||
// relative to left to boundary top/left
|
||||
required int32 x = 1;
|
||||
required int32 y = 2;
|
||||
optional int32 tox = 3;
|
||||
optional int32 toy = 4;
|
||||
required fixed32 shiftToPointsBlock = 7 ;
|
||||
}
|
||||
|
||||
message RouteBorderPointsBlock {
|
||||
required int32 x = 1;
|
||||
required int32 y = 2;
|
||||
required int64 baseId = 3;
|
||||
|
||||
repeated RouteBorderPoint points = 5;
|
||||
|
||||
}
|
||||
|
||||
message RouteBorderPoint {
|
||||
// related to previous point or to the parent if it is first point
|
||||
optional int32 dx = 1;
|
||||
optional int32 dy = 2;
|
||||
optional bool directionInCluster = 3;
|
||||
// direction from left or top
|
||||
optional int32 direction = 3;
|
||||
optional bytes types = 4;
|
||||
optional sint64 roadId = 7;
|
||||
|
||||
|
|
Loading…
Reference in a new issue