From 9575f58151338cbe0762a83ad8b8f95068216139 Mon Sep 17 00:00:00 2001 From: Nicholas Hallahan Date: Fri, 22 Apr 2016 19:22:51 -0700 Subject: [PATCH] Closes #119 --- .../src/main/java/com/spatialdev/osm/OSMMap.java | 2 +- .../src/main/java/com/spatialdev/osm/model/JTSModel.java | 7 +++++-- app/src/main/java/org/redcross/openmapkit/MapActivity.java | 6 ++++++ .../main/java/org/redcross/openmapkit/OSMMapBuilder.java | 2 +- 4 files changed, 13 insertions(+), 4 deletions(-) diff --git a/MapboxAndroidSDK/src/main/java/com/spatialdev/osm/OSMMap.java b/MapboxAndroidSDK/src/main/java/com/spatialdev/osm/OSMMap.java index e2e0f86..36ba2ce 100644 --- a/MapboxAndroidSDK/src/main/java/com/spatialdev/osm/OSMMap.java +++ b/MapboxAndroidSDK/src/main/java/com/spatialdev/osm/OSMMap.java @@ -35,7 +35,7 @@ public class OSMMap implements MapViewListener, MapListener { // DEBUG MODE - SHOW ENVELOPE AROUND TAP ON MAP - private static final boolean DEBUG = true; + private static final boolean DEBUG = false; private MapView mapView; private JTSModel jtsModel; diff --git a/MapboxAndroidSDK/src/main/java/com/spatialdev/osm/model/JTSModel.java b/MapboxAndroidSDK/src/main/java/com/spatialdev/osm/model/JTSModel.java index 45ca4b9..62cab14 100644 --- a/MapboxAndroidSDK/src/main/java/com/spatialdev/osm/model/JTSModel.java +++ b/MapboxAndroidSDK/src/main/java/com/spatialdev/osm/model/JTSModel.java @@ -166,8 +166,11 @@ public OSMElement queryFromTap(ILatLng latLng, float zoom) { } -// Log.i("queryFromTap closestElement", closestElement.toString()); - return closestElement; + Geometry closestElementGeom = closestElement.getJTSGeom(); + if (closestElementGeom != null && closestElementGeom.intersects(geometryFactory.createPoint(coord))) { + return closestElement; + } + return null; } private Envelope createTapEnvelope(Coordinate coord, double lat, double lng, float zoom) { diff --git a/app/src/main/java/org/redcross/openmapkit/MapActivity.java b/app/src/main/java/org/redcross/openmapkit/MapActivity.java index a53663b..ee2b413 100644 --- a/app/src/main/java/org/redcross/openmapkit/MapActivity.java +++ b/app/src/main/java/org/redcross/openmapkit/MapActivity.java @@ -289,6 +289,12 @@ public void onItemClick(AdapterView parent, View view, int position, long id) */ protected void identifyOSMFeature(OSMElement osmElement) { + // only open it if we render the OSM vectors, + // otherwise it is confusing for the user + if (mapView.getZoomLevel() < OSMMapBuilder.MIN_VECTOR_RENDER_ZOOM) { + return; + } + int numRequiredTags = 0; if (ODKCollectHandler.isODKCollectMode()) { Collection requiredTags = ODKCollectHandler.getODKCollectData().getRequiredTags(); diff --git a/app/src/main/java/org/redcross/openmapkit/OSMMapBuilder.java b/app/src/main/java/org/redcross/openmapkit/OSMMapBuilder.java index d2a69db..318521e 100644 --- a/app/src/main/java/org/redcross/openmapkit/OSMMapBuilder.java +++ b/app/src/main/java/org/redcross/openmapkit/OSMMapBuilder.java @@ -35,7 +35,7 @@ */ public class OSMMapBuilder extends AsyncTask { - private static final float MIN_VECTOR_RENDER_ZOOM = 18; + public static final float MIN_VECTOR_RENDER_ZOOM = 18; private static final String PERSISTED_OSM_FILES = "org.redcross.openmapkit.PERSISTED_OSM_FILES"; private static MapActivity mapActivity;