fix small issues
add cloudmade api git-svn-id: https://osmand.googlecode.com/svn/trunk@203 e29c36b1-1cfa-d876-8d93-3434fc2bb7b8
This commit is contained in:
parent
b6ccc10790
commit
ecc99d0dde
5 changed files with 135 additions and 97 deletions
|
@ -14,13 +14,14 @@ public class ToDoConstants {
|
|||
public int DESCRIBE_ABOUT_AUTHORS = 8;
|
||||
|
||||
// TODO ANDROID
|
||||
// 42. Revise UI (icons/layouts). Support different devices. Add inactive/focus(!) icon versions.
|
||||
// Some icons are not fine (as back menu from map - it is blured).
|
||||
|
||||
|
||||
// FUTURE RELEASES
|
||||
// 42. Revise UI (icons/layouts). Support different devices. Add inactive/focus(!) icon versions.
|
||||
// Some icons are not fine (as back menu from map - it is blured).
|
||||
// 56. Add usage of CloudMade API for calculating route (show next turn & distance to it instead of mini map).
|
||||
// 57. Implement routing information about expected time arriving
|
||||
// 58. Implement difference about show route/follow route (show travel time/arrival time, show mini map/next turn, etc)
|
||||
// 46. Implement downloading strategy for tiles : select max zoom to download [16,15,14,...]
|
||||
// That means you can save internet because from [16 -> zoom -> 18], [14 -> zoom -> 16 - suitable for speed > 40], ...
|
||||
// 58. Upload/Download zip-index from site & unzip them on phone
|
||||
// 50. Invent opening hours editor in order to edit POI hours better on device
|
||||
// 53. Add progress bars : to internet communication activities [editing/commiting/deleting poi], do not hide edit poi dialog if operation failed
|
||||
// [move close buttons from alertdialog to own view]
|
||||
|
@ -30,7 +31,7 @@ public class ToDoConstants {
|
|||
// That setting should rule all activities that use internet. It should ask whenever internet is used
|
||||
// (would you like to use internet for that operation - if using internet is not checked).
|
||||
// Internet using now for : edit POI osm, show osm bugs layer, download tiles.
|
||||
// 56. Investigate usage CloudMade API for calculating route.
|
||||
|
||||
// 33. Build transport locations. Create transport index (transport-stops) (investigate)
|
||||
// DONE: Load transport routes in swing.
|
||||
// IDEA TO HAVE :
|
||||
|
@ -51,14 +52,6 @@ public class ToDoConstants {
|
|||
// BUGS Swing
|
||||
|
||||
// DONE ANDROID :
|
||||
// 54. Invent screen to update index from internet (from osmand.googlecode.com)
|
||||
// 32. Introduce POI predefined filters (car filter(other-fuel, transportation-car_wash, show-car) and others)
|
||||
// 48. Enable change favorite point : (for example fav - "car") means last point you left car. It is not static point,
|
||||
// you can always use the same name for different locations.
|
||||
// 52. Make good distribution of POI on map (when POI a lot they are coupling in one place on the south)
|
||||
// 51. Implement console application that prepare indexes to upload on server...
|
||||
// 0) run in background 1) download from internet 2) generates indices for Europe (take care about memory) 3) upload?
|
||||
|
||||
|
||||
// DONE SWING
|
||||
|
||||
|
|
|
@ -114,10 +114,10 @@ public class DataIndexWriter {
|
|||
}
|
||||
|
||||
public DataIndexWriter writeAddress() throws IOException, SQLException{
|
||||
return writeAddress(IndexConstants.ADDRESS_INDEX_DIR+region.getName()+IndexConstants.ADDRESS_INDEX_EXT, null);
|
||||
return writeAddress(IndexConstants.ADDRESS_INDEX_DIR+region.getName()+IndexConstants.ADDRESS_INDEX_EXT, null, true);
|
||||
}
|
||||
|
||||
public DataIndexWriter writeAddress(String fileName, Long date) throws IOException, SQLException{
|
||||
public DataIndexWriter writeAddress(String fileName, Long date, boolean writeWayNodes) throws IOException, SQLException{
|
||||
File file = checkFile(fileName);
|
||||
long now = System.currentTimeMillis();
|
||||
try {
|
||||
|
@ -185,20 +185,21 @@ public class DataIndexWriter {
|
|||
prepStreet.setString(IndexStreetTable.NAME.ordinal() + 1, street.getName());
|
||||
prepStreet.setLong(IndexStreetTable.CITY.ordinal() + 1, city.getId());
|
||||
addBatch(count, prepStreet);
|
||||
for(Way way : street.getWayNodes()){
|
||||
for(Node n : way.getNodes()){
|
||||
if(n == null){
|
||||
continue;
|
||||
if (writeWayNodes) {
|
||||
for (Way way : street.getWayNodes()) {
|
||||
for (Node n : way.getNodes()) {
|
||||
if (n == null) {
|
||||
continue;
|
||||
}
|
||||
assert IndexStreetNodeTable.values().length == 5;
|
||||
prepStreetNode.setLong(IndexStreetNodeTable.ID.ordinal() + 1, n.getId());
|
||||
prepStreetNode.setDouble(IndexStreetNodeTable.LATITUDE.ordinal() + 1, n.getLatitude());
|
||||
prepStreetNode.setDouble(IndexStreetNodeTable.LONGITUDE.ordinal() + 1, n.getLongitude());
|
||||
prepStreetNode.setLong(IndexStreetNodeTable.WAY.ordinal() + 1, way.getId());
|
||||
prepStreetNode.setLong(IndexStreetNodeTable.STREET.ordinal() + 1, street.getId());
|
||||
addBatch(count, prepStreetNode);
|
||||
}
|
||||
assert IndexStreetNodeTable.values().length == 5;
|
||||
prepStreetNode.setLong(IndexStreetNodeTable.ID.ordinal() + 1, n.getId());
|
||||
prepStreetNode.setDouble(IndexStreetNodeTable.LATITUDE.ordinal() + 1, n.getLatitude());
|
||||
prepStreetNode.setDouble(IndexStreetNodeTable.LONGITUDE.ordinal() + 1, n.getLongitude());
|
||||
prepStreetNode.setLong(IndexStreetNodeTable.WAY.ordinal() + 1, way.getId());
|
||||
prepStreetNode.setLong(IndexStreetNodeTable.STREET.ordinal() + 1, street.getId());
|
||||
addBatch(count, prepStreetNode);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
for(Building building : street.getBuildings()){
|
||||
|
|
|
@ -22,27 +22,29 @@ public class IndexBatchCreator {
|
|||
// config params
|
||||
private static final boolean indexPOI = true;
|
||||
private static final boolean indexAddress = true;
|
||||
private static final boolean writeWayNodes = true;
|
||||
|
||||
protected static final Log log = LogUtil.getLog(IndexBatchCreator.class);
|
||||
protected static final String SITE_TO_DOWNLOAD = "http://download.geofabrik.de/osm/europe/"; //$NON-NLS-1$
|
||||
protected static final String[] countriesToDownload = 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
|
||||
// "czech_republic", "great_britain", "italy", // 168, 281, 246,
|
||||
// "netherlands", "france", "germany", //519, 375, 860
|
||||
// "great_britain", "italy", // 281, 246,
|
||||
// "czech_republic", "netherlands", 168, 375,
|
||||
// "france", "germany", //519, 860
|
||||
// ADD TO TOTAL : 2449 MB
|
||||
|
||||
};
|
||||
|
@ -84,8 +86,6 @@ public class IndexBatchCreator {
|
|||
}
|
||||
|
||||
public void runBatch(){
|
||||
// TODO validate all params before running batch
|
||||
|
||||
if(downloadFiles){
|
||||
downloadFiles();
|
||||
}
|
||||
|
@ -154,7 +154,7 @@ public class IndexBatchCreator {
|
|||
DataIndexWriter dataIndexWriter = new DataIndexWriter(indexDirFiles, country);
|
||||
String name = country.getName();
|
||||
if(indexAddress){
|
||||
dataIndexWriter.writeAddress(name + "_" + IndexConstants.ADDRESS_TABLE_VERSION + IndexConstants.ADDRESS_INDEX_EXT, f.lastModified());
|
||||
dataIndexWriter.writeAddress(name + "_" + IndexConstants.ADDRESS_TABLE_VERSION + IndexConstants.ADDRESS_INDEX_EXT, f.lastModified(), writeWayNodes);
|
||||
}
|
||||
if(indexPOI){
|
||||
dataIndexWriter.writePOI(name + "_" + IndexConstants.POI_TABLE_VERSION + IndexConstants.POI_INDEX_EXT, f.lastModified());
|
||||
|
|
|
@ -286,55 +286,6 @@ public class DataExtraction {
|
|||
}
|
||||
|
||||
}
|
||||
// netherlands.osm.bz2 1674 seconds - read
|
||||
|
||||
// Information about progress for belarus.osm [165 seconds] - 580mb
|
||||
// FINE: Loading file E:\Information\OSM maps\belarus_2010_06_02.osm started - 61%
|
||||
// FINE: Correlating data... started after 101921 ms - 10%
|
||||
// FINE: Indexing poi... started after 17062 ms - 0 %
|
||||
// FINE: Indexing cities... started after 47 ms - 0%
|
||||
// FINE: Indexing streets... started after 94 ms - 10%
|
||||
// FINE: Indexing buildings... started after 16531 ms - 20 %
|
||||
// FINE: Normalizing name streets... started after 30890 ms - 0%
|
||||
|
||||
// belarus.osm.bz2 [273 ms] - 40mb
|
||||
// FINE: Memory before task exec: 16 252 928 free : 11 676 888
|
||||
// FINE: Loading file E:\Information\OSM maps\belarus osm\belarus_2010_06_02.osm.bz2 started - 73 %
|
||||
// FINE: Memory before task exec: 95 760 384 free : 17 704 984
|
||||
// FINE: Correlating data... started after 203 657 ms - 7 %
|
||||
// FINE: Indexing poi... started after 20 204 ms
|
||||
// FINE: Indexing cities... started after 62 ms
|
||||
// FINE: Memory before task exec: 95 760 384 free : 45 752 80
|
||||
// FINE: Indexing streets... started after 94 ms - 7 %
|
||||
// FINE: Memory before task exec: 167 510 016 free : 91 616 528
|
||||
// FINE: Indexing buildings... started after 18 672 ms - 13 %
|
||||
// FINE: Memory before task exec: 167 510 016 free : 76 993 976
|
||||
// FINE: Normalizing name streets... started after 32 719 ms
|
||||
|
||||
// minsk.bz2 [36] - 4mb
|
||||
// FINE: Total mem: 16252928 free : 8370296
|
||||
// FINE: Loading file E:\Information\OSM maps\minsk_extr.bz2 started - 63% - 90 % (memory)
|
||||
// FINE: Total mem: 64139264 free : 25069688
|
||||
// FINE: Correlating data... started after 23829 ms - 27%
|
||||
// FINE: Indexing poi... started after 10547 ms - 0%
|
||||
// FINE: Indexing cities... started after 31 ms - 0%
|
||||
// FINE: Indexing streets... started after 94 ms - 1%
|
||||
// FINE: Indexing buildings... started after 672 ms - 7%
|
||||
// FINE: Normalizing name streets... started after 2421 ms - 0%
|
||||
// FINE: Total mem: 64139264 free : 22226792
|
||||
|
||||
// chech.bz2 [1090 ms] - 185mb
|
||||
// FINE: Total mem: 16 252 928 free : 9 132 960
|
||||
// FINE: Loading file E:\Information\OSM maps\czech_republic.osm.bz2 started - 78 % - 90 % (memory)
|
||||
// FINE: Total mem: 226 877 440 free : 42 500 592
|
||||
// FINE: Correlating data... started after 857 788 ms - 5 %
|
||||
// FINE: Indexing poi... started after 58 173 ms
|
||||
// FINE: Total mem: 259 522 560 free : 77 918 344
|
||||
// FINE: Indexing cities... started after 171 ms
|
||||
// FINE: Indexing streets... started after 188 ms - 12 %
|
||||
// FINE: Indexing buildings... started after 135 250 ms - 3 %
|
||||
// FINE: Normalizing name streets... started after 36 657 ms
|
||||
// FINE: Total mem: 259 522 560 free : 8 697 952
|
||||
|
||||
|
||||
public Region readCountry(String path, IProgress progress, IOsmStorageFilter addFilter) throws IOException, SAXException, SQLException{
|
||||
|
|
|
@ -21,6 +21,7 @@ import javax.xml.parsers.DocumentBuilderFactory;
|
|||
import javax.xml.parsers.ParserConfigurationException;
|
||||
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.Node;
|
||||
import org.w3c.dom.NodeList;
|
||||
import org.xml.sax.InputSource;
|
||||
|
@ -92,6 +93,21 @@ public class MapRouterLayer implements MapPanelLayer {
|
|||
}
|
||||
};
|
||||
menu.add(route);
|
||||
Action altroute = new AbstractAction("Calculate alternative route") {
|
||||
private static final long serialVersionUID = 507156107455281238L;
|
||||
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
List<Way> ways = alternateRoute(startRoute, endRoute);
|
||||
DataTileManager<Way> points = new DataTileManager<Way>();
|
||||
points.setZoom(11);
|
||||
for(Way w : ways){
|
||||
LatLon n = w.getLatLon();
|
||||
points.registerObject(n.getLatitude(), n.getLongitude(), w);
|
||||
}
|
||||
map.setPoints(points);
|
||||
}
|
||||
};
|
||||
menu.add(altroute);
|
||||
|
||||
}
|
||||
|
||||
|
@ -134,7 +150,6 @@ public class MapRouterLayer implements MapPanelLayer {
|
|||
while ((s = reader.readLine()) != null) {
|
||||
if (fist) {
|
||||
fist = false;
|
||||
System.out.println(s);
|
||||
}
|
||||
content.append(s).append("\n");
|
||||
}
|
||||
|
@ -179,7 +194,85 @@ public class MapRouterLayer implements MapPanelLayer {
|
|||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public List<Way> alternateRoute(LatLon start, LatLon end) {
|
||||
List<Way> res = new ArrayList<Way>();
|
||||
long time = System.currentTimeMillis();
|
||||
System.out.println("Cloud made route from " + start + " to " + end);
|
||||
if (start != null && end != null) {
|
||||
try {
|
||||
StringBuilder uri = new StringBuilder();
|
||||
// possibly hide that API key because it is privacy of osmand
|
||||
uri.append("http://routes.cloudmade.com/A6421860EBB04234AB5EF2D049F2CD8F/api/0.3/");
|
||||
|
||||
uri.append(start.getLatitude()+"").append(",");
|
||||
uri.append(start.getLongitude()+"").append(",");
|
||||
uri.append(end.getLatitude()+"").append(",");
|
||||
uri.append(end.getLongitude()+"").append("/");
|
||||
uri.append("car.gpx").append("?lang=ru");
|
||||
|
||||
URL url = new URL(uri.toString());
|
||||
URLConnection connection = url.openConnection();
|
||||
StringBuilder content = new StringBuilder();
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
|
||||
{
|
||||
String s = null;
|
||||
boolean fist = true;
|
||||
while ((s = reader.readLine()) != null) {
|
||||
if (fist) {
|
||||
fist = false;
|
||||
}
|
||||
content.append(s).append("\n");
|
||||
}
|
||||
System.out.println(content);
|
||||
}
|
||||
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
|
||||
DocumentBuilder dom = factory.newDocumentBuilder();
|
||||
Document doc = dom.parse(new InputSource(new StringReader(content.toString())));
|
||||
NodeList list = doc.getElementsByTagName("wpt");
|
||||
Way w = new Way(-1);
|
||||
for (int i = 0; i < list.getLength(); i++) {
|
||||
Element item = (Element) list.item(i);
|
||||
try {
|
||||
double lon = Double.parseDouble(item.getAttribute("lon"));
|
||||
double lat = Double.parseDouble(item.getAttribute("lat"));
|
||||
w.addNode(new com.osmand.osm.Node(lat, lon, -1));
|
||||
} catch (NumberFormatException e) {
|
||||
}
|
||||
}
|
||||
list = doc.getElementsByTagName("rtept");
|
||||
for (int i = 0; i < list.getLength(); i++) {
|
||||
Element item = (Element) list.item(i);
|
||||
try {
|
||||
double lon = Double.parseDouble(item.getAttribute("lon"));
|
||||
double lat = Double.parseDouble(item.getAttribute("lat"));
|
||||
System.out.println("Lat " + lat + " lon " + lon);
|
||||
System.out.println("Distance : " + item.getElementsByTagName("distance").item(0).getTextContent());
|
||||
System.out.println("Time : " + item.getElementsByTagName("time").item(0).getTextContent());
|
||||
System.out.println("Offset : " + item.getElementsByTagName("offset").item(0).getTextContent());
|
||||
System.out.println("Direction : " + item.getElementsByTagName("direction").item(0).getTextContent());
|
||||
} catch (NumberFormatException e) {
|
||||
}
|
||||
}
|
||||
|
||||
if (!w.getNodes().isEmpty()) {
|
||||
res.add(w);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
ExceptionHandler.handle(e);
|
||||
} catch (ParserConfigurationException e) {
|
||||
ExceptionHandler.handle(e);
|
||||
} catch (SAXException e) {
|
||||
ExceptionHandler.handle(e);
|
||||
}
|
||||
System.out.println("Finding cloudmade routes " + res.size() + " " + (System.currentTimeMillis() - time) + " ms");
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void prepareToDraw() {
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue