Intermediate commit

This commit is contained in:
Victor Shcherb 2011-11-08 22:02:08 +01:00
parent 6deddb433e
commit 0230e2ce95
6 changed files with 84 additions and 106 deletions

View file

@ -7,23 +7,22 @@ package net.osmand;
*/
public class ToDoConstants {
// Index
// Map QTree (skip small areas!!!)
// new Address
// slightly changed POI (check it)
// Routing index
// == Osmand application (TODO 127) ==
// TODO replace icon for default mode (???)
// TODO prepare C++ version of routing algorithm
// TODO make transport search faster (cancellable.. )
// TODO Test Voice activity
// Map Refactoring
// Remove notification from OsmAndMapTileView (?)
// === Refactoring issues ===
// !|| 125 || Introduce service layer rather than singletons and put all related into new package (services). Review architecture. Split some big classes. ||
// === Common issues ===
// || 110 || Use android voice for pronounce command (could be used in future to pronounce street) (Issue 70) ||
// || 111 || Investigate showing street name while driving (Issue 286) ||
// || 86 || Allow to add/edit custom tags to POI objects (Issue 44) ||
// || 113 || Calculate speed cameras/bumps on the road (announce about them) (Issue 418) ||
@ -41,6 +40,7 @@ public class ToDoConstants {
/////////////////////////// DONE //////////////////////////////
// DONE ANDROID :
// || 110 || Use android voice for pronounce command (could be used in future to pronounce street) (Issue 70) ||
// DONE SWING

View file

@ -34,7 +34,7 @@ public abstract class MapObject implements Comparable<MapObject>, Serializable {
if(this.name == null){
this.name = e.getTag(OSMTagKey.NAME);
}
if(this.enName == null){
if (this.enName == null) {
this.enName = e.getTag(OSMTagKey.NAME_EN);
if(name == null){
this.name = this.enName;

View file

@ -366,11 +366,8 @@ public class IndexCreator {
this.indexTransportCreator = new IndexTransportCreator();
this.indexPoiCreator = new IndexPoiCreator(renderingTypes);
this.indexAddressCreator = new IndexAddressCreator(logMapDataWarn);
this.indexMapCreator = new IndexVectorMapCreator(logMapDataWarn);
this.indexMapCreator = new IndexVectorMapCreator(logMapDataWarn,mapZooms, renderingTypes, zoomWaySmothness);
this.accessor = new OsmDbAccessor();
indexMapCreator.initSettings(mapZooms, renderingTypes, zoomWaySmothness);
// init address
String[] normalizeDefaultSuffixes = null;

View file

@ -63,7 +63,7 @@ public class IndexPoiCreator extends AbstractIndexPartCreator {
public void iterateEntity(Entity e, OsmDbAccessorContext ctx) throws SQLException {
tempAmenityList.clear();
tempAmenityList = Amenity.parseAmenities(e, tempAmenityList);
tempAmenityList = Amenity.parseAmenities(renderingTypes, e, tempAmenityList);
if (!tempAmenityList.isEmpty() && poiPreparedStatement != null) {
// load data for way (location etc...)
ctx.loadEntityData(e);

View file

@ -1,5 +1,7 @@
package net.osmand.data.preparation;
import gnu.trove.list.array.TIntArrayList;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.IOException;
@ -50,17 +52,20 @@ public class IndexVectorMapCreator extends AbstractIndexPartCreator {
private static final int MAP_LEVELS_POWER = 3;
private static final int MAP_LEVELS_MAX = 1 << MAP_LEVELS_POWER;
private MapRenderingTypes renderingTypes;
private MapZooms mapZooms;
// MEMORY map : save it in memory while that is allowed
private Map<Long, Set<Integer>>[] multiPolygonsWays;
private Map<Long, String> multiPolygonsNames = new LinkedHashMap<Long, String>();
private Map<Long, List<Long>> highwayRestrictions = new LinkedHashMap<Long, List<Long>>();
// local purpose
List<Integer> typeUse = new ArrayList<Integer>(8);
TIntArrayList typeUse = new TIntArrayList(8);
List<Long> restrictionsUse = new ArrayList<Long>(8);
private MapZooms mapZooms;
private PreparedStatement mapBinaryStat;
private PreparedStatement mapLowLevelBinaryStat;
@ -72,8 +77,17 @@ public class IndexVectorMapCreator extends AbstractIndexPartCreator {
private final Log logMapDataWarn;
public IndexVectorMapCreator(Log logMapDataWarn) {
public IndexVectorMapCreator(Log logMapDataWarn, MapZooms mapZooms, MapRenderingTypes renderingTypes, int zoomWaySmothness) {
this.logMapDataWarn = logMapDataWarn;
this.mapZooms = mapZooms;
this.zoomWaySmothness = zoomWaySmothness;
this.renderingTypes = renderingTypes;
// init map
multiPolygonsWays = new Map[mapZooms.size()];
for (int i = 0; i < multiPolygonsWays.length; i++) {
multiPolygonsWays[i] = new LinkedHashMap<Long, Set<Integer>>();
}
lowLevelWays = -1;
}
public void indexMapRelationsAndMultiPolygons(Entity e, OsmDbAccessorContext ctx) throws SQLException {
@ -104,7 +118,7 @@ public class IndexVectorMapCreator extends AbstractIndexPartCreator {
return;
}
int mtType = findMultiPolygonType(e, 0);
int mtType = renderingTypes.encodeEntityWithType(e, mapZooms.getLevel(0).getMaxZoom(), true, typeUse);
if (mtType != 0) {
String name = renderingTypes.getEntityName(e);
@ -156,7 +170,7 @@ public class IndexVectorMapCreator extends AbstractIndexPartCreator {
}
putMultipolygonType(multiPolygonsWays[0], way.getId(), mtType, inverse);
for (int i = 1; i < multiPolygonsWays.length; i++) {
int type = findMultiPolygonType(e, i);
int type = renderingTypes.encodeEntityWithType(e, mapZooms.getLevel(0).getMaxZoom(), true, typeUse);
if (type != 0) {
putMultipolygonType(multiPolygonsWays[i], way.getId(), type, inverse);
}
@ -200,45 +214,6 @@ public class IndexVectorMapCreator extends AbstractIndexPartCreator {
}
private void indexHighwayRestrictions(Entity e, OsmDbAccessorContext ctx) throws SQLException {
if (e instanceof Relation && "restriction".equals(e.getTag(OSMTagKey.TYPE))) { //$NON-NLS-1$
String val = e.getTag("restriction"); //$NON-NLS-1$
if (val != null) {
byte type = -1;
if ("no_right_turn".equalsIgnoreCase(val)) { //$NON-NLS-1$
type = MapRenderingTypes.RESTRICTION_NO_RIGHT_TURN;
} else if ("no_left_turn".equalsIgnoreCase(val)) { //$NON-NLS-1$
type = MapRenderingTypes.RESTRICTION_NO_LEFT_TURN;
} else if ("no_u_turn".equalsIgnoreCase(val)) { //$NON-NLS-1$
type = MapRenderingTypes.RESTRICTION_NO_U_TURN;
} else if ("no_straight_on".equalsIgnoreCase(val)) { //$NON-NLS-1$
type = MapRenderingTypes.RESTRICTION_NO_STRAIGHT_ON;
} else if ("only_right_turn".equalsIgnoreCase(val)) { //$NON-NLS-1$
type = MapRenderingTypes.RESTRICTION_ONLY_RIGHT_TURN;
} else if ("only_left_turn".equalsIgnoreCase(val)) { //$NON-NLS-1$
type = MapRenderingTypes.RESTRICTION_ONLY_LEFT_TURN;
} else if ("only_straight_on".equalsIgnoreCase(val)) { //$NON-NLS-1$
type = MapRenderingTypes.RESTRICTION_ONLY_STRAIGHT_ON;
}
if (type != -1) {
ctx.loadEntityData(e);
Collection<EntityId> fromL = ((Relation) e).getMemberIds("from"); //$NON-NLS-1$
Collection<EntityId> toL = ((Relation) e).getMemberIds("to"); //$NON-NLS-1$
if (!fromL.isEmpty() && !toL.isEmpty()) {
EntityId from = fromL.iterator().next();
EntityId to = toL.iterator().next();
if (from.getType() == EntityType.WAY) {
if (!highwayRestrictions.containsKey(from.getId())) {
highwayRestrictions.put(from.getId(), new ArrayList<Long>(4));
}
highwayRestrictions.get(from.getId()).add((to.getId() << 3) | (long) type);
}
}
}
}
}
}
private void putMultipolygonType(Map<Long, Set<Integer>> multiPolygonsWays, long baseId, int mtType, boolean inverse) {
if (mtType == 0) {
return;
@ -253,25 +228,6 @@ public class IndexVectorMapCreator extends AbstractIndexPartCreator {
}
}
private int findMultiPolygonType(Entity e, int level) {
int t = renderingTypes.encodeEntityWithType(e, mapZooms.getLevel(level).getMaxZoom(), true, typeUse);
int mtType = 0;
if (t != 0) {
if ((t & 3) == MapRenderingTypes.MULTY_POLYGON_TYPE) {
mtType = t;
} else {
for (Integer i : typeUse) {
if ((i & 3) == MapRenderingTypes.MULTY_POLYGON_TYPE) {
mtType = i;
break;
}
}
}
}
return mtType;
}
private void combineMultiPolygons(Way w, List<List<Way>> completedRings, List<List<Way>> incompletedRings) {
long lId = w.getEntityIds().get(w.getEntityIds().size() - 1).getId().longValue();
long fId = w.getEntityIds().get(0).getId().longValue();
@ -625,19 +581,6 @@ public class IndexVectorMapCreator extends AbstractIndexPartCreator {
}
@SuppressWarnings("unchecked")
public void initSettings(MapZooms mapZooms, MapRenderingTypes renderingTypes, int zoomWaySmothness) {
this.mapZooms = mapZooms;
this.zoomWaySmothness = zoomWaySmothness;
this.renderingTypes = renderingTypes;
// init map
multiPolygonsWays = new Map[mapZooms.size()];
for (int i = 0; i < multiPolygonsWays.length; i++) {
multiPolygonsWays[i] = new LinkedHashMap<Long, Set<Integer>>();
}
lowLevelWays = -1;
}
public void iterateMainEntity(Entity e, OsmDbAccessorContext ctx) throws SQLException {
if (e instanceof Way || e instanceof Node) {
@ -952,4 +895,44 @@ public class IndexVectorMapCreator extends AbstractIndexPartCreator {
public int getZoomWaySmothness() {
return zoomWaySmothness;
}
// TODO restrictions should be moved to different creator (Routing Map creator)
private void indexHighwayRestrictions(Entity e, OsmDbAccessorContext ctx) throws SQLException {
if (e instanceof Relation && "restriction".equals(e.getTag(OSMTagKey.TYPE))) { //$NON-NLS-1$
String val = e.getTag("restriction"); //$NON-NLS-1$
if (val != null) {
byte type = -1;
if ("no_right_turn".equalsIgnoreCase(val)) { //$NON-NLS-1$
type = MapRenderingTypes.RESTRICTION_NO_RIGHT_TURN;
} else if ("no_left_turn".equalsIgnoreCase(val)) { //$NON-NLS-1$
type = MapRenderingTypes.RESTRICTION_NO_LEFT_TURN;
} else if ("no_u_turn".equalsIgnoreCase(val)) { //$NON-NLS-1$
type = MapRenderingTypes.RESTRICTION_NO_U_TURN;
} else if ("no_straight_on".equalsIgnoreCase(val)) { //$NON-NLS-1$
type = MapRenderingTypes.RESTRICTION_NO_STRAIGHT_ON;
} else if ("only_right_turn".equalsIgnoreCase(val)) { //$NON-NLS-1$
type = MapRenderingTypes.RESTRICTION_ONLY_RIGHT_TURN;
} else if ("only_left_turn".equalsIgnoreCase(val)) { //$NON-NLS-1$
type = MapRenderingTypes.RESTRICTION_ONLY_LEFT_TURN;
} else if ("only_straight_on".equalsIgnoreCase(val)) { //$NON-NLS-1$
type = MapRenderingTypes.RESTRICTION_ONLY_STRAIGHT_ON;
}
if (type != -1) {
ctx.loadEntityData(e);
Collection<EntityId> fromL = ((Relation) e).getMemberIds("from"); //$NON-NLS-1$
Collection<EntityId> toL = ((Relation) e).getMemberIds("to"); //$NON-NLS-1$
if (!fromL.isEmpty() && !toL.isEmpty()) {
EntityId from = fromL.iterator().next();
EntityId to = toL.iterator().next();
if (from.getType() == EntityType.WAY) {
if (!highwayRestrictions.containsKey(from.getId())) {
highwayRestrictions.put(from.getId(), new ArrayList<Long>(4));
}
highwayRestrictions.get(from.getId()).add((to.getId() << 3) | (long) type);
}
}
}
}
}
}
}

View file

@ -52,14 +52,6 @@ public class MapRenderingTypes {
public final static int POLYLINE_TYPE = 2;
public final static int POINT_TYPE = 1;
public final static byte RESTRICTION_NO_RIGHT_TURN = 1;
public final static byte RESTRICTION_NO_LEFT_TURN = 2;
public final static byte RESTRICTION_NO_U_TURN = 3;
public final static byte RESTRICTION_NO_STRAIGHT_ON = 4;
public final static byte RESTRICTION_ONLY_RIGHT_TURN = 5;
public final static byte RESTRICTION_ONLY_LEFT_TURN = 6;
public final static byte RESTRICTION_ONLY_STRAIGHT_ON = 7;
private static char TAG_DELIMETER = '/'; //$NON-NLS-1$
private String resourceName = null;
@ -160,17 +152,17 @@ public class MapRenderingTypes {
return null;
}
public String getEntityName(Entity e) {
String name = e.getTag(OSMTagKey.NAME);
if (name == null) {
name = getNullName(e);
name = e.getTag(OSMTagKey.NAME_EN);
if(name == null) {
name = getNullName(e);
}
}
return name;
}
public Map<AmenityType, Map<String, String>> getAmenityTypeNameToTagVal() {
if (amenityTypeNameToTagVal == null) {
Map<String, MapRulType> types = getEncodingRuleTypes();
@ -438,6 +430,7 @@ public class MapRenderingTypes {
}
// TODO Move to Routing Attributes and finalize
// HIGHWAY special attributes :
// o/oneway 1 bit
// f/free toll 1 bit
@ -446,10 +439,18 @@ public class MapRenderingTypes {
// a/vehicle access 4 bit (height, weight?) - one bit bicycle
// p/parking 1 bit
// c/cycle oneway 1 bit
// TODO
// ci/inside city 1 bit
// ENCODING : ci|c|p|aaaa|sss|rr|f|o - 14 bit
public final static byte RESTRICTION_NO_RIGHT_TURN = 1;
public final static byte RESTRICTION_NO_LEFT_TURN = 2;
public final static byte RESTRICTION_NO_U_TURN = 3;
public final static byte RESTRICTION_NO_STRAIGHT_ON = 4;
public final static byte RESTRICTION_ONLY_RIGHT_TURN = 5;
public final static byte RESTRICTION_ONLY_LEFT_TURN = 6;
public final static byte RESTRICTION_ONLY_STRAIGHT_ON = 7;
public static boolean isOneWayWay(int highwayAttributes){
return (highwayAttributes & 1) > 0;
}
@ -466,10 +467,7 @@ public class MapRenderingTypes {
case 1:
return 40;
case 2:
// for old format it should return 0;
// TODO it should be uncommented because now it is fixed
// return 60;
return 0;
return 60;
case 3:
return 80;
case 4: