From f5ba767ef37fcfcc9846f476450befc6a403f687 Mon Sep 17 00:00:00 2001 From: Victor Shcherb Date: Thu, 4 Aug 2016 09:28:49 +0200 Subject: [PATCH] Support entrance ref for search --- OsmAnd-java/src/net/osmand/data/Building.java | 29 +++++++++++++++++++ OsmAnd-java/src/net/osmand/data/Street.java | 2 +- .../src/net/osmand/osm/edit/EntityParser.java | 10 +++++++ 3 files changed, 40 insertions(+), 1 deletion(-) diff --git a/OsmAnd-java/src/net/osmand/data/Building.java b/OsmAnd-java/src/net/osmand/data/Building.java index aaab175634..f036c05ca1 100644 --- a/OsmAnd-java/src/net/osmand/data/Building.java +++ b/OsmAnd-java/src/net/osmand/data/Building.java @@ -1,6 +1,10 @@ package net.osmand.data; +import java.util.Collections; +import java.util.LinkedHashMap; +import java.util.Map; + import net.osmand.util.Algorithms; public class Building extends MapObject { @@ -10,6 +14,7 @@ public class Building extends MapObject { private BuildingInterpolation interpolationType; private int interpolationInterval; private String name2; + private Map entrances = null; public enum BuildingInterpolation { ALL(-1), EVEN(-2), ODD(-3), ALPHABETIC(-4); @@ -38,6 +43,20 @@ public class Building extends MapObject { return postcode; } + public Map getEntrances() { + if(entrances == null) { + return Collections.emptyMap(); + } + return entrances; + } + + public void addEntrance(String ref, LatLon location) { + if(entrances == null) { + entrances = new LinkedHashMap<>(); + } + entrances.put(ref, location); + } + public int getInterpolationInterval() { return interpolationInterval; } @@ -146,5 +165,15 @@ public class Building extends MapObject { } return loc; } + + + @Override + public boolean equals(Object o) { + boolean res = super.equals(o); + if (res && o instanceof Building) { + return Algorithms.stringsEqual(((MapObject) o).getName(), getName()); + } + return res; + } } diff --git a/OsmAnd-java/src/net/osmand/data/Street.java b/OsmAnd-java/src/net/osmand/data/Street.java index 8697b3fbc4..d5b118a63b 100644 --- a/OsmAnd-java/src/net/osmand/data/Street.java +++ b/OsmAnd-java/src/net/osmand/data/Street.java @@ -38,7 +38,7 @@ public class Street extends MapObject { public void addBuildingCheckById(Building building) { for (Building b : buildings) { - if (b.getId().longValue() == building.getId().longValue()) { + if (b.equals(building)) { return; } } diff --git a/OsmAnd-java/src/net/osmand/osm/edit/EntityParser.java b/OsmAnd-java/src/net/osmand/osm/edit/EntityParser.java index afe42eb6de..9747bc2473 100644 --- a/OsmAnd-java/src/net/osmand/osm/edit/EntityParser.java +++ b/OsmAnd-java/src/net/osmand/osm/edit/EntityParser.java @@ -201,6 +201,16 @@ public class EntityParser { p = e.getTag(OSMTagKey.POSTAL_CODE.getValue()); } b.setPostcode(p); + if(e instanceof Way) { + List nodes = ((Way) e).getNodes(); + for(int i = 0; i < nodes.size(); i++) { + Node node = nodes.get(i); + if(node != null && "yes".equals(node.getTag(OSMTagKey.ENTRANCE)) && + !Algorithms.isEmpty(node.getTag(OSMTagKey.REF))) { + b.addEntrance(node.getTag(OSMTagKey.REF), node.getLatLon()); + } + } + } return b; }