add index creator
git-svn-id: https://osmand.googlecode.com/svn/trunk@579 e29c36b1-1cfa-d876-8d93-3434fc2bb7b8
This commit is contained in:
parent
430cc39841
commit
46e063f731
2 changed files with 91 additions and 74 deletions
|
@ -11,8 +11,8 @@ import java.net.HttpURLConnection;
|
|||
import java.net.MalformedURLException;
|
||||
import java.net.URISyntaxException;
|
||||
import java.net.URL;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.TreeMap;
|
||||
|
||||
import net.osmand.LogUtil;
|
||||
|
||||
|
@ -35,36 +35,25 @@ public class DownloaderIndexFromGoogleCode {
|
|||
// IndexConstants.TRANSPORT_TABLE_VERSION + "" , //$NON-NLS-1$
|
||||
// IndexConstants.ADDRESS_TABLE_VERSION + "", IndexConstants.POI_TABLE_VERSION + "", //$NON-NLS-1$//$NON-NLS-2$
|
||||
// IndexConstants.TRANSPORT_TABLE_VERSION + "" }); //$NON-NLS-1$
|
||||
Map<String, String> indexFiles = DownloaderIndexFromGoogleCode.getIndexFiles(
|
||||
new String[] { IndexConstants.VOICE_INDEX_EXT_ZIP},
|
||||
new String[] { IndexConstants.VOICE_VERSION + "", }, //$NON-NLS-1$
|
||||
new TreeMap<String, String>());
|
||||
System.out.println(indexFiles);
|
||||
// Map<String, String> indexFiles = DownloaderIndexFromGoogleCode.getIndexFiles(
|
||||
// new String[] { IndexConstants.VOICE_INDEX_EXT_ZIP},
|
||||
// new String[] { IndexConstants.VOICE_VERSION + "", }, //$NON-NLS-1$
|
||||
// new TreeMap<String, String>());
|
||||
// System.out.println(indexFiles);
|
||||
|
||||
String odb = ""; //$NON-NLS-1$
|
||||
// put your cookies and personal information for delete
|
||||
// Map<String, String> cookies = new HashMap<String, String>();
|
||||
// cookies.put("__utmz", ""); //$NON-NLS-1$ //$NON-NLS-2$ // ?
|
||||
// cookies.put("__utma", ""); //$NON-NLS-1$ //$NON-NLS-2$ // ?
|
||||
// cookies.put("HSID", ""); //$NON-NLS-1$//$NON-NLS-2$
|
||||
// cookies.put("SID", ""); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
// cookies.put("NID", ""); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
// String pagegen = ""; //$NON-NLS-1$
|
||||
// String token = ""; //$NON-NLS-1$
|
||||
//
|
||||
// StringBuilder cookieString = new StringBuilder();
|
||||
// int size = cookies.size();
|
||||
// for (String c : cookies.keySet()) {
|
||||
// size--;
|
||||
// cookieString.append(c).append("=").append(cookies.get(c)); //$NON-NLS-1$
|
||||
// if (size > 0) {
|
||||
// cookieString.append("; "); //$NON-NLS-1$
|
||||
// }
|
||||
// }
|
||||
// deleteFileFromGoogleDownloads(odb, token, pagegen,
|
||||
// cookieString.toString());
|
||||
|
||||
String cookieHSID = ""; //$NON-NLS-1$
|
||||
String cookieSID = ""; //$NON-NLS-1$
|
||||
String pagegen = ""; //$NON-NLS-1$
|
||||
String token = ""; //$NON-NLS-1$
|
||||
|
||||
|
||||
deleteFileFromGoogleDownloads(odb, token, pagegen, cookieHSID,cookieSID);
|
||||
}
|
||||
|
||||
|
||||
private static Map<String, String> getContent(String[] ext, String[] version, Map<String, String> files) {
|
||||
try {
|
||||
URL url = new URL("http://code.google.com/p/osmand/downloads/list?num=1500&start=0"); //$NON-NLS-1$
|
||||
|
@ -128,8 +117,21 @@ public class DownloaderIndexFromGoogleCode {
|
|||
}
|
||||
|
||||
|
||||
public static String deleteFileFromGoogleDownloads(String fileName, String token, String pagegen, String cookies) throws IOException {
|
||||
public static String deleteFileFromGoogleDownloads(String fileName, String token, String pagegen, String cookieHSID, String cookieSID) throws IOException {
|
||||
// prepare data
|
||||
Map<String, String> cookies = new HashMap<String, String>();
|
||||
cookies.put("HSID", cookieHSID); //$NON-NLS-1$//$NON-NLS-2$
|
||||
cookies.put("SID", cookieSID); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
StringBuilder cookieString = new StringBuilder();
|
||||
int size = cookies.size();
|
||||
for (String c : cookies.keySet()) {
|
||||
size--;
|
||||
cookieString.append(c).append("=").append(cookies.get(c)); //$NON-NLS-1$
|
||||
if (size > 0) {
|
||||
cookieString.append("; "); //$NON-NLS-1$
|
||||
}
|
||||
}
|
||||
|
||||
String urlText = "http://code.google.com/p/osmand/downloads/delete.do?name="+fileName; //$NON-NLS-1$
|
||||
System.out.println(urlText);
|
||||
StringBuilder requestBody = new StringBuilder();
|
||||
|
@ -144,11 +146,9 @@ public class DownloaderIndexFromGoogleCode {
|
|||
URL url = new URL(urlText);
|
||||
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
|
||||
|
||||
connection.setRequestProperty("Cookie", cookies); //$NON-NLS-1$
|
||||
connection.setRequestProperty("Cookie", cookieString.toString()); //$NON-NLS-1$
|
||||
connection.setConnectTimeout(15000);
|
||||
connection.setRequestMethod("POST"); //$NON-NLS-1$
|
||||
// String token = userName + ":" + password; //$NON-NLS-1$
|
||||
// connection.addRequestProperty("Authorization", "Basic " + Base64.encode(token.getBytes("UTF-8"))); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
||||
connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded"); //$NON-NLS-1$//$NON-NLS-2$
|
||||
connection.setRequestProperty("Content-Length", requestBody.length()+""); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
|
||||
|
|
|
@ -32,6 +32,13 @@ public class IndexBatchCreator {
|
|||
private static final boolean writeWayNodes = false;
|
||||
private static final boolean indexMap = true;
|
||||
|
||||
// To remove downloads before updating them (google restriction)
|
||||
// THESE properties should be updated every session you run
|
||||
private static final String cookieHSID = "";
|
||||
private static final String cookieSID = "";
|
||||
private static final String pagegen = "";
|
||||
private static final String token = "";
|
||||
|
||||
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$
|
||||
|
||||
|
@ -55,21 +62,23 @@ public class IndexBatchCreator {
|
|||
|
||||
|
||||
protected static final String[] europeCountries = 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$
|
||||
// "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$
|
||||
// "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$
|
||||
// "kosovo", "latvia", "liechtenstein", // 8.2, 6.5, 0.2 //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
||||
// "lithuania", "luxembourg", "macedonia", // 5, 5, 4 //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
||||
// "malta", "moldova", "monaco", //0.8, 5, 0.6 //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
||||
// "montenegro", "norway", "poland", // 1.2, 56, 87 //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
||||
// "portugal", "romania", "serbia", // 10, 25, 10 //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
||||
// "slovakia", "slovenia", "spain", // 69, 10, 123 //$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$
|
||||
"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$
|
||||
"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$
|
||||
"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$
|
||||
"kosovo", "latvia", "liechtenstein", // 8.2, 6.5, 0.2 //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
||||
"lithuania", "luxembourg", "macedonia", // 5, 5, 4 //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
||||
"malta", "moldova", "monaco", //0.8, 5, 0.6 //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
||||
"montenegro", "norway", "poland", // 1.2, 56, 87 //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
||||
"portugal", "romania", "serbia", // 10, 25, 10 //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
||||
"slovakia", "slovenia", "spain", // 69, 10, 123 //$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$
|
||||
//TOTAL : 1129 MB
|
||||
// TODO map.odb
|
||||
// "czech_republic", "netherlands", // 168, 375,
|
||||
// "great_britain" , "italy", // 310, 246,
|
||||
//// "germany", "france", // 1100, 959 // index by states !
|
||||
|
@ -78,21 +87,22 @@ public class IndexBatchCreator {
|
|||
};
|
||||
|
||||
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"
|
||||
"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"
|
||||
};
|
||||
|
||||
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",
|
||||
"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$
|
||||
// us states
|
||||
// TODO map.odb
|
||||
protected static final String[] usStates = new String[] {
|
||||
// "Alabama", "Alaska", "Arizona", "Arkansas", "California", "Colorado", "Connecticut",
|
||||
// "Delaware", "District_of_Columbia", "Florida", "Georgia", "Guantanamo_Bay", "Hawaii",
|
||||
|
@ -104,6 +114,7 @@ public class IndexBatchCreator {
|
|||
// "Texas", "Utah", "Vermont", "Virginia", "Washington", "West_Virginia", "Wisconsin", "Wyoming",
|
||||
};
|
||||
|
||||
// TODO map.odb
|
||||
protected static final String[] canadaStates = new String[] {
|
||||
// "Alberta","British_Columbia","Manitoba","New_Brunswick","Newfoundland",
|
||||
// "Nova_Scotia","Nunavut", "Nw_Territories","Ontario","Pr_Edwrd_Island",
|
||||
|
@ -112,8 +123,8 @@ public class IndexBatchCreator {
|
|||
|
||||
// NORTH AMERICA
|
||||
protected static final String[] northAmerica = new String[] {
|
||||
// "Bahamas", "Costa_Rica", "Cuba", "Dominica", "Dominican_Republic",
|
||||
// "Guatemala", "Haiti", "Honduras", "Jamaica", "Mexico",
|
||||
"Bahamas", "Costa_Rica", "Cuba", "Dominica", "Dominican_Republic",
|
||||
"Guatemala", "Haiti", "Honduras", "Jamaica", "Mexico",
|
||||
// TODO these
|
||||
// "Anguilla", "Antigua_and_Barbuda", "Aruba", "Barbados", "Belize", "Bermuda", "British_Virgin_Islands",
|
||||
// "El_Salvador", "Federation_of_Saint_Kitts_and_Nevis",
|
||||
|
@ -125,15 +136,15 @@ public class IndexBatchCreator {
|
|||
|
||||
|
||||
protected static final String[] southAmerica = new String[] {
|
||||
// "Argentina","Bolivia","Brazil","Chile","Colombia",
|
||||
// "Ecuador","Falkland_Islands", "French_Guiana","Guyana","Paraguay",
|
||||
// "Peru","Suriname","Uruguay","Venezuela"
|
||||
"Argentina","Bolivia","Brazil","Chile","Colombia",
|
||||
"Ecuador","Falkland_Islands", "French_Guiana","Guyana","Paraguay",
|
||||
"Peru","Suriname","Uruguay","Venezuela"
|
||||
};
|
||||
|
||||
|
||||
// oceania
|
||||
protected static final String[] oceania = new String[] {
|
||||
// "Australia", "New_Zealand",
|
||||
// "Australia", "New_Zealand", // TODO map.odb
|
||||
// TODO only australia, new zealand created
|
||||
// "American_Samoa","Baker_Island","Cocos_Keeling_Islands","Cook_Islands",
|
||||
// "Federated_States_of_Micronesia","Fiji", "French_Polynesia","Guam","Howland_Island",
|
||||
|
@ -146,32 +157,32 @@ public class IndexBatchCreator {
|
|||
|
||||
protected static final String SITE_TO_DOWNLOAD3 = "http://gis-lab.info/data/osm/"; //$NON-NLS-1$
|
||||
protected static final String[] russiaStates = new String[] {
|
||||
// "adygeya", "altay", "altayskiy","amur","arkhan","astrakhan",
|
||||
// "bashkir", "belgorod","bryansk","buryat","chechen", "chel",
|
||||
// "chukot", "chuvash", "dagestan","evrey", "ingush", "irkutsk",
|
||||
// "ivanov","kabardin","kalinin","kalmyk","kaluzh","kamch","karach","karel",
|
||||
// "kemerovo", "khabar", "khakas", "khanty", "kirov", "komi", "kostrom", "krasnodar",
|
||||
// "krasnoyarsk", "kurgan", "kursk", "leningrad", "lipetsk", "magadan", "mariyel", "mordov", "moscow", "mosobl", "murmansk",
|
||||
// "nenec", "nizhegorod", "novgorod", "novosib", "omsk", "orenburg", "orlovsk", "osetiya",
|
||||
// "penz", "perm", "prim", "pskov", "rostov", "ryazan", "sakhalin", "samar", "saratov", "smol",
|
||||
// "stavrop", "stpeter", "sverdl", "tambov", "tatar", "tomsk", "tul", "tumen", "tver", "tyva", "udmurt",
|
||||
// "ulyan", "vladimir", "volgograd", "vologda", "voronezh", "yakut", "yamal", "yarosl", "zabaikal",
|
||||
"adygeya", "altay", "altayskiy","amur","arkhan","astrakhan",
|
||||
"bashkir", "belgorod","bryansk","buryat","chechen", "chel",
|
||||
"chukot", "chuvash", "dagestan","evrey", "ingush", "irkutsk",
|
||||
"ivanov","kabardin","kalinin","kalmyk","kaluzh","kamch","karach","karel",
|
||||
"kemerovo", "khabar", "khakas", "khanty", "kirov", "komi", "kostrom", "krasnodar",
|
||||
"krasnoyarsk", "kurgan", "kursk", "leningrad", "lipetsk", "magadan", "mariyel", "mordov", "moscow", "mosobl", "murmansk",
|
||||
"nenec", "nizhegorod", "novgorod", "novosib", "omsk", "orenburg", "orlovsk", "osetiya",
|
||||
"penz", "perm", "prim", "pskov", "rostov", "ryazan", "sakhalin", "samar", "saratov", "smol",
|
||||
"stavrop", "stpeter", "sverdl", "tambov", "tatar", "tomsk", "tul", "tumen", "tver", "tyva", "udmurt",
|
||||
"ulyan", "vladimir", "volgograd", "vologda", "voronezh", "yakut", "yamal", "yarosl", "zabaikal",
|
||||
};
|
||||
|
||||
protected static final String[] asia = new String[] {
|
||||
// "Afghanistan", "Bahrain", "Bangladesh", "Bhutan", "British_Indian_Ocean_Territory", "Brunei", "Cambodia",
|
||||
// "China", "Christmas_Island", "Democratic_Republic_of_Timor-Leste", "Gaza_Strip", "India", "Indonesia", "Iran",
|
||||
// "Iraq", "Israel", "Jordan", "Kazakhstan", "Kuwait", "Kyrgyzstan", "Laos", "Lebanon", "Macau", "Malaysia",
|
||||
// "Maldives", "Mongolia", "Nepal", "North_Korea", "Oman", "Pakistan", "Paracel_Islands", "Philippines", "Qatar",
|
||||
// "Saudi_Arabia", "Singapore", "South_Korea", "Spratly_Islands", "Sri_Lanka", "Syria", "Taiwan", "Tajikistan",
|
||||
// "Thailand", "Turkmenistan", "Union_of_Myanmar", "United_Arab_Emirates", "Uzbekistan", "Vietnam", "Yemen",
|
||||
"Afghanistan", "Bahrain", "Bangladesh", "Bhutan", "British_Indian_Ocean_Territory", "Brunei", "Cambodia",
|
||||
"China", "Christmas_Island", "Democratic_Republic_of_Timor-Leste", "Gaza_Strip", "India", "Indonesia", "Iran",
|
||||
"Iraq", "Israel", "Jordan", "Kazakhstan", "Kuwait", "Kyrgyzstan", "Laos", "Lebanon", "Macau", "Malaysia",
|
||||
"Maldives", "Mongolia", "Nepal", "North_Korea", "Oman", "Pakistan", "Paracel_Islands", "Philippines", "Qatar",
|
||||
"Saudi_Arabia", "Singapore", "South_Korea", "Spratly_Islands", "Sri_Lanka", "Syria", "Taiwan", "Tajikistan",
|
||||
"Thailand", "Turkmenistan", "Union_of_Myanmar", "United_Arab_Emirates", "Uzbekistan", "Vietnam", "Yemen",
|
||||
// "Japan", // 420 MB
|
||||
};
|
||||
|
||||
|
||||
// africa
|
||||
protected static final String[] africa = new String[] {
|
||||
// "Algeria", "Egypt", "Madagascar", "Morocco", "South_Africa",
|
||||
"Algeria", "Egypt", "Madagascar", "Morocco", "South_Africa",
|
||||
// TODO generate these countries
|
||||
// "Angola", "Benin", "Botswana", "Burkina_Faso", "Burundi", "Cameroon", "Cape_Verde",
|
||||
// "Central_African_Republic", "Chad", "Comoros", "Congo", "Democratic_Republic_of_the_Congo",
|
||||
|
@ -507,6 +518,12 @@ public class IndexBatchCreator {
|
|||
f = zFile;
|
||||
|
||||
}
|
||||
try {
|
||||
DownloaderIndexFromGoogleCode.deleteFileFromGoogleDownloads(f.getName(), token, pagegen, cookieHSID, cookieSID);
|
||||
} catch (IOException e) {
|
||||
log.warn("Deleting file from downloads" + f.getName(), e);
|
||||
}
|
||||
|
||||
mbLengh = (double)f.length() / MB;
|
||||
if(mbLengh > 100){
|
||||
System.err.println("ERROR : file " + f.getName() + " exceeded 100 mb!!! Could not be uploaded.");
|
||||
|
|
Loading…
Reference in a new issue