Commit f84a3c2a authored by Peter's avatar Peter
Browse files

with more compression

parent b65338c0
......@@ -942,6 +942,8 @@ public class GraphHopperStorage implements GraphStorage
int count = pillarNodes.getSize();
int dim = nodeAccess.getDimension();
VDeltaStorage deltaStorage = new VDeltaStorage(dim * count);
deltaStorage.writeLong(count);
if (reverse)
pillarNodes.reverse();
......@@ -967,21 +969,17 @@ public class GraphHopperStorage implements GraphStorage
int ints = byteLen / 4;
if (byteLen % 4 != 0)
ints++;
int geoIntRef = nextGeoRef(ints + 2);
int geoIntRef = nextGeoRef(ints);
edges.setInt(edgePointer + E_GEO, geoIntRef);
long geoPointer = (long) geoIntRef * 4;
ensureGeometry(geoPointer, byteLen + 2 * 4);
ensureGeometry(geoPointer, byteLen);
// write length of array
wayGeometry.setInt(geoPointer + 0, count);
// .. and the used number of bytes (not required but easier for reading)
wayGeometry.setInt(geoPointer + 4, byteLen);
wayGeometry.setBytes(geoPointer + 8, bytes, byteLen);
wayGeometry.setBytes(geoPointer, bytes, byteLen);
tmpEntryCounter += count;
tmpByteCounter += byteLen;
tmpCounter++;
if (tmpCounter % 100000 == 0)
System.out.println(tmpCounter
if (tmpCounter % 10000 == 0)
System.out.println(tmpCounter
+ " entries:" + (float) tmpEntryCounter / tmpCounter
+ " bytes:" + (float) tmpByteCounter / tmpCounter);
} else
......@@ -998,11 +996,19 @@ public class GraphHopperStorage implements GraphStorage
if (geoRef > 0)
{
geoRef *= 4;
count = wayGeometry.getInt(geoRef + 0);
int byteLen = wayGeometry.getInt(geoRef + 4);
byte[] bytes = new byte[byteLen];
wayGeometry.getBytes(geoRef + 8, bytes, byteLen);
// first read to get count
byte[] bytes = new byte[4];
wayGeometry.getBytes(geoRef, bytes, 4);
storage = new VDeltaStorage(bytes);
count = (int) storage.readLong();
int byteLen = count * 6 * nodeAccess.getDimension();
bytes = new byte[byteLen];
wayGeometry.getBytes(geoRef, bytes, byteLen);
storage = new VDeltaStorage(bytes);
// skip long
storage.readLong();
} else if (mode == 0)
return PointList.EMPTY;
......
......@@ -147,41 +147,53 @@ public class MiniGraphUI
// plotPath(path, g2, 1);
g2.setColor(Color.black);
EdgeExplorer explorer = graph.createEdgeExplorer(EdgeFilter.ALL_EDGES);
for (int nodeIndex = 0; nodeIndex < locs; nodeIndex++)
int emptyCount = 0, fullCount = 0;
AllEdgesIterator iter = graph.getAllEdges();
while (iter.next())
{
if (fastPaint && rand.nextInt(30) > 1)
continue;
double lat = na.getLatitude(nodeIndex);
double lon = na.getLongitude(nodeIndex);
int baseNode = iter.getBaseNode();
double lat = na.getLatitude(baseNode);
double lon = na.getLongitude(baseNode);
// mg.plotText(g2, lat, lon, "" + nodeIndex);
if (lat < b.minLat || lat > b.maxLat || lon < b.minLon || lon > b.maxLon)
continue;
EdgeIterator iter = explorer.setBaseNode(nodeIndex);
while (iter.next())
int adjNode = iter.getAdjNode();
int sum = baseNode + adjNode;
if (fastPaint)
{
int nodeId = iter.getAdjNode();
int sum = nodeIndex + nodeId;
if (fastPaint)
{
if (bitset.contains(sum))
continue;
bitset.add(sum);
}
double lat2 = na.getLatitude(nodeId);
double lon2 = na.getLongitude(nodeId);
// mg.plotText(g2, lat * 0.9 + lat2 * 0.1, lon * 0.9 + lon2 * 0.1, iter.getName());
mg.plotText(g2, lat * 0.9 + lat2 * 0.1, lon * 0.9 + lon2 * 0.1, "s:" + (int) encoder.getSpeed(iter.getFlags()));
g2.setColor(Color.BLACK);
if (bitset.contains(sum))
continue;
mg.plotEdge(g2, lat, lon, lat2, lon2);
bitset.add(sum);
}
double lat2 = na.getLatitude(adjNode);
double lon2 = na.getLongitude(adjNode);
// mg.plotText(g2, lat * 0.9 + lat2 * 0.1, lon * 0.9 + lon2 * 0.1, iter.getName());
// mg.plotText(g2, lat * 0.9 + lat2 * 0.1, lon * 0.9 + lon2 * 0.1, "s:" + (int) encoder.getSpeed(iter.getFlags()));
// g2.setColor(Color.BLACK);
if (iter.fetchWayGeometry(0).isEmpty())
{
g2.setColor(Color.RED);
emptyCount++;
} else
{
g2.setColor(Color.BLACK);
fullCount++;
}
mg.plotEdge(g2, lat, lon, lat2, lon2);
g2.setColor(Color.BLACK);
}
System.out.println("emptyCount:" + emptyCount);
System.out.println("fullCount:" + fullCount);
System.out.println("edges:" + graph.getAllEdges().getMaxId());
}
});
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment