diff --git a/OsmAnd-java/src/net/osmand/binary/GeocodingUtilities.java b/OsmAnd-java/src/net/osmand/binary/GeocodingUtilities.java index 841535779d..df73cb362a 100644 --- a/OsmAnd-java/src/net/osmand/binary/GeocodingUtilities.java +++ b/OsmAnd-java/src/net/osmand/binary/GeocodingUtilities.java @@ -137,7 +137,7 @@ public class GeocodingUtilities { } - public List reverseGeocodingSearch(RoutingContext ctx, double lat, double lon) throws IOException { + public List reverseGeocodingSearch(RoutingContext ctx, double lat, double lon, boolean allowEmptyNames) throws IOException { RoutePlannerFrontEnd rp = new RoutePlannerFrontEnd(false); List lst = new ArrayList(); List listR = new ArrayList(); @@ -151,14 +151,14 @@ public class GeocodingUtilities { continue; } // System.out.println(road.toString() + " " + Math.sqrt(p.distSquare)); - boolean emptyName = Algorithms.isEmpty(road.getName()) && Algorithms.isEmpty(road.getRef("", false, true)); - if (!emptyName) { + String name = Algorithms.isEmpty(road.getName()) ? road.getRef("", false, true) : road.getName(); + if (allowEmptyNames || !Algorithms.isEmpty(name)) { if (distSquare == 0 || distSquare > p.distSquare) { distSquare = p.distSquare; } GeocodingResult sr = new GeocodingResult(); sr.searchPoint = new LatLon(lat, lon); - sr.streetName = Algorithms.isEmpty(road.getName()) ? road.getRef("", false, true) : road.getName(); + sr.streetName = name == null ? "" : name; sr.point = p; sr.connectionPoint = new LatLon(MapUtils.get31LatitudeY(p.preciseY), MapUtils.get31LongitudeX(p.preciseX)); sr.regionFP = road.region.getFilePointer(); diff --git a/OsmAnd-java/src/net/osmand/map/OsmandRegions.java b/OsmAnd-java/src/net/osmand/map/OsmandRegions.java index 8384af4362..bc07bb87a5 100644 --- a/OsmAnd-java/src/net/osmand/map/OsmandRegions.java +++ b/OsmAnd-java/src/net/osmand/map/OsmandRegions.java @@ -93,7 +93,7 @@ public class OsmandRegions { } - public void prepareFile(String fileName) throws IOException { + public BinaryMapIndexReader prepareFile(String fileName) throws IOException { reader = new BinaryMapIndexReader(new RandomAccessFile(fileName, "r"), new File(fileName)); // final Collator clt = OsmAndCollator.primaryCollator(); final Map parentRelations = new LinkedHashMap(); @@ -138,6 +138,7 @@ public class OsmandRegions { } } structureWorldRegions(new ArrayList(fullNamesToRegionData.values())); + return reader; } public boolean containsCountry(String name) { diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml index f2bf7a3af9..340d70a08a 100644 --- a/OsmAnd/res/values/strings.xml +++ b/OsmAnd/res/values/strings.xml @@ -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 --> + Road Show map Route is calculated Round trip diff --git a/OsmAnd/src/net/osmand/plus/CurrentPositionHelper.java b/OsmAnd/src/net/osmand/plus/CurrentPositionHelper.java index 3855f8c94c..a811f068ec 100644 --- a/OsmAnd/src/net/osmand/plus/CurrentPositionHelper.java +++ b/OsmAnd/src/net/osmand/plus/CurrentPositionHelper.java @@ -1,10 +1,8 @@ package net.osmand.plus; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; +import android.os.AsyncTask; +import android.support.annotation.NonNull; +import android.support.annotation.Nullable; import net.osmand.Location; import net.osmand.PlatformUtil; @@ -21,7 +19,12 @@ import net.osmand.router.RoutePlannerFrontEnd; import net.osmand.router.RoutingConfiguration; import net.osmand.router.RoutingContext; import net.osmand.util.MapUtils; -import android.os.AsyncTask; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; public class CurrentPositionHelper { @@ -43,12 +46,13 @@ public class CurrentPositionHelper { return lastAskedLocation; } - public boolean getRouteSegment(Location loc, ResultMatcher result) { - return scheduleRouteSegmentFind(loc, false, null, result); + public boolean getRouteSegment(Location loc, @Nullable ApplicationMode appMode, + ResultMatcher result) { + return scheduleRouteSegmentFind(loc, false, true, null, result, appMode); } public boolean getGeocodingResult(Location loc, ResultMatcher result) { - return scheduleRouteSegmentFind(loc, false, result, null); + return scheduleRouteSegmentFind(loc, false, false, result, null, null); } public RouteDataObject getLastKnownRouteSegment(Location loc) { @@ -61,12 +65,12 @@ public class CurrentPositionHelper { return r; } if (r == null) { - scheduleRouteSegmentFind(loc, true, null, null); + scheduleRouteSegmentFind(loc, true, false, null, null, null); return null; } double d = getOrthogonalDistance(r, loc); if (d > 15) { - scheduleRouteSegmentFind(loc, true, null, null); + scheduleRouteSegmentFind(loc, true, false, null, null, null); } if (d < 70) { return r; @@ -76,14 +80,19 @@ public class CurrentPositionHelper { ///////////////////////// PRIVATE IMPLEMENTATION ////////////////////////// - private boolean scheduleRouteSegmentFind(final Location loc, final boolean storeFound, final ResultMatcher geoCoding, final ResultMatcher result) { + private boolean scheduleRouteSegmentFind(final Location loc, + final boolean storeFound, + final boolean allowEmptyNames, + @Nullable final ResultMatcher geoCoding, + @Nullable final ResultMatcher result, + @Nullable final ApplicationMode appMode) { boolean res = false; if (loc != null) { new AsyncTask() { @Override protected Void doInBackground(Void... params) { try { - processGeocoding(loc, geoCoding, storeFound, result); + processGeocoding(loc, geoCoding, storeFound, allowEmptyNames, result, appMode); } catch (Exception e) { log.error("Error processing geocoding", e); e.printStackTrace(); @@ -96,8 +105,9 @@ public class CurrentPositionHelper { return res; } - private void initCtx(OsmandApplication app, List checkReaders) { - am = app.getSettings().getApplicationMode(); + private void initCtx(OsmandApplication app, List checkReaders, + @NonNull ApplicationMode appMode) { + am = appMode; String p ; if (am.isDerivedRoutingFrom(ApplicationMode.BICYCLE)) { p = GeneralRouterProfile.BICYCLE.name().toLowerCase(); @@ -129,9 +139,15 @@ public class CurrentPositionHelper { } // single synchronized method - private synchronized void processGeocoding(Location loc, ResultMatcher geoCoding, boolean storeFound, final ResultMatcher result) throws IOException { + private synchronized void processGeocoding(@NonNull Location loc, + @Nullable ResultMatcher geoCoding, + boolean storeFound, + boolean allowEmptyNames, + @Nullable final ResultMatcher result, + @Nullable ApplicationMode appMode) throws IOException { + final List gr = runUpdateInThread(loc.getLatitude(), loc.getLongitude(), - geoCoding != null); + geoCoding != null, allowEmptyNames, appMode); if (storeFound) { lastAskedLocation = loc; lastFound = gr == null || gr.isEmpty() ? null : gr.get(0).point.getRoad(); @@ -146,17 +162,25 @@ public class CurrentPositionHelper { }); } } - - private List runUpdateInThread(double lat, double lon, boolean geocoding) throws IOException { + + @Nullable + private List runUpdateInThread(double lat, double lon, + boolean geocoding, + boolean allowEmptyNames, + @Nullable ApplicationMode appMode) throws IOException { + List checkReaders = checkReaders(lat, lon, usedReaders); - if (ctx == null || am != app.getSettings().getApplicationMode() || checkReaders != usedReaders) { - initCtx(app, checkReaders); + if (appMode == null) { + appMode = app.getSettings().getApplicationMode(); + } + if (ctx == null || am != appMode || checkReaders != usedReaders) { + initCtx(app, checkReaders, appMode); if (ctx == null) { return null; } } try { - return new GeocodingUtilities().reverseGeocodingSearch(geocoding ? defCtx : ctx, lat, lon); + return new GeocodingUtilities().reverseGeocodingSearch(geocoding ? defCtx : ctx, lat, lon, allowEmptyNames); } catch (Exception e) { e.printStackTrace(); return null; diff --git a/OsmAnd/src/net/osmand/plus/OsmAndLocationProvider.java b/OsmAnd/src/net/osmand/plus/OsmAndLocationProvider.java index 729ba13194..b3046bc6c3 100644 --- a/OsmAnd/src/net/osmand/plus/OsmAndLocationProvider.java +++ b/OsmAnd/src/net/osmand/plus/OsmAndLocationProvider.java @@ -859,8 +859,9 @@ public class OsmAndLocationProvider implements SensorEventListener { return currentPositionHelper.getLastKnownRouteSegment(getLastKnownLocation()); } - public boolean getRouteSegment(net.osmand.Location loc, ResultMatcher result) { - return currentPositionHelper.getRouteSegment(loc, result); + public boolean getRouteSegment(net.osmand.Location loc, @Nullable ApplicationMode appMode, + ResultMatcher result) { + return currentPositionHelper.getRouteSegment(loc, appMode, result); } public boolean getGeocodingResult(net.osmand.Location loc, ResultMatcher result) { diff --git a/OsmAnd/src/net/osmand/plus/OsmandApplication.java b/OsmAnd/src/net/osmand/plus/OsmandApplication.java index 5a832fbd7b..e78ad9ab4d 100644 --- a/OsmAnd/src/net/osmand/plus/OsmandApplication.java +++ b/OsmAnd/src/net/osmand/plus/OsmandApplication.java @@ -758,7 +758,7 @@ public class OsmandApplication extends MultiDexApplication { return lang; } - public RoutingConfiguration.Builder getDefaultRoutingConfig() { + public synchronized RoutingConfiguration.Builder getDefaultRoutingConfig() { if(defaultRoutingConfig == null) { defaultRoutingConfig = appInitializer.getLazyDefaultRoutingConfig(); } diff --git a/OsmAnd/src/net/osmand/plus/activities/MapActivity.java b/OsmAnd/src/net/osmand/plus/activities/MapActivity.java index 35e7fe63c6..4e4f9dc846 100644 --- a/OsmAnd/src/net/osmand/plus/activities/MapActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/MapActivity.java @@ -403,14 +403,24 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven @Override public void updateProgress(int progress) { if (findViewById(R.id.MapHudButtonsOverlay).getVisibility() == View.VISIBLE) { - pbExtView.setVisibility(View.GONE); - pb.setVisibility(View.VISIBLE); + if (pbExtView.getVisibility() == View.VISIBLE) { + pbExtView.setVisibility(View.GONE); + } + if (pb.getVisibility() == View.GONE) { + pb.setVisibility(View.VISIBLE); + } pb.setProgress(progress); + pb.invalidate(); pb.requestLayout(); } else { - pb.setVisibility(View.GONE); - pbExtView.setVisibility(View.VISIBLE); + if (pb.getVisibility() == View.VISIBLE) { + pb.setVisibility(View.GONE); + } + if (pbExtView.getVisibility() == View.GONE) { + pbExtView.setVisibility(View.VISIBLE); + } pbExt.setProgress(progress); + pbExt.invalidate(); pbExt.requestLayout(); } } diff --git a/OsmAnd/src/net/osmand/plus/helpers/AvoidSpecificRoads.java b/OsmAnd/src/net/osmand/plus/helpers/AvoidSpecificRoads.java index 5c6bc512d0..e43f76a30a 100644 --- a/OsmAnd/src/net/osmand/plus/helpers/AvoidSpecificRoads.java +++ b/OsmAnd/src/net/osmand/plus/helpers/AvoidSpecificRoads.java @@ -11,12 +11,14 @@ import android.widget.ImageButton; import android.widget.ImageView; import android.widget.TextView; import android.widget.Toast; + import net.osmand.CallbackWithObject; import net.osmand.Location; import net.osmand.ResultMatcher; import net.osmand.binary.RouteDataObject; import net.osmand.data.LatLon; import net.osmand.data.PointDescription; +import net.osmand.plus.ApplicationMode; import net.osmand.plus.OsmAndFormatter; import net.osmand.plus.OsmandApplication; import net.osmand.plus.R; @@ -25,15 +27,14 @@ import net.osmand.plus.mapcontextmenu.MapContextMenu; import net.osmand.plus.routing.RoutingHelper; import net.osmand.plus.views.AnimateDraggingMapThread; import net.osmand.plus.views.ContextMenuLayer; -import net.osmand.router.RoutingConfiguration; -import net.osmand.router.RoutingConfiguration.Builder; +import net.osmand.util.Algorithms; import net.osmand.util.MapUtils; import java.util.ArrayList; import java.util.List; public class AvoidSpecificRoads { - private List missingRoads; + private List impassableRoads; private OsmandApplication app; public AvoidSpecificRoads(OsmandApplication app) { @@ -47,24 +48,23 @@ public class AvoidSpecificRoads { } } - public List getMissingRoads() { - if (missingRoads == null) { - missingRoads = app.getDefaultRoutingConfig().getImpassableRoads(); + private List getImpassableRoads() { + if (impassableRoads == null) { + impassableRoads = app.getDefaultRoutingConfig().getImpassableRoads(); } - return missingRoads; + return impassableRoads; } - - public ArrayAdapter createAdapter(final MapActivity ctx) { + private ArrayAdapter createAdapter(final MapActivity ctx) { final ArrayList points = new ArrayList<>(); - points.addAll(getMissingRoads()); + points.addAll(getImpassableRoads()); final LatLon mapLocation = ctx.getMapLocation(); return new ArrayAdapter(ctx, R.layout.waypoint_reached, R.id.title, points) { + @NonNull @Override - public View getView(final int position, View convertView, ViewGroup parent) { - // User super class to create the View + public View getView(final int position, View convertView, @NonNull ViewGroup parent) { View v = convertView; if (v == null || v.findViewById(R.id.info_close) == null) { v = ctx.getLayoutInflater().inflate(R.layout.waypoint_reached, parent, false); @@ -107,24 +107,26 @@ public class AvoidSpecificRoads { protected String getText(RouteDataObject obj) { - return RoutingHelper.formatStreetName(obj.getName(app.getSettings().MAP_PREFERRED_LOCALE.get(), - app.getSettings().MAP_TRANSLITERATE_NAMES.get()), - obj.getRef(app.getSettings().MAP_PREFERRED_LOCALE.get(), app.getSettings().MAP_TRANSLITERATE_NAMES.get(), true), - obj.getDestinationName(app.getSettings().MAP_PREFERRED_LOCALE.get(), app.getSettings().MAP_TRANSLITERATE_NAMES.get(), true), + String name = RoutingHelper.formatStreetName(obj.getName(app.getSettings().MAP_PREFERRED_LOCALE.get(), + app.getSettings().MAP_TRANSLITERATE_NAMES.get()), + obj.getRef(app.getSettings().MAP_PREFERRED_LOCALE.get(), app.getSettings().MAP_TRANSLITERATE_NAMES.get(), true), + obj.getDestinationName(app.getSettings().MAP_PREFERRED_LOCALE.get(), app.getSettings().MAP_TRANSLITERATE_NAMES.get(), true), app.getString(R.string.towards)); + + return Algorithms.isEmpty(name) ? app.getString(R.string.shared_string_road) : name; } public void showDialog(@NonNull final MapActivity mapActivity) { AlertDialog.Builder bld = new AlertDialog.Builder(mapActivity); bld.setTitle(R.string.impassable_road); - if (getMissingRoads().size() == 0) { + if (getImpassableRoads().size() == 0) { bld.setMessage(R.string.avoid_roads_msg); } else { final ArrayAdapter listAdapter = createAdapter(mapActivity); bld.setAdapter(listAdapter, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { - RouteDataObject obj = getMissingRoads().get(which); + RouteDataObject obj = getImpassableRoads().get(which); double lat = MapUtils.get31LatitudeY(obj.getPoint31YTile(0)); double lon = MapUtils.get31LongitudeX(obj.getPoint31XTile(0)); showOnMap(mapActivity, lat, lon, getText(obj), dialog); @@ -144,7 +146,7 @@ public class AvoidSpecificRoads { } - protected void selectFromMap(final MapActivity mapActivity) { + private void selectFromMap(final MapActivity mapActivity) { ContextMenuLayer cm = mapActivity.getMapLayers().getContextMenuLayer(); cm.setSelectOnMap(new CallbackWithObject() { @@ -165,7 +167,9 @@ public class AvoidSpecificRoads { final Location ll = new Location(""); ll.setLatitude(loc.getLatitude()); ll.setLongitude(loc.getLongitude()); - app.getLocationProvider().getRouteSegment(ll, new ResultMatcher() { + ApplicationMode appMode = app.getRoutingHelper().getAppMode(); + + app.getLocationProvider().getRouteSegment(ll, appMode, new ResultMatcher() { @Override public boolean publish(RouteDataObject object) { @@ -207,7 +211,9 @@ public class AvoidSpecificRoads { final Location ll = new Location(""); ll.setLatitude(loc.getLatitude()); ll.setLongitude(loc.getLongitude()); - app.getLocationProvider().getRouteSegment(ll, new ResultMatcher() { + ApplicationMode appMode = app.getRoutingHelper().getAppMode(); + + app.getLocationProvider().getRouteSegment(ll, appMode, new ResultMatcher() { @Override public boolean publish(RouteDataObject object) { @@ -239,9 +245,9 @@ public class AvoidSpecificRoads { boolean showDialog, @Nullable MapActivity activity, @NonNull LatLon loc) { - if(!app.getDefaultRoutingConfig().addImpassableRoad(object, ll)) { + if (!app.getDefaultRoutingConfig().addImpassableRoad(object, ll)) { LatLon location = getLocation(object); - if(location != null) { + if (location != null) { app.getSettings().removeImpassableRoad(getLocation(object)); } } diff --git a/OsmAnd/src/net/osmand/plus/routing/RoutingHelper.java b/OsmAnd/src/net/osmand/plus/routing/RoutingHelper.java index 0b7f5e4265..9a6fe402c3 100644 --- a/OsmAnd/src/net/osmand/plus/routing/RoutingHelper.java +++ b/OsmAnd/src/net/osmand/plus/routing/RoutingHelper.java @@ -952,14 +952,14 @@ public class RoutingHelper { } public void startRouteCalculationThread(RouteCalculationParams params, boolean paramsChanged, boolean updateProgress) { - if (updateProgress) { - updateProgress(params); - } synchronized (this) { final Thread prevRunningJob = currentRunningJob; RouteRecalculationThread newThread = new RouteRecalculationThread( "Calculating route", params, paramsChanged); //$NON-NLS-1$ currentRunningJob = newThread; + if (updateProgress) { + updateProgress(params); + } if (prevRunningJob != null) { newThread.setWaitPrevJob(prevRunningJob); } @@ -974,7 +974,7 @@ public class RoutingHelper { } else { progressRoute = this.progressRoute; } - if(progressRoute != null ) { + if (progressRoute != null ) { app.runInUIThread(new Runnable() { @Override @@ -986,6 +986,8 @@ public class RoutingHelper { if (all > 0) { int t = (int) Math.min(p * p / (all * all) * 100f, 99); progressRoute.updateProgress(t); + } else { + progressRoute.updateProgress(0); } Thread t = currentRunningJob; if(t instanceof RouteRecalculationThread && ((RouteRecalculationThread) t).params != params) { diff --git a/OsmAnd/src/net/osmand/plus/views/ImpassableRoadsLayer.java b/OsmAnd/src/net/osmand/plus/views/ImpassableRoadsLayer.java index 1b93053e7e..27136462c4 100644 --- a/OsmAnd/src/net/osmand/plus/views/ImpassableRoadsLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/ImpassableRoadsLayer.java @@ -34,15 +34,14 @@ public class ImpassableRoadsLayer extends OsmandMapLayer implements private static final int startZoom = 10; private final MapActivity activity; private Bitmap roadWorkIcon; - private OsmandMapTileView view; private Paint paint; - private Map missingRoadLocations; - private List missingRoads; + private Map impassableRoadLocations; + private List impassableRoads; private RoutingHelper routingHelper; private ContextMenuLayer contextMenuLayer; - private Set mPreservedRoadDataObjects; + private Set storedRoadDataObjects; public ImpassableRoadsLayer(MapActivity activity) { this.activity = activity; @@ -50,7 +49,6 @@ public class ImpassableRoadsLayer extends OsmandMapLayer implements @Override public void initLayer(OsmandMapTileView view) { - this.view = view; roadWorkIcon = BitmapFactory.decodeResource(view.getResources(), R.drawable.map_pin_avoid_road); paint = new Paint(); routingHelper = activity.getRoutingHelper(); @@ -58,9 +56,9 @@ public class ImpassableRoadsLayer extends OsmandMapLayer implements contextMenuLayer = view.getLayerByClass(ContextMenuLayer.class); List impassibleRoads = activity.getMyApplication().getSettings().getImpassableRoadPoints(); - mPreservedRoadDataObjects = new HashSet<>(impassibleRoads.size()); + storedRoadDataObjects = new HashSet<>(impassibleRoads.size()); for (LatLon impassibleRoad : impassibleRoads) { - mPreservedRoadDataObjects.add(new PreservedRoadDataObject(impassibleRoad)); + storedRoadDataObjects.add(new StoredRoadDataObject(impassibleRoad)); } } @@ -75,21 +73,25 @@ public class ImpassableRoadsLayer extends OsmandMapLayer implements @Override public void onPrepareBufferImage(Canvas canvas, RotatedTileBox tileBox, DrawSettings settings) { if (tileBox.getZoom() >= startZoom) { - for (long id : getMissingRoadLocations().keySet()) { - if(contextMenuLayer.getMoveableObject() instanceof RouteDataObject) { + for (long id : getImpassableRoadLocations().keySet()) { + if (contextMenuLayer.getMoveableObject() instanceof RouteDataObject) { RouteDataObject object = (RouteDataObject) contextMenuLayer.getMoveableObject(); if (object.id == id) { continue; } } - Location location = getMissingRoadLocations().get(id); + Location location = getImpassableRoadLocations().get(id); final double latitude = location.getLatitude(); final double longitude = location.getLongitude(); - drawPoint(canvas, tileBox, latitude, longitude); + if (tileBox.containsLatLon(latitude, longitude)) { + drawPoint(canvas, tileBox, latitude, longitude); + } } - for (PreservedRoadDataObject preservedRoadDataObject : mPreservedRoadDataObjects) { - final LatLon latLon = preservedRoadDataObject.getLatLon(); - drawPoint(canvas, tileBox, latLon.getLatitude(), latLon.getLongitude()); + for (StoredRoadDataObject storedRoadDataObject : storedRoadDataObjects) { + final LatLon latLon = storedRoadDataObject.getLatLon(); + if (tileBox.containsLatLon(latLon)) { + drawPoint(canvas, tileBox, latLon.getLatitude(), latLon.getLongitude()); + } } } } @@ -106,18 +108,18 @@ public class ImpassableRoadsLayer extends OsmandMapLayer implements canvas.drawBitmap(roadWorkIcon, left, top, paint); } - public Map getMissingRoadLocations() { - if (missingRoadLocations == null) { - missingRoadLocations = activity.getMyApplication().getDefaultRoutingConfig().getImpassableRoadLocations(); + private Map getImpassableRoadLocations() { + if (impassableRoadLocations == null) { + impassableRoadLocations = activity.getMyApplication().getDefaultRoutingConfig().getImpassableRoadLocations(); } - return missingRoadLocations; + return impassableRoadLocations; } - public List getMissingRoads() { - if (missingRoads == null) { - missingRoads = activity.getMyApplication().getDefaultRoutingConfig().getImpassableRoads(); + private List getImpassableRoads() { + if (impassableRoads == null) { + impassableRoads = activity.getMyApplication().getDefaultRoutingConfig().getImpassableRoads(); } - return missingRoads; + return impassableRoads; } @Override @@ -130,7 +132,7 @@ public class ImpassableRoadsLayer extends OsmandMapLayer implements return true; } - public int getRadiusPoi(RotatedTileBox tb) { + private int getRadiusPoi(RotatedTileBox tb) { int r; if (tb.getZoom() < startZoom) { r = 0; @@ -167,8 +169,8 @@ public class ImpassableRoadsLayer extends OsmandMapLayer implements int compare = getRadiusPoi(tileBox); int radius = compare * 3 / 2; - for (RouteDataObject road : getMissingRoads()) { - Location location = getMissingRoadLocations().get(road.getId()); + for (RouteDataObject road : getImpassableRoads()) { + Location location = getImpassableRoadLocations().get(road.getId()); if (location != null) { int x = (int) tileBox.getPixXFromLatLon(location.getLatitude(), location.getLongitude()); int y = (int) tileBox.getPixYFromLatLon(location.getLatitude(), location.getLongitude()); @@ -179,9 +181,9 @@ public class ImpassableRoadsLayer extends OsmandMapLayer implements } } } - if (!mPreservedRoadDataObjects.isEmpty()) { + if (!storedRoadDataObjects.isEmpty()) { activity.getMyApplication().getAvoidSpecificRoads().initPreservedData(); - mPreservedRoadDataObjects.clear(); + storedRoadDataObjects.clear(); } } @@ -189,7 +191,7 @@ public class ImpassableRoadsLayer extends OsmandMapLayer implements public LatLon getObjectLocation(Object o) { if (o instanceof RouteDataObject) { RouteDataObject route = (RouteDataObject) o; - Location location = missingRoadLocations.get(route.getId()); + Location location = impassableRoadLocations.get(route.getId()); return new LatLon(location.getLatitude(), location.getLongitude()); } return null; @@ -255,15 +257,15 @@ public class ImpassableRoadsLayer extends OsmandMapLayer implements } } - private static class PreservedRoadDataObject { - private final LatLon mLatLon; + private static class StoredRoadDataObject { + private final LatLon latLon; - private PreservedRoadDataObject(LatLon latLon) { - this.mLatLon = latLon; + private StoredRoadDataObject(LatLon latLon) { + this.latLon = latLon; } public LatLon getLatLon() { - return mLatLon; + return latLon; } } } diff --git a/OsmAndCore-sample/src/net/osmand/core/samples/android/sample1/CurrentPositionHelper.java b/OsmAndCore-sample/src/net/osmand/core/samples/android/sample1/CurrentPositionHelper.java index c0ce4d406f..258405ea12 100644 --- a/OsmAndCore-sample/src/net/osmand/core/samples/android/sample1/CurrentPositionHelper.java +++ b/OsmAndCore-sample/src/net/osmand/core/samples/android/sample1/CurrentPositionHelper.java @@ -148,7 +148,7 @@ public class CurrentPositionHelper { } } try { - return new GeocodingUtilities().reverseGeocodingSearch(defCtx, lat, lon); + return new GeocodingUtilities().reverseGeocodingSearch(defCtx, lat, lon, false); } catch (Exception e) { e.printStackTrace(); return null;