bugfix
git-svn-id: https://osmand.googlecode.com/svn/trunk@472 e29c36b1-1cfa-d876-8d93-3434fc2bb7b8
This commit is contained in:
parent
59ed71f20f
commit
cae2fec932
10 changed files with 295 additions and 114 deletions
Binary file not shown.
|
@ -8,48 +8,35 @@ package net.osmand;
|
|||
public class ToDoConstants {
|
||||
|
||||
// TODO swing
|
||||
// ! 9. Fix issues with big files (such as netherlands) - save memory (!)
|
||||
// Current result : for big file (1 - task 60-80% time, 90% memory) (?) (+)
|
||||
// 11. Index buildings using interpolations (from nodes) (+)
|
||||
// ! 12. Reinvent UI of swing app (remove Region object and clear other MapObject) use indexes to show results
|
||||
|
||||
// TODO max 86
|
||||
// TODO max 87
|
||||
// ! 81. Add some objects to POI category (1) to add them into OSM 2) to help navigation)
|
||||
// highway (?), traffic_calming (?), barrier(?), military(?-), landuse (?), office(?), man_made(?), power(?),
|
||||
// railway( station, subway?) - issue 17
|
||||
// 86. Allow to add/edit custom tags to POI objects.
|
||||
// 87. Use network availability for defining loading tiles from internet.
|
||||
|
||||
// TODO check network availability
|
||||
// TODO's in IndexCreator and other files!
|
||||
// TODO order in nodes.tmp.odb !!! fix for future
|
||||
|
||||
// TODO BUGS/Improvements:
|
||||
// 1! VELCOM - competition (ppt)
|
||||
// 2. rotate map gps without location
|
||||
// 3! Transport redesign call UI (enable context menu call, switch go to goal/not)
|
||||
// 4. recalculating route when location is far from !
|
||||
// 5. keyboard (issue 43 )?
|
||||
|
||||
// TODO BUGS:
|
||||
// USA indexes
|
||||
// ! VELCOM - competition (ppt)
|
||||
|
||||
// rotate map gps without location
|
||||
// recalculating route when location is far from !
|
||||
// ----- from site ---
|
||||
// - 5 (?)
|
||||
// - menu order (41)
|
||||
// - 81. (17)
|
||||
// -- house tagging (31)
|
||||
// --- go back to osmand (23)
|
||||
// --- keyboard (43)
|
||||
// --- add poi tags (44)
|
||||
|
||||
// 6. Download with wget
|
||||
// 7. progress while map is loading
|
||||
|
||||
// PRESENTS : mediamarkt, parfum, coffee, (al-parfum), (om?), olia?
|
||||
|
||||
|
||||
// Unscheduled (complex)
|
||||
// 65. Intermediate points - for better control routing, to avoid traffic jams ...(?)
|
||||
// 40. Support simple vector road rendering (require new index file) (?)
|
||||
// 63. Support simple offline routing(require new index file) (?)
|
||||
|
||||
// Improvements
|
||||
// ! Download with wget
|
||||
// ! progress while map is loading
|
||||
|
||||
// Not clear if it is really needed
|
||||
// 69. Add phone information to POI
|
||||
// 70. Show building numbers over map (require changing address index - index 2 more columns lat/lon for fast search)
|
||||
|
@ -64,15 +51,9 @@ public class ToDoConstants {
|
|||
// DONE SWING
|
||||
// 10. Improve address indexing (use relations). (+)
|
||||
// use relation "a6" (to accumulate streets!), "a3" to read all cities & define boundaries for city (& define that street in city).
|
||||
|
||||
// public static void main(String[] args) throws SQLException, ClassNotFoundException {
|
||||
// File dir = new File("e:\\Information\\OSM maps\\osm_map\\!big!\\");
|
||||
// Class.forName("org.sqlite.JDBC");
|
||||
// for(File f : dir.listFiles()){
|
||||
// if(f.getName().endsWith(".odb")){
|
||||
// IndexCreator.removeWayNodes(f);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// ! 9. Fix issues with big files (such as netherlands) - save memory (!)
|
||||
// Current result : for big file (1 - task 60-80% time, 90% memory) (?) (+)
|
||||
// 11. Index buildings using interpolations (from nodes) (+)
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -35,7 +35,7 @@ public class DataTileManager<T> {
|
|||
}
|
||||
|
||||
public void setZoom(int zoom) {
|
||||
// TODO !!! it is required to reindex all stored objects
|
||||
// it is required to reindex all stored objects
|
||||
if(!isEmpty()){
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
|
|
@ -26,6 +26,7 @@ import net.osmand.data.TransportStop;
|
|||
import net.osmand.data.City.CityType;
|
||||
import net.osmand.data.index.IndexConstants.IndexBuildingTable;
|
||||
import net.osmand.data.index.IndexConstants.IndexCityTable;
|
||||
import net.osmand.data.index.IndexConstants.IndexMapWays;
|
||||
import net.osmand.data.index.IndexConstants.IndexPoiTable;
|
||||
import net.osmand.data.index.IndexConstants.IndexStreetNodeTable;
|
||||
import net.osmand.data.index.IndexConstants.IndexStreetTable;
|
||||
|
@ -36,6 +37,9 @@ import net.osmand.osm.Node;
|
|||
import net.osmand.osm.Way;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
|
||||
|
||||
|
@ -129,7 +133,6 @@ public class DataIndexWriter {
|
|||
stat.executeUpdate(IndexConstants.generateCreateIndexSQL(IndexPoiTable.values()));
|
||||
stat.execute("PRAGMA user_version = " + IndexConstants.POI_TABLE_VERSION); //$NON-NLS-1$
|
||||
stat.close();
|
||||
|
||||
}
|
||||
|
||||
public DataIndexWriter writeAddress() throws IOException, SQLException{
|
||||
|
@ -382,7 +385,71 @@ public class DataIndexWriter {
|
|||
stat.execute("PRAGMA user_version = " + IndexConstants.TRANSPORT_TABLE_VERSION); //$NON-NLS-1$
|
||||
stat.close();
|
||||
}
|
||||
|
||||
public static void createMapIndexStructure(Connection conn) throws SQLException{
|
||||
Statement stat = conn.createStatement();
|
||||
stat.execute(IndexConstants.generateCreateSQL(IndexMapWays.values()));
|
||||
stat.execute(IndexConstants.generateCreateIndexSQL(IndexMapWays.values()));
|
||||
stat.execute("CREATE VIRTUAL TABLE "+IndexConstants.indexMapLocationsTable+" USING rtree (id, minLon, maxLon, minLat, maxLat);");
|
||||
stat.execute("PRAGMA user_version = " + IndexConstants.MAP_TABLE_VERSION); //$NON-NLS-1$
|
||||
stat.close();
|
||||
}
|
||||
|
||||
public static PreparedStatement createStatementMapWaysInsert(Connection conn) throws SQLException{
|
||||
assert IndexMapWays.values().length == 3;
|
||||
return conn.prepareStatement(IndexConstants.generatePrepareStatementToInsert(IndexMapWays.getTable(), 3));
|
||||
}
|
||||
public static PreparedStatement createStatementMapWaysLocationsInsert(Connection conn) throws SQLException{
|
||||
return conn.prepareStatement(IndexConstants.generatePrepareStatementToInsert(IndexConstants.indexMapLocationsTable, 5));
|
||||
}
|
||||
|
||||
public static void insertMapWayIndex(Map<PreparedStatement, Integer> statements,
|
||||
PreparedStatement mapWayStat, PreparedStatement mapWayLocationsStat, Way w, int batchSize) throws SQLException {
|
||||
assert IndexMapWays.values().length == 3;
|
||||
JSONObject tags = new JSONObject();
|
||||
for (String tagKey : w.getTagKeySet()) {
|
||||
try {
|
||||
tags.put(tagKey, w.getTag(tagKey));
|
||||
} catch (JSONException e) {
|
||||
}
|
||||
}
|
||||
JSONArray nodes = new JSONArray();
|
||||
boolean init = false;
|
||||
double minLat = -180;
|
||||
double maxLat = 180;
|
||||
double minLon = -360;
|
||||
double maxLon = 360;
|
||||
for (Node n : w.getNodes()) {
|
||||
if (n != null) {
|
||||
try {
|
||||
JSONArray ar = new JSONArray();
|
||||
ar.put(n.getId());
|
||||
ar.put(n.getLatitude());
|
||||
ar.put(n.getLongitude());
|
||||
minLat = Math.min(minLat, n.getLatitude());
|
||||
maxLat = Math.max(maxLat, n.getLatitude());
|
||||
minLon = Math.min(minLon, n.getLatitude());
|
||||
maxLon = Math.max(maxLon, n.getLatitude());
|
||||
init = true;
|
||||
nodes.put(ar);
|
||||
} catch (JSONException e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (init) {
|
||||
mapWayStat.setLong(IndexMapWays.ID.ordinal() + 1, w.getId());
|
||||
mapWayStat.setString(IndexMapWays.TAGS.ordinal() + 1, tags.toString());
|
||||
mapWayStat.setString(IndexMapWays.NODES.ordinal() + 1, nodes.toString());
|
||||
addBatch(statements, mapWayStat);
|
||||
|
||||
mapWayLocationsStat.setLong(1, w.getId());
|
||||
mapWayLocationsStat.setDouble(2, minLon);
|
||||
mapWayLocationsStat.setDouble(3, maxLon);
|
||||
mapWayLocationsStat.setDouble(4, minLat);
|
||||
mapWayLocationsStat.setDouble(5, maxLat);
|
||||
addBatch(statements, mapWayLocationsStat);
|
||||
}
|
||||
}
|
||||
|
||||
private static void addBatch(Map<PreparedStatement, Integer> count, PreparedStatement p) throws SQLException{
|
||||
addBatch(count, p, BATCH_SIZE);
|
||||
|
|
|
@ -40,10 +40,15 @@ public class IndexBatchCreator {
|
|||
private static final Set<String> doNotWriteWayNodesInUploading = new LinkedHashSet<String>();
|
||||
static {
|
||||
doNotWriteWayNodesInUploading.addAll(Arrays.asList(new String[]{
|
||||
"great_britain",
|
||||
"great_britain", "netherlands",
|
||||
// US
|
||||
"us_alabama", "us_california", "us_florida", "us_georgia", "us_illinois", "us_indiana",
|
||||
"us_kentucky", "us_maryland", "us_massachusetts", "us_missouri", "us_new_york",
|
||||
"us_kentucky", "us_maryland", "us_massachusetts", "us_missouri", "us_new_york",
|
||||
"us_north_carolina", "us_north_dakota", "us_ohio", "us_oklahoma", "us_oregon", "us_pennsylvania",
|
||||
"us_south_carolina", "us_tennessee", "us_texas", "us_utah", "us_vermont", "us_virginia",
|
||||
"us_washington", "us_west_virginia", "us_wisconsin", "us_wyoming",
|
||||
// asia
|
||||
"japan",
|
||||
}));
|
||||
// next could be : australia
|
||||
}
|
||||
|
@ -67,6 +72,7 @@ public class IndexBatchCreator {
|
|||
//TOTAL : 1129 MB
|
||||
// "czech_republic", "netherlands", // 168, 375,
|
||||
// "great_britain" , "italy", // 310, 246,
|
||||
//// "germany", "france", // 1100, 959 // index by states !
|
||||
// ADD TO TOTAL : 2449 MB
|
||||
|
||||
};
|
||||
|
@ -87,16 +93,14 @@ public class IndexBatchCreator {
|
|||
|
||||
protected static final String SITE_TO_DOWNLOAD2 = "http://downloads.cloudmade.com/"; //$NON-NLS-1$
|
||||
// us states
|
||||
// TODO Address (out of memory) : west-virginia, virginia, vermont, utas, texas, tennesse, pensilvania, oregon,..
|
||||
protected static final String[] usStates = new String[] {
|
||||
// "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",
|
||||
// "Montana", "Nebraska", "Nevada", "New_Hampshire", "New_Jersey", "New_Mexico",
|
||||
// TODO
|
||||
// "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",
|
||||
};
|
||||
|
||||
|
@ -106,15 +110,31 @@ public class IndexBatchCreator {
|
|||
// "Quebec","Saskatchewan","Yukon",
|
||||
};
|
||||
|
||||
// NORTH AMERICA
|
||||
protected static final String[] northAmerica = new String[] {
|
||||
// "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",
|
||||
// "Greenland", "Grenada", "Guadeloupe", "Martinique",
|
||||
// "Netherlands_Antilles", "Nicaragua", "Panama", "Puerto_Rico", "St_Lucia",
|
||||
// "St_Pierre_and_Miquelon", "St_Vincent_and_the_Grenadines", "Trinidad_and_Tobago", "Virgin_Islands",
|
||||
|
||||
};
|
||||
|
||||
|
||||
protected static final String[] southAmerica = new String[] {
|
||||
// "Argentina","Bolivia","Brazil","Chile","Colombia",
|
||||
// "Ecuador","Falkland_Islands", "French_Guiana","Guyana","Paraguay",
|
||||
// "Peru","Suriname","Uruguay","Venezuela"
|
||||
};
|
||||
|
||||
// TODO only australia, new zealand created
|
||||
|
||||
// oceania
|
||||
protected static final String[] oceania = new String[] {
|
||||
// "Australia", "New_Zealand",
|
||||
// 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",
|
||||
// "Independent_State_of_Samoa","Jarvis_Island","Johnston_Atoll","Kiribati",
|
||||
|
@ -130,22 +150,47 @@ public class IndexBatchCreator {
|
|||
// "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",
|
||||
// "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",
|
||||
};
|
||||
|
||||
// TODO Japan
|
||||
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",
|
||||
// TODO generate these countries
|
||||
// "Angola", "Benin", "Botswana", "Burkina_Faso", "Burundi", "Cameroon", "Cape_Verde",
|
||||
// "Central_African_Republic", "Chad", "Comoros", "Congo", "Democratic_Republic_of_the_Congo",
|
||||
// "Djibouti", "Equatorial_Guinea", "Eritrea", "Ethiopia", "Gabon", "Gambia", "Ghana",
|
||||
// "Glorioso_Islands", "Guinea", "Guinea-Bissau", "Ivory_Coast", "Juan_De_Nova_Island", "Kenya",
|
||||
// "Lesotho", "Liberia", "Libya", "Malawi", "Mali", "Mauritania", "Mauritius", "Mayotte",
|
||||
// "Mozambique", "Namibia", "Niger", "Nigeria", "Reunion", "Rwanda", "Sao_Tome_and_Principe",
|
||||
// "Senegal", "Seychelles", "Sierra_Leone", "Somalia", "St_Helena", "Sudan", "Swaziland",
|
||||
// "Togo", "Tunisia", "Uganda", "United_Republic_of_Tanzania", "Western_Sahara", "Zambia", "Zimbabwe",
|
||||
};
|
||||
|
||||
|
||||
protected static final String[] continents = new String[] {
|
||||
// "africa", // 160M
|
||||
// "australia-oceania", // 202M
|
||||
// "central-america", // 115M
|
||||
// "south-america", // 163M
|
||||
// "asia", // 911 M
|
||||
// + europe, north america
|
||||
};
|
||||
|
||||
|
||||
|
@ -225,7 +270,15 @@ public class IndexBatchCreator {
|
|||
downloadFile(url, "Germany_"+country, alreadyGeneratedFiles, alreadyUploadedFiles);
|
||||
}
|
||||
|
||||
// TODO NORTH AMERICA partially //
|
||||
|
||||
// north america //
|
||||
for(String country : northAmerica){
|
||||
country = country.toLowerCase();
|
||||
String url = SITE_TO_DOWNLOAD2 + "north_america/"+country+"/"+country +".osm.bz2"; //$NON-NLS-1$
|
||||
downloadFile(url, country, alreadyGeneratedFiles, alreadyUploadedFiles);
|
||||
}
|
||||
|
||||
|
||||
// usa
|
||||
for(String country : usStates){
|
||||
country = country.toLowerCase();
|
||||
|
@ -254,6 +307,13 @@ public class IndexBatchCreator {
|
|||
downloadFile(url, country, alreadyGeneratedFiles, alreadyUploadedFiles);
|
||||
}
|
||||
|
||||
// africa //
|
||||
for(String country : africa){
|
||||
country = country.toLowerCase();
|
||||
String url = SITE_TO_DOWNLOAD2 + "africa/"+country+"/"+country +".osm.bz2"; //$NON-NLS-1$
|
||||
downloadFile(url, country, alreadyGeneratedFiles, alreadyUploadedFiles);
|
||||
}
|
||||
|
||||
// russia
|
||||
for(String country : russiaStates){
|
||||
country = country.toLowerCase();
|
||||
|
@ -268,8 +328,6 @@ public class IndexBatchCreator {
|
|||
downloadFile(url, country, alreadyGeneratedFiles, alreadyUploadedFiles);
|
||||
}
|
||||
|
||||
// TODO AFRICA not done //
|
||||
// TODO Antarctica not done //
|
||||
|
||||
System.out.println("DOWNLOADING FILES FINISHED");
|
||||
}
|
||||
|
@ -437,7 +495,7 @@ public class IndexBatchCreator {
|
|||
summary = "POI index for " ;
|
||||
} else if(f.getName().endsWith(IndexConstants.ADDRESS_INDEX_EXT) || f.getName().endsWith(IndexConstants.ADDRESS_INDEX_EXT_ZIP)){
|
||||
regionName = f.getName().substring(0, f.getName().length() - IndexConstants.ADDRESS_INDEX_EXT.length() - 2);
|
||||
summary = "Adress index for " ;
|
||||
summary = "Address index for " ;
|
||||
} else if(f.getName().endsWith(IndexConstants.TRANSPORT_INDEX_EXT) || f.getName().endsWith(IndexConstants.TRANSPORT_INDEX_EXT_ZIP)){
|
||||
regionName = f.getName().substring(0, f.getName().length() - IndexConstants.TRANSPORT_INDEX_EXT.length() - 2);
|
||||
summary = "Transport index for ";
|
||||
|
|
|
@ -406,4 +406,43 @@ public class IndexConstants {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
public static String indexMapLocationsTable = "map_locations";
|
||||
|
||||
public enum IndexMapWays implements IndexColumn {
|
||||
ID("long", true), TAGS, NODES;
|
||||
boolean index = false;
|
||||
String type = null;
|
||||
|
||||
private IndexMapWays() {
|
||||
}
|
||||
|
||||
private IndexMapWays(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
private IndexMapWays(String type, boolean index) {
|
||||
this(type);
|
||||
this.index = index;
|
||||
}
|
||||
|
||||
public static String getTable() {
|
||||
return "ways"; //$NON-NLS-1$
|
||||
}
|
||||
|
||||
public String getTableName() {
|
||||
return getTable();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isIndex() {
|
||||
return index;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -70,13 +70,11 @@ public class IndexCreator {
|
|||
private static final Log log = LogFactory.getLog(DataExtraction.class);
|
||||
// TODO check
|
||||
// 1. check postal_code if the building was registered by relation!
|
||||
|
||||
// TODO normalizing (!!!), lowercase, converting en street names after all!
|
||||
// TODO find proper location for streets ! centralize them
|
||||
|
||||
|
||||
public static final int BATCH_SIZE = 5000;
|
||||
public static final String TEMP_NODES_DB = "nodes"+IndexConstants.MAP_INDEX_EXT;
|
||||
public static final String TEMP_NODES_DB = "nodes.tmp.odb";
|
||||
public static final int STEP_MAIN = 1;
|
||||
public static final int STEP_ADDRESS_RELATIONS = 2;
|
||||
public static final int STEP_CITY_NODES = 3;
|
||||
|
@ -128,6 +126,11 @@ public class IndexCreator {
|
|||
private PreparedStatement addressStreetStat;
|
||||
private PreparedStatement addressBuildingStat;
|
||||
private PreparedStatement addressStreetNodeStat;
|
||||
|
||||
private File mapFile;
|
||||
private Connection mapConnection;
|
||||
private PreparedStatement mapWaysStat;
|
||||
private PreparedStatement mapWayLocsStat;
|
||||
|
||||
// choose what to use ?
|
||||
private boolean loadInMemory = true;
|
||||
|
@ -924,6 +927,12 @@ public class IndexCreator {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(indexMap && e instanceof Way){
|
||||
// manipulate what kind of way to load
|
||||
loadEntityData(e, true);
|
||||
DataIndexWriter.insertMapWayIndex(pStatements, mapWaysStat, mapWayLocsStat, (Way) e, BATCH_SIZE);
|
||||
}
|
||||
|
||||
if (indexAddress) {
|
||||
// index not only buildings but also nodes that belongs to addr:interpolation ways
|
||||
|
@ -1036,11 +1045,7 @@ public class IndexCreator {
|
|||
}
|
||||
boolean loadFromPath = dbFile == null;
|
||||
if (dbFile == null) {
|
||||
if (indexMap) {
|
||||
dbFile = new File(workingDir, getMapFileName());
|
||||
} else {
|
||||
dbFile = new File(workingDir, TEMP_NODES_DB);
|
||||
}
|
||||
dbFile = new File(workingDir, TEMP_NODES_DB);
|
||||
// to save space
|
||||
if (dbFile.exists()) {
|
||||
dbFile.delete();
|
||||
|
@ -1114,6 +1119,23 @@ public class IndexCreator {
|
|||
pselectWay = dbConn.prepareStatement("select * from ways where id = ?");
|
||||
pselectRelation = dbConn.prepareStatement("select * from relations where id = ?");
|
||||
pselectTags = dbConn.prepareStatement("select key, value from tags where id = ? and type = ?");
|
||||
|
||||
if(indexMap){
|
||||
mapFile = new File(workingDir, getMapFileName());
|
||||
// to save space
|
||||
if (mapFile.exists()) {
|
||||
mapFile.delete();
|
||||
}
|
||||
mapFile.getParentFile().mkdirs();
|
||||
mapConnection = DriverManager.getConnection("jdbc:sqlite:" + mapFile.getAbsolutePath());
|
||||
|
||||
DataIndexWriter.createMapIndexStructure(mapConnection);
|
||||
mapWaysStat = DataIndexWriter.createStatementMapWaysInsert(mapConnection);
|
||||
mapWayLocsStat = DataIndexWriter.createStatementMapWaysLocationsInsert(mapConnection);
|
||||
pStatements.put(mapWaysStat, 0);
|
||||
pStatements.put(mapWayLocsStat, 0);
|
||||
mapConnection.setAutoCommit(false);
|
||||
}
|
||||
|
||||
if (indexPOI) {
|
||||
poiIndexFile = new File(workingDir, getPoiFileName());
|
||||
|
@ -1124,10 +1146,10 @@ public class IndexCreator {
|
|||
poiIndexFile.getParentFile().mkdirs();
|
||||
// creating nodes db to fast access for all nodes
|
||||
poiConnection = DriverManager.getConnection("jdbc:sqlite:" + poiIndexFile.getAbsolutePath());
|
||||
poiConnection.setAutoCommit(false);
|
||||
DataIndexWriter.createPoiIndexStructure(poiConnection);
|
||||
poiPreparedStatement = DataIndexWriter.createStatementAmenityInsert(poiConnection);
|
||||
pStatements.put(poiPreparedStatement, 0);
|
||||
poiConnection.setAutoCommit(false);
|
||||
}
|
||||
|
||||
if (indexTransport) {
|
||||
|
@ -1294,6 +1316,14 @@ public class IndexCreator {
|
|||
}
|
||||
}
|
||||
|
||||
if (mapConnection != null) {
|
||||
mapConnection.commit();
|
||||
mapConnection.close();
|
||||
if (lastModifiedDate != null) {
|
||||
mapFile.setLastModified(lastModifiedDate);
|
||||
}
|
||||
}
|
||||
|
||||
if (addressConnection != null) {
|
||||
addressConnection.commit();
|
||||
addressConnection.close();
|
||||
|
@ -1320,26 +1350,12 @@ public class IndexCreator {
|
|||
st.close();
|
||||
dbConn.close();
|
||||
}
|
||||
|
||||
|
||||
public static void main(String[] args) throws IOException, SAXException, SQLException {
|
||||
File workDir = new File("C:/");
|
||||
IndexCreator extr = new IndexCreator(workDir);
|
||||
extr.setIndexPOI(true);
|
||||
// extr.setIndexTransport(true);
|
||||
// extr.setIndexAddress(true);
|
||||
// extr.setNormalizeStreets(true);
|
||||
// extr.setSaveAddressWays(true);
|
||||
// public static void main(String[] args) throws IOException, SAXException, SQLException {
|
||||
// IndexCreator creator = new IndexCreator(new File("e:\\Information\\OSM maps\\osmand\\"));
|
||||
// creator.setIndexMap(true);
|
||||
//
|
||||
// creator.generateIndexes(new File("e:/Information/OSM maps/belarus osm/minsk.osm.bz2"), new ConsoleProgressImplementation(3), null);
|
||||
// }
|
||||
|
||||
// 1. generates using nodes db
|
||||
// File file = new File(workDir, "nodes.map.odb");
|
||||
// extr.setNodesDBFile(file);
|
||||
// extr.generateIndexes(file, new ConsoleProgressImplementation(2), null);
|
||||
|
||||
// 2. generates using osm bz2
|
||||
// extr.generateIndexes(new File("e:/Information/OSM maps/belarus osm/belarus_2010_06_02.osm.bz2"), new ConsoleProgressImplementation(4), null);
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,6 +31,7 @@ import net.osmand.map.IMapLocationListener;
|
|||
import net.osmand.map.ITileSource;
|
||||
import net.osmand.osm.LatLon;
|
||||
import net.osmand.osm.MapUtils;
|
||||
import net.osmand.render.RendererLayer;
|
||||
import net.osmand.views.AnimateDraggingMapThread;
|
||||
import net.osmand.views.ContextMenuLayer;
|
||||
import net.osmand.views.FavoritesLayer;
|
||||
|
@ -203,9 +204,11 @@ public class MapActivity extends Activity implements IMapLocationListener, Senso
|
|||
// 1. route layer
|
||||
routeLayer = new RouteLayer(routingHelper);
|
||||
mapView.addLayer(routeLayer, 1);
|
||||
// 2. route layer
|
||||
// 1.5. traffic layer
|
||||
trafficLayer = new YandexTrafficLayer();
|
||||
mapView.addLayer(trafficLayer, 1.5f);
|
||||
// mapView.addLayer(new RendererLayer(), 1.6f);
|
||||
|
||||
// 2. osm bugs layer
|
||||
osmBugsLayer = new OsmBugsLayer(this);
|
||||
// 3. poi layer
|
||||
|
|
|
@ -7,12 +7,12 @@ import java.util.List;
|
|||
import net.osmand.IProgress;
|
||||
import net.osmand.LogUtil;
|
||||
import net.osmand.data.index.IndexConstants;
|
||||
import net.osmand.osm.Node;
|
||||
import net.osmand.osm.Way;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
|
||||
import android.database.Cursor;
|
||||
import android.database.SQLException;
|
||||
import android.database.sqlite.SQLiteDatabase;
|
||||
|
||||
public class RenderMapsRepositories {
|
||||
|
@ -29,17 +29,24 @@ public class RenderMapsRepositories {
|
|||
|
||||
public boolean initializeNewResource(final IProgress progress, File file) {
|
||||
long start = System.currentTimeMillis();
|
||||
try {
|
||||
// TODO should support multiple db
|
||||
if(db != null){
|
||||
// close previous db
|
||||
db.close();
|
||||
}
|
||||
db = SQLiteDatabase.openOrCreateDatabase(file, null);
|
||||
|
||||
if(db.getVersion() != IndexConstants.MAP_TABLE_VERSION){
|
||||
db.close();
|
||||
db = null;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
} catch(SQLException e){
|
||||
|
||||
}
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("Initializing db " + file.getAbsolutePath() + " " + (System.currentTimeMillis() - start) + "ms"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
||||
}
|
||||
|
@ -73,22 +80,27 @@ public class RenderMapsRepositories {
|
|||
|
||||
|
||||
public void loadMap(double topLatitude, double leftLongitude, double bottomLatitude, double rightLongitude, int zoom) {
|
||||
cBottomLatitude = bottomLatitude - (topLatitude -bottomLatitude);
|
||||
cTopLatitude = topLatitude + (topLatitude -bottomLatitude);
|
||||
cLeftLongitude = leftLongitude - (rightLongitude - leftLongitude);
|
||||
cRightLongitude = rightLongitude + (rightLongitude - leftLongitude);
|
||||
cBottomLatitude = bottomLatitude - (topLatitude - bottomLatitude) / 2;
|
||||
cTopLatitude = topLatitude + (topLatitude - bottomLatitude) / 2;
|
||||
cLeftLongitude = leftLongitude - (rightLongitude - leftLongitude) / 2;
|
||||
cRightLongitude = rightLongitude + (rightLongitude - leftLongitude) / 2;
|
||||
cZoom = zoom;
|
||||
|
||||
String query = "SELECT ways.id way, node.id node, node.latitude, node.longitude FROM (" + //$NON-NLS-1$
|
||||
"SELECT DISTINCT ways.id id FROM ways JOIN " + //$NON-NLS-1$
|
||||
"(SELECT id, latitude, longitude FROM node WHERE ?< latitude AND latitude < ? AND ? < longitude AND longitude < ?) A "+ //$NON-NLS-1$
|
||||
"ON A.id = ways.node) B "+ //$NON-NLS-1$
|
||||
"JOIN ways ON B.id=ways.id JOIN node ON ways.node = node.id"; //$NON-NLS-1$
|
||||
// String query = "SELECT ways.id way, node.id node, node.latitude, node.longitude FROM (" + //$NON-NLS-1$
|
||||
// "SELECT DISTINCT ways.id id FROM ways JOIN " + //$NON-NLS-1$
|
||||
// "(SELECT id, latitude, longitude FROM node WHERE ?< latitude AND latitude < ? AND ? < longitude AND longitude < ?) A "+ //$NON-NLS-1$
|
||||
// "ON A.id = ways.node) B "+ //$NON-NLS-1$
|
||||
// "JOIN ways ON B.id=ways.id JOIN node ON ways.node = node.id"; //$NON-NLS-1$
|
||||
|
||||
log.info(String.format("BLat=%s, TLat=%s, LLong=%s, RLong=%s, zoom=%s", cBottomLatitude, cTopLatitude, cLeftLongitude, cRightLongitude, zoom)); //$NON-NLS-1$
|
||||
log.info(String.format(
|
||||
"BLat=%s, TLat=%s, LLong=%s, RLong=%s, zoom=%s", cBottomLatitude, cTopLatitude, cLeftLongitude, cRightLongitude, zoom)); //$NON-NLS-1$
|
||||
|
||||
long now = System.currentTimeMillis();
|
||||
|
||||
// String query = "SELECT id, tags, nodes FROM ways WHERE ? < latitude AND latitude < ? AND ? < longitude AND longitude < ? "; //$NON-NLS-1$
|
||||
String query = "SELECT id FROM "+IndexConstants.indexMapLocationsTable + //$NON-NLS-1$
|
||||
" WHERE ? < maxLat AND ? > minLat AND maxLon > ? AND minLon < ?"; //$NON-NLS-1$
|
||||
|
||||
Cursor result = db.rawQuery(query, new String[]{Double.toString(cBottomLatitude),Double.toString(cTopLatitude),
|
||||
Double.toString(cLeftLongitude), Double.toString(cRightLongitude)});
|
||||
|
||||
|
@ -96,21 +108,22 @@ public class RenderMapsRepositories {
|
|||
try {
|
||||
int count = 0;
|
||||
if (result.moveToFirst()) {
|
||||
long id = result.getLong(0);
|
||||
long prevId = -1;
|
||||
Way way = new Way(id);
|
||||
do {
|
||||
long id = result.getLong(0);
|
||||
Way way = new Way(id);
|
||||
// JSONArray nodes;
|
||||
// try {
|
||||
// nodes = new JSONArray(result.getString(2));
|
||||
// for (int i = 0; i < nodes.length(); i++) {
|
||||
// JSONArray obj = nodes.getJSONArray(i);
|
||||
// Node node = new Node(obj.getDouble(1), obj.getDouble(2), obj.getLong(0));
|
||||
// way.addNode(node);
|
||||
// }
|
||||
//
|
||||
// } catch (JSONException e) {
|
||||
// }
|
||||
count++;
|
||||
if (prevId != -1) {
|
||||
id = result.getLong(0);
|
||||
if (id != prevId) {
|
||||
local.add(way);
|
||||
way = new Way(id);
|
||||
}
|
||||
}
|
||||
Node node = new Node(result.getDouble(2), result.getDouble(3), result.getLong(1));
|
||||
way.addNode(node);
|
||||
prevId = id;
|
||||
// local.add(way);
|
||||
} while (result.moveToNext());
|
||||
|
||||
cWays = local;
|
||||
|
|
|
@ -249,6 +249,10 @@ public class YandexTrafficLayer implements OsmandMapLayer {
|
|||
int start = str.indexOf("timestamp:"); //$NON-NLS-1$
|
||||
start = str.indexOf("\"", start) + 1; //$NON-NLS-1$
|
||||
int end = str.indexOf("\"", start); //$NON-NLS-1$
|
||||
// exception case
|
||||
if (start < 0 || end < 0) {
|
||||
return;
|
||||
}
|
||||
mTimestamp = str.substring(start, end);
|
||||
lastTimestampUpdated = System.currentTimeMillis();
|
||||
Algoritms.closeStream(in);
|
||||
|
|
Loading…
Reference in a new issue