small improvement
git-svn-id: https://osmand.googlecode.com/svn/trunk@305 e29c36b1-1cfa-d876-8d93-3434fc2bb7b8
This commit is contained in:
parent
ff38418d90
commit
c4d79fa614
1 changed files with 41 additions and 39 deletions
|
@ -32,7 +32,7 @@ public class IndexBatchCreator {
|
||||||
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$
|
||||||
"bulgaria", "croatia", "cyprus", // 13, 12, 5 //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
|
// "bulgaria", "croatia", "cyprus", // 13, 12, 5 //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
|
||||||
// "denmark", "estonia", "faroe_islands", // 75, 38, 1.5 //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
// "denmark", "estonia", "faroe_islands", // 75, 38, 1.5 //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
||||||
// "finland", "greece", "hungary", //80, 25, 14 //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
// "finland", "greece", "hungary", //80, 25, 14 //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
||||||
// "iceland", "ireland", "isle_of_man", // 5.9, 27, 1.1 //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
// "iceland", "ireland", "isle_of_man", // 5.9, 27, 1.1 //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
||||||
|
@ -59,14 +59,14 @@ public class IndexBatchCreator {
|
||||||
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
|
||||||
protected static final String[] usStates = new String[] {
|
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",
|
"Delaware", "District_of_Columbia", "Florida", "Georgia", "Guantanamo_Bay", "Hawaii",
|
||||||
// "Idaho", "Illinois", "Indiana", "Iowa", "Kansas", "Kentucky", "Louisiana", "Maine",
|
"Idaho", "Illinois", "Indiana", "Iowa", "Kansas", "Kentucky", "Louisiana", "Maine",
|
||||||
// "Maryland", "Massachusetts", "Michigan", "Minnesota", "Mississippi", "Missouri",
|
"Maryland", "Massachusetts", "Michigan", "Minnesota", "Mississippi", "Missouri",
|
||||||
// "Montana", "Nebraska", "Nevada", "New_Hampshire", "New_Jersey", "New_Mexico",
|
"Montana", "Nebraska", "Nevada", "New_Hampshire", "New_Jersey", "New_Mexico",
|
||||||
// "New_York", "North_Carolina", "North_Dakota", "Ohio", "Oklahoma", "Oregon",
|
"New_York", "North_Carolina", "North_Dakota", "Ohio", "Oklahoma", "Oregon",
|
||||||
// "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",
|
||||||
|
@ -137,6 +137,7 @@ public class IndexBatchCreator {
|
||||||
File f = new File(osmDirFiles, country +".osm.bz2");
|
File f = new File(osmDirFiles, country +".osm.bz2");
|
||||||
downloadFile(url, f); //$NON-NLS-1$
|
downloadFile(url, f); //$NON-NLS-1$
|
||||||
generateIndex(f, alreadyGeneratedFiles, alreadyUploadedFiles);
|
generateIndex(f, alreadyGeneratedFiles, alreadyUploadedFiles);
|
||||||
|
System.gc();
|
||||||
}
|
}
|
||||||
|
|
||||||
for(String country : usStates){
|
for(String country : usStates){
|
||||||
|
@ -192,45 +193,46 @@ public class IndexBatchCreator {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (f.getName().endsWith(".osm.bz2") || f.getName().endsWith(".osm")) {
|
if (f.getName().endsWith(".osm.bz2") || f.getName().endsWith(".osm")) {
|
||||||
System.gc();
|
generateIndex(f, alreadyGeneratedFiles, alreadyUploadedFiles);
|
||||||
try {
|
|
||||||
generateIndex(f, alreadyGeneratedFiles, alreadyUploadedFiles);
|
|
||||||
} catch (OutOfMemoryError e) {
|
|
||||||
log.error("OutOfMemory", e);
|
|
||||||
System.gc();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
System.out.println("GENERATING INDEXES FINISHED ");
|
System.out.println("GENERATING INDEXES FINISHED ");
|
||||||
}
|
}
|
||||||
protected void generateIndex(File f, Set<String> alreadyGeneratedFiles, Set<String> alreadyUploadedFiles){
|
protected void generateIndex(File f, Set<String> alreadyGeneratedFiles, Set<String> alreadyUploadedFiles) {
|
||||||
if(!generateIndexes){
|
if (!generateIndexes) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
DataExtraction extr = new DataExtraction(indexAddress, indexPOI, indexTransport, indexAddress, false, false, indexDirFiles);
|
|
||||||
try {
|
try {
|
||||||
alreadyGeneratedFiles.add(f.getName());
|
DataExtraction extr = new DataExtraction(indexAddress, indexPOI, indexTransport, indexAddress, false, false, indexDirFiles);
|
||||||
Region country = extr.readCountry(f.getAbsolutePath(), new ConsoleProgressImplementation(9), null);
|
try {
|
||||||
DataIndexWriter dataIndexWriter = new DataIndexWriter(indexDirFiles, country);
|
alreadyGeneratedFiles.add(f.getName());
|
||||||
String name = country.getName();
|
Region country = extr.readCountry(f.getAbsolutePath(), new ConsoleProgressImplementation(9), null);
|
||||||
if(indexAddress){
|
DataIndexWriter dataIndexWriter = new DataIndexWriter(indexDirFiles, country);
|
||||||
String fName = name + "_" + IndexConstants.ADDRESS_TABLE_VERSION + IndexConstants.ADDRESS_INDEX_EXT;
|
String name = country.getName();
|
||||||
dataIndexWriter.writeAddress(fName, f.lastModified(), writeWayNodes);
|
if (indexAddress) {
|
||||||
uploadIndex(new File(indexDirFiles, fName), alreadyUploadedFiles);
|
String fName = name + "_" + IndexConstants.ADDRESS_TABLE_VERSION + IndexConstants.ADDRESS_INDEX_EXT;
|
||||||
|
dataIndexWriter.writeAddress(fName, f.lastModified(), writeWayNodes);
|
||||||
|
uploadIndex(new File(indexDirFiles, fName), alreadyUploadedFiles);
|
||||||
|
}
|
||||||
|
if (indexPOI) {
|
||||||
|
String fName = name + "_" + IndexConstants.POI_TABLE_VERSION + IndexConstants.POI_INDEX_EXT;
|
||||||
|
dataIndexWriter.writePOI(fName, f.lastModified());
|
||||||
|
uploadIndex(new File(indexDirFiles, fName), alreadyUploadedFiles);
|
||||||
|
}
|
||||||
|
if (indexTransport) {
|
||||||
|
String fName = name + "_" + IndexConstants.TRANSPORT_TABLE_VERSION + IndexConstants.TRANSPORT_INDEX_EXT;
|
||||||
|
dataIndexWriter.writeTransport(fName, f.lastModified());
|
||||||
|
uploadIndex(new File(indexDirFiles, fName), alreadyUploadedFiles);
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("Exception generating indexes for " + f.getName()); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
if(indexPOI){
|
} catch (OutOfMemoryError e) {
|
||||||
String fName = name + "_" + IndexConstants.POI_TABLE_VERSION + IndexConstants.POI_INDEX_EXT;
|
System.gc();
|
||||||
dataIndexWriter.writePOI(fName, f.lastModified());
|
log.error("OutOfMemory", e);
|
||||||
uploadIndex(new File(indexDirFiles, fName), alreadyUploadedFiles);
|
|
||||||
}
|
|
||||||
if(indexTransport){
|
|
||||||
String fName = name + "_" + IndexConstants.TRANSPORT_TABLE_VERSION + IndexConstants.TRANSPORT_INDEX_EXT;
|
|
||||||
dataIndexWriter.writeTransport(fName, f.lastModified());
|
|
||||||
uploadIndex(new File(indexDirFiles, fName), alreadyUploadedFiles);
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
log.error("Exception generating indexes for " + f.getName()); //$NON-NLS-1$
|
|
||||||
}
|
}
|
||||||
|
System.gc();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected File[] getSortedFiles(File dir){
|
protected File[] getSortedFiles(File dir){
|
||||||
|
|
Loading…
Reference in a new issue