fix bugs add germany/france

git-svn-id: https://osmand.googlecode.com/svn/trunk@310 e29c36b1-1cfa-d876-8d93-3434fc2bb7b8
This commit is contained in:
Victor Shcherb 2010-07-09 21:17:27 +00:00
parent e16371d336
commit 7a08a96aa0
4 changed files with 55 additions and 35 deletions

View file

@ -24,7 +24,6 @@ public class ToDoConstants {
// Not clear if it is really needed // Not clear if it is really needed
// 43. Enable poi filter by name // 43. Enable poi filter by name
// 58. Upload/Download zip-index from site & unzip them on phone
// 45. Get clear <Use internet> settings. Move that setting on top settings screen. // 45. Get clear <Use internet> settings. Move that setting on top settings screen.
// That setting should rule all activities that use internet. It should ask whenever internet is used // That setting should rule all activities that use internet. It should ask whenever internet is used
// (would you like to use internet for that operation - if using internet is not checked). // (would you like to use internet for that operation - if using internet is not checked).
@ -55,6 +54,7 @@ public class ToDoConstants {
// Fix some missing turns in CloudMade (for secondary roads wo name). Add them (if dist to prev/next turn > 150m) [dacha] ! // 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) // 33. Build transport locations. Create transport index (transport-stops) (investigate)
// Not implemented : show key/transit stops on map, follow mode (show next stop) // Not implemented : show key/transit stops on map, follow mode (show next stop)
// 58. Upload/Download zip-index from site & unzip them on phone
// DONE SWING // DONE SWING

View file

@ -71,7 +71,6 @@ public class GoogleCodeUploadIndex {
} }
private int MB = 1 << 20;
/** /**
* Uploads the contents of the file {@link #fileName} to the project's * Uploads the contents of the file {@link #fileName} to the project's
* Google Code upload url. Performs the basic http authentication required * Google Code upload url. Performs the basic http authentication required
@ -126,15 +125,8 @@ public class GoogleCodeUploadIndex {
sendLine(out, ""); //$NON-NLS-1$ sendLine(out, ""); //$NON-NLS-1$
int count; int count;
byte[] buf = new byte[8192]; byte[] buf = new byte[8192];
int uploaded = 0;
int mb = 0;
while ( (count = in.read(buf)) >= 0 ) { while ( (count = in.read(buf)) >= 0 ) {
out.write(buf, 0, count); out.write(buf, 0, count);
uploaded += count;
if(uploaded > MB){
uploaded = 0;
log("Uploaded " + (++mb) + " megabytes ");
}
} }
in.close(); in.close();
sendLine(out, ""); //$NON-NLS-1$ sendLine(out, ""); //$NON-NLS-1$

View file

@ -32,7 +32,7 @@ public class IndexBatchCreator {
protected static final Log log = LogUtil.getLog(IndexBatchCreator.class); 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$ 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[] { protected static final String[] countriesToDownload1 = new String[] {
// "albania", "andorra", "austria", // 5.3, 0.4, 100 //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ // "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$ // "belarus", "belgium", "bosnia-herzegovina", // 39, 43, 4.1 //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
@ -49,17 +49,30 @@ public class IndexBatchCreator {
// "sweden", "switzerland", "turkey", // 88, 83, 17 //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ // "sweden", "switzerland", "turkey", // 88, 83, 17 //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
// "ukraine", // 19 //$NON-NLS-1$ // "ukraine", // 19 //$NON-NLS-1$
// TOTAL : 1129 MB // TOTAL : 1129 MB
// "great_britain", "italy", // 281, 246,
// "czech_republic", "netherlands", // 168, 375, // "czech_republic", "netherlands", // 168, 375,
// "france", "germany", //519, 860 // "great_britain", "italy", // 281, 246,
// ADD TO TOTAL : 2449 MB // ADD TO TOTAL : 2449 MB
// TODO transport, poi : "czech_republic", "netherlands", "great_britain", "italy"
// currently : austria, spain address > 100 MB // address : "great_britain", "italy" - out of memory
// address : "great_britain", "italy", "france", "germany" - out of memory
// poi : "france", "germany" - out of memory
}; };
// TODO all
protected static final String[] franceProvinces = new String[] {
"alsace","aquitaine", "auvergne", "basse-normandie", "bourgogne", "bretagne", "centre",
"champagne-ardenne", "corse", "franche-comte", "haute-normandie", "ile-de-france",
"languedoc-roussillon", "limousin", "lorraine", "midi-pyrenees", "nord-pas-de-calais",
"pays-de-la-loire", "picardie","poitou-charentes", "provence-alpes-cote-d-azur", "rhone-alpes"
};
// TODO all
protected static final String[] germanyLands = new String[] {
"baden-wuerttemberg","bayern", "berlin", "brandenburg", "bremen", "hamburg", "hessen",
"mecklenburg-vorpommern", "niedersachsen", "nordrhein-westfalen", "rheinland-pfalz", "saarland",
"sachsen-anhalt", "sachsen", "schleswig-holstein", "thueringen",
};
protected static final String SITE_TO_DOWNLOAD2 = "http://downloads.cloudmade.com/"; //$NON-NLS-1$ protected static final String SITE_TO_DOWNLOAD2 = "http://downloads.cloudmade.com/"; //$NON-NLS-1$
// us states // us states
// TODO address // TODO address
@ -73,6 +86,7 @@ public class IndexBatchCreator {
// "Pennsylvania", "Rhode Island", "South Carolina", "South Dakota", "Tennessee", // "Pennsylvania", "Rhode Island", "South Carolina", "South Dakota", "Tennessee",
// "Texas", "Utah", "Vermont", "Virginia", "Washington", "West_Virginia", "Wisconsin", "Wyoming", // "Texas", "Utah", "Vermont", "Virginia", "Washington", "West_Virginia", "Wisconsin", "Wyoming",
}; };
protected static final String[] canadaStates = new String[] { protected static final String[] canadaStates = new String[] {
// "Alberta","British_Columbia","Manitoba","New_Brunswick","Newfoundland", // "Alberta","British_Columbia","Manitoba","New_Brunswick","Newfoundland",
// "Nova_Scotia","Nunavut", "Nw_Territories","Ontario","Pr_Edwrd_Island", // "Nova_Scotia","Nunavut", "Nw_Territories","Ontario","Pr_Edwrd_Island",
@ -80,7 +94,6 @@ public class IndexBatchCreator {
}; };
boolean downloadFiles = false; boolean downloadFiles = false;
boolean generateIndexes = false; boolean generateIndexes = false;
boolean uploadIndexes = false; boolean uploadIndexes = false;
@ -130,37 +143,45 @@ public class IndexBatchCreator {
} }
} }
protected void downloadFiles(Set<String> alreadyGeneratedFiles, Set<String> alreadyUploadedFiles){ protected void downloadFiles(Set<String> alreadyGeneratedFiles, Set<String> alreadyUploadedFiles){
// clean before downloading // clean before downloading
// for(File f : osmDirFiles.listFiles()){ // for(File f : osmDirFiles.listFiles()){
// log.info("Delete old file " + f.getName()); //$NON-NLS-1$ // log.info("Delete old file " + f.getName()); //$NON-NLS-1$
// f.delete(); // f.delete();
// } // }
// europe
for(String country : countriesToDownload1){ for(String country : countriesToDownload1){
String url = SITE_TO_DOWNLOAD1 + country +".osm.bz2"; //$NON-NLS-1$ String url = SITE_TO_DOWNLOAD1 + country +".osm.bz2"; //$NON-NLS-1$
log.info("Downloading country " + country + " from " + url); //$NON-NLS-1$//$NON-NLS-2$ downloadFile(url, country, alreadyGeneratedFiles, alreadyUploadedFiles);
File f = new File(osmDirFiles, country +".osm.bz2");
downloadFile(url, f); //$NON-NLS-1$
generateIndex(f, alreadyGeneratedFiles, alreadyUploadedFiles);
System.gc();
} }
// france
for(String country : franceProvinces){
String url = SITE_TO_DOWNLOAD1 +"france/" + country +".osm.bz2"; //$NON-NLS-1$
downloadFile(url, country, alreadyGeneratedFiles, alreadyUploadedFiles);
}
// germany
for(String country : germanyLands){
String url = SITE_TO_DOWNLOAD1 +"germany/" + country +".osm.bz2"; //$NON-NLS-1$
downloadFile(url, country, alreadyGeneratedFiles, alreadyUploadedFiles);
}
// usa
for(String country : usStates){ for(String country : usStates){
country = country.toLowerCase(); country = country.toLowerCase();
String url = SITE_TO_DOWNLOAD2 + "north_america/united_states/"+country+"/"+country +".osm.bz2"; //$NON-NLS-1$ String url = SITE_TO_DOWNLOAD2 + "north_america/united_states/"+country+"/"+country +".osm.bz2"; //$NON-NLS-1$
log.info("Downloading country " + country + " from " + url); //$NON-NLS-1$//$NON-NLS-2$ downloadFile(url, "US_"+country, alreadyGeneratedFiles, alreadyUploadedFiles);
File f = new File(osmDirFiles, "US_"+country +".osm.bz2"); //$NON-NLS-1$
downloadFile(url, f);
generateIndex(f, alreadyGeneratedFiles, alreadyUploadedFiles);
} }
// canada
for(String country : canadaStates){ for(String country : canadaStates){
country = country.toLowerCase(); country = country.toLowerCase();
String url = SITE_TO_DOWNLOAD2 + "north_america/canada/"+country+"/"+country +".osm.bz2"; //$NON-NLS-1$ String url = SITE_TO_DOWNLOAD2 + "north_america/canada/"+country+"/"+country +".osm.bz2"; //$NON-NLS-1$
log.info("Downloading country " + country + " from " + url); //$NON-NLS-1$//$NON-NLS-2$ downloadFile(url, "Canada_"+country, alreadyGeneratedFiles, alreadyUploadedFiles);
File f = new File(osmDirFiles, "Canada_"+country +".osm.bz2"); //$NON-NLS-1$
downloadFile(url, f);
generateIndex(f, alreadyGeneratedFiles, alreadyUploadedFiles);
} }
System.out.println("DOWNLOADING FILES FINISHED"); System.out.println("DOWNLOADING FILES FINISHED");
} }
@ -168,12 +189,14 @@ public class IndexBatchCreator {
private final static int DOWNLOAD_DEBUG = 1 << 20; private final static int DOWNLOAD_DEBUG = 1 << 20;
private final static int MB = 1 << 20; private final static int MB = 1 << 20;
private final static int BUFFER_SIZE = 1 << 15; private final static int BUFFER_SIZE = 1 << 15;
protected void downloadFile(String url, File toSave) { protected void downloadFile(String url, String country, Set<String> alreadyGeneratedFiles, Set<String> alreadyUploadedFiles) {
byte[] buffer = new byte[BUFFER_SIZE]; byte[] buffer = new byte[BUFFER_SIZE];
int count = 0; int count = 0;
int downloaded = 0; int downloaded = 0;
int mbDownloaded = 0; int mbDownloaded = 0;
File toSave = new File(osmDirFiles, country+".osm.bz2");
try { try {
log.info("Downloading country " + country + " from " + url); //$NON-NLS-1$//$NON-NLS-2$
FileOutputStream ostream = new FileOutputStream(toSave); FileOutputStream ostream = new FileOutputStream(toSave);
InputStream stream = new URL(url).openStream(); InputStream stream = new URL(url).openStream();
while ((count = stream.read(buffer)) != -1) { while ((count = stream.read(buffer)) != -1) {
@ -187,9 +210,11 @@ public class IndexBatchCreator {
} }
ostream.close(); ostream.close();
stream.close(); stream.close();
generateIndex(toSave, alreadyGeneratedFiles, alreadyUploadedFiles);
} catch (IOException e) { } catch (IOException e) {
log.error("Input/output exception " + toSave.getName() + " downloading from " + url, e); //$NON-NLS-1$ //$NON-NLS-2$ log.error("Input/output exception " + toSave.getName() + " downloading from " + url, e); //$NON-NLS-1$ //$NON-NLS-2$
} }
} }
protected void generatedIndexes(Set<String> alreadyGeneratedFiles, Set<String> alreadyUploadedFiles) { protected void generatedIndexes(Set<String> alreadyGeneratedFiles, Set<String> alreadyUploadedFiles) {
@ -295,6 +320,7 @@ public class IndexBatchCreator {
while((read = is.read(BUFFER)) != -1){ while((read = is.read(BUFFER)) != -1){
zout.write(BUFFER, 0, read); zout.write(BUFFER, 0, read);
} }
is.close();
zout.close(); zout.close();
} catch (IOException e) { } catch (IOException e) {
log.error("Exception while zipping file"); log.error("Exception while zipping file");

View file

@ -269,11 +269,13 @@ public class MapInfoLayer implements OsmandMapLayer {
long toFindTime = time; long toFindTime = time;
if(followingMode){ if(followingMode){
toFindTime += System.currentTimeMillis(); toFindTime += System.currentTimeMillis();
} else {
Calendar c = Calendar.getInstance();
toFindTime -= c.getTimeZone().getOffset(0);
} }
if(Math.abs(toFindTime - cachedLeftTime) > 30000){ if(Math.abs(toFindTime - cachedLeftTime) > 30000){
cachedLeftTime = toFindTime; cachedLeftTime = toFindTime;
Calendar c = Calendar.getInstance(); cachedLeftTimeString = DateFormat.format("kk:mm", cachedLeftTime).toString(); //$NON-NLS-1$
cachedLeftTimeString = DateFormat.format("kk:mm", cachedLeftTime - c.getTimeZone().getOffset(0) ).toString(); //$NON-NLS-1$
} }
} }
if(cachedLeftTimeString != null) { if(cachedLeftTimeString != null) {