bugfix issue 153

git-svn-id: https://osmand.googlecode.com/svn/trunk@659 e29c36b1-1cfa-d876-8d93-3434fc2bb7b8
This commit is contained in:
Victor Shcherb 2010-11-12 12:44:47 +00:00
parent b7a3a09b32
commit b68a330e8f
4 changed files with 23 additions and 14 deletions

View file

@ -18,7 +18,7 @@ public class BinaryInspector {
public static void main(String[] args) throws IOException {
args = new String[]{"E:\\Information\\OSM maps\\osmand\\Luxembourg.map.pbf"};
args = new String[]{"E:\\Information\\OSM maps\\osmand\\Minsk.map.pbf"};
// args = new String[]{"E:\\Information\\OSM maps\\osmand\\Minsk.map.pbf"};
// args = new String[]{"E:\\Information\\OSM maps\\osmand\\Belarus_4.map.pbf"};
// args = new String[]{"E:\\Information\\OSM maps\\osmand\\Netherlands.map.pbf"};
// args = new String[]{"E:\\Information\\OSM maps\\osm_map\\Netherlands\\Netherlands_trans.map.pbf"};
@ -74,7 +74,9 @@ public class BinaryInspector {
System.out.println(MessageFormat.format("{0}. {1} data {3} - {2} bytes", i, partname, p.getLength(), name));
if(p instanceof TransportIndex){
TransportIndex ti = ((TransportIndex) p);
System.out.println("\t Bounds " + formatBounds(ti.getLeft(), ti.getRight(), ti.getTop(), ti.getBottom()));
int sh = (31 - BinaryMapIndexReader.TRANSPORT_STOP_ZOOM);
System.out.println("\t Bounds " + formatBounds(ti.getLeft() << sh, ti.getRight() << sh,
ti.getTop() << sh, ti.getBottom() << sh));
} else if(p instanceof MapIndex){
MapIndex m = ((MapIndex) p);
for(MapRoot mi : m.getRoots()){

View file

@ -31,7 +31,7 @@ import com.google.protobuf.WireFormat;
public class BinaryMapIndexReader {
private final static int TRANSPORT_STOP_ZOOM = 24;
public final static int TRANSPORT_STOP_ZOOM = 24;
private final RandomAccessFile raf;
private int version;

View file

@ -1925,7 +1925,7 @@ public class IndexCreator {
while(rset.next()){
Long route = transportRoutes.get(rset.getLong(1));
if(route == null){
log.error("Something goes wrong with route id = " + rset.getLong(1));
log.error("Something goes wrong with transport route id = " + rset.getLong(1));
} else {
routes.add(route);
}
@ -1933,7 +1933,7 @@ public class IndexCreator {
rset.close();
writer.writeTransportStop(id, x24, y24, name, nameEn, stringTable, routes);
} else {
log.error("Something goes wrong with id = " + id);
log.error("Something goes wrong with transport id = " + id);
}
} else {
long ptr = ((NonLeafElement) e[i]).getPtr();
@ -2502,18 +2502,14 @@ public class IndexCreator {
creator.setIndexTransport(true);
creator.recreateOnlyBinaryFile = false;
creator.deleteDatabaseIndexes = true;
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);
// creator.generateIndexes(new File("e:/Information/OSM maps/belarus osm/forest.osm"), new ConsoleProgressImplementation(3), null);
// creator.setNodesDBFile(new File("e:/Information/OSM maps/osmand/ams.tmp.odb"));
// creator.generateIndexes(new File("e:/Information/OSM maps/osm_map/ams_part_map.osm"), new ConsoleProgressImplementation(3), null);
@ -2525,7 +2521,8 @@ public class IndexCreator {
// creator.generateIndexes(new File("e:/Information/OSM maps/osm_map/forest_complex.osm"), new ConsoleProgressImplementation(25), null);
// creator.generateIndexes(new File("e:/Information/OSM maps/osm_map/luxembourg.osm.pbf"), new ConsoleProgressImplementation(25), null);
creator.setNodesDBFile(new File("e:/Information/OSM maps/osmand/luxembourg.tmp.odb"));
creator.generateIndexes(new File("e:/Information/OSM maps/osm_map/luxembourg.osm.pbf"), new ConsoleProgressImplementation(15), null);
System.out.println("WHOLE GENERATION TIME : " + (System.currentTimeMillis() - time));
System.out.println("COORDINATES_SIZE " + BinaryMapIndexWriter.COORDINATES_SIZE + " count " + BinaryMapIndexWriter.COORDINATES_COUNT);

View file

@ -380,11 +380,21 @@ public class CachedNodes
buffHeader.reset();
}
static Map<String, Integer> fileNamesMap = new LinkedHashMap<String, Integer>();
int calKey(String fileName,int idx)
{
if(fileName != null) {
Integer i = fileNamesMap.get(fileName);
if(i == null){
if(fileNamesMap.size() > 31){
throw new ArrayIndexOutOfBoundsException();
}
fileNamesMap.put(fileName, fileNamesMap.size());
i = fileNamesMap.get(fileName);
}
// System.out.println(idx + " " + fileName + " " + ((idx << 5)+ fileName.toLowerCase().hashCode() % 32));
return ((idx << 5)+ fileName.toLowerCase().hashCode() % 32);
return ((idx << 5)+ i);
} else{
System.out.println("CachedNodes.calKey: fileName null");
return 0;