Merge branch 'master' of ssh://github.com/osmandapp/Osmand

This commit is contained in:
Alexey Pelykh 2014-02-23 00:11:14 +02:00
commit 3dea3362c4
6 changed files with 50 additions and 57 deletions

View file

@ -57,10 +57,13 @@ public class BinaryInspector {
if(args.length == 1 && "test".equals(args[0])) {
in.inspector(new String[]{
//"-vpoi",
// "-vmap", "-vmapobjects",
//"-vstreets",
//"-vmap", "-vmapobjects",
//"-vaddress", "-vcities", "-vstreets", "-vstreetgroups","-vbuildings",
//"-zoom=16",
//"-bbox=4,55,7,50",
"/home/victor/projects/osmand/osm-gen/Map.obf"});
//"/home/victor/osmand/Test.obf"
//"/home/victor/projects/osmand/osm-gen/Map.obf"
});
} else {
in.inspector(args);
}

View file

@ -156,10 +156,7 @@ public class RoutePlannerFrontEnd {
private List<RouteSegmentResult> searchRouteInternalPrepare(final RoutingContext ctx, RouteSegment start, RouteSegment end,
PrecalculatedRouteDirection routeDirection) throws IOException, InterruptedException {
ctx.targetX = end.road.getPoint31XTile(end.getSegmentStart());
ctx.targetY = end.road.getPoint31YTile(end.getSegmentStart());
ctx.startX = start.road.getPoint31XTile(start.getSegmentStart());
ctx.startY = start.road.getPoint31YTile(start.getSegmentStart());
ctx.initStartAndTargetPoints(start, end);
if(routeDirection != null) {
ctx.precalculatedRouteDirection = routeDirection.adopt(ctx);
}
@ -178,6 +175,7 @@ public class RoutePlannerFrontEnd {
}
}
private void refreshProgressDistance(RoutingContext ctx) {
if(ctx.calculationProgress != null) {
ctx.calculationProgress.distanceFromBegin = 0;

View file

@ -78,7 +78,7 @@ public class RoutingContext {
// 3. Warm object caches
ArrayList<RouteSegment> segmentsToVisitPrescripted = new ArrayList<BinaryRoutePlanner.RouteSegment>(5);
ArrayList<RouteSegment> segmentsToVisitNotForbidden = new ArrayList<BinaryRoutePlanner.RouteSegment>(5);
// 5. debug information (package accessor)
public TileStatistics global = new TileStatistics();
@ -106,7 +106,10 @@ public class RoutingContext {
// old planner
public FinalRouteSegment finalRouteSegment;
public RoutingContext(RoutingContext cp) {
RoutingContext(RoutingContext cp) {
this.config = cp.config;
this.map.putAll(cp.map);
this.calculationMode = cp.calculationMode;
@ -131,11 +134,7 @@ public class RoutingContext {
}
}
public RoutingContext(RoutingConfiguration config, NativeLibrary nativeLibrary, BinaryMapIndexReader[] map) {
this(config, nativeLibrary, map, null);
}
public RoutingContext(RoutingConfiguration config, NativeLibrary nativeLibrary, BinaryMapIndexReader[] map, RouteCalculationMode calcMode) {
RoutingContext(RoutingConfiguration config, NativeLibrary nativeLibrary, BinaryMapIndexReader[] map, RouteCalculationMode calcMode) {
this.calculationMode = calcMode;
for (BinaryMapIndexReader mr : map) {
List<RouteRegion> rr = mr.getRoutingIndexes();
@ -207,6 +206,13 @@ public class RoutingContext {
config.heuristicCoefficient);
}
public void initStartAndTargetPoints(RouteSegment start, RouteSegment end) {
targetX = end.road.getPoint31XTile(end.getSegmentStart());
targetY = end.road.getPoint31YTile(end.getSegmentStart());
startX = start.road.getPoint31XTile(start.getSegmentStart());
startY = start.road.getPoint31YTile(start.getSegmentStart());
}
public void registerRouteDataObject(RouteDataObject o ) {
if(!getRouter().acceptLine(o)){
return;
@ -459,8 +465,9 @@ public class RoutingContext {
}
}
TLongIterator it = ts.iterator();
TLongObjectHashMap<RouteDataObject> excludeDuplications = new TLongObjectHashMap<RouteDataObject>();
while(it.hasNext()){
getAllObjects(it.next(), toFillIn);
getAllObjects(it.next(), toFillIn, excludeDuplications);
}
timeToFindInitialSegments += (System.nanoTime() - now);
}
@ -573,8 +580,7 @@ public class RoutingContext {
}
}
private void getAllObjects(long tileId, final List<RouteDataObject> toFillIn) {
TLongObjectHashMap<RouteDataObject> excludeDuplications = new TLongObjectHashMap<RouteDataObject>();
private void getAllObjects(long tileId, final List<RouteDataObject> toFillIn, TLongObjectHashMap<RouteDataObject> excludeDuplications) {
if (tileRoutes.containsKey(tileId)) {
List<RouteDataObject> routes = tileRoutes.get(tileId);
if (routes != null) {
@ -843,5 +849,7 @@ public class RoutingContext {
return map.keySet().toArray(new BinaryMapIndexReader[map.size()]);
}
}

View file

@ -37,7 +37,7 @@ public class CurrentPositionHelper {
return;
}
RoutingConfiguration cfg = RoutingConfiguration.getDefault().build(p.name().toLowerCase(), 10);
ctx = new RoutingContext(cfg, null, app.getTodoAPI().getRoutingMapFiles());
ctx = new RoutePlannerFrontEnd(false).buildRoutingContext(cfg, null, app.getTodoAPI().getRoutingMapFiles());
}
private RouteDataObject runUpdateInThread(Location loc) {

View file

@ -124,7 +124,6 @@ public class OsMoDroidLayer extends OsmandMapLayer implements ContextMenuLayer.I
opIcon = BitmapFactory.decodeResource(view.getResources(), R.drawable.bicycle_location);
osMoDroidPointArrayList = myOsMoDroidPlugin.getOsMoDroidPointArrayList(layerId);
osMoDroidFixedPointArrayList = myOsMoDroidPlugin.getOsMoDroidFixedPointArrayList(layerId);
myOsMoDroidPlugin.getGpxArrayList(layerId);
initUI();
}
@ -250,13 +249,13 @@ public class OsMoDroidLayer extends OsmandMapLayer implements ContextMenuLayer.I
public void onDraw(Canvas canvas, RotatedTileBox tileBox, DrawSettings settings) {}
public void getOsMoDroidPointFromPoint(RotatedTileBox tb,PointF point, List<? super OsMoDroidPoint> om) {
if (myOsMoDroidPlugin.getOsMoDroidPointArrayList(layerId) != null) {
if (osMoDroidPointArrayList != null) {
int ex = (int) point.x;
int ey = (int) point.y;
try {
for (int i = 0; i < myOsMoDroidPlugin.getOsMoDroidPointArrayList(layerId).size(); i++) {
OsMoDroidPoint n = myOsMoDroidPlugin.getOsMoDroidPointArrayList(layerId).get(i);
for (int i = 0; i < osMoDroidPointArrayList.size(); i++) {
OsMoDroidPoint n = osMoDroidPointArrayList.get(i);
if (!om.contains(n)) {
int x = (int) tb.getPixXFromLatLon(n.latlon.getLatitude(), n.latlon.getLongitude());
int y = (int) tb.getPixYFromLatLon(n.latlon.getLatitude(), n.latlon.getLongitude());
@ -270,13 +269,13 @@ public class OsMoDroidLayer extends OsmandMapLayer implements ContextMenuLayer.I
// synchronized block
}
}
if (myOsMoDroidPlugin.getOsMoDroidFixedPointArrayList(layerId) != null) {
if (osMoDroidFixedPointArrayList != null) {
int ex = (int) point.x;
int ey = (int) point.y;
try {
for (int i = 0; i < myOsMoDroidPlugin.getOsMoDroidFixedPointArrayList(layerId).size(); i++) {
OsMoDroidPoint n = myOsMoDroidPlugin.getOsMoDroidFixedPointArrayList(layerId).get(i);
for (int i = 0; i <osMoDroidFixedPointArrayList.size(); i++) {
OsMoDroidPoint n =osMoDroidFixedPointArrayList.get(i);
if (!om.contains(n)) {
int x = (int) tb.getPixXFromLatLon(n.latlon.getLatitude(), n.latlon.getLongitude());
int y = (int) tb.getPixYFromLatLon(n.latlon.getLatitude(), n.latlon.getLongitude());

View file

@ -110,7 +110,7 @@ public class OsMoDroidPlugin extends OsmandPlugin implements MonitoringInfoContr
private OsMoDroidLayer osmoDroidLayer;
protected boolean connected = false;
ArrayList<OsMoDroidLayer> osmoDroidLayerList = new ArrayList<OsMoDroidLayer>();
private AsyncTask<Void, Void, ArrayList<ColoredGPX>> task;
private AsyncTask<Void, Void, Void> task;
public ArrayList<OsMoDroidPoint> getOsMoDroidPointArrayList(int id) {
ArrayList<OsMoDroidPoint> result = new ArrayList<OsMoDroidPoint>();
@ -214,6 +214,7 @@ public class OsMoDroidPlugin extends OsmandPlugin implements MonitoringInfoContr
log.error(e.getMessage(), e);
}
getGpxArrayList();
}
@Override
@ -316,51 +317,35 @@ qa.item(R.string.osmodroid_unseek).icons(R.drawable.abs__ic_commit_search_api_ho
}).reg();
}
public void getGpxArrayList(final int id) {
final ArrayList<ColoredGPX> result = new ArrayList<ColoredGPX>();
public void getGpxArrayList() {
if(task!=null){
task.cancel(true);
}
task = new AsyncTask<Void, Void, ArrayList<ColoredGPX>>() {
@Override
protected ArrayList<ColoredGPX> doInBackground(Void... params) {
task = new AsyncTask<Void, Void, Void>() {
@Override
protected Void doInBackground(Void... params) {
for (OsMoDroidLayer l : osmoDroidLayerList){
ArrayList<ColoredGPX> temp = new ArrayList<ColoredGPX>();
try {
for (int i = 0; i < mIRemoteService.getNumberOfGpx(id); i++) {
for (int i = 0; i < mIRemoteService.getNumberOfGpx(l.layerId); i++) {
ColoredGPX cg = new ColoredGPX();
cg.gpxFile = GPXUtilities.loadGPXFile(app, new File(mIRemoteService.getGpxFile(id, i)), false);
cg.color = mIRemoteService.getGpxColor(id, i);
cg.gpxFile = GPXUtilities.loadGPXFile(app, new File(mIRemoteService.getGpxFile(l.layerId, i)), false);
cg.color = mIRemoteService.getGpxColor(l.layerId, i);
temp.add(cg);
}
return temp;
l.inGPXFilelist(temp);
} catch (RemoteException e) {
log.error(e.getMessage(), e);
}
return temp;
}
@Override
protected void onPostExecute(ArrayList<ColoredGPX> backgroundresult) {
if(backgroundresult!=null){
try {
for (OsMoDroidLayer l : osmoDroidLayerList){
if (l.layerId==id){
l.inGPXFilelist(backgroundresult);
}
}
} catch (ConcurrentModificationException e) {
log.error(e.getMessage(), e);
}
catch (ConcurrentModificationException e) {
log.error(e.getMessage(), e);
}
}
return null;
}
};
task.execute();
}
}