add routing information to yours project and add missing turns for cloudmade
git-svn-id: https://osmand.googlecode.com/svn/trunk@308 e29c36b1-1cfa-d876-8d93-3434fc2bb7b8
This commit is contained in:
parent
b32a4b3a9c
commit
e94b2b8350
6 changed files with 78 additions and 21 deletions
|
@ -15,10 +15,10 @@ public class ToDoConstants {
|
|||
|
||||
|
||||
// TODO ANDROID
|
||||
|
||||
// 61. Provide route information for YOURS (calclate turns/angle/expected time) [done]
|
||||
// Fix some missing turns in CloudMade (for secondary roads wo name). Add them (if dist to prev/next turn > 150m) [dacha] !
|
||||
// for 0.3
|
||||
// 60. Audio guidance for routing !
|
||||
// 68. Implement service to app work with screen offline
|
||||
// (introduce special settings how often update location to monitoring & audio guidance)
|
||||
|
||||
// 43. Enable poi filter by name
|
||||
// 58. Upload/Download zip-index from site & unzip them on phone
|
||||
|
@ -48,6 +48,8 @@ public class ToDoConstants {
|
|||
// BUGS Swing
|
||||
|
||||
// DONE ANDROID :
|
||||
// 61. Provide route information for YOURS (calclate turns/angle/expected time)
|
||||
// Fix some missing turns in CloudMade (for secondary roads wo name). Add them (if dist to prev/next turn > 150m) [dacha] !
|
||||
// 33. Build transport locations. Create transport index (transport-stops) (investigate)
|
||||
// Not implemented : show key/transit stops on map, follow mode (show next stop)
|
||||
|
||||
|
|
|
@ -71,6 +71,7 @@ public class GoogleCodeUploadIndex {
|
|||
}
|
||||
|
||||
|
||||
private int MB = 1 << 20;
|
||||
/**
|
||||
* Uploads the contents of the file {@link #fileName} to the project's
|
||||
* Google Code upload url. Performs the basic http authentication required
|
||||
|
@ -125,8 +126,15 @@ public class GoogleCodeUploadIndex {
|
|||
sendLine(out, ""); //$NON-NLS-1$
|
||||
int count;
|
||||
byte[] buf = new byte[8192];
|
||||
int uploaded = 0;
|
||||
int mb = 0;
|
||||
while ( (count = in.read(buf)) >= 0 ) {
|
||||
out.write(buf, 0, count);
|
||||
uploaded += count;
|
||||
if(uploaded > MB){
|
||||
uploaded = 0;
|
||||
log("Uploaded " + (++mb) + " megabytes ");
|
||||
}
|
||||
}
|
||||
in.close();
|
||||
sendLine(out, ""); //$NON-NLS-1$
|
||||
|
|
|
@ -23,12 +23,13 @@ import com.osmand.impl.ConsoleProgressImplementation;
|
|||
public class IndexBatchCreator {
|
||||
// config params
|
||||
private static final boolean indexPOI = true;
|
||||
private static final boolean indexAddress = false;
|
||||
private static final boolean indexAddress = true;
|
||||
private static final boolean indexTransport = true;
|
||||
private static final boolean writeWayNodes = true;
|
||||
|
||||
protected static final Log log = LogUtil.getLog(IndexBatchCreator.class);
|
||||
protected static final String SITE_TO_DOWNLOAD1 = "http://download.geofabrik.de/osm/europe/"; //$NON-NLS-1$
|
||||
// TODO transport for all - it should be small!!!
|
||||
protected static final String[] countriesToDownload1 = new String[] {
|
||||
// "albania", "andorra", "austria", // 5.3, 0.4, 100 //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
||||
// "belarus", "belgium", "bosnia-herzegovina", // 39, 43, 4.1 //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
||||
|
@ -58,8 +59,9 @@ public class IndexBatchCreator {
|
|||
|
||||
protected static final String SITE_TO_DOWNLOAD2 = "http://downloads.cloudmade.com/"; //$NON-NLS-1$
|
||||
// us states
|
||||
// TODO address
|
||||
protected static final String[] usStates = new String[] {
|
||||
"Alabama", "Alaska", "Arizona", "Arkansas", "California", "Colorado", "Connecticut",
|
||||
"Alabama", "Alaska", "Arizona", "Arkansas", "California", "Colorado", "Connecticut",
|
||||
"Delaware", "District_of_Columbia", "Florida", "Georgia", "Guantanamo_Bay", "Hawaii",
|
||||
"Idaho", "Illinois", "Indiana", "Iowa", "Kansas", "Kentucky", "Louisiana", "Maine",
|
||||
"Maryland", "Massachusetts", "Michigan", "Minnesota", "Mississippi", "Missouri",
|
||||
|
@ -68,10 +70,11 @@ public class IndexBatchCreator {
|
|||
"Pennsylvania", "Rhode Island", "South Carolina", "South Dakota", "Tennessee",
|
||||
"Texas", "Utah", "Vermont", "Virginia", "Washington", "West_Virginia", "Wisconsin", "Wyoming",
|
||||
};
|
||||
// TODO address
|
||||
protected static final String[] canadaStates = new String[] {
|
||||
// "Alberta","British_Columbia","Manitoba","New_Brunswick","Newfoundland",
|
||||
// "Nova_Scotia","Nunavut", "Nw_Territories","Ontario","Pr_Edwrd_Island",
|
||||
// "Quebec","Saskatchewan","Yukon",
|
||||
"Alberta","British_Columbia","Manitoba","New_Brunswick","Newfoundland",
|
||||
"Nova_Scotia","Nunavut", "Nw_Territories","Ontario","Pr_Edwrd_Island",
|
||||
"Quebec","Saskatchewan","Yukon",
|
||||
};
|
||||
|
||||
|
||||
|
@ -277,9 +280,9 @@ public class IndexBatchCreator {
|
|||
} else {
|
||||
return;
|
||||
}
|
||||
if(mbLengh > 90){
|
||||
if(mbLengh > 100){
|
||||
System.err.println("ERROR : file " + f.getName() + " exceeded 90 mb!!! Could not be uploaded.");
|
||||
// return; // ? do not try?
|
||||
return; // restriction for google code
|
||||
}
|
||||
alreadyUploadedFiles.add(f.getName());
|
||||
GoogleCodeUploadIndex uploader = new GoogleCodeUploadIndex();
|
||||
|
|
|
@ -235,7 +235,7 @@ public class DownloadIndexActivity extends ListActivity {
|
|||
s = getString(R.string.transport);
|
||||
}
|
||||
|
||||
item.setText(s + "\n " + e.getKey().substring(0, l)); //$NON-NLS-1$
|
||||
item.setText(s + "\n " + e.getKey().substring(0, l).replace('_', ' ')); //$NON-NLS-1$
|
||||
description.setText(e.getValue().replace(':', '\n'));
|
||||
return row;
|
||||
}
|
||||
|
|
|
@ -231,7 +231,7 @@ public class RouteProvider {
|
|||
} else if(delta < 110){
|
||||
type = TurnType.valueOf(TurnType.TL);
|
||||
description = getString(ctx, R.string.route_tl);
|
||||
} else if(delta < 125){
|
||||
} else if(delta < 135){
|
||||
type = TurnType.valueOf(TurnType.TSHL);
|
||||
description = getString(ctx, R.string.route_tshl);
|
||||
} else if(delta < 225){
|
||||
|
@ -272,17 +272,61 @@ public class RouteProvider {
|
|||
|
||||
|
||||
|
||||
int sum = 0;
|
||||
for (int i = directions.size() - 1; i >= 0; i--) {
|
||||
directions.get(i).afterLeftTime = sum;
|
||||
sum += directions.get(i).expectedTime;
|
||||
}
|
||||
|
||||
if(res.directions == null || res.directions.isEmpty()){
|
||||
res.directions = new ArrayList<RouteDirectionInfo>(directions);
|
||||
} else {
|
||||
// TODO try to add missing turns
|
||||
// res.directions = new ArrayList<RouteDirectionInfo>(directions);
|
||||
int currentDirection= 0;
|
||||
// one more
|
||||
for (int i = 0; i <= res.directions.size() && currentDirection < directions.size(); i++) {
|
||||
while(currentDirection < directions.size()){
|
||||
int distanceAfter = 0;
|
||||
if (i < res.directions.size()) {
|
||||
RouteDirectionInfo resInfo = res.directions.get(i);
|
||||
int r1 = directions.get(currentDirection).routePointOffset;
|
||||
int r2 = resInfo.routePointOffset;
|
||||
distanceAfter = listDistance[resInfo.routePointOffset];
|
||||
float dist = locations.get(r1).distanceTo(locations.get(r2));
|
||||
// take into account that move roundabout is special turn that could be very lengthy
|
||||
if (dist < 100) {
|
||||
// the same turn duplicate
|
||||
currentDirection++;
|
||||
continue; // while cycle
|
||||
} else if (directions.get(currentDirection).routePointOffset > resInfo.routePointOffset) {
|
||||
// check it at the next point
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// add turn because it was missed
|
||||
RouteDirectionInfo toAdd = directions.get(currentDirection);
|
||||
float calcSpeed = toAdd.expectedTime == 0 ? speed :((float) toAdd.distance / toAdd.expectedTime);
|
||||
|
||||
if(i > 0){
|
||||
// update previous
|
||||
RouteDirectionInfo previous = res.directions.get(i - 1);
|
||||
calcSpeed = previous.expectedTime == 0 ? calcSpeed :((float) previous.distance / previous.expectedTime);
|
||||
previous.distance = listDistance[previous.routePointOffset] - listDistance[toAdd.routePointOffset];
|
||||
previous.expectedTime = (int) ((float) previous.distance / calcSpeed);
|
||||
}
|
||||
toAdd.distance = listDistance[toAdd.routePointOffset] - distanceAfter;
|
||||
toAdd.expectedTime = (int) ((float) toAdd.distance / calcSpeed);
|
||||
if(i < res.directions.size()){
|
||||
res.directions.add(i, toAdd);
|
||||
} else {
|
||||
res.directions.add(toAdd);
|
||||
}
|
||||
|
||||
i++;
|
||||
currentDirection++;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
int sum = 0;
|
||||
for (int i = res.directions.size() - 1; i >= 0; i--) {
|
||||
res.directions.get(i).afterLeftTime = sum;
|
||||
sum += res.directions.get(i).expectedTime;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -532,7 +532,7 @@ public class RoutingHelper {
|
|||
|
||||
// calculated vars
|
||||
|
||||
// after action (for i.e. after turn to next turn)
|
||||
// after action (excluding expectedTime)
|
||||
public int afterLeftTime;
|
||||
// distance after action (for i.e. after turn to next turn)
|
||||
public int distance;
|
||||
|
|
Loading…
Reference in a new issue