Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
00817771bf
4 changed files with 28 additions and 38 deletions
|
@ -56,11 +56,11 @@ public class BinaryInspector {
|
|||
in.inspector(args);
|
||||
// test cases show info
|
||||
/*in.inspector(new String[]{
|
||||
"-vpoi",
|
||||
//"-vmap", "-vmapobjects",
|
||||
//"-vpoi",
|
||||
"-vmap", "-vmapobjects",
|
||||
//"-vstreets",
|
||||
"-bbox=4,55,7,50",
|
||||
"/home/victor/projects/osmand/osm-gen/World_sea_map.obf"});*/
|
||||
"/home/victor/projects/osmand/osm-gen/World_seamarks_2.obf"});*/
|
||||
}
|
||||
|
||||
private void printToFile(String s) throws IOException {
|
||||
|
|
|
@ -12,13 +12,12 @@ import java.util.Iterator;
|
|||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
import java.util.TreeMap;
|
||||
|
||||
import net.osmand.PlatformUtil;
|
||||
import net.osmand.data.AmenityType;
|
||||
import net.osmand.osm.edit.Entity;
|
||||
import net.osmand.osm.edit.OSMSettings.OSMTagKey;
|
||||
import net.osmand.util.Algorithms;
|
||||
|
||||
|
@ -133,8 +132,17 @@ public class MapRenderingTypes {
|
|||
return amenityTypeNameToTagVal;
|
||||
}
|
||||
|
||||
public Iterator<Map<String, String>> splitTagsIntoDifferentObjects(final Map<String, String> tags) {
|
||||
public Collection<Map<String, String>> splitTagsIntoDifferentObjects(final Map<String, String> tags) {
|
||||
// check open sea maps tags
|
||||
boolean split = splitIsNeeded(tags);
|
||||
if(!split) {
|
||||
return Collections.singleton(tags);
|
||||
} else {
|
||||
return splitOpenSeaMapsTags(tags);
|
||||
}
|
||||
}
|
||||
|
||||
protected boolean splitIsNeeded(final Map<String, String> tags) {
|
||||
boolean seamark = false;
|
||||
for(String s : tags.keySet()) {
|
||||
if(s.startsWith("seamark:")) {
|
||||
|
@ -142,35 +150,10 @@ public class MapRenderingTypes {
|
|||
break;
|
||||
}
|
||||
}
|
||||
if(!seamark) {
|
||||
return oneIterator(tags);
|
||||
} else {
|
||||
return splitOpenSeaMapsTags(tags);
|
||||
}
|
||||
return seamark;
|
||||
}
|
||||
|
||||
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) {
|
||||
private Collection<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";
|
||||
|
@ -197,15 +180,19 @@ public class MapRenderingTypes {
|
|||
common.put(s, value);
|
||||
}
|
||||
}
|
||||
List<Map<String, String>> res = new ArrayList<Map<String,String>>();
|
||||
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);
|
||||
res.add(0, g.getValue());
|
||||
} else {
|
||||
res.add(g.getValue());
|
||||
}
|
||||
}
|
||||
return groupByOpenSeamaps.values().iterator();
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -142,6 +142,10 @@ public abstract class Entity {
|
|||
return tags.put(key, value);
|
||||
}
|
||||
|
||||
public void replaceTags(Map<String, String> toPut){
|
||||
tags = new LinkedHashMap<String, String>(toPut);
|
||||
}
|
||||
|
||||
public String getTag(OSMTagKey key){
|
||||
return getTag(key.getValue());
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package net.osmand.osm.edit;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
@ -110,9 +110,8 @@ public class EntityParser {
|
|||
amenitiesList.clear();
|
||||
// it could be collection of amenities
|
||||
boolean relation = entity instanceof Relation;
|
||||
Iterator<Map<String, String>> it = renderingTypes.splitTagsIntoDifferentObjects(entity.getTags());
|
||||
while (it.hasNext()) {
|
||||
Map<String, String> tags = it.next();
|
||||
Collection<Map<String, String>> it = renderingTypes.splitTagsIntoDifferentObjects(entity.getTags());
|
||||
for(Map<String, String> tags : it) {
|
||||
if (!tags.isEmpty()) {
|
||||
boolean purerelation = relation && !"multipolygon".equals(tags.get("type"));
|
||||
for (Map.Entry<String, String> e : tags.entrySet()) {
|
||||
|
|
Loading…
Reference in a new issue