Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
01f43a91c9
8 changed files with 61 additions and 28 deletions
|
@ -81,7 +81,7 @@ public class BinaryRoutePlannerOld {
|
|||
TLongObjectHashMap<RouteSegment> visitedDirectSegments = new TLongObjectHashMap<RouteSegment>();
|
||||
TLongObjectHashMap<RouteSegment> visitedOppositeSegments = new TLongObjectHashMap<RouteSegment>();
|
||||
|
||||
boolean runRecalculation = ctx.previouslyCalculatedRoute != null && ctx.previouslyCalculatedRoute.size() > 0
|
||||
boolean runRecalculation = ctx.previouslyCalculatedRoute != null && ctx.previouslyCalculatedRoute.size() > 0
|
||||
&& ctx.config.recalculateDistance != 0;
|
||||
if (runRecalculation) {
|
||||
RouteSegment previous = null;
|
||||
|
|
|
@ -23,7 +23,7 @@ import org.apache.commons.logging.Log;
|
|||
public class RoutePlannerFrontEnd {
|
||||
|
||||
private boolean useOldVersion;
|
||||
protected static final Log log = PlatformUtil.getLog(BinaryRoutePlannerOld.class);
|
||||
protected static final Log log = PlatformUtil.getLog(RoutePlannerFrontEnd.class);
|
||||
|
||||
public RoutePlannerFrontEnd(boolean useOldVersion) {
|
||||
this.useOldVersion = useOldVersion;
|
||||
|
@ -336,19 +336,25 @@ public class RoutePlannerFrontEnd {
|
|||
List<RouteSegmentResult> prev = ctx.previouslyCalculatedRoute;
|
||||
long id = points.get(1).getRoad().id;
|
||||
int ss = points.get(1).getSegmentStart();
|
||||
int px = points.get(1).getRoad().getPoint31XTile(ss);
|
||||
int py = points.get(1).getRoad().getPoint31YTile(ss);
|
||||
for (int i = 0; i < prev.size(); i++) {
|
||||
RouteSegmentResult rsr = prev.get(i);
|
||||
if (id == rsr.getObject().getId() && ss == rsr.getEndPointIndex()) {
|
||||
firstPartRecalculatedRoute = new ArrayList<RouteSegmentResult>(i + 1);
|
||||
restPartRecalculatedRoute = new ArrayList<RouteSegmentResult>(prev.size() - i);
|
||||
for (int k = 0; k < prev.size(); k++) {
|
||||
if (k <= i) {
|
||||
firstPartRecalculatedRoute.add(prev.get(k));
|
||||
} else {
|
||||
restPartRecalculatedRoute.add(prev.get(k));
|
||||
if (id == rsr.getObject().getId()) {
|
||||
if (MapUtils.getDistance(rsr.getPoint(rsr.getEndPointIndex()), MapUtils.get31LatitudeY(py),
|
||||
MapUtils.get31LongitudeX(px)) < 50) {
|
||||
firstPartRecalculatedRoute = new ArrayList<RouteSegmentResult>(i + 1);
|
||||
restPartRecalculatedRoute = new ArrayList<RouteSegmentResult>(prev.size() - i);
|
||||
for (int k = 0; k < prev.size(); k++) {
|
||||
if (k <= i) {
|
||||
firstPartRecalculatedRoute.add(prev.get(k));
|
||||
} else {
|
||||
restPartRecalculatedRoute.add(prev.get(k));
|
||||
}
|
||||
}
|
||||
System.out.println("Recalculate only first part of the route");
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -224,7 +224,7 @@ public class ConfigureMapMenu {
|
|||
final String[] txtNames = new String[txtValues.length];
|
||||
for (int i = 0; i < txtNames.length; i++) {
|
||||
txtNames[i] = (int) (txtValues[i] * 100) + " %";
|
||||
if (view.getSettings().TEXT_SCALE.get() == txtValues[i]) {
|
||||
if (Math.abs(view.getSettings().TEXT_SCALE.get() - txtValues[i]) < 0.1f) {
|
||||
selected = i;
|
||||
}
|
||||
}
|
||||
|
@ -235,6 +235,7 @@ public class ConfigureMapMenu {
|
|||
refreshMapComplete(activity);
|
||||
adapter.setItemDescription(pos, getScale(activity));
|
||||
ad.notifyDataSetInvalidated();
|
||||
dialog.dismiss();
|
||||
}
|
||||
});
|
||||
b.show();
|
||||
|
|
|
@ -36,11 +36,14 @@ public class DownloadIndexAdapter extends OsmandBaseExpandableListAdapter implem
|
|||
private int updateColor;
|
||||
private OsmandRegions osmandRegions;
|
||||
private java.text.DateFormat format;
|
||||
private OsmandApplication app;
|
||||
|
||||
public DownloadIndexAdapter(DownloadIndexFragment downloadFragment, List<IndexItem> indexFiles) {
|
||||
this.downloadFragment = downloadFragment;
|
||||
|
||||
this.indexFiles = new ArrayList<IndexItem>(indexFiles);
|
||||
List<IndexItemCategory> cats = IndexItemCategory.categorizeIndexItems(downloadFragment.getMyApplication(), indexFiles);
|
||||
app = downloadFragment.getMyApplication();
|
||||
List<IndexItemCategory> cats = IndexItemCategory.categorizeIndexItems(app, indexFiles);
|
||||
synchronized (this) {
|
||||
list.clear();
|
||||
list.addAll(cats);
|
||||
|
@ -165,7 +168,7 @@ public class DownloadIndexAdapter extends OsmandBaseExpandableListAdapter implem
|
|||
list.clear();
|
||||
Collection<IndexItem> items = (Collection<IndexItem>) results.values;
|
||||
if (items != null && !items.isEmpty()) {
|
||||
list.addAll(IndexItemCategory.categorizeIndexItems(downloadFragment.getMyApplication(), items));
|
||||
list.addAll(IndexItemCategory.categorizeIndexItems(app, items));
|
||||
} else if(DownloadIndexAdapter.this.indexFiles.isEmpty()){
|
||||
list.add(new IndexItemCategory(downloadFragment.getResources().getString(R.string.no_index_file_to_download), 1));
|
||||
} else {
|
||||
|
|
|
@ -1,8 +1,11 @@
|
|||
package net.osmand.plus.download;
|
||||
|
||||
import java.io.File;
|
||||
import java.text.Collator;
|
||||
import java.text.MessageFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
|
@ -264,6 +267,8 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment {
|
|||
@Override
|
||||
protected void onPostExecute(List<LocalIndexInfo> result) {
|
||||
this.result = result;
|
||||
listAdapter.sortData();
|
||||
|
||||
getDownloadActivity().setSupportProgressBarIndeterminateVisibility(false);
|
||||
getDownloadActivity().setLocalIndexInfos(result);
|
||||
}
|
||||
|
@ -759,6 +764,19 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment {
|
|||
filterCategory = null;
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
public void sortData() {
|
||||
final Collator cl = Collator.getInstance();
|
||||
for(List<LocalIndexInfo> i : data.values()) {
|
||||
Collections.sort(i, new Comparator<LocalIndexInfo>() {
|
||||
|
||||
@Override
|
||||
public int compare(LocalIndexInfo lhs, LocalIndexInfo rhs) {
|
||||
return cl.compare(lhs.getName(), rhs.getName());
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public LocalIndexInfo findCategory(LocalIndexInfo val, boolean backuped){
|
||||
for(LocalIndexInfo i : category){
|
||||
|
@ -1017,8 +1035,8 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment {
|
|||
name = fileName.substring(0, ls);
|
||||
}
|
||||
|
||||
if (name.endsWith("-roads")){
|
||||
return ctx.getString(R.string.download_roads_only_item);
|
||||
if (name.endsWith("-roads")) {
|
||||
return ctx.getString(R.string.download_roads_only_item);
|
||||
}
|
||||
|
||||
return "";
|
||||
|
|
|
@ -16,11 +16,13 @@ public class RouteCalculationParams {
|
|||
public LatLon end;
|
||||
public List<LatLon> intermediates;
|
||||
|
||||
|
||||
public OsmandApplication ctx;
|
||||
public ApplicationMode mode;
|
||||
public RouteService type;
|
||||
public GPXRouteParams gpxRoute;
|
||||
public RouteCalculationResult previousToRecalculate;
|
||||
public boolean onlyStartPointChanged;
|
||||
public boolean fast;
|
||||
public boolean leftSide;
|
||||
public RouteCalculationProgress calculationProgress;
|
||||
|
|
|
@ -394,7 +394,8 @@ public class RouteProvider {
|
|||
rp.leftSide = routeParams.leftSide;
|
||||
rp.type = routeParams.type;
|
||||
rp.fast = routeParams.fast;
|
||||
rp.previousToRecalculate = routeParams.previousToRecalculate;
|
||||
rp.onlyStartPointChanged = routeParams.onlyStartPointChanged;
|
||||
rp.previousToRecalculate = routeParams.previousToRecalculate;
|
||||
rp.intermediates = new ArrayList<LatLon>();
|
||||
for(Location w : intermediates) {
|
||||
rp.intermediates.add(new LatLon(w.getLatitude(), w.getLongitude()));
|
||||
|
@ -656,8 +657,7 @@ public class RouteProvider {
|
|||
}
|
||||
ctx.leftSideNavigation = params.leftSide;
|
||||
ctx.calculationProgress = params.calculationProgress;
|
||||
if(params.previousToRecalculate != null) {
|
||||
// not used any more
|
||||
if(params.previousToRecalculate != null && params.onlyStartPointChanged) {
|
||||
ctx.previouslyCalculatedRoute = params.previousToRecalculate.getOriginalRoute();
|
||||
}
|
||||
LatLon st = new LatLon(params.start.getLatitude(), params.start.getLongitude());
|
||||
|
|
|
@ -138,7 +138,7 @@ public class RoutingHelper {
|
|||
RouteCalculationResult previousRoute = route;
|
||||
clearCurrentRoute(finalLocation, intermediatePoints);
|
||||
// to update route
|
||||
setCurrentLocation(currentLocation, false, previousRoute);
|
||||
setCurrentLocation(currentLocation, false, previousRoute, true);
|
||||
}
|
||||
|
||||
public synchronized void clearCurrentRoute(LatLon newFinalLocation, List<LatLon> newIntermediatePoints) {
|
||||
|
@ -227,7 +227,7 @@ public class RoutingHelper {
|
|||
}
|
||||
|
||||
public Location setCurrentLocation(Location currentLocation, boolean returnUpdatedLocation) {
|
||||
return setCurrentLocation(currentLocation, returnUpdatedLocation, route);
|
||||
return setCurrentLocation(currentLocation, returnUpdatedLocation, route, false);
|
||||
}
|
||||
|
||||
public double getRouteDeviation(){
|
||||
|
@ -240,7 +240,8 @@ public class RoutingHelper {
|
|||
return getOrthogonalDistance(lastFixedLocation, routeNodes.get(route.currentRoute -1), routeNodes.get(route.currentRoute));
|
||||
}
|
||||
|
||||
private Location setCurrentLocation(Location currentLocation, boolean returnUpdatedLocation, RouteCalculationResult previousRoute) {
|
||||
private Location setCurrentLocation(Location currentLocation, boolean returnUpdatedLocation,
|
||||
RouteCalculationResult previousRoute, boolean targetPointsChanged) {
|
||||
Location locationProjection = currentLocation;
|
||||
if (finalLocation == null || currentLocation == null) {
|
||||
isDeviatedFromRoute = false;
|
||||
|
@ -316,7 +317,7 @@ public class RoutingHelper {
|
|||
|
||||
if (calculateRoute) {
|
||||
recalculateRouteInBackground(false, currentLocation, finalLocation, intermediatePoints, currentGPXRoute,
|
||||
previousRoute.isCalculated() ? previousRoute : null, false);
|
||||
previousRoute.isCalculated() ? previousRoute : null, false, !targetPointsChanged);
|
||||
} else {
|
||||
Thread job = currentRunningJob;
|
||||
if(job instanceof RouteRecalculationThread) {
|
||||
|
@ -772,29 +773,31 @@ public class RoutingHelper {
|
|||
}
|
||||
|
||||
public void recalculateRouteDueToSettingsChange() {
|
||||
recalculateRouteInBackground(true, lastFixedLocation, finalLocation, intermediatePoints, currentGPXRoute, route, true);
|
||||
recalculateRouteInBackground(true, lastFixedLocation, finalLocation, intermediatePoints, currentGPXRoute, route,
|
||||
true, false);
|
||||
}
|
||||
|
||||
private void recalculateRouteInBackground(boolean force, final Location start, final LatLon end, final List<LatLon> intermediates,
|
||||
final GPXRouteParamsBuilder gpxRoute, final RouteCalculationResult previousRoute, boolean paramsChanged){
|
||||
final GPXRouteParamsBuilder gpxRoute, final RouteCalculationResult previousRoute, boolean paramsChanged, boolean onlyStartPointChanged){
|
||||
if (start == null || end == null) {
|
||||
return;
|
||||
}
|
||||
if(currentRunningJob == null){
|
||||
if (currentRunningJob == null) {
|
||||
// do not evaluate very often
|
||||
if (force || System.currentTimeMillis() - lastTimeEvaluatedRoute > evalWaitInterval) {
|
||||
RouteCalculationParams params = new RouteCalculationParams();
|
||||
params.start = start;
|
||||
params.end = end;
|
||||
params.intermediates = intermediates;
|
||||
params.gpxRoute = gpxRoute == null? null : gpxRoute.build(start, settings);
|
||||
params.gpxRoute = gpxRoute == null ? null : gpxRoute.build(start, settings);
|
||||
params.onlyStartPointChanged = onlyStartPointChanged;
|
||||
params.previousToRecalculate = previousRoute;
|
||||
params.leftSide = settings.DRIVING_REGION.get().leftHandDriving;
|
||||
params.fast = settings.FAST_ROUTE_MODE.getModeValue(mode);
|
||||
params.type = settings.ROUTER_SERVICE.getModeValue(mode);
|
||||
params.mode = mode;
|
||||
params.ctx = app;
|
||||
if(previousRoute == null && params.type == RouteService.OSMAND) {
|
||||
if (previousRoute == null && params.type == RouteService.OSMAND) {
|
||||
params.calculationProgress = new RouteCalculationProgress();
|
||||
updateProgress(params.calculationProgress);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue