Fix rendering

This commit is contained in:
Victor Shcherb 2012-03-22 00:30:48 +01:00
parent 3dca79c49f
commit 9651d8e136
10 changed files with 235 additions and 131 deletions

View file

@ -15,7 +15,8 @@ public class ToDoConstants {
// Routing index !! // Routing index !!
// Identify coastline areas and pure ocean areas !!! // Identify coastline areas and pure ocean areas !!!
// Extract & remove the code with multipolygons // Extract & remove the code with multipolygons
// render different texts // Render : different texts support render.xml
// Render : support additional tags in render.xml
// FIXME layer and renderer 1) FIXME Layer 2 2) FIXME oneway 1 // FIXME layer and renderer 1) FIXME Layer 2 2) FIXME oneway 1

View file

@ -3,6 +3,7 @@ package net.osmand.binary;
import gnu.trove.map.hash.TIntObjectHashMap; import gnu.trove.map.hash.TIntObjectHashMap;
import net.osmand.binary.BinaryMapIndexReader.MapIndex; import net.osmand.binary.BinaryMapIndexReader.MapIndex;
import net.osmand.binary.BinaryMapIndexReader.TagValuePair; import net.osmand.binary.BinaryMapIndexReader.TagValuePair;
import net.osmand.osm.MapRenderingTypes;
public class BinaryMapDataObject { public class BinaryMapDataObject {
protected int[] coordinates = null; protected int[] coordinates = null;
@ -10,6 +11,7 @@ public class BinaryMapDataObject {
protected boolean area = false; protected boolean area = false;
protected int[] types = null; protected int[] types = null;
protected int[] additionalTypes = null; protected int[] additionalTypes = null;
protected int objectType = MapRenderingTypes.POINT_TYPE;
protected TIntObjectHashMap<String> objectNames = null; protected TIntObjectHashMap<String> objectNames = null;
protected long id = 0; protected long id = 0;
@ -35,11 +37,12 @@ public class BinaryMapDataObject {
return name; return name;
} }
public String getRef(){ public int getObjectType() {
if(mapIndex.refEncodingType != -1 && objectNames != null) { return objectType;
return objectNames.get(mapIndex.refEncodingType); }
}
return null; public void setObjectType(int objectType) {
this.objectType = objectType;
} }
public TIntObjectHashMap<String> getObjectNames() { public TIntObjectHashMap<String> getObjectNames() {
@ -54,6 +57,35 @@ public class BinaryMapDataObject {
return types; return types;
} }
public boolean containsType(int cachedType) {
if(cachedType != -1) {
for(int i=0; i<types.length; i++){
if(types[i] == cachedType) {
return true;
}
}
}
return false;
}
public boolean containsAdditionalType(int cachedType) {
if (cachedType != -1) {
for (int i = 0; i < additionalTypes.length; i++) {
if (additionalTypes[i] == cachedType) {
return true;
}
}
}
return false;
}
public String getNameByType(int type) {
if(type != -1 && objectNames != null) {
return objectNames.get(type);
}
return null;
}
public int[] getAdditionalTypes() { public int[] getAdditionalTypes() {
return additionalTypes; return additionalTypes;
} }
@ -62,15 +94,20 @@ public class BinaryMapDataObject {
return area; return area;
} }
public boolean isCycle(){
if(coordinates == null || coordinates.length < 2) {
return false;
}
return coordinates[0] == coordinates[coordinates.length - 2] &&
coordinates[1] == coordinates[coordinates.length - 1];
}
public void setArea(boolean area) { public void setArea(boolean area) {
this.area = area; this.area = area;
} }
public TagValuePair getTagValue(int indType){ public TagValuePair getTagValue(int indType){
if(mapIndex == null){ throw new UnsupportedOperationException("This functions is deprecated and should be deleted");
return null;
}
return mapIndex.decodeType(types[indType]);
} }
public long getId() { public long getId() {
@ -86,6 +123,20 @@ public class BinaryMapDataObject {
} }
public int getSimpleLayer(){
if(mapIndex != null) {
for (int i = 0; i < additionalTypes.length; i++) {
if (mapIndex.positiveLayers.contains(additionalTypes[i])) {
return 1;
} else if (mapIndex.negativeLayers.contains(additionalTypes[i])) {
return -1;
}
}
}
return 0;
}
public MapIndex getMapIndex() { public MapIndex getMapIndex() {
return mapIndex; return mapIndex;
} }

View file

@ -3,6 +3,7 @@ package net.osmand.binary;
import gnu.trove.list.array.TIntArrayList; import gnu.trove.list.array.TIntArrayList;
import gnu.trove.map.TIntObjectMap; import gnu.trove.map.TIntObjectMap;
import gnu.trove.map.hash.TIntObjectHashMap; import gnu.trove.map.hash.TIntObjectHashMap;
import gnu.trove.set.hash.TIntHashSet;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
@ -564,22 +565,6 @@ public class BinaryMapIndexReader {
} }
} }
private void initMapEncodingRule(MapIndex index, int type, int id, String tag, String val) {
if(!index.encodingRules.containsKey(tag)){
index.encodingRules.put(tag, new LinkedHashMap<String, Integer>());
}
index.encodingRules.get(tag).put(val, id);
if("name".equals(tag)){
index.nameEncodingType = id;
} else if("natural".equals(tag) && "coastline".equals(val)){
index.coastlineEncodingType = id;
} else if("ref".equals(tag)){
index.refEncodingType = id;
}
if(!index.decodingRules.containsKey(id)){
index.decodingRules.put(id, new TagValuePair(tag, val, type));
}
}
private void readMapEncodingRule(MapIndex index, int id) throws IOException { private void readMapEncodingRule(MapIndex index, int id) throws IOException {
int type = 0; int type = 0;
@ -590,7 +575,7 @@ public class BinaryMapIndexReader {
int tag = WireFormat.getTagFieldNumber(t); int tag = WireFormat.getTagFieldNumber(t);
switch (tag) { switch (tag) {
case 0: case 0:
initMapEncodingRule(index, type, id, tags, val); index.initMapEncodingRule(type, id, tags, val);
return; return;
case MapEncodingRule.VALUE_FIELD_NUMBER : case MapEncodingRule.VALUE_FIELD_NUMBER :
val = codedIS.readString().intern(); val = codedIS.readString().intern();
@ -1329,6 +1314,10 @@ public class BinaryMapIndexReader {
public int nameEncodingType = 0; public int nameEncodingType = 0;
public int refEncodingType = -1; public int refEncodingType = -1;
public int coastlineEncodingType = -1; public int coastlineEncodingType = -1;
public int onewayAttribute = -1;
public int onewayReverseAttribute = -1;
public TIntHashSet positiveLayers = new TIntHashSet(2);
public TIntHashSet negativeLayers = new TIntHashSet(2);
public List<MapRoot> getRoots() { public List<MapRoot> getRoots() {
return roots; return roots;
@ -1338,6 +1327,36 @@ public class BinaryMapIndexReader {
return decodingRules.get(type); return decodingRules.get(type);
} }
private void initMapEncodingRule(int type, int id, String tag, String val) {
if(!encodingRules.containsKey(tag)){
encodingRules.put(tag, new LinkedHashMap<String, Integer>());
}
encodingRules.get(tag).put(val, id);
if(!decodingRules.containsKey(id)){
decodingRules.put(id, new TagValuePair(tag, val, type));
}
if("name".equals(tag)){
nameEncodingType = id;
} else if("natural".equals(tag) && "coastline".equals(val)){
coastlineEncodingType = id;
} else if("oneway".equals(tag) && "yes".equals(val)){
onewayAttribute = id;
} else if("oneway".equals(tag) && "-1".equals(val)){
onewayReverseAttribute = id;
} else if("ref".equals(tag)){
refEncodingType = id;
} else if("layer".equals(tag)){
if(val != null && !val.equals("0") && val.length() > 0) {
if(val.startsWith("-")) {
negativeLayers.add(id);
} else {
positiveLayers.add(id);
}
}
}
}
} }
public static class TagValuePair { public static class TagValuePair {

View file

@ -39,7 +39,10 @@ public class RenderingRuleStorageProperties {
public static final String ICON = "icon"; public static final String ICON = "icon";
public static final String LAYER = "layer"; public static final String LAYER = "layer";
public static final String ORDER = "order"; public static final String ORDER = "order";
public static final String ORDER_TYPE = "orderType"; public static final String OBJECT_TYPE = "objectType";
public static final String POINT = "point";
public static final String AREA = "area";
public static final String CYCLE = "cycle";
public static final String TAG = "tag"; public static final String TAG = "tag";
public static final String VALUE = "value"; public static final String VALUE = "value";
public static final String MINZOOM = "minzoom"; public static final String MINZOOM = "minzoom";
@ -82,7 +85,10 @@ public class RenderingRuleStorageProperties {
public RenderingRuleProperty R_ICON; public RenderingRuleProperty R_ICON;
public RenderingRuleProperty R_LAYER; public RenderingRuleProperty R_LAYER;
public RenderingRuleProperty R_ORDER; public RenderingRuleProperty R_ORDER;
public RenderingRuleProperty R_ORDER_TYPE; public RenderingRuleProperty R_POINT;
public RenderingRuleProperty R_AREA;
public RenderingRuleProperty R_CYCLE;
public RenderingRuleProperty R_OBJECT_TYPE;
public RenderingRuleProperty R_TAG; public RenderingRuleProperty R_TAG;
public RenderingRuleProperty R_VALUE; public RenderingRuleProperty R_VALUE;
public RenderingRuleProperty R_MINZOOM; public RenderingRuleProperty R_MINZOOM;
@ -121,11 +127,13 @@ public class RenderingRuleStorageProperties {
R_MAXZOOM = registerRuleInternal(RenderingRuleProperty.createInputLessIntProperty(MAXZOOM)); R_MAXZOOM = registerRuleInternal(RenderingRuleProperty.createInputLessIntProperty(MAXZOOM));
R_NIGHT_MODE = registerRuleInternal(RenderingRuleProperty.createInputBooleanProperty(NIGHT_MODE)); R_NIGHT_MODE = registerRuleInternal(RenderingRuleProperty.createInputBooleanProperty(NIGHT_MODE));
R_LAYER = registerRuleInternal(RenderingRuleProperty.createInputIntProperty(LAYER)); R_LAYER = registerRuleInternal(RenderingRuleProperty.createInputIntProperty(LAYER));
R_ORDER_TYPE = registerRuleInternal(RenderingRuleProperty.createInputIntProperty(ORDER_TYPE)); R_POINT = registerRuleInternal(RenderingRuleProperty.createInputBooleanProperty(POINT));
R_AREA = registerRuleInternal(RenderingRuleProperty.createInputBooleanProperty(AREA));
R_CYCLE = registerRuleInternal(RenderingRuleProperty.createInputBooleanProperty(CYCLE));
R_TEXT_LENGTH = registerRuleInternal(RenderingRuleProperty.createInputIntProperty(TEXT_LENGTH)); R_TEXT_LENGTH = registerRuleInternal(RenderingRuleProperty.createInputIntProperty(TEXT_LENGTH));
R_REF = registerRuleInternal(RenderingRuleProperty.createInputBooleanProperty(REF)); R_REF = registerRuleInternal(RenderingRuleProperty.createInputBooleanProperty(REF));
R_ATTR_INT_VALUE = registerRuleInternal(RenderingRuleProperty.createOutputIntProperty(ATTR_INT_VALUE)); R_ATTR_INT_VALUE = registerRuleInternal(RenderingRuleProperty.createOutputIntProperty(ATTR_INT_VALUE));
R_ATTR_BOOL_VALUE = registerRuleInternal(RenderingRuleProperty.createOutputBooleanProperty(ATTR_BOOL_VALUE)); R_ATTR_BOOL_VALUE = registerRuleInternal(RenderingRuleProperty.createOutputBooleanProperty(ATTR_BOOL_VALUE));
R_ATTR_COLOR_VALUE = registerRuleInternal(RenderingRuleProperty.createOutputColorProperty(ATTR_COLOR_VALUE)); R_ATTR_COLOR_VALUE = registerRuleInternal(RenderingRuleProperty.createOutputColorProperty(ATTR_COLOR_VALUE));
@ -133,6 +141,7 @@ public class RenderingRuleStorageProperties {
// order - no sense to make it float // order - no sense to make it float
R_ORDER = registerRuleInternal(RenderingRuleProperty.createOutputIntProperty(ORDER)); R_ORDER = registerRuleInternal(RenderingRuleProperty.createOutputIntProperty(ORDER));
R_OBJECT_TYPE = registerRuleInternal(RenderingRuleProperty.createInputIntProperty(OBJECT_TYPE));
R_SHADOW_LEVEL = registerRuleInternal(RenderingRuleProperty.createOutputIntProperty(SHADOW_LEVEL)); R_SHADOW_LEVEL = registerRuleInternal(RenderingRuleProperty.createOutputIntProperty(SHADOW_LEVEL));
// text properties // text properties

View file

@ -453,7 +453,6 @@ public class RenderingRulesStorage {
searchRequest.setIntFilter(storage.PROPS.R_LAYER, 1); searchRequest.setIntFilter(storage.PROPS.R_LAYER, 1);
searchRequest.setIntFilter(storage.PROPS.R_MINZOOM, 15); searchRequest.setIntFilter(storage.PROPS.R_MINZOOM, 15);
searchRequest.setIntFilter(storage.PROPS.R_MAXZOOM, 15); searchRequest.setIntFilter(storage.PROPS.R_MAXZOOM, 15);
searchRequest.setIntFilter(storage.PROPS.R_ORDER_TYPE, 2);
// searchRequest.setBooleanFilter(storage.PROPS.R_NIGHT_MODE, true); // searchRequest.setBooleanFilter(storage.PROPS.R_NIGHT_MODE, true);
// searchRequest.setBooleanFilter(storage.PROPS.get("hmRendered"), true); // searchRequest.setBooleanFilter(storage.PROPS.get("hmRendered"), true);

View file

@ -75,13 +75,57 @@
--> -->
<!-- input exact layer, orderType check tag, value --> <!-- input layer check tag, value, point, cycle, area -->
<!-- point = 1, line = 2, polygon = 3 --> <!-- output ! objectType point = 1, line = 2, polygon = 3 and order -->
<order> <order>
<!-- point has order 128 --> <!-- point has order 128 -->
<filter tag="" value="" order="128" orderType="1"/> <filter tag="" value="" point="true" order="128" objectType="1"/>
<!-- default polygon -->
<filter cycle="true" layer="-1" tag="" value="" order="1" objectType="3"/>
<filter area="true" layer="-1" tag="" value="" order="1" objectType="3"/>
<!-- default line -->
<filter layer="-1" tag="" value="" order="10" objectType="2"/>
<filter tag="" value="" order="11" objectType="2"/>
<group orderType="3">
<filter layer="-1" tag="building" value="" order="1"/>
<filter tag="building" value="" order="64"/>
<group orderType="2"> <filter tag="railway" value="" order="58"/>
<filter tag="highway" value="road" order="35"/>
<filter tag="highway" value="unclassified" order="35"/>
<filter tag="highway" value="residential" order="35"/>
<filter tag="highway" value="service" order="35"/>
<filter tag="highway" value="pedestrian" order="35"/>
<filter tag="highway" value="footway" order="35"/>
<filter tag="highway" value="" order="35"/>
<filter tag="aeroway" value="" order="35"/>
<filter tag="power" value="" order="7"/>
<filter tag="amenity" value="" order="7"/>
<filter tag="tourism" value="" order="7"/>
<filter tag="military" value="" order="7"/>
<filter tag="leisure" value="" order="7"/>
<filter tag="waterway" value="" order="6"/>
<filter tag="landuse" value="reservoir" order="5"/>
<filter tag="landuse" value="water" order="5"/>
<filter tag="landuse" value="" order="1"/>
<filter tag="natural" value="water" order="5"/>
<filter tag="natural" value="bay" order="5"/>
<filter tag="natural" value="coastline" order="1"/>
<filter tag="natural" value="" order="1"/>
<groupFilter>
<filter cycle="true"/>
<filter area="true"/>
</groupFilter>
</group>
<group objectType="2">
<!-- Over buildings --> <!-- Over buildings -->
<filter tag="aerialway" value="" order="68"/> <filter tag="aerialway" value="" order="68"/>
<filter tag="power" value="" order="68"/> <filter tag="power" value="" order="68"/>
@ -189,46 +233,9 @@
<filter tag="admin_level" value="0" order="0"/> <filter tag="admin_level" value="0" order="0"/>
<filter tag="admin_level" value="1" order="0"/> <filter tag="admin_level" value="1" order="0"/>
<filter layer="-1" tag="" value="" order="10"/>
<filter tag="" value="" order="11"/>
</group> </group>
<group orderType="3">
<filter layer="-1" tag="building" value="" order="1"/>
<filter tag="building" value="" order="64"/>
<filter tag="railway" value="" order="58"/>
<filter tag="highway" value="road" order="35"/>
<filter tag="highway" value="unclassified" order="35"/>
<filter tag="highway" value="residential" order="35"/>
<filter tag="highway" value="service" order="35"/>
<filter tag="highway" value="pedestrian" order="35"/>
<filter tag="highway" value="footway" order="35"/>
<filter tag="highway" value="" order="35"/>
<filter tag="aeroway" value="" order="35"/>
<filter tag="power" value="" order="7"/>
<filter tag="amenity" value="" order="7"/>
<filter tag="tourism" value="" order="7"/>
<filter tag="military" value="" order="7"/>
<filter tag="leisure" value="" order="7"/>
<filter tag="waterway" value="" order="6"/>
<filter tag="landuse" value="reservoir" order="5"/>
<filter tag="landuse" value="water" order="5"/>
<filter tag="landuse" value="" order="1"/>
<filter tag="natural" value="water" order="5"/>
<filter tag="natural" value="bay" order="5"/>
<filter tag="natural" value="coastline" order="1"/>
<filter tag="natural" value="" order="1"/>
<filter layer="-1" tag="" value="" order="1"/>
<filter tag="" value="" order="1"/>
</group>
</order> </order>

View file

@ -698,8 +698,9 @@ public class BinaryRoutePlanner {
startLat+"", startLon+"", endLat+"", endLon+"")); startLat+"", startLon+"", endLat+"", endLon+""));
for (RouteSegmentResult res : result) { for (RouteSegmentResult res : result) {
String name = res.object.getName(); String name = res.object.getName();
if(res.object.getRef() != null) { String ref = res.object.getNameByType(res.object.getMapIndex().refEncodingType);
name += " " + res.object.getRef(); if(ref != null) {
name += " " + ref;
} }
// (res.object.getId() >> 1) // (res.object.getId() >> 1)
System.out.println(MessageFormat.format("\t<segment id=\"{0}\" start=\"{1}\" end=\"{2}\" name=\"{3}\"/>", System.out.println(MessageFormat.format("\t<segment id=\"{0}\" start=\"{1}\" end=\"{2}\" name=\"{3}\"/>",

View file

@ -374,18 +374,14 @@ public class MapRenderRepositories {
} }
count++; count++;
for (int i = 0; i < r.getTypes().length; i++) { // TODO refactor !
if (r.getTypes()[i] == r.getMapIndex().coastlineEncodingType) { if(r.containsType(r.getMapIndex().coastlineEncodingType)) {
// multy polygon r.getId() >> 3 TagValuePair pair = r.getMapIndex().decodeType(r.getMapIndex().coastlineEncodingType);
TagValuePair pair = r.getMapIndex().decodeType(r.getTypes()[i]); pair = new TagValuePair(pair.tag, pair.value, 0);
if (pair != null) { if (!multiPolygons.containsKey(pair)) {
pair = new TagValuePair(pair.tag, pair.value, r.getTypes()[i]); multiPolygons.put(pair, new ArrayList<BinaryMapDataObject>());
if (!multiPolygons.containsKey(pair)) {
multiPolygons.put(pair, new ArrayList<BinaryMapDataObject>());
}
multiPolygons.get(pair).add(r);
}
} }
multiPolygons.get(pair).add(r);
} }
if (checkWhetherInterrupted()) { if (checkWhetherInterrupted()) {
return false; return false;

View file

@ -36,7 +36,6 @@ import android.graphics.Paint.Style;
import android.graphics.Path; import android.graphics.Path;
import android.graphics.PathEffect; import android.graphics.PathEffect;
import android.graphics.PointF; import android.graphics.PointF;
import android.graphics.Xfermode;
import android.graphics.PorterDuff.Mode; import android.graphics.PorterDuff.Mode;
import android.graphics.PorterDuffColorFilter; import android.graphics.PorterDuffColorFilter;
import android.graphics.Shader; import android.graphics.Shader;
@ -382,42 +381,37 @@ public class OsmandRenderer {
BinaryMapDataObject o = objects.get(i); BinaryMapDataObject o = objects.get(i);
int sh = i << 8; int sh = i << 8;
if (o instanceof MultyPolygon) { if (o instanceof MultyPolygon) {
int layer = ((MultyPolygon) o).getLayer(); //FIXME Multipolygon : 1
render.setTagValueZoomLayer(((MultyPolygon) o).getTag(), ((MultyPolygon) o).getValue(), rc.zoom, layer); // int layer = ((MultyPolygon) o).getLayer();
render.setIntFilter(render.ALL.R_ORDER_TYPE, MapRenderingTypes.POLYGON_TYPE); // render.setTagValueZoomLayer(((MultyPolygon) o).getTag(), ((MultyPolygon) o).getValue(), rc.zoom, layer);
if(render.search(RenderingRulesStorage.ORDER_RULES)) { // render.setIntFilter(render.ALL.R_ORDER_TYPE, MapRenderingTypes.POLYGON_TYPE);
int order = render.getIntPropertyValue(render.ALL.R_ORDER); // if(render.search(RenderingRulesStorage.ORDER_RULES)) {
put(orderMap, order, sh, init); // int order = render.getIntPropertyValue(render.ALL.R_ORDER);
if(render.isSpecified(render.ALL.R_SHADOW_LEVEL)){ // put(orderMap, order, sh, init);
rc.shadowLevelMin = Math.min(rc.shadowLevelMin, order); // if(render.isSpecified(render.ALL.R_SHADOW_LEVEL)){
rc.shadowLevelMax = Math.max(rc.shadowLevelMax, order); // rc.shadowLevelMin = Math.min(rc.shadowLevelMin, order);
render.clearValue(render.ALL.R_SHADOW_LEVEL); // rc.shadowLevelMax = Math.max(rc.shadowLevelMax, order);
} // render.clearValue(render.ALL.R_SHADOW_LEVEL);
} // }
// }
} else { } else {
for (int j = 0; j < o.getTypes().length; j++) { for (int j = 0; j < o.getTypes().length; j++) {
// put(orderMap, BinaryMapDataObject.getOrder(o.getTypes()[j]), sh + j, init); // put(orderMap, BinaryMapDataObject.getOrder(o.getTypes()[j]), sh + j, init);
int wholeType = o.getTypes()[j]; int wholeType = o.getTypes()[j];
int mask = MapRenderingTypes.POINT_TYPE;
if(o.getPointsLength() > 1) {
if(o.isArea()){
mask = MapRenderingTypes.POLYGON_TYPE;
} else {
mask = MapRenderingTypes.POLYLINE_TYPE;
}
}
int layer = 0; int layer = 0;
if (mask != MapRenderingTypes.POINT_TYPE) { if (o.getPointsLength() > 1) {
// FIXME Layer layer = o.getSimpleLayer();
// layer = MapRenderingTypes.getNegativeWayLayer(wholeType);
} }
TagValuePair pair = o.getMapIndex().decodeType(wholeType); TagValuePair pair = o.getMapIndex().decodeType(wholeType);
if (pair != null) { if (pair != null) {
render.setTagValueZoomLayer(pair.tag, pair.value, rc.zoom, layer); render.setTagValueZoomLayer(pair.tag, pair.value, rc.zoom, layer);
render.setIntFilter(render.ALL.R_ORDER_TYPE, mask); render.setBooleanFilter(render.ALL.R_AREA, o.isArea());
render.setBooleanFilter(render.ALL.R_POINT, o.getPointsLength() == 1);
render.setBooleanFilter(render.ALL.R_CYCLE, o.isCycle());
if (render.search(RenderingRulesStorage.ORDER_RULES)) { if (render.search(RenderingRulesStorage.ORDER_RULES)) {
o.setObjectType(render.getIntPropertyValue(render.ALL.R_OBJECT_TYPE));
int order = render.getIntPropertyValue(render.ALL.R_ORDER); int order = render.getIntPropertyValue(render.ALL.R_ORDER);
put(orderMap, order, sh + j, init); put(orderMap, order, sh + j, init);
if (render.isSpecified(render.ALL.R_SHADOW_LEVEL)) { if (render.isSpecified(render.ALL.R_SHADOW_LEVEL)) {
@ -450,19 +444,18 @@ public class OsmandRenderer {
boolean renderText, boolean drawOnlyShadow) { boolean renderText, boolean drawOnlyShadow) {
rc.allObjects++; rc.allObjects++;
if (obj instanceof MultyPolygon) { if (obj instanceof MultyPolygon) {
// TODO
if(!drawOnlyShadow){ if(!drawOnlyShadow){
drawMultiPolygon(obj, render, canvas, rc); drawMultiPolygon(obj, render, canvas, rc);
} }
} else { } else {
int mainType = obj.getTypes()[l]; int type = obj.getObjectType();
TagValuePair pair = obj.getMapIndex().decodeType(mainType); TagValuePair pair = obj.getMapIndex().decodeType(obj.getTypes()[l]);
if (obj.getPointsLength() == 1 && !drawOnlyShadow) { if (type == MapRenderingTypes.POINT_TYPE && !drawOnlyShadow) {
drawPoint(obj, render, canvas, rc, pair, renderText); drawPoint(obj, render, canvas, rc, pair, renderText);
} else if (!obj.isArea()) { } else if (type == MapRenderingTypes.POLYLINE_TYPE) {
// FIXME Layer drawPolyline(obj, render, canvas, rc, pair, obj.getSimpleLayer(), drawOnlyShadow);
// int layer = MapRenderingTypes.getNegativeWayLayer(mainType); } else if (type == MapRenderingTypes.POLYGON_TYPE && !drawOnlyShadow) {
drawPolyline(obj, render, canvas, rc, pair, 0, drawOnlyShadow);
} else if (obj.isArea() && !drawOnlyShadow) {
drawPolygon(obj, render, canvas, rc, pair); drawPolygon(obj, render, canvas, rc, pair);
} }
} }
@ -738,11 +731,14 @@ public class OsmandRenderer {
if(!rendered || !updatePaint(render, paint, 0, false, rc)){ if(!rendered || !updatePaint(render, paint, 0, false, rc)){
return; return;
} }
boolean oneway = false; int oneway = 0;
//FIXME oneway if(rc.zoom >= 16 && "highway".equals(pair.tag) ){ //$NON-NLS-1$
// if(rc.zoom >= 16 && "highway".equals(pair.tag) && MapRenderingTypes.isOneWayWay(obj.getHighwayAttributes())){ //$NON-NLS-1$ if(obj.containsAdditionalType(obj.getMapIndex().onewayAttribute)) {
// oneway = true; oneway = 1;
// } } else if(obj.containsAdditionalType(obj.getMapIndex().onewayReverseAttribute)){
oneway = -1;
}
}
rc.visible++; rc.visible++;
@ -789,8 +785,8 @@ public class OsmandRenderer {
} }
} }
if(oneway && !drawOnlyShadow){ if(oneway != 0 && !drawOnlyShadow){
Paint[] paints = getOneWayPaints(); Paint[] paints = oneway == -1? getReverseOneWayPaints() : getOneWayPaints();
for (int i = 0; i < paints.length; i++) { for (int i = 0; i < paints.length; i++) {
canvas.drawPath(path, paints[i]); canvas.drawPath(path, paints[i]);
} }
@ -803,6 +799,7 @@ public class OsmandRenderer {
private static Paint[] oneWay = null; private static Paint[] oneWay = null;
private static Paint[] reverseOneWay = null;
private static Paint oneWayPaint(){ private static Paint oneWayPaint(){
Paint oneWay = new Paint(); Paint oneWay = new Paint();
oneWay.setStyle(Style.STROKE); oneWay.setStyle(Style.STROKE);
@ -811,6 +808,33 @@ public class OsmandRenderer {
return oneWay; return oneWay;
} }
public static Paint[] getReverseOneWayPaints(){
if(reverseOneWay == null){
PathEffect arrowDashEffect1 = new DashPathEffect(new float[] { 0, 12, 10, 152 }, 0);
PathEffect arrowDashEffect2 = new DashPathEffect(new float[] { 0, 13, 9, 152 }, 1);
PathEffect arrowDashEffect3 = new DashPathEffect(new float[] { 0, 14, 2, 148 }, 1);
PathEffect arrowDashEffect4 = new DashPathEffect(new float[] { 0, 15, 1, 148 }, 1);
reverseOneWay = new Paint[4];
reverseOneWay[0] = oneWayPaint();
reverseOneWay[0].setStrokeWidth(1);
reverseOneWay[0].setPathEffect(arrowDashEffect1);
reverseOneWay[1] = oneWayPaint();
reverseOneWay[1].setStrokeWidth(2);
reverseOneWay[1].setPathEffect(arrowDashEffect2);
reverseOneWay[2] = oneWayPaint();
reverseOneWay[2].setStrokeWidth(3);
reverseOneWay[2].setPathEffect(arrowDashEffect3);
reverseOneWay[3] = oneWayPaint();
reverseOneWay[3].setStrokeWidth(4);
reverseOneWay[3].setPathEffect(arrowDashEffect4);
}
return oneWay;
}
public static Paint[] getOneWayPaints(){ public static Paint[] getOneWayPaints(){
if(oneWay == null){ if(oneWay == null){
PathEffect arrowDashEffect1 = new DashPathEffect(new float[] { 0, 12, 10, 152 }, 0); PathEffect arrowDashEffect1 = new DashPathEffect(new float[] { 0, 12, 10, 152 }, 0);

View file

@ -326,11 +326,8 @@ public class TextRenderer {
public void renderText(BinaryMapDataObject obj, RenderingRuleSearchRequest render, RenderingContext rc, TagValuePair pair, public void renderText(BinaryMapDataObject obj, RenderingRuleSearchRequest render, RenderingContext rc, TagValuePair pair,
float xMid, float yMid, Path path, PointF[] points) { float xMid, float yMid, Path path, PointF[] points) {
// TODO other render text // TODO other render text
String ref = null; String ref = obj.getNameByType(obj.getMapIndex().refEncodingType);
if(obj.getMapIndex().refEncodingType >= 0 ) { String name = obj.getNameByType(obj.getMapIndex().nameEncodingType);
ref = obj.getObjectNames().get(obj.getMapIndex().refEncodingType);
}
String name = obj.getObjectNames().get(obj.getMapIndex().nameEncodingType);
if(ref != null && ref.trim().length() > 0){ if(ref != null && ref.trim().length() > 0){
createTextDrawInfo(render, rc, pair, xMid, yMid, path, points, ref, true); createTextDrawInfo(render, rc, pair, xMid, yMid, path, points, ref, true);
} }