From ee74636b35da95fa8a1353f16d25c7001164ae5d Mon Sep 17 00:00:00 2001 From: Victor Shcherb Date: Wed, 2 Dec 2015 13:45:47 +0100 Subject: [PATCH] Update utilties --- .../net/osmand/binary/GeocodingUtilities.java | 5 ++-- .../osmand/plus/CurrentPositionHelper.java | 8 ----- .../audionotes/AudioVideoNotesPlugin.java | 29 ++++++++++--------- 3 files changed, 18 insertions(+), 24 deletions(-) diff --git a/OsmAnd-java/src/net/osmand/binary/GeocodingUtilities.java b/OsmAnd-java/src/net/osmand/binary/GeocodingUtilities.java index 8e5ee77bb9..e0990de0e3 100644 --- a/OsmAnd-java/src/net/osmand/binary/GeocodingUtilities.java +++ b/OsmAnd-java/src/net/osmand/binary/GeocodingUtilities.java @@ -39,8 +39,9 @@ public class GeocodingUtilities { public static final float THRESHOLD_MULTIPLIER_SKIP_STREETS_AFTER = 4; public static final float STOP_SEARCHING_STREET_WITH_MULTIPLIER_RADIUS = 100; public static final float STOP_SEARCHING_STREET_WITHOUT_MULTIPLIER_RADIUS = 400; - public static final float DISTANCE_STREET_FROM_CLOSEST = 1000; + public static final float DISTANCE_STREET_NAME_PROXIMITY_BY_NAME = 15000; + public static final float DISTANCE_STREET_FROM_CLOSEST_WITH_SAME_NAME = 1000; public static final float THRESHOLD_MULTIPLIER_SKIP_BUILDINGS_AFTER = 1.5f; public static final float DISTANCE_BULDING_PROXIMITY = 100; @@ -277,7 +278,7 @@ public class GeocodingUtilities { for (GeocodingResult street : streetsList) { if(streetDistance == 0) { streetDistance = street.getDistance(); - } else if(street.getDistance() > streetDistance + DISTANCE_STREET_FROM_CLOSEST) { + } else if(street.getDistance() > streetDistance + DISTANCE_STREET_FROM_CLOSEST_WITH_SAME_NAME) { continue; } street.connectionPoint = road.connectionPoint; diff --git a/OsmAnd/src/net/osmand/plus/CurrentPositionHelper.java b/OsmAnd/src/net/osmand/plus/CurrentPositionHelper.java index cc21ededa8..268d3e0f10 100644 --- a/OsmAnd/src/net/osmand/plus/CurrentPositionHelper.java +++ b/OsmAnd/src/net/osmand/plus/CurrentPositionHelper.java @@ -89,15 +89,7 @@ public class CurrentPositionHelper { protected void justifyResult(List res, final ResultMatcher result) { List complete = new ArrayList(); double minBuildingDistance = 0; - double minStreetDistance = 0; for (GeocodingResult r : res) { - double streetDistance = r.getDistance(); - if(minStreetDistance == 0) { - minStreetDistance = streetDistance; - } else if(streetDistance > GeocodingUtilities.THRESHOLD_MULTIPLIER_SKIP_STREETS_AFTER * minStreetDistance || - streetDistance > minStreetDistance + GeocodingUtilities.DISTANCE_STREET_FROM_CLOSEST) { - break; - } Collection rar = app.getResourceManager().getAddressRepositories(); RegionAddressRepository foundRepo = null; for(RegionAddressRepository repo : rar) { diff --git a/OsmAnd/src/net/osmand/plus/audionotes/AudioVideoNotesPlugin.java b/OsmAnd/src/net/osmand/plus/audionotes/AudioVideoNotesPlugin.java index b9cebf179a..688f3d9427 100644 --- a/OsmAnd/src/net/osmand/plus/audionotes/AudioVideoNotesPlugin.java +++ b/OsmAnd/src/net/osmand/plus/audionotes/AudioVideoNotesPlugin.java @@ -134,7 +134,7 @@ public class AudioVideoNotesPlugin extends OsmandPlugin { private DataTileManager recordings = new DataTileManager(14); private Map recordingByFileName = new LinkedHashMap<>(); private AudioNotesLayer audioNotesLayer; - private MapActivity activity; + private MapActivity mapActivity; private static File mediaRecFile; private static MediaRecorder mediaRec; private File lastTakingPhoto; @@ -475,7 +475,7 @@ public class AudioVideoNotesPlugin extends OsmandPlugin { @Override public void registerLayers(MapActivity activity) { - this.activity = activity; + this.mapActivity = activity; if (audioNotesLayer != null) { activity.getMapView().removeLayer(audioNotesLayer); } @@ -718,16 +718,17 @@ public class AudioVideoNotesPlugin extends OsmandPlugin { @Override public void mapActivityResume(MapActivity activity) { - this.activity = activity; - ; + this.mapActivity = activity; ((AudioManager) activity.getSystemService(Context.AUDIO_SERVICE)).registerMediaButtonEventReceiver( new ComponentName(activity, MediaRemoteControlReceiver.class)); } - - public MapActivity getActivity() { - return activity; + + @Override + public void mapActivityPause(MapActivity activity) { + this.mapActivity = null; } + public void recordVideo(final double lat, final double lon, final MapActivity mapActivity) { if (AV_EXTERNAL_RECORDER.get()) { captureVideoExternal(lat, lon, mapActivity); @@ -1035,7 +1036,7 @@ public class AudioVideoNotesPlugin extends OsmandPlugin { private void updateRecordControl(final MapActivity mapActivity, final File f) { recordControl.setText(app.getString(R.string.shared_string_control_stop), ""); - recordControl.setImageDrawable(activity.getResources().getDrawable(R.drawable.widget_icon_av_active)); + recordControl.setImageDrawable(mapActivity.getResources().getDrawable(R.drawable.widget_icon_av_active)); final MapInfoLayer mil = mapActivity.getMapLayers().getMapInfoLayer(); final boolean contains = recordControl.isVisible(); if (!contains) { @@ -1060,8 +1061,8 @@ public class AudioVideoNotesPlugin extends OsmandPlugin { } private void updateContextMenu(Recording rec) { - if (activity != null) { - MapContextMenu menu = activity.getContextMenu(); + if (mapActivity != null) { + MapContextMenu menu = mapActivity.getContextMenu(); if (menu.isVisible()) { if (rec != null) { menu.show(new LatLon(rec.lat, rec.lon), audioNotesLayer.getObjectName(rec), rec); @@ -1196,9 +1197,9 @@ public class AudioVideoNotesPlugin extends OsmandPlugin { newMap.remove(r.file.getName()); recordingByFileName = newMap; Algorithms.removeAllFiles(r.file); - if (activity != null) { - activity.getContextMenu().close(); - activity.getMapView().refreshMap(); + if (mapActivity != null) { + mapActivity.getContextMenu().close(); + mapActivity.getMapView().refreshMap(); } } @@ -1217,7 +1218,7 @@ public class AudioVideoNotesPlugin extends OsmandPlugin { public boolean onMapActivityKeyEvent(KeyEvent key) { if (KeyEvent.KEYCODE_CAMERA == key.getKeyCode()) { - defaultAction(activity); + defaultAction(mapActivity); return true; } return false;