import java.io.File;\r
import java.io.FileInputStream;\r
import java.io.FileOutputStream;\r
+import java.io.FilenameFilter;\r
import java.io.IOException;\r
import java.io.ObjectInputStream;\r
import java.io.ObjectOutputStream;\r
import java.net.HttpURLConnection;\r
import java.net.URL;\r
+import java.util.ArrayList;\r
+import java.util.HashMap;\r
+import java.util.List;\r
\r
-import android.os.Handler;\r
import android.os.StatFs;\r
import android.util.Log;\r
\r
this.level = level;\r
}\r
}\r
+ \r
+ public static class MapMenu {\r
+ List<HashMap<String, String>> groupList;\r
+ ArrayList<ArrayList<HashMap<String, String>>> childList;\r
+\r
+ MapMenu(List<HashMap<String, String>> groups, ArrayList<ArrayList<HashMap<String, String>>> childs) {\r
+ groupList = groups;\r
+ childList = childs;\r
+ }\r
+ }\r
+\r
//\r
// define the maps here\r
//\r
private static final osm_map_values[] osm_maps = {\r
- new osm_map_values("Whole Planet", "-180", "-90", "180", "90", 5985878379L, 0),\r
- new osm_map_values("Africa", "-20.8", "-35.2", "52.5", "37.4", 180836389L, 0),\r
- new osm_map_values("Angola", "11.4", "-18.1", "24.2", "-5.3", 56041641L, 1),\r
- new osm_map_values("Burundi", "28.9", "-4.5", "30.9", "-2.2", 56512924L, 1),\r
- new osm_map_values("Democratic Republic of the Congo", "11.7", "-13.6", "31.5", "5.7",65026791L, 1),\r
- new osm_map_values("Kenya", "33.8","-5.2", "42.4", "4.9", 58545273L, 1),\r
- new osm_map_values("Lesotho", "26.9", "-30.7", "29.6","-28.4", 54791041L, 1),\r
- new osm_map_values("Madagascar", "43.0","-25.8", "50.8","-11.8", 56801099L, 1),\r
- new osm_map_values("Nambia+Botswana","11.4", "-29.1","29.5", "-16.9", 61807049L, 1),\r
- new osm_map_values("Reunion", "55.2","-21.4", "55.9","-20.9", 58537419L, 1),\r
- new osm_map_values("Rwanda", "28.8","-2.9", "30.9","-1.0", 56313710L, 1),\r
- new osm_map_values("South Africa","15.6", "-35.2","33.3", "-21.9", 73545245L, 1),\r
- new osm_map_values("Uganda", "29.3","-1.6", "35.1","4.3", 57376589L, 1),\r
- new osm_map_values("Asia", "23.8","0.1", "195.0","82.4", 797725952L, 0),\r
- new osm_map_values("China", "67.3","5.3", "135.0","54.5", 259945160L, 1),\r
- new osm_map_values("Cyprus", "32.0","34.5", "34.9","35.8", 58585278L, 1),\r
- new osm_map_values("India+Nepal","67.9", "5.5","89.6", "36.0", 82819344L, 1),\r
- new osm_map_values("Indonesia", "93.7","-17.3", "155.5","7.6", 74648081L, 1),\r
- new osm_map_values("Iran", "43.5","24.4", "63.6","40.4", 69561312L, 1),\r
- new osm_map_values("Iraq", "38.7","28.5", "49.2","37.4", 59146383L, 1),\r
- new osm_map_values("Israel", "33.99","29.8", "35.95","33.4", 65065351L, 1),\r
- new osm_map_values("Japan+Korea+Taiwan","117.6", "20.5","151.3", "47.1", 305538751L, 1),\r
- new osm_map_values("Malasia+Singapore","94.3", "-5.9","108.6", "6.8", 58849792L, 1),\r
- new osm_map_values("Mongolia", "87.5","41.4", "120.3","52.7", 60871187L, 1),\r
- new osm_map_values("Thailand", "97.5","5.7", "105.2","19.7", 62422864L, 1),\r
- new osm_map_values("Turkey", "25.1","35.8", "46.4","42.8", 81758047L, 1),\r
- new osm_map_values("UAE+Other", "51.5","22.6", "56.7","26.5", 57419510L, 1),\r
- new osm_map_values("Australia", "110.5","-44.2", "154.9","-9.2", 128502185L, 0),\r
- new osm_map_values("Australia", "110.5","-44.2", "154.9","-9.2", 128502185L, 1),\r
- new osm_map_values("Tasmania", "144.0","-45.1", "155.3","-24.8", 103573989L, 1),\r
- new osm_map_values("Victoria+New South Wales","140.7", "-39.4","153.7", "-26.9", 99307594L, 1),\r
- new osm_map_values("New Zealand","165.2", "-47.6","179.1", "-33.7", 64757454L, 1),\r
- new osm_map_values("Europe", "-12.97","33.59", "34.15","72.10", 2753910015L, 0),\r
- new osm_map_values("Western Europe","-17.6", "34.5","42.9", "70.9", 2832986851L, 1),\r
- new osm_map_values("Austria", "9.4","46.32", "17.21","49.1", 222359992L, 1),\r
- new osm_map_values("BeNeLux", "2.08","48.87", "7.78","54.52", 533865194L, 1),\r
- new osm_map_values("Faroe Islands","-7.8", "61.3","-6.1", "62.5", 54526101L, 1),\r
- new osm_map_values("France", "-5.45","42.00", "8.44","51.68", 1112047845L, 1),\r
- new osm_map_values("Germany", "5.18","46.84", "15.47","55.64", 944716238L, 1),\r
- new osm_map_values("Bavaria", "10.3","47.8", "13.6","49.7", 131799419L, 2),\r
- new osm_map_values("Saxonia", "11.8","50.1", "15.0","51.7", 112073909L, 2),\r
- new osm_map_values("Germany+Austria+Switzerland","3.4", "44.5","18.6", "55.1", 1385785353L, 1),\r
- new osm_map_values("Iceland", "-25.3","62.8", "-11.4","67.5", 57281405L, 1),\r
- new osm_map_values("Ireland", "-11.17","51.25", "-5.23","55.9", 70186936L, 1),\r
- new osm_map_values("Italy", "6.52","36.38", "18.96","47.19", 291401314L, 1),\r
- new osm_map_values("Spain+Portugal","-11.04", "34.87","4.62", "44.41", 292407746L, 1),\r
- new osm_map_values("Mallorca", "2.2","38.8", "4.7","40.2", 88100718L, 2),\r
- new osm_map_values("Galicia", "-10.0","41.7", "-6.3","44.1", 64605237L, 2),\r
- new osm_map_values("Scandinavia", "4.0","54.4", "32.1","71.5", 299021928L, 1),\r
- new osm_map_values("Finland", "18.6","59.2", "32.3","70.3", 128871467L, 1),\r
- new osm_map_values("Denmark", "7.49","54.33", "13.05","57.88", 120025875L, 1),\r
- new osm_map_values("Switzerland","5.79", "45.74","10.59", "47.84", 162616817L, 1),\r
- new osm_map_values("UK", "-9.7", "49.6","2.2", "61.2", 245161510L, 1),\r
- new osm_map_values("Bulgaria", "24.7","42.1", "24.8","42.1", 56607427L, 1),\r
- new osm_map_values("Czech Republic","11.91", "48.48","19.02", "51.17", 234138824L, 1),\r
- new osm_map_values("Croatia", "13.4","42.1", "19.4","46.9", 99183280L, 1),\r
- new osm_map_values("Estonia", "21.5","57.5", "28.2","59.6", 79276178L, 1),\r
- new osm_map_values("Greece", "28.9","37.8", "29.0","37.8", 55486527L, 1),\r
- new osm_map_values("Crete", "23.3","34.5", "26.8","36.0", 57032630L, 1),\r
- new osm_map_values("Hungary", "16.08","45.57", "23.03","48.39", 109831319L, 1),\r
- new osm_map_values("Latvia", "20.7","55.6", "28.3","58.1", 71490706L, 1),\r
- new osm_map_values("Lithuania", "20.9","53.8", "26.9","56.5", 67992457L, 1),\r
- new osm_map_values("Poland", "13.6","48.8", "24.5","55.0", 266136768L, 1),\r
- new osm_map_values("Romania", "20.3","43.5", "29.9","48.4", 134525863L, 1),\r
- new osm_map_values("North America","-178.1", "6.5","-10.4", "84.0", 2477309662L, 0),\r
- new osm_map_values("Alaska", "-179.5","49.5", "-129","71.6", 72320027L, 1),\r
- new osm_map_values("Canada", "-141.3","41.5", "-52.2","70.2", 937813467L, 1),\r
- new osm_map_values("Hawaii", "-161.07","18.49", "-154.45","22.85", 57311788L, 1),\r
- new osm_map_values("USA (except Alaska and Hawaii)","-125.4", "24.3","-66.5", "49.3", 2216912004L, 1),\r
- new osm_map_values("Nevada", "-120.2","35.0", "-113.8","42.1", 136754975L, 2),\r
- new osm_map_values("Oregon", "-124.8","41.8", "-116.3","46.3", 101627308L, 2),\r
- new osm_map_values("Washington State","-125.0", "45.5","-116.9", "49.0", 98178877L, 2),\r
- new osm_map_values("South+Middle America","-83.5", "-56.3","-30.8", "13.7", 159615197L, 0),\r
- new osm_map_values("Argentina", "-73.9","-57.3", "-51.6","-21.0", 87516152L, 1),\r
- new osm_map_values("Argentina+Chile","-77.2", "-56.3","-52.7", "-16.1", 91976696L, 1),\r
- new osm_map_values("Bolivia", "-70.5","-23.1", "-57.3","-9.3", 58242168L, 1),\r
- new osm_map_values("Brazil", "-71.4","-34.7", "-32.8","5.4", 105527899L, 1),\r
- new osm_map_values("Cuba", "-85.3","19.6", "-74.0","23.6", 56608942L, 1),\r
- new osm_map_values("Colombia", "-79.1","-4.0", "-66.7","12.6", 78658454L, 1),\r
- new osm_map_values("Ecuador", "-82.6","-5.4", "-74.4","2.3", 61501914L, 1),\r
- new osm_map_values("Guyana+Suriname+Guyane Francaise","-62.0", "1.0","-51.2", "8.9", 57040689L, 1),\r
- new osm_map_values("Haiti+Republica Dominicana","-74.8", "17.3","-68.2", "20.1", 63528584L, 1),\r
- new osm_map_values("Jamaica", "-78.6","17.4", "-75.9","18.9", 53958307L, 1),\r
- new osm_map_values("Mexico", "-117.6","14.1", "-86.4","32.8", 251108617L, 1),\r
- new osm_map_values("Paraguay", "-63.8","-28.1", "-53.6","-18.8", 57188715L, 1),\r
- new osm_map_values("Peru", "-82.4","-18.1", "-67.5","0.4", 65421441L, 1),\r
- new osm_map_values("Uruguay", "-59.2","-36.5", "-51.7","-29.7", 63542225L, 1),\r
- new osm_map_values("Venezuela", "-73.6","0.4", "-59.7","12.8", 64838882L, 1)\r
+ new osm_map_values("Whole Planet","-180","-90","180","90", 7449814676L, 0),\r
+ new osm_map_values("Africa","-30.89","-36.17","61.68","38.40", 280880799L, 0),\r
+ new osm_map_values("Angola","11.4","-18.1","24.2","-5.3", 55850695L, 1),\r
+ new osm_map_values("Burundi","28.9","-4.5","30.9","-2.2", 60694550L, 1),\r
+ new osm_map_values("Canary Islands","-18.69","26.52","-12.79","29.99", 58904212L, 1),\r
+ new osm_map_values("Democratic Republic of the Congo","11.7","-13.6","31.5","5.7", 70168822L, 1),\r
+ new osm_map_values("Ethiopia","32.89","3.33","48.07","14.97", 68113437L, 1),\r
+ new osm_map_values("Guinea","-15.47","7.12","-7.58","12.74", 57466702L, 1),\r
+ new osm_map_values("Ivory Coast","-8.72","4.09","-2.43","10.80", 62652062L, 1),\r
+ new osm_map_values("Kenya","33.8","-5.2","42.4","4.9", 64420106L, 1),\r
+ new osm_map_values("Lesotho","26.9","-30.7","29.6","-28.4", 55533656L, 1),\r
+ new osm_map_values("Liberia","-15.00","-0.73","-7.20","8.65", 55963569L, 1),\r
+ new osm_map_values("Lybia","9.32","19.40","25.54","33.63", 63127225L, 1),\r
+ new osm_map_values("Madagascar","42.25","-26.63","51.20","-11.31", 56681202L, 1),\r
+ new osm_map_values("Nambia+Botswana","11.4","-29.1","29.5","-16.9", 64357926L, 1),\r
+ new osm_map_values("Reunion","55.2","-21.4","55.9","-20.9", 59487456L, 1),\r
+ new osm_map_values("Rwanda","28.8","-2.9","30.9","-1.0", 60654274L, 1),\r
+ new osm_map_values("South Africa+Lesotho","15.93","-36.36","33.65","-22.08", 79904318L, 1),\r
+ new osm_map_values("Tanzania","29.19","-11.87","40.74","-0.88", 65380211L, 1),\r
+ new osm_map_values("Uganda","29.3","-1.6","35.1","4.3", 61521337L, 1),\r
+ new osm_map_values("Asia","23.8","0.1","195.0","82.4", 1185692230L, 0),\r
+ new osm_map_values("Azerbaijan","44.74","38.34","51.69","42.37", 64563990L, 1),\r
+ new osm_map_values("China","67.3","5.3","135.0","54.5", 354889731L, 1),\r
+ new osm_map_values("Cyprus","32.0","34.5","34.9","35.8", 62657503L, 1),\r
+ new osm_map_values("India+Nepal","67.9","5.5","89.6","36.0", 96930647L, 1),\r
+ new osm_map_values("Indonesia","93.7","-17.3","155.5","7.6", 81860551L, 1),\r
+ new osm_map_values("Iran","43.5","24.4","63.6","40.4", 79782055L, 1),\r
+ new osm_map_values("Iraq","38.7","28.5","49.2","37.4", 64053119L, 1),\r
+ new osm_map_values("Israel","33.99","29.8","35.95","33.4", 73981247L, 1),\r
+ new osm_map_values("Japan+Korea+Taiwan","117.6","20.5","151.3","47.1", 451295345L, 1),\r
+ new osm_map_values("Kazakhstan","46.44","40.89","87.36","55.45", 114949353L, 1),\r
+ new osm_map_values("Kyrgyzstan","69.23","39.13","80.33","43.29", 62425757L, 1),\r
+ new osm_map_values("Malasia+Singapore","94.3","-5.9","108.6","6.8", 61142116L, 1),\r
+ new osm_map_values("Mongolia","87.5","41.4","120.3","52.7", 66228736L, 1),\r
+ new osm_map_values("Nambia+Botswana","11.4","-29.1","29.5","-16.9", 64357926L, 1),\r
+ new osm_map_values("Pakistan","60.83","23.28","77.89","37.15", 74060802L, 1),\r
+ new osm_map_values("Philippines","115.58","4.47","127.85","21.60", 71601316L, 1),\r
+ new osm_map_values("Saudi Arabia","33.2","16.1","55.9","33.5", 100651634L, 1),\r
+ new osm_map_values("Thailand","97.5","5.7","105.2","19.7", 68260330L, 1),\r
+ new osm_map_values("Turkey","25.1","35.8","46.4","42.8", 105200911L, 1),\r
+ new osm_map_values("Turkmenistan","51.78","35.07","66.76","42.91", 62188003L, 1),\r
+ new osm_map_values("UAE+Other","51.5","22.6","56.7","26.5", 61873090L, 1),\r
+ new osm_map_values("Australia+Oceania","89.84","-57.39","179.79","7.26", 185657003L, 0),\r
+ new osm_map_values("Australia","110.5","-44.2","154.9","-9.2", 138812990L, 0),\r
+ new osm_map_values("Tasmania","144.0","-45.1","155.3","-24.8", 109169592L, 1),\r
+ new osm_map_values("Victoria+New South Wales","140.7","-39.4","153.7","-26.9", 104820309L, 1),\r
+ new osm_map_values("New Caledonia","157.85","-25.05","174.15","-16.85", 54512722L, 1),\r
+ new osm_map_values("New Zealand","165.2","-47.6","179.1","-33.7", 68221081L, 1),\r
+ new osm_map_values("Europe","-12.97","33.59","34.15","72.10", 3570653608L, 0),\r
+ new osm_map_values("Western Europe","-17.6","34.5","42.9","70.9", 3700019849L, 1),\r
+ new osm_map_values("Austria","9.4","46.32","17.21","49.1", 289080462L, 1),\r
+ new osm_map_values("Azores","-31.62","36.63","-24.67","40.13", 54507108L, 1),\r
+ new osm_map_values("BeNeLux","2.08","48.87","7.78","54.52", 656716695L, 1),\r
+ new osm_map_values("Denmark","7.65","54.32","15.58","58.07", 154275079L, 1),\r
+ new osm_map_values("Faroe Islands","-7.8","61.3","-6.1","62.5", 54931474L, 1),\r
+ new osm_map_values("France","-5.45","42.00","8.44","51.68", 1468741961L, 1),\r
+ new osm_map_values("Alsace","6.79","47.27","8.48","49.17", 144023488L, 2),\r
+ new osm_map_values("Aquitaine","-2.27","42.44","1.50","45.76", 186786072L, 2),\r
+ new osm_map_values("Auvergne","2.01","44.57","4.54","46.85", 118942252L, 2),\r
+ new osm_map_values("Basse-Normandie","-2.09","48.13","1.03","49.98", 111940365L, 2),\r
+ new osm_map_values("Bourgogne","2.80","46.11","5.58","48.45", 114109115L, 2),\r
+ new osm_map_values("Bretagne","-5.58","46.95","-0.96","48.99", 188689862L, 2),\r
+ new osm_map_values("Centre","0.01","46.29","3.18","48.99", 208870488L, 2),\r
+ new osm_map_values("Champagne-Ardenne","3.34","47.53","5.94","50.28", 112266252L, 2),\r
+ new osm_map_values("Corse","8.12","41.32","9.95","43.28", 67997394L, 2),\r
+ new osm_map_values("Franche-Comte","5.20","46.21","7.83","48.07", 131236689L, 2),\r
+ new osm_map_values("Haute-Normandie","-0.15","48.62","1.85","50.18", 90484736L, 2),\r
+ new osm_map_values("Ile-de-France","1.40","48.07","3.61","49.29", 152890366L, 2),\r
+ new osm_map_values("Languedoc-Roussillon","1.53","42.25","4.89","45.02", 168413195L, 2),\r
+ new osm_map_values("Limousin","0.58","44.87","2.66","46.50", 98422724L, 2),\r
+ new osm_map_values("Lorraine","4.84","47.77","7.72","49.73", 137538540L, 2),\r
+ new osm_map_values("Midi-Pyrenees","-0.37","42.18","3.50","45.10", 186740619L, 2),\r
+ new osm_map_values("Nord-pas-de-Calais","1.42","49.92","4.49","51.31", 145320230L, 2),\r
+ new osm_map_values("Pays-de-la-Loire","-2.88","46.20","0.97","48.62", 243736184L, 2),\r
+ new osm_map_values("Picardie","1.25","48.79","4.31","50.43", 163238861L, 2),\r
+ new osm_map_values("Poitou-Charentes","-1.69","45.04","1.26","47.23", 197886714L, 2),\r
+ new osm_map_values("Provence-Alpes-Cote-d-Azur","4.21","42.91","7.99","45.18", 179863755L, 2),\r
+ new osm_map_values("Rhone-Alpes","3.65","44.07","7.88","46.64", 201452039L, 2),\r
+ new osm_map_values("Germany","5.18","46.84","15.47","55.64", 1187298374L, 1),\r
+ new osm_map_values("Baden-Wuerttemberg","7.32","47.14","10.57","49.85", 247149038L, 2),\r
+ new osm_map_values("Bayern","8.92","47.22","13.90","50.62", 306577202L, 2),\r
+ new osm_map_values("Mittelfranken","9.86","48.78","11.65","49.84", 95916401L, 2),\r
+ new osm_map_values("Niederbayern","11.55","47.75","14.12","49.42", 119427776L, 2),\r
+ new osm_map_values("Oberbayern","10.67","47.05","13.57","49.14", 147630851L, 2),\r
+ new osm_map_values("Oberfranken","10.31","49.54","12.49","50.95", 104963024L, 2),\r
+ new osm_map_values("Oberpfalz","11.14","48.71","13.47","50.43", 112413336L, 2),\r
+ new osm_map_values("Schwaben","9.27","47.10","11.36","49.09", 126836560L, 2),\r
+ new osm_map_values("Unterfranken","8.59","49.16","10.93","50.67", 124601596L, 2),\r
+ new osm_map_values("Berlin","13.03","52.28","13.81","52.73", 78189548L, 2),\r
+ new osm_map_values("Brandenburg","11.17","51.30","14.83","53.63", 126821283L, 2),\r
+ new osm_map_values("Bremen","8.43","52.96","9.04","53.66", 69427370L, 2),\r
+ new osm_map_values("Hamburg","9.56","53.34","10.39","53.80", 76388380L, 2),\r
+ new osm_map_values("Hessen","7.72","49.34","10.29","51.71", 155980870L, 2),\r
+ new osm_map_values("Mecklenburg-Vorpommern","10.54","53.05","14.48","55.05", 92107050L, 2),\r
+ new osm_map_values("Niedersachsen","6.40","51.24","11.69","54.22", 288712601L, 2),\r
+ new osm_map_values("Nordrhein-westfalen","5.46","50.26","9.52","52.59", 335383638L, 2),\r
+ new osm_map_values("Rheinland-Pfalz","6.06","48.91","8.56","51.00", 157909942L, 2),\r
+ new osm_map_values("Saarland","6.30","49.06","7.46","49.69", 78579241L, 2),\r
+ new osm_map_values("Sachsen-Anhalt","10.50","50.88","13.26","53.11", 115314663L, 2),\r
+ new osm_map_values("Sachsen","11.82","50.11","15.10","51.73", 134182818L, 2),\r
+ new osm_map_values("Schleswig-Holstein","7.41","53.30","11.98","55.20", 114865543L, 2),\r
+ new osm_map_values("Thueringen","9.81","50.15","12.72","51.70", 112896293L, 2),\r
+ new osm_map_values("Germany+Austria+Switzerland","3.4","44.5","18.6","55.1", 1763000779L, 1),\r
+ new osm_map_values("Iceland","-25.3","62.8","-11.4","67.5", 58803839L, 1),\r
+ new osm_map_values("Ireland","-11.17","51.25","-5.23","55.9", 74456575L, 1),\r
+ new osm_map_values("Italy","6.52","36.38","18.96","47.19", 373215809L, 1),\r
+ new osm_map_values("Spain+Portugal","-11.04","34.87","4.62","44.41", 354839261L, 1),\r
+ new osm_map_values("Mallorca","2.2","38.8","4.7","40.2", 66781797L, 2),\r
+ new osm_map_values("Galicia","-10.0","41.7","-6.3","44.1", 69081612L, 2),\r
+ new osm_map_values("Scandinavia","4.0","54.4","32.1","71.5", 386082513L, 1),\r
+ new osm_map_values("Finland","18.6","59.2","32.3","70.3", 167464389L, 1),\r
+ new osm_map_values("Denmark","7.49","54.33","13.05","57.88", 142017133L, 1),\r
+ new osm_map_values("Switzerland","5.79","45.74","10.59","47.84", 197612725L, 1),\r
+ new osm_map_values("UK","-9.7","49.6","2.2","61.2", 308044592L, 1),\r
+ new osm_map_values("England","-7.80","48.93","2.41","56.14", 331085897L, 1),\r
+ new osm_map_values("Buckinghamshire","-1.19","51.44","-0.43","52.25", 74619627L, 2),\r
+ new osm_map_values("Cambridgeshire","-0.55","51.96","0.56","52.79", 71849188L, 2),\r
+ new osm_map_values("Cumbria","-3.96","53.85","-2.11","55.24", 71699620L, 2),\r
+ new osm_map_values("East_yorkshire_with_hull","-1.16","53.50","0.54","54.26", 68241870L, 2),\r
+ new osm_map_values("Essex","-0.07","51.40","1.36","52.14", 82991499L, 2),\r
+ new osm_map_values("Herefordshire","-3.19","51.78","-2.29","52.45", 66471962L, 2),\r
+ new osm_map_values("Kent","-0.02","50.81","1.65","51.53", 75449128L, 2),\r
+ new osm_map_values("Lancashire","-3.20","53.43","-2.00","54.29", 75096621L, 2),\r
+ new osm_map_values("Leicestershire","-1.65","52.34","-0.61","53.03", 75492394L, 2),\r
+ new osm_map_values("Norfolk","0.10","52.30","2.04","53.41", 71556838L, 2),\r
+ new osm_map_values("Nottinghamshire","-1.39","52.73","-0.62","53.55", 72979826L, 2),\r
+ new osm_map_values("Oxfordshire","-1.77","51.41","-0.82","52.22", 73351886L, 2),\r
+ new osm_map_values("Shropshire","-3.29","52.26","-2.18","53.05", 69144272L, 2),\r
+ new osm_map_values("Somerset","-3.89","50.77","-2.20","51.40", 72098176L, 2),\r
+ new osm_map_values("South_yorkshire","-1.88","53.25","-0.80","53.71", 72594920L, 2),\r
+ new osm_map_values("Suffolk","0.29","51.88","1.81","52.60", 72985880L, 2),\r
+ new osm_map_values("Surrey","-0.90","51.02","0.10","51.52", 79850137L, 2),\r
+ new osm_map_values("Wiltshire","-2.41","50.90","-1.44","51.76", 71244578L, 2),\r
+ new osm_map_values("Scotland","-8.13","54.49","-0.15","61.40", 102111248L, 2),\r
+ new osm_map_values("Wales","-5.56","51.28","-2.60","53.60", 84860075L, 2),\r
+ new osm_map_values("Albania","19.09","39.55","21.12","42.72", 71097966L, 1),\r
+ new osm_map_values("Belarus","23.12","51.21","32.87","56.23", 100471644L, 1),\r
+ new osm_map_values("Russia","27.9","41.5","190.4", "77.6", 508559360L, 1),\r
+ new osm_map_values("Bulgaria","24.7","42.1","24.8","42.1", 62211433L, 1),\r
+ new osm_map_values("Bosnia-Herzegovina","15.69","42.52","19.67","45.32", 75756822L, 1),\r
+ new osm_map_values("Czech Republic","11.91","48.48","19.02","51.17", 288911729L, 1),\r
+ new osm_map_values("Croatia","13.4","42.1","19.4","46.9", 118479986L, 1),\r
+ new osm_map_values("Estonia","21.5","57.5","28.2","59.6", 86149958L, 1),\r
+ new osm_map_values("Greece","28.9","37.8","29.0","37.8", 59191120L, 1),\r
+ new osm_map_values("Crete","23.3","34.5","26.8","36.0", 61121443L, 1),\r
+ new osm_map_values("Hungary","16.08","45.57","23.03","48.39", 129046944L, 1),\r
+ new osm_map_values("Latvia","20.7","55.6","28.3","58.1", 81683354L, 1),\r
+ new osm_map_values("Lithuania","20.9","53.8","26.9","56.5", 77228922L, 1),\r
+ new osm_map_values("Poland","13.6","48.8","24.5","55.0", 331299544L, 1),\r
+ new osm_map_values("Romania","20.3","43.5","29.9","48.4", 150011857L, 1),\r
+ new osm_map_values("North America","-178.1","6.5","-10.4","84.0", 2738147321L, 0),\r
+ new osm_map_values("Alaska","-179.5","49.5","-129","71.6", 72413728L, 1),\r
+ new osm_map_values("Canada","-141.3","41.5","-52.2","70.2", 1125713287L, 1),\r
+ new osm_map_values("Hawaii","-161.07","18.49","-154.45","22.85", 57463829L, 1),\r
+ new osm_map_values("USA (except Alaska and Hawaii)","-125.4","24.3","-66.5","49.3", 2356238167L, 1),\r
+ new osm_map_values("Midwest","-104.11","35.92","-80.46","49.46", 663062321L, 2),\r
+ new osm_map_values("Michigan","-90.47","41.64","-79.00","49.37", 207416918L, 2),\r
+ new osm_map_values("Ohio","-84.87","38.05","-79.85","43.53", 143571732L, 2),\r
+ new osm_map_values("Northeast","-80.58","38.72","-66.83","47.53", 517925445L, 2),\r
+ new osm_map_values("Massachusetts","-73.56","40.78","-68.67","42.94", 159493455L, 2),\r
+ new osm_map_values("Vermont","-73.49","42.68","-71.41","45.07", 74308439L, 2),\r
+ new osm_map_values("Pacific","-180.05","15.87","-129.75","73.04", 78496182L, 2),\r
+ new osm_map_values("South","-106.70","23.98","-71.46","40.70", 1135650708L, 2),\r
+ new osm_map_values("Arkansas","-94.67","32.95","-89.59","36.60", 89637645L, 2),\r
+ new osm_map_values("District of Columbia","-77.17","38.74","-76.86","39.05", 64042148L, 2),\r
+ new osm_map_values("Florida","-88.75","23.63","-77.67","31.05", 118647388L, 2),\r
+ new osm_map_values("Louisiana","-94.09","28.09","-88.62","33.07", 136435773L, 2),\r
+ new osm_map_values("Maryland","-79.54","37.83","-74.99","40.22", 134152161L, 2),\r
+ new osm_map_values("Mississippi","-91.71","29.99","-88.04","35.05", 100291749L, 2),\r
+ new osm_map_values("Oklahoma","-103.41","33.56","-94.38","37.38", 106601625L, 2),\r
+ new osm_map_values("Texas","-106.96","25.62","-92.97","36.58", 220587321L, 2),\r
+ new osm_map_values("Virginia","-83.73","36.49","-74.25","39.52", 218627122L, 2),\r
+ new osm_map_values("West Virginia","-82.70","37.15","-77.66","40.97", 133830267L, 2),\r
+ new osm_map_values("West","-133.11","31.28","-101.99","49.51", 616041200L, 2),\r
+ new osm_map_values("Arizona","-114.88","30.01","-108.99","37.06", 89434673L, 2),\r
+ new osm_map_values("California","-125.94","32.43","-114.08","42.07", 303663259L, 2),\r
+ new osm_map_values("Colorado","-109.11","36.52","-100.41","41.05", 132835514L, 2),\r
+ new osm_map_values("Idaho","-117.30","41.93","-110.99","49.18", 97305030L, 2),\r
+ new osm_map_values("Montana","-116.10","44.31","-102.64","49.74", 93935496L, 2),\r
+ new osm_map_values("New Mexico","-109.10","26.98","-96.07","37.05", 185648327L, 2),\r
+ new osm_map_values("Nevada","-120.2","35.0","-113.8","42.1", 138055868L, 2),\r
+ new osm_map_values("Oregon","-124.8","41.8","-116.3","46.3", 103551459L, 2),\r
+ new osm_map_values("Utah","-114.11","36.95","-108.99","42.05", 78249845L, 2),\r
+ new osm_map_values("Washington State","-125.0","45.5","-116.9","49.0", 100601625L, 2),\r
+ new osm_map_values("South+Middle America","-83.5","-56.3","-30.8","13.7", 204217202L, 0),\r
+ new osm_map_values("Argentina","-73.9","-57.3","-51.6","-21.0", 105910515L, 1),\r
+ new osm_map_values("Argentina+Chile","-77.2","-56.3","-52.7","-16.1", 111585063L, 1),\r
+ new osm_map_values("Bolivia","-70.5","-23.1","-57.3","-9.3", 59215113L, 1),\r
+ new osm_map_values("Brazil","-71.4","-34.7","-32.8","5.4", 127279780L, 1),\r
+ new osm_map_values("Chile","-81.77","-58.50","-65.46","-17.41", 84808355L, 1),\r
+ new osm_map_values("Cuba","-85.3","19.6","-74.0","23.6", 57704852L, 1),\r
+ new osm_map_values("Colombia","-79.1","-4.0","-66.7","12.6", 85701114L, 1),\r
+ new osm_map_values("Ecuador","-82.6","-5.4","-74.4","2.3", 63453353L, 1),\r
+ new osm_map_values("Guyana+Suriname+Guyane Francaise","-62.0","1.0","-51.2","8.9", 57226004L, 1),\r
+ new osm_map_values("Haiti+Republica Dominicana","-74.8","17.3","-68.2","20.1", 63826780L, 1),\r
+ new osm_map_values("Jamaica","-78.6","17.4","-75.9","18.9", 53888545L, 1),\r
+ new osm_map_values("Mexico","-117.6","14.1","-86.4","32.8", 258877491L, 1),\r
+ new osm_map_values("Paraguay","-63.8","-28.1","-53.6","-18.8", 60539032L, 1),\r
+ new osm_map_values("Peru","-82.4","-18.1","-67.5","0.4", 71286591L, 1),\r
+ new osm_map_values("Uruguay","-59.2","-36.5","-51.7","-29.7", 64850903L, 1),\r
+ new osm_map_values("Venezuela","-73.6","0.4","-59.7","12.8", 74521456L, 1)\r
};\r
\r
- private static String[] OSM_MAP_NAME_LIST_inkl_SIZE_ESTIMATE = null;\r
-\r
- public static int[] OSM_MAP_NAME_ORIG_ID_LIST = null;\r
-\r
private Boolean stop_me = false;\r
- private static final int SOCKET_CONNECT_TIMEOUT = 25000; // 25 secs.\r
- private static final int SOCKET_READ_TIMEOUT = 15000; // 15 secs.\r
+ private static final int SOCKET_CONNECT_TIMEOUT = 60000; // 60 secs.\r
+ private static final int SOCKET_READ_TIMEOUT = 120000; // 120 secs.\r
private static final int MAP_WRITE_FILE_BUFFER = 1024 * 64;\r
private static final int MAP_WRITE_MEM_BUFFER = 1024 * 64;\r
private static final int MAP_READ_FILE_BUFFER = 1024 * 64;\r
private static final int UPDATE_PROGRESS_EVERY_CYCLE = 8;\r
private static final int MAX_RETRIES = 5;\r
- private static final String MAP_FILENAME_PRI = "navitmap.bin";\r
- private static final String MAP_FILENAME_NUM = "navitmap_%03d.bin";\r
private static final String MAP_FILENAME_PATH = Navit.MAP_FILENAME_PATH;\r
- private static final String TAG = "NavitMapDownloader";\r
+ private static final String TAG = "NavitMapDownloader";\r
+ private static final String MAP_BULLETPOINT = " * ";\r
\r
- private Handler mHandler;\r
private osm_map_values map_values;\r
- private int map_slot;\r
private int dialog_num;\r
- \r
+\r
public static final int EXIT_SUCCESS = 0;\r
public static final int EXIT_RECOVERABLE_ERROR = 1;\r
public static final int EXIT_UNRECOVERABLE_ERROR = 2;\r
- \r
+\r
public static int retry_counter = 0;\r
\r
public void run()\r
int exit_code;\r
retry_counter = 0;\r
\r
- Log.v(TAG, "map_num3=" + this.map_slot);\r
+ Log.v(TAG, "start download " + map_values.map_name);\r
\r
- NavitMessages.sendDialogMessage( mHandler, NavitMessages.DIALOG_PROGRESS_BAR\r
+ NavitDialogs.sendDialogMessage( NavitDialogs.MSG_PROGRESS_BAR\r
, Navit.get_text("Mapdownload"), Navit.get_text("downloading") + ": " + map_values.map_name\r
- , Navit.MAPDOWNLOAD_DIALOG, 20 , 0);\r
+ , NavitDialogs.DIALOG_MAPDOWNLOAD, 20 , 0);\r
\r
do\r
{\r
{\r
Thread.sleep(10 + retry_counter * 1000);\r
} catch (InterruptedException e1) {}\r
- } while ( ( exit_code = download_osm_map(mHandler, map_values, map_slot)) == EXIT_RECOVERABLE_ERROR\r
+ } while ( ( exit_code = download_osm_map(map_values)) == EXIT_RECOVERABLE_ERROR\r
&& retry_counter++ < MAX_RETRIES\r
&& !stop_me);\r
\r
if (exit_code == EXIT_SUCCESS)\r
{\r
- NavitMessages.sendDialogMessage( mHandler, NavitMessages.DIALOG_TOAST\r
+ NavitDialogs.sendDialogMessage( NavitDialogs.MSG_TOAST\r
, null, map_values.map_name + " " + Navit.get_text("ready")\r
, dialog_num , 0 , 0);\r
\r
Log.d(TAG, "success");\r
}\r
- \r
+\r
if (exit_code == EXIT_SUCCESS || stop_me )\r
{\r
- NavitMessages.sendDialogMessage( mHandler , NavitMessages.DIALOG_REMOVE_PROGRESS_BAR, null, null, dialog_num \r
+ NavitDialogs.sendDialogMessage( NavitDialogs.MSG_MAP_DOWNLOAD_FINISHED, MAP_FILENAME_PATH + map_values.map_name + ".bin", null, dialog_num \r
, exit_code , 0 );\r
}\r
}\r
Log.d(TAG, "stop_me -> true");\r
}\r
\r
- public NavitMapDownloader(Navit main, Handler h, int map_id, int dialog_num, int map_slot)\r
+ public NavitMapDownloader(int map_id)\r
{\r
- this.mHandler = h;\r
this.map_values = osm_maps[map_id];\r
- this.map_slot = map_slot;\r
}\r
\r
- public static String[] getMenu()\r
- {\r
- // need only init once\r
- if (OSM_MAP_NAME_LIST_inkl_SIZE_ESTIMATE != null) \r
- { \r
- return OSM_MAP_NAME_LIST_inkl_SIZE_ESTIMATE;\r
+ public static MapMenu getMenu() {\r
+ ArrayList<HashMap<String, String>> resultGroups = new ArrayList<HashMap<String, String>>();\r
+ ArrayList<ArrayList<HashMap<String, String>>> resultChilds =\r
+ new ArrayList<ArrayList<HashMap<String, String>>>();\r
+ ArrayList<HashMap<String, String>> secList = new ArrayList<HashMap<String, String>>();\r
+\r
+ // add already downloaded maps\r
+ HashMap<String, String> downloaded_maps_hash = new HashMap<String, String>();\r
+ downloaded_maps_hash.put("category_name", Navit.get_text("Downloaded Maps"));\r
+ resultGroups.add(downloaded_maps_hash);\r
+\r
+ for (NavitMap map : getAvailableMaps()) {\r
+ HashMap<String, String> child = new HashMap<String, String>();\r
+ child.put("map_name", map.mapName + " " + (map.size() / 1024 / 1024) + "MB");\r
+ child.put("map_location", map.getLocation());\r
+\r
+ secList.add(child);\r
}\r
- \r
- String menu_temp[] = new String[osm_maps.length*2];\r
- OSM_MAP_NAME_ORIG_ID_LIST = new int[osm_maps.length*2];\r
- int counter = 0;\r
- int previous_level = -1;\r
- for (int i = 0; i < osm_maps.length; i++)\r
- {\r
- switch (osm_maps[i].level)\r
- {\r
- case 0: \r
- if (previous_level > 0)\r
- {\r
- OSM_MAP_NAME_ORIG_ID_LIST[counter] = -1;\r
- menu_temp[counter++] = "======";\r
+ resultChilds.add(secList);\r
+ secList = null;\r
+\r
+ // add all maps\r
+ for (int currentMapIndex = 0; currentMapIndex < osm_maps.length; currentMapIndex++) {\r
+ if (osm_maps[currentMapIndex].level == 0) {\r
+ if (secList != null && secList.size() > 0) {\r
+ resultChilds.add(secList);\r
}\r
- menu_temp[counter] = "";\r
- break;\r
- case 1:\r
- menu_temp[counter] = new String(" * ");\r
- break;\r
- default:\r
- menu_temp[counter] = new String(" ** ");\r
+ secList = new ArrayList<HashMap<String, String>>();\r
+ HashMap<String, String> map_info_hash = new HashMap<String, String>();\r
+ map_info_hash.put("category_name", osm_maps[currentMapIndex].map_name);\r
+ resultGroups.add(map_info_hash);\r
}\r
- \r
- menu_temp[counter] = menu_temp[counter].concat(osm_maps[i].map_name + " " + (osm_maps[i].est_size_bytes / 1024 / 1024) + "MB");\r
- counter++;\r
- OSM_MAP_NAME_ORIG_ID_LIST[counter-1] = i;\r
- \r
- previous_level = osm_maps[i].level;\r
- }\r
- \r
- OSM_MAP_NAME_LIST_inkl_SIZE_ESTIMATE = new String[counter];\r
- for (int i = 0; i < counter; i++)\r
- {\r
- OSM_MAP_NAME_LIST_inkl_SIZE_ESTIMATE[i] = menu_temp[i];\r
+\r
+ HashMap<String, String> child = new HashMap<String, String>();\r
+ child.put("map_name", (osm_maps[currentMapIndex].level > 1 ? MAP_BULLETPOINT : "")\r
+ + osm_maps[currentMapIndex].map_name + " "\r
+ + (osm_maps[currentMapIndex].est_size_bytes / 1024 / 1024) + "MB");\r
+ child.put("map_index", String.valueOf(currentMapIndex));\r
+\r
+ secList.add(child);\r
}\r
- return OSM_MAP_NAME_LIST_inkl_SIZE_ESTIMATE;\r
+ resultChilds.add(secList);\r
+\r
+ return new MapMenu(resultGroups, resultChilds);\r
}\r
\r
- public int download_osm_map(Handler handler, osm_map_values map_values, int map_number)\r
+ public int download_osm_map(osm_map_values map_values)\r
{\r
int exit_code = EXIT_SUCCESS;\r
boolean resume = false;\r
outputFile = new File(MAP_FILENAME_PATH, fileName);\r
\r
long old_download_size = outputFile.length();\r
- long start_timestamp = System.nanoTime();\r
\r
outputFile.mkdir();\r
URL url = null;\r
{\r
ObjectInputStream infoStream = new ObjectInputStream(new FileInputStream(MAP_FILENAME_PATH + fileName + ".info"));\r
String resume_proto = infoStream.readUTF();\r
- String resume_host = infoStream.readUTF();\r
+ infoStream.readUTF(); // read the host name (unused for now)\r
String resume_file = infoStream.readUTF();\r
infoStream.close();\r
// looks like the same file, try to resume\r
file.delete();\r
}\r
}\r
- \r
+\r
if (url == null)\r
{\r
url = new URL("http://maps.navit-project.org/api/map/?bbox=" + map_values.lon1 + ","\r
+ map_values.lat1 + "," + map_values.lon2 + "," + map_values.lat2);\r
}\r
- \r
+\r
Log.v(TAG, "connect to " + url.toString());\r
// URL url = new URL("http://192.168.2.101:8080/zweibruecken.bin");\r
c = (HttpURLConnection) url.openConnection();\r
c.setRequestMethod("GET");\r
- c.setDoOutput(true);\r
c.setReadTimeout(SOCKET_READ_TIMEOUT);\r
c.setConnectTimeout(SOCKET_CONNECT_TIMEOUT);\r
\r
already_read = old_download_size;\r
}\r
\r
- real_size_bytes = c.getContentLength();\r
+ real_size_bytes = c.getContentLength() + already_read;\r
long fileTime = c.getLastModified();\r
- Log.d(TAG, "size: " + real_size_bytes \r
+ Log.d(TAG, "size: " + real_size_bytes\r
+ ", read: " + already_read\r
+ ", timestamp: " + fileTime);\r
- \r
\r
if (!resume)\r
{\r
infoStream.writeUTF(c.getURL().getProtocol());\r
infoStream.writeUTF(c.getURL().getHost());\r
infoStream.writeUTF(c.getURL().getFile());\r
+ infoStream.writeLong(real_size_bytes);\r
infoStream.close();\r
}\r
- \r
+\r
Log.v(TAG, "Connection ref: " + c.getURL());\r
if ( real_size_bytes <= 0)\r
real_size_bytes = map_values.est_size_bytes;\r
buf = new BufferedOutputStream(new FileOutputStream(outputFile, resume) , MAP_WRITE_FILE_BUFFER);\r
bif = new BufferedInputStream(c.getInputStream(), MAP_READ_FILE_BUFFER);\r
\r
+ long start_timestamp = System.nanoTime();\r
byte[] buffer = new byte[MAP_WRITE_MEM_BUFFER];\r
int len1 = 0;\r
int alt_cur = 0;\r
}\r
Log.e(TAG, "info: " + info);\r
\r
- NavitMessages.sendDialogMessage( handler, NavitMessages.DIALOG_PROGRESS_BAR\r
+ NavitDialogs.sendDialogMessage( NavitDialogs.MSG_PROGRESS_BAR\r
, Navit.get_text("Mapdownload"), info\r
, dialog_num, (int) (real_size_bytes / 1024), (int) (already_read / 1024));\r
}\r
\r
if (stop_me)\r
{\r
- NavitMessages.sendDialogMessage( handler, NavitMessages.DIALOG_TOAST\r
+ NavitDialogs.sendDialogMessage( NavitDialogs.MSG_TOAST\r
, null, Navit.get_text("Map download aborted!")\r
, dialog_num , 0 , 0);\r
\r
}\r
else\r
{\r
- NavitMessages.sendDialogMessage( mHandler, NavitMessages.DIALOG_PROGRESS_BAR\r
+ NavitDialogs.sendDialogMessage( NavitDialogs.MSG_PROGRESS_BAR\r
, Navit.get_text("Mapdownload")\r
, Navit.get_text("Error downloading map!")\r
, dialog_num, (int) (real_size_bytes / 1024), (int) (already_read / 1024));\r
}\r
catch (Exception e)\r
{\r
- NavitMessages.sendDialogMessage( mHandler, NavitMessages.DIALOG_PROGRESS_BAR\r
+ NavitDialogs.sendDialogMessage( NavitDialogs.MSG_PROGRESS_BAR\r
, Navit.get_text("Mapdownload")\r
, Navit.get_text("Error downloading map!")\r
, dialog_num, (int) (real_size_bytes / 1024), (int) (already_read / 1024));\r
\r
if (exit_code == EXIT_SUCCESS)\r
{\r
- String final_fileName = MAP_FILENAME_PRI;\r
- \r
- if (map_number>0)\r
- {\r
- final_fileName = String.format(MAP_FILENAME_NUM, map_number);\r
- }\r
+ File final_outputFile = new File(MAP_FILENAME_PATH, map_values.map_name + ".bin");\r
\r
- File final_outputFile = new File(MAP_FILENAME_PATH, final_fileName);\r
- // delete an already final filename, first\r
+ // delete an already existing file first\r
final_outputFile.delete();\r
- // rename file to final name\r
+ // rename file to its final name\r
outputFile.renameTo(final_outputFile);\r
}\r
- \r
+\r
return exit_code;\r
}\r
- \r
+\r
private boolean checkFreeSpace(long needed_bytes)\r
{\r
- StatFs fsInfo = new StatFs(MAP_FILENAME_PATH);\r
- \r
- long free_space = (long)fsInfo.getAvailableBlocks() * fsInfo.getBlockSize();\r
- \r
+ long free_space = getFreeSpace();\r
+ \r
if ( needed_bytes <= 0 )\r
needed_bytes = MAP_WRITE_FILE_BUFFER;\r
\r
if (free_space < needed_bytes )\r
{\r
Log.e(TAG, "Not enough free space. Please free at least " + needed_bytes / 1024 /1024 + "Mb.");\r
- \r
- NavitMessages.sendDialogMessage( mHandler, NavitMessages.DIALOG_PROGRESS_BAR\r
+\r
+ NavitDialogs.sendDialogMessage( NavitDialogs.MSG_PROGRESS_BAR\r
, Navit.get_text("Mapdownload")\r
, Navit.get_text("Error downloading map!") + "\n" + Navit.get_text("Not enough free space")\r
, dialog_num, (int)(needed_bytes / 1024), (int)(free_space / 1024));\r
- \r
+\r
return false;\r
}\r
return true;\r
}\r
+\r
+ public static long getFreeSpace()\r
+ {\r
+ StatFs fsInfo = new StatFs(MAP_FILENAME_PATH);\r
+ return (long)fsInfo.getAvailableBlocks() * fsInfo.getBlockSize();\r
+ }\r
+ \r
+ public static NavitMap[] getAvailableMaps()\r
+ {\r
+ class filterMaps implements FilenameFilter {\r
+ public boolean accept(File dir, String filename)\r
+ {\r
+ if (filename.endsWith(".bin"))\r
+ return true;\r
+ return false;\r
+ }\r
+ }\r
+ File map_dir = new File(MAP_FILENAME_PATH);\r
+ String map_file_names[] = map_dir.list(new filterMaps());\r
+ NavitMap maps[] = new NavitMap[map_file_names.length];\r
+ for (int map_file_index = 0; map_file_index < map_file_names.length; map_file_index++) {\r
+ maps[map_file_index] = new NavitMap(MAP_FILENAME_PATH, map_file_names[map_file_index]);\r
+ }\r
+ return maps;\r
+ }\r
}\r