Update rendering types

This commit is contained in:
Victor Shcherb 2013-07-15 00:21:48 +02:00
parent d3c2545dcf
commit d99c5a9dca
5 changed files with 45 additions and 48 deletions

View file

@ -64,8 +64,34 @@ public class MapRenderingTypes {
init();
}
}
public void getAmenityTagValue(AmenityType type, String subType, StringBuilder tag, StringBuilder value) {
tag.setLength(0);
tag.append(type.getDefaultTag());
value.setLength(0);
value.append(subType);
Map<AmenityType, Map<String, String>> m = getAmenityTypeNameToTagVal();
if (m.containsKey(type)) {
Map<String, String> map = m.get(type);
if (map.containsKey(subType)) {
String res = map.get(subType);
if (res != null) {
int i = res.indexOf(' ');
if (i != -1) {
tag.setLength(0);
tag.append(res.substring(0, i));
value.setLength(0);
value.append(res.substring(i + 1));
} else {
tag.setLength(0);
tag.append(res);
}
}
}
}
}
public Map<AmenityType, Map<String, String>> getAmenityTypeNameToTagVal() {
private Map<AmenityType, Map<String, String>> getAmenityTypeNameToTagVal() {
if (amenityTypeNameToTagVal == null) {
Map<String, AmenityRuleType> types = getAmenityEncodingRuleTypes();
amenityTypeNameToTagVal = new LinkedHashMap<AmenityType, Map<String, String>>();
@ -90,6 +116,7 @@ public class MapRenderingTypes {
}
public Map<String, AmenityType> getAmenityNameToType(){
if(amenityNameToType == null){
amenityNameToType = new LinkedHashMap<String, AmenityType>();
@ -320,6 +347,6 @@ public class MapRenderingTypes {
protected boolean poiSpecified;
protected AmenityRuleType targetTagValue;
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.6 KiB

View file

@ -434,27 +434,11 @@ public class EditingPOIActivity implements DialogProvider {
final String msg = n.getId() == -1 ? resources.getString(R.string.poi_action_add) : resources
.getString(R.string.poi_action_change);
OsmPoint.Action action = n.getId() == -1 ? OsmPoint.Action.CREATE : OsmPoint.Action.MODIFY;
Map<AmenityType, Map<String, String>> typeNameToTagVal = MapRenderingTypes.getDefault().getAmenityTypeNameToTagVal();
AmenityType type = a.getType();
String tag = type.getDefaultTag();
StringBuilder tag = new StringBuilder();
StringBuilder value = new StringBuilder();
String subType = typeText.getText().toString();
String val = subType;
if (typeNameToTagVal.containsKey(type)) {
Map<String, String> map = typeNameToTagVal.get(type);
if (map.containsKey(subType)) {
String res = map.get(subType);
if (res != null) {
int i = res.indexOf(' ');
if (i != -1) {
tag = res.substring(0, i);
val = res.substring(i + 1);
} else {
tag = res;
}
}
}
}
n.putTag(tag, val);
MapRenderingTypes.getDefault().getAmenityTagValue(a.getType(), subType, tag, value);
n.putTag(tag.toString(), value.toString());
String name = nameText.getText().toString();
if(name.length() > 0) {
n.putTag(OSMTagKey.NAME.getValue(), name);

View file

@ -62,28 +62,10 @@ public class OpenstreetmapLocalUtil implements OpenstreetmapUtil {
Node entity = new Node(n.getLocation().getLatitude(),
n.getLocation().getLongitude(),
nodeId);
Map<AmenityType, Map<String, String>> typeNameToTagVal = MapRenderingTypes.getDefault().getAmenityTypeNameToTagVal();
AmenityType type = n.getType();
String tag = type.getDefaultTag();
String subType = n.getSubType();
String val = subType;
if (typeNameToTagVal.containsKey(type)) {
Map<String, String> map = typeNameToTagVal.get(type);
if (map.containsKey(subType)) {
String res = map.get(subType);
if (res != null) {
int i = res.indexOf(' ');
if (i != -1) {
tag = res.substring(0, i);
val = res.substring(i + 1);
} else {
tag = res;
}
}
}
}
entity.putTag(tag, val);
StringBuilder tag = new StringBuilder();
StringBuilder value = new StringBuilder();
MapRenderingTypes.getDefault().getAmenityTagValue(n.getType(), n.getSubType(), tag, value);
entity.putTag(tag.toString(), value.toString());
entity.putTag(OSMTagKey.NAME.getValue(), n.getName());
entity.putTag(OSMTagKey.OPENING_HOURS.getValue(), n.getOpeningHours());

View file

@ -10,6 +10,7 @@ import net.osmand.access.AccessibleToast;
import net.osmand.data.Amenity;
import net.osmand.data.AmenityType;
import net.osmand.data.LatLon;
import net.osmand.osm.MapRenderingTypes;
import net.osmand.plus.ContextMenuAdapter;
import net.osmand.plus.ContextMenuAdapter.OnContextMenuClick;
import net.osmand.plus.OsmAndFormatter;
@ -181,10 +182,13 @@ public class POIMapLayer extends OsmandMapLayer implements ContextMenuLayer.ICon
canvas.drawCircle(x, y, r, pointAltUI);
canvas.drawCircle(x, y, r, point);
String id = null;
if (RenderingIcons.containsIcon(o.getType().getDefaultTag() + "_" + o.getSubType())) {
id = o.getType().getDefaultTag() + "_" + o.getSubType();
} else if(RenderingIcons.containsIcon(o.getSubType())){
id = o.getSubType();
StringBuilder tag = new StringBuilder();
StringBuilder value = new StringBuilder();
MapRenderingTypes.getDefault().getAmenityTagValue(o.getType(), o.getSubType(), tag, value);
if (RenderingIcons.containsIcon(tag + "_" + value)) {
id = tag + "_" + value;
} else if(RenderingIcons.containsIcon(tag.toString())){
id = tag.toString();
}
if(id != null){
Bitmap bmp = RenderingIcons.getIcon(view.getContext(), id);