fix small issues

git-svn-id: https://osmand.googlecode.com/svn/trunk@609 e29c36b1-1cfa-d876-8d93-3434fc2bb7b8
This commit is contained in:
Victor Shcherb 2010-10-29 13:28:59 +00:00
parent 042b616517
commit ec94b03c1a
5 changed files with 47 additions and 33 deletions

View file

@ -10,6 +10,7 @@ import java.util.ArrayList;
import java.util.List;
import net.osmand.Algoritms;
import net.osmand.osm.MapRenderingTypes;
import net.osmand.osm.MapUtils;
import com.google.protobuf.CodedInputStreamRAF;
@ -27,7 +28,7 @@ public class BinaryMapIndexReader {
public BinaryMapIndexReader(final RandomAccessFile raf) throws IOException {
this.raf = raf;
codedIS = CodedInputStreamRAF.newInstance(raf, 256);
codedIS = CodedInputStreamRAF.newInstance(raf, 1024);
init();
}
@ -491,14 +492,24 @@ public class BinaryMapIndexReader {
RandomAccessFile raf = new RandomAccessFile(new File("e:\\Information\\OSM maps\\osmand\\Minsk.map.pbf"), "r");
BinaryMapIndexReader reader = new BinaryMapIndexReader(raf);
System.out.println("VERSION " + reader.getVersion());
int sleft = MapUtils.get31TileNumberX(27.578);
int sright = MapUtils.get31TileNumberX(27.583);
int stop = MapUtils.get31TileNumberY(53.916);
int sbottom = MapUtils.get31TileNumberY(53.9138);
int sleft = MapUtils.get31TileNumberX(27.596);
int sright = MapUtils.get31TileNumberX(27.599);
int stop = MapUtils.get31TileNumberY(53.921);
int sbottom = MapUtils.get31TileNumberY(53.919);
System.out.println("SEARCH " + sleft + " " + sright + " " + stop + " " + sbottom);
for (BinaryMapDataObject obj : reader.searchMapIndex(buildSearchRequest(sleft, sright, stop, sbottom, 18))) {
if(obj.getId() >> 3 == 25323337l){
System.out.println("!");
}
for(int i=0; i<obj.getTypes().length; i++){
int t = obj.getTypes()[i];
if((t & 3) == MapRenderingTypes.POLYGON_TYPE){
System.out.println((obj.getId() >> 3) + " " + t);
}
}
if (obj.getName() != null) {
System.out.println(" " + obj.getName());
}
}

View file

@ -173,6 +173,8 @@ public class BinaryMapIndexWriter {
size += CodedOutputStream.computeStringSize(OsmandOdb.StringTable.S_FIELD_NUMBER, s);
}
codedOutStream.writeTag(OsmandOdb.MapTree.STRINGTABLE_FIELD_NUMBER, WireFormat.FieldType.MESSAGE.getWireType());
STRING_TABLE_SIZE += CodedOutputStream.computeTagSize(OsmandOdb.MapTree.STRINGTABLE_FIELD_NUMBER) +
CodedOutputStream.computeRawVarint32Size(size) + size;
codedOutStream.writeRawVarint32(size);
for(String s : map.keySet()){
codedOutStream.writeString(OsmandOdb.StringTable.S_FIELD_NUMBER, s);
@ -185,6 +187,7 @@ public class BinaryMapIndexWriter {
public static int ID_SIZE = 0;
public static int TYPES_SIZE = 0;
public static int MAP_DATA_SIZE = 0;
public static int STRING_TABLE_SIZE = 0;
public void writeMapData(long id, byte[] nodes, byte[] types, String name, int highwayAttributes, byte[] restrictions) throws IOException{
assert state.peek() == MAP_TREE;

View file

@ -86,6 +86,7 @@ import rtree.Rect;
* save runtime memory and generate indexes on the fly.
* It will be longer than load in memory (needed part) and save into index.
*/
@SuppressWarnings("unchecked")
public class IndexCreator {
private static final Log log = LogFactory.getLog(IndexCreator.class);
@ -153,9 +154,12 @@ public class IndexCreator {
private RTree[] mapTree = null;
// MEMORY map : save it in memory while that is allowed
private Map<Long, Set<Integer>> multiPolygonsWays0 = new LinkedHashMap<Long, Set<Integer>>();
private Map<Long, Set<Integer>> multiPolygonsWays1 = new LinkedHashMap<Long, Set<Integer>>();
private Map<Long, Set<Integer>> multiPolygonsWays2 = new LinkedHashMap<Long, Set<Integer>>();
private Map<Long, Set<Integer>>[] multiPolygonsWays = new Map[MAP_ZOOMS.length - 1];
{
for (int i = 0; i < multiPolygonsWays.length; i++) {
multiPolygonsWays[i] = new LinkedHashMap<Long, Set<Integer>>();
}
}
private Map<Long, String> multiPolygonsNames = new LinkedHashMap<Long, String>();
private Map<Long, List<Long>> highwayRestrictions = new LinkedHashMap<Long, List<Long>>();
@ -435,9 +439,11 @@ public class IndexCreator {
}
}
}
if(loadTags && e.getTagKeySet().isEmpty()){
if(loadTags){
for(Map.Entry<EntityId, Entity> es : map.entrySet()){
loadEntityTags(es.getKey().getType(), es.getValue());
if( es.getValue().getTagKeySet().isEmpty()){
loadEntityTags(es.getKey().getType(), es.getValue());
}
}
}
e.initializeLinks(map);
@ -1098,8 +1104,7 @@ public class IndexCreator {
int mtType = findMultiPolygonType(e, 0);
if (mtType != 0) {
int mtType1 = findMultiPolygonType(e, 1);
int mtType2 = findMultiPolygonType(e, 2);
String name = MapRenderingTypes.getEntityName(e, mtType);
List<List<Way>> completedRings = new ArrayList<List<Way>>();
List<List<Way>> incompletedRings = new ArrayList<List<Way>>();
@ -1128,9 +1133,13 @@ public class IndexCreator {
if(!inner && name != null){
multiPolygonsNames.put(es.getId(), name);
}
putMultipolygonType(multiPolygonsWays0, es.getId(), mtType, inverse);
putMultipolygonType(multiPolygonsWays1, es.getId(), mtType1, inverse);
putMultipolygonType(multiPolygonsWays2, es.getId(), mtType2, inverse);
putMultipolygonType(multiPolygonsWays[0], es.getId(), mtType, inverse);
for(int i=1; i<multiPolygonsWays.length; i++){
int type = findMultiPolygonType(e, i);
if (type != 0) {
putMultipolygonType(multiPolygonsWays[i], es.getId(), type, inverse);
}
}
}
}
@ -1334,16 +1343,7 @@ public class IndexCreator {
private void writeBinaryEntityToMapDatabase(Entity e, long baseId, boolean inverse, int level) throws SQLException {
int type = MapRenderingTypes.encodeEntityWithType(e, level, false, typeUse);
Map<Long, Set<Integer>> multiPolygonsWays;
if (level == 0) {
multiPolygonsWays = multiPolygonsWays0;
} else if (level == 1) {
multiPolygonsWays = multiPolygonsWays1;
} else if (level == 2) {
multiPolygonsWays = multiPolygonsWays2;
} else {
multiPolygonsWays = Collections.emptyMap();
}
Map<Long, Set<Integer>> multiPolygonsWays = this.multiPolygonsWays[level];
boolean hasMulti = e instanceof Way && multiPolygonsWays.containsKey(e.getId());
if (hasMulti) {
Set<Integer> set = multiPolygonsWays.get(e.getId());
@ -1960,11 +1960,7 @@ public class IndexCreator {
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);
System.out.println("COORDINATES_SIZE " + BinaryMapIndexWriter.COORDINATES_SIZE);
System.out.println("TYPES_SIZE " + BinaryMapIndexWriter.TYPES_SIZE);
System.out.println("ID_SIZE " + BinaryMapIndexWriter.ID_SIZE);
System.out.println("MAP_DATA_SIZE " + BinaryMapIndexWriter.MAP_DATA_SIZE);
// 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);
@ -1980,7 +1976,11 @@ public class IndexCreator {
// creator.generateIndexes(new File("e:/Information/OSM maps/osm_map/forest_complex.osm"), new ConsoleProgressImplementation(25), null);
System.out.println("COORDINATES_SIZE " + BinaryMapIndexWriter.COORDINATES_SIZE);
System.out.println("TYPES_SIZE " + BinaryMapIndexWriter.TYPES_SIZE);
System.out.println("ID_SIZE " + BinaryMapIndexWriter.ID_SIZE);
System.out.println("MAP_DATA_SIZE " + BinaryMapIndexWriter.MAP_DATA_SIZE);
System.out.println("STRING_TABLE_SIZE " + BinaryMapIndexWriter.STRING_TABLE_SIZE);
}
}

View file

@ -2,7 +2,7 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="net.osmand" android:versionName="0.4.3" android:versionCode="19">
<application android:icon="@drawable/icon" android:label="@string/app_name"
android:debuggable="false" android:name=".activities.OsmandApplication" android:description="@string/app_description">
android:debuggable="true" android:name=".activities.OsmandApplication" android:description="@string/app_description">
<activity android:name=".activities.MainMenuActivity"
android:label="@string/app_name">
<intent-filter>

View file

@ -361,7 +361,7 @@ public class MapRenderRepositories {
Integer type, List<BinaryMapDataObject> directList, List<BinaryMapDataObject> inverselist) {
MultyPolygon pl = new MultyPolygon();
// delete direction last bit (to not show point)
pl.setType((type & 0x7fff) << 1);
pl.setType(type & 0x7fff);
for (int km = 0; km < 2; km++) {
List<BinaryMapDataObject> list = km == 0 ? directList : inverselist;
for (BinaryMapDataObject o : list) {