Merge remote-tracking branch 'origin/master'

This commit is contained in:
Weblate 2017-10-15 18:36:14 +02:00
commit f2f80d9374
11 changed files with 142 additions and 95 deletions

View file

@ -137,7 +137,7 @@ public class GeocodingUtilities {
} }
public List<GeocodingResult> reverseGeocodingSearch(RoutingContext ctx, double lat, double lon) throws IOException { public List<GeocodingResult> reverseGeocodingSearch(RoutingContext ctx, double lat, double lon, boolean allowEmptyNames) throws IOException {
RoutePlannerFrontEnd rp = new RoutePlannerFrontEnd(false); RoutePlannerFrontEnd rp = new RoutePlannerFrontEnd(false);
List<GeocodingResult> lst = new ArrayList<GeocodingUtilities.GeocodingResult>(); List<GeocodingResult> lst = new ArrayList<GeocodingUtilities.GeocodingResult>();
List<RouteSegmentPoint> listR = new ArrayList<BinaryRoutePlanner.RouteSegmentPoint>(); List<RouteSegmentPoint> listR = new ArrayList<BinaryRoutePlanner.RouteSegmentPoint>();
@ -151,14 +151,14 @@ public class GeocodingUtilities {
continue; continue;
} }
// System.out.println(road.toString() + " " + Math.sqrt(p.distSquare)); // System.out.println(road.toString() + " " + Math.sqrt(p.distSquare));
boolean emptyName = Algorithms.isEmpty(road.getName()) && Algorithms.isEmpty(road.getRef("", false, true)); String name = Algorithms.isEmpty(road.getName()) ? road.getRef("", false, true) : road.getName();
if (!emptyName) { if (allowEmptyNames || !Algorithms.isEmpty(name)) {
if (distSquare == 0 || distSquare > p.distSquare) { if (distSquare == 0 || distSquare > p.distSquare) {
distSquare = p.distSquare; distSquare = p.distSquare;
} }
GeocodingResult sr = new GeocodingResult(); GeocodingResult sr = new GeocodingResult();
sr.searchPoint = new LatLon(lat, lon); 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.point = p;
sr.connectionPoint = new LatLon(MapUtils.get31LatitudeY(p.preciseY), MapUtils.get31LongitudeX(p.preciseX)); sr.connectionPoint = new LatLon(MapUtils.get31LatitudeY(p.preciseY), MapUtils.get31LongitudeX(p.preciseX));
sr.regionFP = road.region.getFilePointer(); sr.regionFP = road.region.getFilePointer();

View file

@ -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)); reader = new BinaryMapIndexReader(new RandomAccessFile(fileName, "r"), new File(fileName));
// final Collator clt = OsmAndCollator.primaryCollator(); // final Collator clt = OsmAndCollator.primaryCollator();
final Map<String, String> parentRelations = new LinkedHashMap<String, String>(); final Map<String, String> parentRelations = new LinkedHashMap<String, String>();
@ -138,6 +138,7 @@ public class OsmandRegions {
} }
} }
structureWorldRegions(new ArrayList<WorldRegion>(fullNamesToRegionData.values())); structureWorldRegions(new ArrayList<WorldRegion>(fullNamesToRegionData.values()));
return reader;
} }
public boolean containsCountry(String name) { public boolean containsCountry(String name) {

View file

@ -9,6 +9,7 @@
3. All your modified/created strings are in the top of the file (to make easier find what\'s translated). 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 PLEASE: Have a look at http://code.google.com/p/osmand/wiki/UIConsistency, it may really improve your and our work :-) Thx - Hardy
--> -->
<string name="shared_string_road">Road</string>
<string name="show_map">Show map</string> <string name="show_map">Show map</string>
<string name="route_is_calculated">Route is calculated</string> <string name="route_is_calculated">Route is calculated</string>
<string name="round_trip">Round trip</string> <string name="round_trip">Round trip</string>

View file

@ -1,10 +1,8 @@
package net.osmand.plus; package net.osmand.plus;
import java.io.IOException; import android.os.AsyncTask;
import java.util.ArrayList; import android.support.annotation.NonNull;
import java.util.Collections; import android.support.annotation.Nullable;
import java.util.HashMap;
import java.util.List;
import net.osmand.Location; import net.osmand.Location;
import net.osmand.PlatformUtil; import net.osmand.PlatformUtil;
@ -21,7 +19,12 @@ import net.osmand.router.RoutePlannerFrontEnd;
import net.osmand.router.RoutingConfiguration; import net.osmand.router.RoutingConfiguration;
import net.osmand.router.RoutingContext; import net.osmand.router.RoutingContext;
import net.osmand.util.MapUtils; 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 { public class CurrentPositionHelper {
@ -43,12 +46,13 @@ public class CurrentPositionHelper {
return lastAskedLocation; return lastAskedLocation;
} }
public boolean getRouteSegment(Location loc, ResultMatcher<RouteDataObject> result) { public boolean getRouteSegment(Location loc, @Nullable ApplicationMode appMode,
return scheduleRouteSegmentFind(loc, false, null, result); ResultMatcher<RouteDataObject> result) {
return scheduleRouteSegmentFind(loc, false, true, null, result, appMode);
} }
public boolean getGeocodingResult(Location loc, ResultMatcher<GeocodingResult> result) { public boolean getGeocodingResult(Location loc, ResultMatcher<GeocodingResult> result) {
return scheduleRouteSegmentFind(loc, false, result, null); return scheduleRouteSegmentFind(loc, false, false, result, null, null);
} }
public RouteDataObject getLastKnownRouteSegment(Location loc) { public RouteDataObject getLastKnownRouteSegment(Location loc) {
@ -61,12 +65,12 @@ public class CurrentPositionHelper {
return r; return r;
} }
if (r == null) { if (r == null) {
scheduleRouteSegmentFind(loc, true, null, null); scheduleRouteSegmentFind(loc, true, false, null, null, null);
return null; return null;
} }
double d = getOrthogonalDistance(r, loc); double d = getOrthogonalDistance(r, loc);
if (d > 15) { if (d > 15) {
scheduleRouteSegmentFind(loc, true, null, null); scheduleRouteSegmentFind(loc, true, false, null, null, null);
} }
if (d < 70) { if (d < 70) {
return r; return r;
@ -76,14 +80,19 @@ public class CurrentPositionHelper {
///////////////////////// PRIVATE IMPLEMENTATION ////////////////////////// ///////////////////////// PRIVATE IMPLEMENTATION //////////////////////////
private boolean scheduleRouteSegmentFind(final Location loc, final boolean storeFound, final ResultMatcher<GeocodingResult> geoCoding, final ResultMatcher<RouteDataObject> result) { private boolean scheduleRouteSegmentFind(final Location loc,
final boolean storeFound,
final boolean allowEmptyNames,
@Nullable final ResultMatcher<GeocodingResult> geoCoding,
@Nullable final ResultMatcher<RouteDataObject> result,
@Nullable final ApplicationMode appMode) {
boolean res = false; boolean res = false;
if (loc != null) { if (loc != null) {
new AsyncTask<Void, Void, Void>() { new AsyncTask<Void, Void, Void>() {
@Override @Override
protected Void doInBackground(Void... params) { protected Void doInBackground(Void... params) {
try { try {
processGeocoding(loc, geoCoding, storeFound, result); processGeocoding(loc, geoCoding, storeFound, allowEmptyNames, result, appMode);
} catch (Exception e) { } catch (Exception e) {
log.error("Error processing geocoding", e); log.error("Error processing geocoding", e);
e.printStackTrace(); e.printStackTrace();
@ -96,8 +105,9 @@ public class CurrentPositionHelper {
return res; return res;
} }
private void initCtx(OsmandApplication app, List<BinaryMapReaderResource> checkReaders) { private void initCtx(OsmandApplication app, List<BinaryMapReaderResource> checkReaders,
am = app.getSettings().getApplicationMode(); @NonNull ApplicationMode appMode) {
am = appMode;
String p ; String p ;
if (am.isDerivedRoutingFrom(ApplicationMode.BICYCLE)) { if (am.isDerivedRoutingFrom(ApplicationMode.BICYCLE)) {
p = GeneralRouterProfile.BICYCLE.name().toLowerCase(); p = GeneralRouterProfile.BICYCLE.name().toLowerCase();
@ -129,9 +139,15 @@ public class CurrentPositionHelper {
} }
// single synchronized method // single synchronized method
private synchronized void processGeocoding(Location loc, ResultMatcher<GeocodingResult> geoCoding, boolean storeFound, final ResultMatcher<RouteDataObject> result) throws IOException { private synchronized void processGeocoding(@NonNull Location loc,
@Nullable ResultMatcher<GeocodingResult> geoCoding,
boolean storeFound,
boolean allowEmptyNames,
@Nullable final ResultMatcher<RouteDataObject> result,
@Nullable ApplicationMode appMode) throws IOException {
final List<GeocodingResult> gr = runUpdateInThread(loc.getLatitude(), loc.getLongitude(), final List<GeocodingResult> gr = runUpdateInThread(loc.getLatitude(), loc.getLongitude(),
geoCoding != null); geoCoding != null, allowEmptyNames, appMode);
if (storeFound) { if (storeFound) {
lastAskedLocation = loc; lastAskedLocation = loc;
lastFound = gr == null || gr.isEmpty() ? null : gr.get(0).point.getRoad(); lastFound = gr == null || gr.isEmpty() ? null : gr.get(0).point.getRoad();
@ -147,16 +163,24 @@ public class CurrentPositionHelper {
} }
} }
private List<GeocodingResult> runUpdateInThread(double lat, double lon, boolean geocoding) throws IOException { @Nullable
private List<GeocodingResult> runUpdateInThread(double lat, double lon,
boolean geocoding,
boolean allowEmptyNames,
@Nullable ApplicationMode appMode) throws IOException {
List<BinaryMapReaderResource> checkReaders = checkReaders(lat, lon, usedReaders); List<BinaryMapReaderResource> checkReaders = checkReaders(lat, lon, usedReaders);
if (ctx == null || am != app.getSettings().getApplicationMode() || checkReaders != usedReaders) { if (appMode == null) {
initCtx(app, checkReaders); appMode = app.getSettings().getApplicationMode();
}
if (ctx == null || am != appMode || checkReaders != usedReaders) {
initCtx(app, checkReaders, appMode);
if (ctx == null) { if (ctx == null) {
return null; return null;
} }
} }
try { try {
return new GeocodingUtilities().reverseGeocodingSearch(geocoding ? defCtx : ctx, lat, lon); return new GeocodingUtilities().reverseGeocodingSearch(geocoding ? defCtx : ctx, lat, lon, allowEmptyNames);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
return null; return null;

View file

@ -859,8 +859,9 @@ public class OsmAndLocationProvider implements SensorEventListener {
return currentPositionHelper.getLastKnownRouteSegment(getLastKnownLocation()); return currentPositionHelper.getLastKnownRouteSegment(getLastKnownLocation());
} }
public boolean getRouteSegment(net.osmand.Location loc, ResultMatcher<RouteDataObject> result) { public boolean getRouteSegment(net.osmand.Location loc, @Nullable ApplicationMode appMode,
return currentPositionHelper.getRouteSegment(loc, result); ResultMatcher<RouteDataObject> result) {
return currentPositionHelper.getRouteSegment(loc, appMode, result);
} }
public boolean getGeocodingResult(net.osmand.Location loc, ResultMatcher<GeocodingResult> result) { public boolean getGeocodingResult(net.osmand.Location loc, ResultMatcher<GeocodingResult> result) {

View file

@ -758,7 +758,7 @@ public class OsmandApplication extends MultiDexApplication {
return lang; return lang;
} }
public RoutingConfiguration.Builder getDefaultRoutingConfig() { public synchronized RoutingConfiguration.Builder getDefaultRoutingConfig() {
if(defaultRoutingConfig == null) { if(defaultRoutingConfig == null) {
defaultRoutingConfig = appInitializer.getLazyDefaultRoutingConfig(); defaultRoutingConfig = appInitializer.getLazyDefaultRoutingConfig();
} }

View file

@ -403,14 +403,24 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
@Override @Override
public void updateProgress(int progress) { public void updateProgress(int progress) {
if (findViewById(R.id.MapHudButtonsOverlay).getVisibility() == View.VISIBLE) { if (findViewById(R.id.MapHudButtonsOverlay).getVisibility() == View.VISIBLE) {
pbExtView.setVisibility(View.GONE); if (pbExtView.getVisibility() == View.VISIBLE) {
pb.setVisibility(View.VISIBLE); pbExtView.setVisibility(View.GONE);
}
if (pb.getVisibility() == View.GONE) {
pb.setVisibility(View.VISIBLE);
}
pb.setProgress(progress); pb.setProgress(progress);
pb.invalidate();
pb.requestLayout(); pb.requestLayout();
} else { } else {
pb.setVisibility(View.GONE); if (pb.getVisibility() == View.VISIBLE) {
pbExtView.setVisibility(View.VISIBLE); pb.setVisibility(View.GONE);
}
if (pbExtView.getVisibility() == View.GONE) {
pbExtView.setVisibility(View.VISIBLE);
}
pbExt.setProgress(progress); pbExt.setProgress(progress);
pbExt.invalidate();
pbExt.requestLayout(); pbExt.requestLayout();
} }
} }

View file

@ -11,12 +11,14 @@ import android.widget.ImageButton;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.TextView; import android.widget.TextView;
import android.widget.Toast; import android.widget.Toast;
import net.osmand.CallbackWithObject; import net.osmand.CallbackWithObject;
import net.osmand.Location; import net.osmand.Location;
import net.osmand.ResultMatcher; import net.osmand.ResultMatcher;
import net.osmand.binary.RouteDataObject; import net.osmand.binary.RouteDataObject;
import net.osmand.data.LatLon; import net.osmand.data.LatLon;
import net.osmand.data.PointDescription; import net.osmand.data.PointDescription;
import net.osmand.plus.ApplicationMode;
import net.osmand.plus.OsmAndFormatter; import net.osmand.plus.OsmAndFormatter;
import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R; 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.routing.RoutingHelper;
import net.osmand.plus.views.AnimateDraggingMapThread; import net.osmand.plus.views.AnimateDraggingMapThread;
import net.osmand.plus.views.ContextMenuLayer; import net.osmand.plus.views.ContextMenuLayer;
import net.osmand.router.RoutingConfiguration; import net.osmand.util.Algorithms;
import net.osmand.router.RoutingConfiguration.Builder;
import net.osmand.util.MapUtils; import net.osmand.util.MapUtils;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
public class AvoidSpecificRoads { public class AvoidSpecificRoads {
private List<RouteDataObject> missingRoads; private List<RouteDataObject> impassableRoads;
private OsmandApplication app; private OsmandApplication app;
public AvoidSpecificRoads(OsmandApplication app) { public AvoidSpecificRoads(OsmandApplication app) {
@ -47,24 +48,23 @@ public class AvoidSpecificRoads {
} }
} }
public List<RouteDataObject> getMissingRoads() { private List<RouteDataObject> getImpassableRoads() {
if (missingRoads == null) { if (impassableRoads == null) {
missingRoads = app.getDefaultRoutingConfig().getImpassableRoads(); impassableRoads = app.getDefaultRoutingConfig().getImpassableRoads();
} }
return missingRoads; return impassableRoads;
} }
private ArrayAdapter<RouteDataObject> createAdapter(final MapActivity ctx) {
public ArrayAdapter<RouteDataObject> createAdapter(final MapActivity ctx) {
final ArrayList<RouteDataObject> points = new ArrayList<>(); final ArrayList<RouteDataObject> points = new ArrayList<>();
points.addAll(getMissingRoads()); points.addAll(getImpassableRoads());
final LatLon mapLocation = ctx.getMapLocation(); final LatLon mapLocation = ctx.getMapLocation();
return new ArrayAdapter<RouteDataObject>(ctx, return new ArrayAdapter<RouteDataObject>(ctx,
R.layout.waypoint_reached, R.id.title, points) { R.layout.waypoint_reached, R.id.title, points) {
@NonNull
@Override @Override
public View getView(final int position, View convertView, ViewGroup parent) { public View getView(final int position, View convertView, @NonNull ViewGroup parent) {
// User super class to create the View
View v = convertView; View v = convertView;
if (v == null || v.findViewById(R.id.info_close) == null) { if (v == null || v.findViewById(R.id.info_close) == null) {
v = ctx.getLayoutInflater().inflate(R.layout.waypoint_reached, parent, false); v = ctx.getLayoutInflater().inflate(R.layout.waypoint_reached, parent, false);
@ -107,24 +107,26 @@ public class AvoidSpecificRoads {
protected String getText(RouteDataObject obj) { protected String getText(RouteDataObject obj) {
return RoutingHelper.formatStreetName(obj.getName(app.getSettings().MAP_PREFERRED_LOCALE.get(), String name = RoutingHelper.formatStreetName(obj.getName(app.getSettings().MAP_PREFERRED_LOCALE.get(),
app.getSettings().MAP_TRANSLITERATE_NAMES.get()), app.getSettings().MAP_TRANSLITERATE_NAMES.get()),
obj.getRef(app.getSettings().MAP_PREFERRED_LOCALE.get(), app.getSettings().MAP_TRANSLITERATE_NAMES.get(), true), 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), obj.getDestinationName(app.getSettings().MAP_PREFERRED_LOCALE.get(), app.getSettings().MAP_TRANSLITERATE_NAMES.get(), true),
app.getString(R.string.towards)); app.getString(R.string.towards));
return Algorithms.isEmpty(name) ? app.getString(R.string.shared_string_road) : name;
} }
public void showDialog(@NonNull final MapActivity mapActivity) { public void showDialog(@NonNull final MapActivity mapActivity) {
AlertDialog.Builder bld = new AlertDialog.Builder(mapActivity); AlertDialog.Builder bld = new AlertDialog.Builder(mapActivity);
bld.setTitle(R.string.impassable_road); bld.setTitle(R.string.impassable_road);
if (getMissingRoads().size() == 0) { if (getImpassableRoads().size() == 0) {
bld.setMessage(R.string.avoid_roads_msg); bld.setMessage(R.string.avoid_roads_msg);
} else { } else {
final ArrayAdapter<?> listAdapter = createAdapter(mapActivity); final ArrayAdapter<?> listAdapter = createAdapter(mapActivity);
bld.setAdapter(listAdapter, new DialogInterface.OnClickListener() { bld.setAdapter(listAdapter, new DialogInterface.OnClickListener() {
@Override @Override
public void onClick(DialogInterface dialog, int which) { 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 lat = MapUtils.get31LatitudeY(obj.getPoint31YTile(0));
double lon = MapUtils.get31LongitudeX(obj.getPoint31XTile(0)); double lon = MapUtils.get31LongitudeX(obj.getPoint31XTile(0));
showOnMap(mapActivity, lat, lon, getText(obj), dialog); 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(); ContextMenuLayer cm = mapActivity.getMapLayers().getContextMenuLayer();
cm.setSelectOnMap(new CallbackWithObject<LatLon>() { cm.setSelectOnMap(new CallbackWithObject<LatLon>() {
@ -165,7 +167,9 @@ public class AvoidSpecificRoads {
final Location ll = new Location(""); final Location ll = new Location("");
ll.setLatitude(loc.getLatitude()); ll.setLatitude(loc.getLatitude());
ll.setLongitude(loc.getLongitude()); ll.setLongitude(loc.getLongitude());
app.getLocationProvider().getRouteSegment(ll, new ResultMatcher<RouteDataObject>() { ApplicationMode appMode = app.getRoutingHelper().getAppMode();
app.getLocationProvider().getRouteSegment(ll, appMode, new ResultMatcher<RouteDataObject>() {
@Override @Override
public boolean publish(RouteDataObject object) { public boolean publish(RouteDataObject object) {
@ -207,7 +211,9 @@ public class AvoidSpecificRoads {
final Location ll = new Location(""); final Location ll = new Location("");
ll.setLatitude(loc.getLatitude()); ll.setLatitude(loc.getLatitude());
ll.setLongitude(loc.getLongitude()); ll.setLongitude(loc.getLongitude());
app.getLocationProvider().getRouteSegment(ll, new ResultMatcher<RouteDataObject>() { ApplicationMode appMode = app.getRoutingHelper().getAppMode();
app.getLocationProvider().getRouteSegment(ll, appMode, new ResultMatcher<RouteDataObject>() {
@Override @Override
public boolean publish(RouteDataObject object) { public boolean publish(RouteDataObject object) {
@ -239,9 +245,9 @@ public class AvoidSpecificRoads {
boolean showDialog, boolean showDialog,
@Nullable MapActivity activity, @Nullable MapActivity activity,
@NonNull LatLon loc) { @NonNull LatLon loc) {
if(!app.getDefaultRoutingConfig().addImpassableRoad(object, ll)) { if (!app.getDefaultRoutingConfig().addImpassableRoad(object, ll)) {
LatLon location = getLocation(object); LatLon location = getLocation(object);
if(location != null) { if (location != null) {
app.getSettings().removeImpassableRoad(getLocation(object)); app.getSettings().removeImpassableRoad(getLocation(object));
} }
} }

View file

@ -952,14 +952,14 @@ public class RoutingHelper {
} }
public void startRouteCalculationThread(RouteCalculationParams params, boolean paramsChanged, boolean updateProgress) { public void startRouteCalculationThread(RouteCalculationParams params, boolean paramsChanged, boolean updateProgress) {
if (updateProgress) {
updateProgress(params);
}
synchronized (this) { synchronized (this) {
final Thread prevRunningJob = currentRunningJob; final Thread prevRunningJob = currentRunningJob;
RouteRecalculationThread newThread = new RouteRecalculationThread( RouteRecalculationThread newThread = new RouteRecalculationThread(
"Calculating route", params, paramsChanged); //$NON-NLS-1$ "Calculating route", params, paramsChanged); //$NON-NLS-1$
currentRunningJob = newThread; currentRunningJob = newThread;
if (updateProgress) {
updateProgress(params);
}
if (prevRunningJob != null) { if (prevRunningJob != null) {
newThread.setWaitPrevJob(prevRunningJob); newThread.setWaitPrevJob(prevRunningJob);
} }
@ -974,7 +974,7 @@ public class RoutingHelper {
} else { } else {
progressRoute = this.progressRoute; progressRoute = this.progressRoute;
} }
if(progressRoute != null ) { if (progressRoute != null ) {
app.runInUIThread(new Runnable() { app.runInUIThread(new Runnable() {
@Override @Override
@ -986,6 +986,8 @@ public class RoutingHelper {
if (all > 0) { if (all > 0) {
int t = (int) Math.min(p * p / (all * all) * 100f, 99); int t = (int) Math.min(p * p / (all * all) * 100f, 99);
progressRoute.updateProgress(t); progressRoute.updateProgress(t);
} else {
progressRoute.updateProgress(0);
} }
Thread t = currentRunningJob; Thread t = currentRunningJob;
if(t instanceof RouteRecalculationThread && ((RouteRecalculationThread) t).params != params) { if(t instanceof RouteRecalculationThread && ((RouteRecalculationThread) t).params != params) {

View file

@ -34,15 +34,14 @@ public class ImpassableRoadsLayer extends OsmandMapLayer implements
private static final int startZoom = 10; private static final int startZoom = 10;
private final MapActivity activity; private final MapActivity activity;
private Bitmap roadWorkIcon; private Bitmap roadWorkIcon;
private OsmandMapTileView view;
private Paint paint; private Paint paint;
private Map<Long, Location> missingRoadLocations; private Map<Long, Location> impassableRoadLocations;
private List<RouteDataObject> missingRoads; private List<RouteDataObject> impassableRoads;
private RoutingHelper routingHelper; private RoutingHelper routingHelper;
private ContextMenuLayer contextMenuLayer; private ContextMenuLayer contextMenuLayer;
private Set<PreservedRoadDataObject> mPreservedRoadDataObjects; private Set<StoredRoadDataObject> storedRoadDataObjects;
public ImpassableRoadsLayer(MapActivity activity) { public ImpassableRoadsLayer(MapActivity activity) {
this.activity = activity; this.activity = activity;
@ -50,7 +49,6 @@ public class ImpassableRoadsLayer extends OsmandMapLayer implements
@Override @Override
public void initLayer(OsmandMapTileView view) { public void initLayer(OsmandMapTileView view) {
this.view = view;
roadWorkIcon = BitmapFactory.decodeResource(view.getResources(), R.drawable.map_pin_avoid_road); roadWorkIcon = BitmapFactory.decodeResource(view.getResources(), R.drawable.map_pin_avoid_road);
paint = new Paint(); paint = new Paint();
routingHelper = activity.getRoutingHelper(); routingHelper = activity.getRoutingHelper();
@ -58,9 +56,9 @@ public class ImpassableRoadsLayer extends OsmandMapLayer implements
contextMenuLayer = view.getLayerByClass(ContextMenuLayer.class); contextMenuLayer = view.getLayerByClass(ContextMenuLayer.class);
List<LatLon> impassibleRoads = activity.getMyApplication().getSettings().getImpassableRoadPoints(); List<LatLon> impassibleRoads = activity.getMyApplication().getSettings().getImpassableRoadPoints();
mPreservedRoadDataObjects = new HashSet<>(impassibleRoads.size()); storedRoadDataObjects = new HashSet<>(impassibleRoads.size());
for (LatLon impassibleRoad : impassibleRoads) { 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 @Override
public void onPrepareBufferImage(Canvas canvas, RotatedTileBox tileBox, DrawSettings settings) { public void onPrepareBufferImage(Canvas canvas, RotatedTileBox tileBox, DrawSettings settings) {
if (tileBox.getZoom() >= startZoom) { if (tileBox.getZoom() >= startZoom) {
for (long id : getMissingRoadLocations().keySet()) { for (long id : getImpassableRoadLocations().keySet()) {
if(contextMenuLayer.getMoveableObject() instanceof RouteDataObject) { if (contextMenuLayer.getMoveableObject() instanceof RouteDataObject) {
RouteDataObject object = (RouteDataObject) contextMenuLayer.getMoveableObject(); RouteDataObject object = (RouteDataObject) contextMenuLayer.getMoveableObject();
if (object.id == id) { if (object.id == id) {
continue; continue;
} }
} }
Location location = getMissingRoadLocations().get(id); Location location = getImpassableRoadLocations().get(id);
final double latitude = location.getLatitude(); final double latitude = location.getLatitude();
final double longitude = location.getLongitude(); final double longitude = location.getLongitude();
drawPoint(canvas, tileBox, latitude, longitude); if (tileBox.containsLatLon(latitude, longitude)) {
drawPoint(canvas, tileBox, latitude, longitude);
}
} }
for (PreservedRoadDataObject preservedRoadDataObject : mPreservedRoadDataObjects) { for (StoredRoadDataObject storedRoadDataObject : storedRoadDataObjects) {
final LatLon latLon = preservedRoadDataObject.getLatLon(); final LatLon latLon = storedRoadDataObject.getLatLon();
drawPoint(canvas, tileBox, latLon.getLatitude(), latLon.getLongitude()); 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); canvas.drawBitmap(roadWorkIcon, left, top, paint);
} }
public Map<Long, Location> getMissingRoadLocations() { private Map<Long, Location> getImpassableRoadLocations() {
if (missingRoadLocations == null) { if (impassableRoadLocations == null) {
missingRoadLocations = activity.getMyApplication().getDefaultRoutingConfig().getImpassableRoadLocations(); impassableRoadLocations = activity.getMyApplication().getDefaultRoutingConfig().getImpassableRoadLocations();
} }
return missingRoadLocations; return impassableRoadLocations;
} }
public List<RouteDataObject> getMissingRoads() { private List<RouteDataObject> getImpassableRoads() {
if (missingRoads == null) { if (impassableRoads == null) {
missingRoads = activity.getMyApplication().getDefaultRoutingConfig().getImpassableRoads(); impassableRoads = activity.getMyApplication().getDefaultRoutingConfig().getImpassableRoads();
} }
return missingRoads; return impassableRoads;
} }
@Override @Override
@ -130,7 +132,7 @@ public class ImpassableRoadsLayer extends OsmandMapLayer implements
return true; return true;
} }
public int getRadiusPoi(RotatedTileBox tb) { private int getRadiusPoi(RotatedTileBox tb) {
int r; int r;
if (tb.getZoom() < startZoom) { if (tb.getZoom() < startZoom) {
r = 0; r = 0;
@ -167,8 +169,8 @@ public class ImpassableRoadsLayer extends OsmandMapLayer implements
int compare = getRadiusPoi(tileBox); int compare = getRadiusPoi(tileBox);
int radius = compare * 3 / 2; int radius = compare * 3 / 2;
for (RouteDataObject road : getMissingRoads()) { for (RouteDataObject road : getImpassableRoads()) {
Location location = getMissingRoadLocations().get(road.getId()); Location location = getImpassableRoadLocations().get(road.getId());
if (location != null) { if (location != null) {
int x = (int) tileBox.getPixXFromLatLon(location.getLatitude(), location.getLongitude()); int x = (int) tileBox.getPixXFromLatLon(location.getLatitude(), location.getLongitude());
int y = (int) tileBox.getPixYFromLatLon(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(); activity.getMyApplication().getAvoidSpecificRoads().initPreservedData();
mPreservedRoadDataObjects.clear(); storedRoadDataObjects.clear();
} }
} }
@ -189,7 +191,7 @@ public class ImpassableRoadsLayer extends OsmandMapLayer implements
public LatLon getObjectLocation(Object o) { public LatLon getObjectLocation(Object o) {
if (o instanceof RouteDataObject) { if (o instanceof RouteDataObject) {
RouteDataObject route = (RouteDataObject) o; RouteDataObject route = (RouteDataObject) o;
Location location = missingRoadLocations.get(route.getId()); Location location = impassableRoadLocations.get(route.getId());
return new LatLon(location.getLatitude(), location.getLongitude()); return new LatLon(location.getLatitude(), location.getLongitude());
} }
return null; return null;
@ -255,15 +257,15 @@ public class ImpassableRoadsLayer extends OsmandMapLayer implements
} }
} }
private static class PreservedRoadDataObject { private static class StoredRoadDataObject {
private final LatLon mLatLon; private final LatLon latLon;
private PreservedRoadDataObject(LatLon latLon) { private StoredRoadDataObject(LatLon latLon) {
this.mLatLon = latLon; this.latLon = latLon;
} }
public LatLon getLatLon() { public LatLon getLatLon() {
return mLatLon; return latLon;
} }
} }
} }

View file

@ -148,7 +148,7 @@ public class CurrentPositionHelper {
} }
} }
try { try {
return new GeocodingUtilities().reverseGeocodingSearch(defCtx, lat, lon); return new GeocodingUtilities().reverseGeocodingSearch(defCtx, lat, lon, false);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
return null; return null;