Commit poi with name

This commit is contained in:
Victor Shcherb 2015-01-06 21:45:58 +01:00
parent 7a7d2b325a
commit c95dcf10e4
3 changed files with 19 additions and 9 deletions

View file

@ -60,13 +60,13 @@ public class BinaryInspector {
// test cases show info
if(args.length == 1 && "test".equals(args[0])) {
in.inspector(new String[]{
//"-vpoi",
"-vpoi",
// "-vmap", "-vmapobjects",
// "-vrouting",
// "-vaddress", "-vcities", "-vstreets", "-vstreetgroups","-vbuildings",
//"-zoom=16",
//"-bbox=4,55,7,50",
// "/home/victor/projects/osmand/osm-gen/Map.obf"
"/home/victor/projects/osmand/osm-gen/Map.obf"
});
} else {
in.inspector(args);

View file

@ -305,6 +305,7 @@ public class MapRenderingTypes {
rType.poiSpecified = parent.poiSpecified;
rType.poiCategory = parent.poiCategory;
rType.poiPrefix = parent.poiPrefix;
rType.poiWithNameOnly = parent.poiWithNameOnly;
rType.namePrefix = parent.namePrefix;
rType = registerRuleType(rType);
}
@ -375,15 +376,15 @@ public class MapRenderingTypes {
return null;
}
public AmenityType getAmenityType(String tag, String val){
return getAmenityType(tag, val, false);
public AmenityType getAmenityType(String tag, String val, boolean hasName){
return getAmenityType(tag, val, false, hasName);
}
public AmenityType getAmenityTypeForRelation(String tag, String val){
return getAmenityType(tag, val, true);
public AmenityType getAmenityTypeForRelation(String tag, String val, boolean hasName){
return getAmenityType(tag, val, true, hasName);
}
private AmenityType getAmenityType(String tag, String val, boolean relation){
private AmenityType getAmenityType(String tag, String val, boolean relation, boolean hasName){
// register amenity types
Map<String, MapRulType> rules = getEncodingRuleTypes();
MapRulType rt = rules.get(constructRuleKey(tag, val));
@ -391,6 +392,9 @@ public class MapRenderingTypes {
if((relation && !rt.relation) || rt.isAdditionalOrText()) {
return null;
}
if(rt.poiWithNameOnly && !hasName) {
return null;
}
return rt.poiCategory;
}
rt = rules.get(constructRuleKey(tag, null));
@ -398,6 +402,9 @@ public class MapRenderingTypes {
if((relation && !rt.relation) || rt.isAdditionalOrText()) {
return null;
}
if(rt.poiWithNameOnly && !hasName) {
return null;
}
return rt.poiCategory;
}
return null;
@ -526,6 +533,7 @@ public class MapRenderingTypes {
rtype.poiCategory = AmenityType.getAndRegisterType(poiCategory);
}
}
rtype.poiWithNameOnly = Boolean.parseBoolean(parser.getAttributeValue("", "poi_with_name"));
String poiPrefix = parser.getAttributeValue("", "poi_prefix");
if (poiPrefix != null) {
rtype.poiPrefix = poiPrefix;
@ -704,6 +712,7 @@ public class MapRenderingTypes {
protected String category = null;
protected String poiPrefix;
protected boolean poiWithNameOnly;
protected AmenityType poiCategory;
// poi_category was specially removed for one tag/value, to skip unnecessary objects
protected boolean poiSpecified;

View file

@ -114,9 +114,10 @@ public class EntityParser {
for(Map<String, String> tags : it) {
if (!tags.isEmpty()) {
boolean purerelation = relation && !"multipolygon".equals(tags.get("type"));
boolean hasName = !Algorithms.isEmpty(tags.get("name"));
for (Map.Entry<String, String> e : tags.entrySet()) {
AmenityType type = purerelation ? renderingTypes.getAmenityTypeForRelation(e.getKey(), e.getValue())
: renderingTypes.getAmenityType(e.getKey(), e.getValue());
AmenityType type = purerelation ? renderingTypes.getAmenityTypeForRelation(e.getKey(), e.getValue(), hasName)
: renderingTypes.getAmenityType(e.getKey(), e.getValue(), hasName );
if (type != null) {
String subtype = renderingTypes.getAmenitySubtype(e.getKey(), e.getValue());
Amenity a = parseAmenity(entity, type, subtype, tags, renderingTypes);