Merge remote-tracking branch 'origin/master'

This commit is contained in:
Weblate 2013-11-30 20:19:35 +01:00
commit 41698cfcd8
5 changed files with 110 additions and 18 deletions

View file

@ -58,8 +58,9 @@ public class BinaryInspector {
/*in.inspector(new String[]{
"-vpoi",
//"-vmap", "-vmapobjects",
//"-vstreets", "-bbox=14.4,50.1,14.5,50.01",
"/home/victor/projects/osmand/osm-gen/Map.obf"});*/
//"-vstreets",
"-bbox=4,55,7,50",
"/home/victor/projects/osmand/osm-gen/World_sea_map.obf"});*/
}
private void printToFile(String s) throws IOException {
@ -808,8 +809,8 @@ public class BinaryInspector {
PoiSubType st = p.subTypes.get(i);
println("\t\t\t" + st.name + " " + (st.text ? "text":(" encoded " + st.possibleValues.size())));
}
req.poiTypeFilter = null;//TODO: for test only
// index.searchPoi(p, req);
req.poiTypeFilter = null;//for test only
index.searchPoi(p, req);
}

View file

@ -38,6 +38,7 @@ public class AmenityType {
public static AmenityType ADMINISTRATIVE = reg("administrative", "administrative"); // [TAG] administrative //$NON-NLS-1$ //$NON-NLS-2$
public static AmenityType EDUCATION = reg("education", "amenity"); // school, ... //$NON-NLS-1$ //$NON-NLS-2$
public static AmenityType MAN_MADE = reg("man_made", "man_made"); // [TAG] man_made and others //$NON-NLS-1$ //$NON-NLS-2$
public static AmenityType SEAMARK = reg("seamark", "seamark"); // [TAG] seamark //$NON-NLS-1$ //$NON-NLS-2$
public static AmenityType SUSTENANCE = reg("sustenance", "amenity"); // restaurant, cafe, ... //$NON-NLS-1$ //$NON-NLS-2$
public static AmenityType SHOP = reg("shop", "shop"); // [TAG] amenity convenience = reg("", product); clothes,... //$NON-NLS-1$ //$NON-NLS-2$

View file

@ -6,6 +6,7 @@ import java.io.InputStream;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashMap;
@ -132,8 +133,89 @@ public class MapRenderingTypes {
return amenityTypeNameToTagVal;
}
public Iterator<Map<String, String>> splitTagsIntoDifferentObjects(final Map<String, String> tags) {
// check open sea maps tags
boolean seamark = false;
for(String s : tags.keySet()) {
if(s.startsWith("seamark:")) {
seamark = true;
break;
}
}
if(!seamark) {
return oneIterator(tags);
} else {
return splitOpenSeaMapsTags(tags);
}
}
private <T> Iterator<T> oneIterator(final T obj) {
return new Iterator<T>() {
boolean hasNext = true;
@Override
public void remove() {
throw new UnsupportedOperationException();
}
@Override
public T next() {
hasNext = false;
return obj;
}
@Override
public boolean hasNext() {
return hasNext;
}
};
}
private Iterator<Map<String, String>> splitOpenSeaMapsTags(final Map<String, String> tags) {
Map<String, Map<String, String>> groupByOpenSeamaps = new HashMap<String, Map<String, String>>();
Map<String, String> common = new HashMap<String, String>();
String ATTACHED_KEY = "seamark:attached";
String type = "";
for (String s : tags.keySet()) {
String value = tags.get(s);
if (s.equals("seamark:type")) {
type = value;
common.put(ATTACHED_KEY, openSeaType(value));
} else if (s.startsWith("seamark:")) {
String stype = s.substring("seamark:".length());
int ind = stype.indexOf(':');
if (ind == -1) {
common.put(s, value);
} else {
String group = openSeaType(stype.substring(0, ind));
String add = stype.substring(ind + 1);
if (!groupByOpenSeamaps.containsKey(group)) {
groupByOpenSeamaps.put(group, new HashMap<String, String>());
}
groupByOpenSeamaps.get(group).put("seamark:" + add, value);
}
} else {
common.put(s, value);
}
}
for (Entry<String, Map<String, String>> g : groupByOpenSeamaps.entrySet()) {
g.getValue().putAll(common);
g.getValue().put("seamark", g.getKey());
if (openSeaType(type).equals(g.getKey())) {
g.getValue().remove(ATTACHED_KEY);
g.getValue().put("seamark", type);
}
}
return groupByOpenSeamaps.values().iterator();
}
private String openSeaType(String value) {
if(value.equals("light_major") || value.equals("light_minor")) {
return "light";
}
return value;
}
public Map<String, AmenityType> getAmenityNameToType(){
if(amenityNameToType == null){
amenityNameToType = new LinkedHashMap<String, AmenityType>();
@ -275,14 +357,14 @@ public class MapRenderingTypes {
Map<String, MapRulType> rules = getEncodingRuleTypes();
MapRulType rt = rules.get(constructRuleKey(tag, val));
if(rt != null && rt.isPOISpecified()) {
if(relation && !rt.relation) {
if((relation && !rt.relation) || rt.isAdditionalOrText()) {
return null;
}
return rt.poiCategory;
}
rt = rules.get(constructRuleKey(tag, null));
if(rt != null && rt.isPOISpecified()) {
if(relation && !rt.relation) {
if((relation && !rt.relation) || rt.isAdditionalOrText()) {
return null;
}
return rt.poiCategory;
@ -729,5 +811,7 @@ public class MapRenderingTypes {
}
}

View file

@ -1,7 +1,8 @@
package net.osmand.osm.edit;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import net.osmand.data.Amenity;
import net.osmand.data.AmenityType;
@ -102,19 +103,23 @@ public class EntityParser {
public static List<Amenity> parseAmenities(MapRenderingTypes renderingTypes,
Entity entity, List<Amenity> amenitiesList){
amenitiesList.clear();
// it could be collection of amenities
boolean relation = entity instanceof Relation;
Collection<String> keySet = entity.getTagKeySet();
if (!keySet.isEmpty()) {
boolean purerelation = relation && !"multipolygon".equals(entity.getTag("type"));
for (String t : keySet) {
AmenityType type = purerelation? renderingTypes.getAmenityTypeForRelation(t, entity.getTag(t)):
renderingTypes.getAmenityType(t, entity.getTag(t));
if (type != null) {
String subtype = renderingTypes.getAmenitySubtype(t, entity.getTag(t));
Amenity a = parseAmenity(entity, type, subtype, renderingTypes);
if(checkAmenitiesToAdd(a, amenitiesList) && !"no".equals(subtype)){
amenitiesList.add(a);
Iterator<Map<String, String>> it = renderingTypes.splitTagsIntoDifferentObjects(entity.getTags());
while (it.hasNext()) {
Map<String, String> tags = it.next();
if (!tags.isEmpty()) {
boolean purerelation = relation && !"multipolygon".equals(tags.get("type"));
for (Map.Entry<String, String> e : tags.entrySet()) {
AmenityType type = purerelation ? renderingTypes.getAmenityTypeForRelation(e.getKey(), e.getValue())
: renderingTypes.getAmenityType(e.getKey(), e.getValue());
if (type != null) {
String subtype = renderingTypes.getAmenitySubtype(e.getKey(), e.getValue());
Amenity a = parseAmenity(entity, type, subtype, renderingTypes);
if (checkAmenitiesToAdd(a, amenitiesList) && !"no".equals(subtype)) {
amenitiesList.add(a);
}
}
}
}

View file

@ -9,6 +9,7 @@
3. All your modified/created strings are in the top of the file (to make easier find what\'s translated).
PLEASE: Have a look at http://code.google.com/p/osmand/wiki/UIConsistency, it may really improve your and our work :-) Thx - Hardy
-->
<string name="amenity_type_seamark">Seamark</string>
<string name="app_modes_choose_descr">Choose available application modes in application</string>
<string name="app_modes_choose">Application Modes</string>
<string name="map_widget_appearance">Remaining elements:</string>