reimplement search postal_code (now it is similar to specify city)
git-svn-id: https://osmand.googlecode.com/svn/trunk@178 e29c36b1-1cfa-d876-8d93-3434fc2bb7b8
This commit is contained in:
parent
f23475ad1b
commit
38831b822a
17 changed files with 301 additions and 160 deletions
|
@ -26,13 +26,17 @@ public class ToDoConstants {
|
||||||
// DONE : partially olga
|
// DONE : partially olga
|
||||||
// TODO : everywhere put non-nls, check all translated into russian [swing could not be translated]
|
// TODO : everywhere put non-nls, check all translated into russian [swing could not be translated]
|
||||||
|
|
||||||
// 42. Revise UI (icons/layouts). Support different devices. Add inactive/focus(!) icon versions.
|
// 34. Suppport navigation for calculated route (example of get route from internet is in swing app).
|
||||||
// Some icons are not fine (as back menu from map - it is blured).
|
// DONE : MiniMap done, Routing settings done, RouteLayer done, RoutingHelper done.
|
||||||
|
// TODO : Test again?
|
||||||
|
|
||||||
// 37. Get rid of exit button (!). Think about when notification should go & how clear resources if it is necessary
|
// 37. Get rid of exit button (!). Think about when notification should go & how clear resources if it is necessary
|
||||||
// DONE :
|
// DONE :
|
||||||
// TODO : add to app settings preference (Refresh indexes).
|
// TODO : add to app settings preference (Refresh indexes).
|
||||||
|
|
||||||
|
// 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).
|
||||||
|
|
||||||
// 32. Introduce POI predefined filters (car filter(other-fuel, transportation-car_wash, show-car) and others)
|
// 32. Introduce POI predefined filters (car filter(other-fuel, transportation-car_wash, show-car) and others)
|
||||||
// DONE : back end (POI filter object, save, delete, read)
|
// DONE : back end (POI filter object, save, delete, read)
|
||||||
// TODO : activity to create/edit new index, activity to read both user defined/osm standard, add actions to remove/create
|
// TODO : activity to create/edit new index, activity to read both user defined/osm standard, add actions to remove/create
|
||||||
|
@ -42,9 +46,6 @@ public class ToDoConstants {
|
||||||
// DONE: Load transport routes in swing.
|
// DONE: Load transport routes in swing.
|
||||||
// TODO: Create transport index, create transport activity
|
// TODO: Create transport index, create transport activity
|
||||||
|
|
||||||
// 34. Suppport navigation for calculated route (example of get route from internet is in swing app).
|
|
||||||
// DONE : MiniMap done, Routing settings done, RouteLayer done, RoutingHelper done.
|
|
||||||
// TODO : Test again?
|
|
||||||
|
|
||||||
|
|
||||||
// FUTURE RELEASES
|
// FUTURE RELEASES
|
||||||
|
@ -56,16 +57,16 @@ public class ToDoConstants {
|
||||||
// (would you like to use internet for that operation - if using internet is not checked).
|
// (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.
|
// Internet using now for : edit POI osm, show osm bugs layer, download tiles.
|
||||||
// 47. Internet connectivity could be checked before trying to use
|
// 47. Internet connectivity could be checked before trying to use
|
||||||
|
// 48. 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?
|
||||||
// 46. Implement downloading strategy for tiles (do not load 17 zoom, load only 16 for example) - try to scale 15 zoom for 17 (?)
|
// 46. Implement downloading strategy for tiles (do not load 17 zoom, load only 16 for example) - try to scale 15 zoom for 17 (?)
|
||||||
// 40. Support simple vector road rendering (require new index file) (?)
|
// 40. Support simple vector road rendering (require new index file) (?)
|
||||||
// 26. Show the whole street on map (when it is chosen in search activity). Possibly extend that story to show layer with streets. (?)
|
// 26. Show the whole street on map (when it is chosen in search activity). Possibly extend that story to show layer with streets. (?)
|
||||||
|
|
||||||
|
|
||||||
// BUGS Android
|
// BUGS Android
|
||||||
// 6. Improvement postal_code search : replace search city <-> postal_code (show streets for postal_code)
|
|
||||||
// 5. Improvement : Implement caching files existing on FS, implement specific method in RM
|
// 5. Improvement : Implement caching files existing on FS, implement specific method in RM
|
||||||
// Introducing cache of file names that are on disk (creating new File() consumes a lot of memory)
|
// Introducing cache of file names that are on disk (creating new File() consumes a lot of memory)
|
||||||
// 7. Update map is duplicated in target & in update menu (context menu)
|
|
||||||
|
|
||||||
|
|
||||||
// TODO swing
|
// TODO swing
|
||||||
|
|
|
@ -3,9 +3,7 @@ package com.osmand.data;
|
||||||
import java.text.Collator;
|
import java.text.Collator;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.SortedSet;
|
|
||||||
import java.util.TreeMap;
|
import java.util.TreeMap;
|
||||||
import java.util.TreeSet;
|
|
||||||
|
|
||||||
import com.osmand.Algoritms;
|
import com.osmand.Algoritms;
|
||||||
import com.osmand.osm.Entity;
|
import com.osmand.osm.Entity;
|
||||||
|
@ -48,7 +46,6 @@ public class City extends MapObject {
|
||||||
private CityType type = null;
|
private CityType type = null;
|
||||||
// Be attentive ! Working with street names ignoring case
|
// Be attentive ! Working with street names ignoring case
|
||||||
private Map<String, Street> streets = new TreeMap<String, Street>(Collator.getInstance());
|
private Map<String, Street> streets = new TreeMap<String, Street>(Collator.getInstance());
|
||||||
private SortedSet<String> postcodes = new TreeSet<String>();
|
|
||||||
|
|
||||||
public City(Node el){
|
public City(Node el){
|
||||||
super(el);
|
super(el);
|
||||||
|
@ -99,15 +96,11 @@ public class City extends MapObject {
|
||||||
return registerStreet(street, false);
|
return registerStreet(street, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Street registerBuilding(Entity e){
|
public Building registerBuilding(Entity e){
|
||||||
String number = e.getTag(OSMTagKey.ADDR_HOUSE_NUMBER);
|
String number = e.getTag(OSMTagKey.ADDR_HOUSE_NUMBER);
|
||||||
String street = e.getTag(OSMTagKey.ADDR_STREET);
|
String street = e.getTag(OSMTagKey.ADDR_STREET);
|
||||||
if( street != null && number != null){
|
if( street != null && number != null){
|
||||||
Building building = registerStreet(street).registerBuilding(e);
|
return registerStreet(street).registerBuilding(e);
|
||||||
if (building.getPostcode() != null) {
|
|
||||||
postcodes.add(building.getPostcode());
|
|
||||||
}
|
|
||||||
return streets.get(street.toLowerCase());
|
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
35
DataExtractionOSM/src/com/osmand/data/PostCode.java
Normal file
35
DataExtractionOSM/src/com/osmand/data/PostCode.java
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
package com.osmand.data;
|
||||||
|
|
||||||
|
import java.text.Collator;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.TreeMap;
|
||||||
|
|
||||||
|
public class PostCode extends MapObject {
|
||||||
|
private Map<String, Street> streets = new TreeMap<String, Street>(Collator.getInstance());
|
||||||
|
|
||||||
|
public PostCode(String name){
|
||||||
|
setName(name);
|
||||||
|
setEnName(name);
|
||||||
|
setId(-1L);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isEmptyWithStreets(){
|
||||||
|
return streets.isEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Street getStreet(String name){
|
||||||
|
return streets.get(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Collection<Street> getStreets() {
|
||||||
|
return streets.values();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Street registerStreet(Street street, boolean useEnglishNames){
|
||||||
|
String name = street.getName(useEnglishNames);
|
||||||
|
streets.put(name, street);
|
||||||
|
return street;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -1,14 +0,0 @@
|
||||||
package com.osmand.data;
|
|
||||||
|
|
||||||
public class PostcodeBasedStreet extends Street {
|
|
||||||
|
|
||||||
public PostcodeBasedStreet(City city, String postcode) {
|
|
||||||
super(city, postcode);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Long getId() {
|
|
||||||
return -1l;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -63,7 +63,7 @@ public class Street extends MapObject {
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isRegisteredInCity(){
|
public boolean isRegisteredInCity(){
|
||||||
return city.getStreet(getName()) == this;
|
return city != null && city.getStreet(getName()) == this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -71,7 +71,7 @@ public class Street extends MapObject {
|
||||||
if (name.equals(getName())) {
|
if (name.equals(getName())) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (city.getStreet(getName()) == this) {
|
if (city != null && city.getStreet(getName()) == this) {
|
||||||
city.unregisterStreet(getName());
|
city.unregisterStreet(getName());
|
||||||
super.setName(name);
|
super.setName(name);
|
||||||
Street s = city.registerStreet(this);
|
Street s = city.registerStreet(this);
|
||||||
|
@ -93,7 +93,7 @@ public class Street extends MapObject {
|
||||||
return city;
|
return city;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void doDataPreparation() {
|
public void sortBuildings(){
|
||||||
Collections.sort(buildings, new Comparator<Building>(){
|
Collections.sort(buildings, new Comparator<Building>(){
|
||||||
@Override
|
@Override
|
||||||
public int compare(Building o1, Building o2) {
|
public int compare(Building o1, Building o2) {
|
||||||
|
@ -102,6 +102,10 @@ public class Street extends MapObject {
|
||||||
return i1 - i2;
|
return i1 - i2;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public void doDataPreparation() {
|
||||||
|
sortBuildings();
|
||||||
calculateCenter();
|
calculateCenter();
|
||||||
if(location == null){
|
if(location == null){
|
||||||
List<LatLon> nodes = new ArrayList<LatLon>();
|
List<LatLon> nodes = new ArrayList<LatLon>();
|
||||||
|
|
|
@ -115,24 +115,39 @@ public class DataExtraction {
|
||||||
|
|
||||||
|
|
||||||
protected class DataExtractionOsmFilter implements IOsmStorageFilter {
|
protected class DataExtractionOsmFilter implements IOsmStorageFilter {
|
||||||
final ArrayList<Node> places;
|
ArrayList<Node> places = new ArrayList<Node>();
|
||||||
final ArrayList<Entity> buildings;
|
ArrayList<Entity> buildings = new ArrayList<Entity>();
|
||||||
final ArrayList<Entity> amenities;
|
ArrayList<Entity> amenities = new ArrayList<Entity>();
|
||||||
final ArrayList<Way> ways;
|
ArrayList<Way> ways = new ArrayList<Way>();
|
||||||
final ArrayList<Relation> transport;
|
ArrayList<Relation> transport = new ArrayList<Relation>();
|
||||||
|
Map<Long, String> postalCodes = new LinkedHashMap<Long, String>();
|
||||||
|
|
||||||
int currentCount = 0;
|
int currentCount = 0;
|
||||||
private Connection conn;
|
private Connection conn;
|
||||||
private PreparedStatement prep;
|
private PreparedStatement prep;
|
||||||
|
|
||||||
|
|
||||||
public DataExtractionOsmFilter(ArrayList<Entity> amenities, ArrayList<Entity> buildings, ArrayList<Node> places,
|
public DataExtractionOsmFilter() {
|
||||||
ArrayList<Way> ways, ArrayList<Relation> transport) {
|
}
|
||||||
this.amenities = amenities;
|
|
||||||
this.buildings = buildings;
|
public ArrayList<Node> getPlaces() {
|
||||||
this.places = places;
|
return places;
|
||||||
this.ways = ways;
|
}
|
||||||
this.transport = transport;
|
public ArrayList<Entity> getBuildings() {
|
||||||
|
return buildings;
|
||||||
|
}
|
||||||
|
public ArrayList<Entity> getAmenities() {
|
||||||
|
return amenities;
|
||||||
|
}
|
||||||
|
public ArrayList<Way> getWays() {
|
||||||
|
return ways;
|
||||||
|
}
|
||||||
|
public ArrayList<Relation> getTransport() {
|
||||||
|
return transport;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Map<Long, String> getPostalCodes() {
|
||||||
|
return postalCodes;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void initDatabase() throws SQLException {
|
public void initDatabase() throws SQLException {
|
||||||
|
@ -232,6 +247,15 @@ public class DataExtraction {
|
||||||
ways.add((Way) e);
|
ways.add((Way) e);
|
||||||
processed = true;
|
processed = true;
|
||||||
}
|
}
|
||||||
|
if(e instanceof Relation){
|
||||||
|
if(e.getTag(OSMTagKey.POSTAL_CODE) != null){
|
||||||
|
String tag = e.getTag(OSMTagKey.POSTAL_CODE);
|
||||||
|
for(Long l : ((Relation)e).getMemberIds()){
|
||||||
|
postalCodes.put(l, tag);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// do not need to mark processed
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if(indexTransport){
|
if(indexTransport){
|
||||||
if(e instanceof Relation && e.getTag(OSMTagKey.ROUTE) != null){
|
if(e instanceof Relation && e.getTag(OSMTagKey.ROUTE) != null){
|
||||||
|
@ -314,12 +338,7 @@ public class DataExtraction {
|
||||||
|
|
||||||
|
|
||||||
public Region readCountry(String path, IProgress progress, IOsmStorageFilter addFilter) throws IOException, SAXException, SQLException{
|
public Region readCountry(String path, IProgress progress, IOsmStorageFilter addFilter) throws IOException, SAXException, SQLException{
|
||||||
// data to load & index
|
|
||||||
final ArrayList<Node> places = new ArrayList<Node>();
|
|
||||||
final ArrayList<Entity> buildings = new ArrayList<Entity>();
|
|
||||||
final ArrayList<Entity> amenities = new ArrayList<Entity>();
|
|
||||||
final ArrayList<Way> ways = new ArrayList<Way>();
|
|
||||||
final ArrayList<Relation> transport = new ArrayList<Relation>();
|
|
||||||
|
|
||||||
File f = new File(path);
|
File f = new File(path);
|
||||||
InputStream stream = new FileInputStream(f);
|
InputStream stream = new FileInputStream(f);
|
||||||
|
@ -342,7 +361,14 @@ public class DataExtraction {
|
||||||
storage.getFilters().add(addFilter);
|
storage.getFilters().add(addFilter);
|
||||||
}
|
}
|
||||||
|
|
||||||
DataExtractionOsmFilter filter = new DataExtractionOsmFilter(amenities, buildings, places, ways, transport);
|
DataExtractionOsmFilter filter = new DataExtractionOsmFilter();
|
||||||
|
// data to load & index
|
||||||
|
final ArrayList<Node> places = filter.getPlaces();
|
||||||
|
final ArrayList<Entity> buildings = filter.getBuildings();
|
||||||
|
final ArrayList<Entity> amenities = filter.getAmenities();
|
||||||
|
final ArrayList<Way> ways = filter.getWays();
|
||||||
|
final ArrayList<Relation> transport = filter.getTransport();
|
||||||
|
Map<Long, String> postalCodes = filter.getPostalCodes();
|
||||||
storage.getFilters().add(filter);
|
storage.getFilters().add(filter);
|
||||||
// 0. Loading osm file
|
// 0. Loading osm file
|
||||||
try {
|
try {
|
||||||
|
@ -393,7 +419,7 @@ public class DataExtraction {
|
||||||
|
|
||||||
// 5. reading buildings
|
// 5. reading buildings
|
||||||
progress.setGeneralProgress("[95 of 100]");
|
progress.setGeneralProgress("[95 of 100]");
|
||||||
readingBuildings(progress, buildings, country);
|
readingBuildings(progress, buildings, country, postalCodes);
|
||||||
}
|
}
|
||||||
|
|
||||||
progress.setGeneralProgress("[100 of 100]");
|
progress.setGeneralProgress("[100 of 100]");
|
||||||
|
@ -451,7 +477,7 @@ public class DataExtraction {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void readingBuildings(IProgress progress, final ArrayList<Entity> buildings, Region country) {
|
private void readingBuildings(IProgress progress, final ArrayList<Entity> buildings, Region country, Map<Long, String> postalCodes) {
|
||||||
// found buildings (index addresses)
|
// found buildings (index addresses)
|
||||||
progress.startTask("Indexing buildings...", buildings.size());
|
progress.startTask("Indexing buildings...", buildings.size());
|
||||||
for(Entity b : buildings){
|
for(Entity b : buildings){
|
||||||
|
@ -470,7 +496,10 @@ public class DataExtraction {
|
||||||
city = country.getClosestCity(center);
|
city = country.getClosestCity(center);
|
||||||
}
|
}
|
||||||
if (city != null) {
|
if (city != null) {
|
||||||
city.registerBuilding(b);
|
Building building = city.registerBuilding(b);
|
||||||
|
if(postalCodes.containsKey(building.getId()) ){
|
||||||
|
building.setPostcode(postalCodes.get(building.getId()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -664,12 +693,6 @@ public class DataExtraction {
|
||||||
|
|
||||||
// Performance testing methods
|
// Performance testing methods
|
||||||
public static void main(String[] args) throws IOException, SAXException, SQLException, ParserConfigurationException {
|
public static void main(String[] args) throws IOException, SAXException, SQLException, ParserConfigurationException {
|
||||||
ArrayList<Entity> amenities = new ArrayList<Entity>();
|
|
||||||
ArrayList<Entity> buildings = new ArrayList<Entity>();
|
|
||||||
ArrayList<Node> places = new ArrayList<Node>();
|
|
||||||
ArrayList<Relation> transport = new ArrayList<Relation>();
|
|
||||||
ArrayList<Way> ways = new ArrayList<Way>();
|
|
||||||
|
|
||||||
long time = System.currentTimeMillis();
|
long time = System.currentTimeMillis();
|
||||||
OsmBaseStorage storage = new OsmBaseStorage();
|
OsmBaseStorage storage = new OsmBaseStorage();
|
||||||
String path = "E:\\Information\\OSM maps\\belarus_2010_06_02.osm";
|
String path = "E:\\Information\\OSM maps\\belarus_2010_06_02.osm";
|
||||||
|
@ -704,7 +727,7 @@ public class DataExtraction {
|
||||||
});
|
});
|
||||||
DataExtraction e = new DataExtraction(true, true, true, true, false, true, new File(wDir));
|
DataExtraction e = new DataExtraction(true, true, true, true, false, true, new File(wDir));
|
||||||
|
|
||||||
DataExtractionOsmFilter filter = e.new DataExtractionOsmFilter(amenities, buildings, places, ways, transport);
|
DataExtractionOsmFilter filter = e.new DataExtractionOsmFilter();
|
||||||
filter.initDatabase();
|
filter.initDatabase();
|
||||||
storage.getFilters().add(filter);
|
storage.getFilters().add(filter);
|
||||||
|
|
||||||
|
@ -715,7 +738,7 @@ public class DataExtraction {
|
||||||
storage.parseOSM(stream, new ConsoleProgressImplementation(), streamFile, true);
|
storage.parseOSM(stream, new ConsoleProgressImplementation(), streamFile, true);
|
||||||
System.out.println("Total mem: " + Runtime.getRuntime().totalMemory() + " free : " + Runtime.getRuntime().freeMemory());
|
System.out.println("Total mem: " + Runtime.getRuntime().totalMemory() + " free : " + Runtime.getRuntime().freeMemory());
|
||||||
System.out.println("All time " + (System.currentTimeMillis() - time) + " ms"); //
|
System.out.println("All time " + (System.currentTimeMillis() - time) + " ms"); //
|
||||||
System.out.println(amenities.size() + " " + buildings.size() + " " + places.size() + " " + ways.size());
|
// System.out.println(amenities.size() + " " + buildings.size() + " " + places.size() + " " + ways.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,6 +8,7 @@ public class OSMSettings {
|
||||||
// ways
|
// ways
|
||||||
HIGHWAY("highway"), //$NON-NLS-1$
|
HIGHWAY("highway"), //$NON-NLS-1$
|
||||||
BUILDING("building"), //$NON-NLS-1$
|
BUILDING("building"), //$NON-NLS-1$
|
||||||
|
POSTAL_CODE("postal_code"), //$NON-NLS-1$
|
||||||
// transport
|
// transport
|
||||||
ROUTE("route"), //$NON-NLS-1$
|
ROUTE("route"), //$NON-NLS-1$
|
||||||
OPERATOR("operator"), //$NON-NLS-1$
|
OPERATOR("operator"), //$NON-NLS-1$
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<resources>
|
<resources>
|
||||||
|
<string name="use_online_routing_descr">Использовать интернет для расчета маршрута</string>
|
||||||
|
<string name="use_online_routing">Online маршрутизация</string>
|
||||||
<string name="user_password_descr">Указать пароль для работы с OSM</string>
|
<string name="user_password_descr">Указать пароль для работы с OSM</string>
|
||||||
<string name="user_password">Пароль</string>
|
<string name="user_password">Пароль</string>
|
||||||
<string name="osm_settings_descr">Упраление слоем open street bugs, установка osm логина </string>
|
<string name="osm_settings_descr">Упраление слоем open street bugs, установка osm логина </string>
|
||||||
|
@ -75,7 +77,7 @@
|
||||||
<color name="color_red">#FF0000</color>
|
<color name="color_red">#FF0000</color>
|
||||||
<string name="searchpoi_activity">Выберите poi</string>
|
<string name="searchpoi_activity">Выберите poi</string>
|
||||||
<string name="search_POI_level_btn">Найти еще</string>
|
<string name="search_POI_level_btn">Найти еще</string>
|
||||||
<string name="incremental_search_city">Выберите город. Чтобы найти дереавню введите как минимум 3 первых буквы.</string>
|
<string name="incremental_search_city">Выберите город. Введите 3 первых буквы, чтобы найти деревню, 2 цифры - индекс.</string>
|
||||||
<string name="incremental_search_street">Выберите улицу</string>
|
<string name="incremental_search_street">Выберите улицу</string>
|
||||||
<string name="incremental_search_building">Выберите здание</string>
|
<string name="incremental_search_building">Выберите здание</string>
|
||||||
<string name="choose_available_region">Выберите регион</string>
|
<string name="choose_available_region">Выберите регион</string>
|
||||||
|
|
|
@ -77,7 +77,7 @@
|
||||||
<color name="color_red">#FF0000</color>
|
<color name="color_red">#FF0000</color>
|
||||||
<string name="searchpoi_activity">Choose poi</string>
|
<string name="searchpoi_activity">Choose poi</string>
|
||||||
<string name="search_POI_level_btn">Find more</string>
|
<string name="search_POI_level_btn">Find more</string>
|
||||||
<string name="incremental_search_city">Search city incrementally. In order to find villages input more than 3 first symbols.</string>
|
<string name="incremental_search_city">Search city incrementally. In order to find villages/postcodes input more than 3 first symbols.</string>
|
||||||
<string name="incremental_search_street">Search street incrementally</string>
|
<string name="incremental_search_street">Search street incrementally</string>
|
||||||
<string name="incremental_search_building">Search building incrementally</string>
|
<string name="incremental_search_building">Search building incrementally</string>
|
||||||
<string name="choose_available_region">Choose region</string>
|
<string name="choose_available_region">Choose region</string>
|
||||||
|
|
|
@ -290,6 +290,7 @@ public class OsmandSettings {
|
||||||
|
|
||||||
public static final String LAST_SEARCHED_REGION = "last_searched_region"; //$NON-NLS-1$
|
public static final String LAST_SEARCHED_REGION = "last_searched_region"; //$NON-NLS-1$
|
||||||
public static final String LAST_SEARCHED_CITY = "last_searched_city"; //$NON-NLS-1$
|
public static final String LAST_SEARCHED_CITY = "last_searched_city"; //$NON-NLS-1$
|
||||||
|
public static final String lAST_SEARCHED_POSTCODE= "last_searched_postcode"; //$NON-NLS-1$
|
||||||
public static final String LAST_SEARCHED_STREET = "last_searched_street"; //$NON-NLS-1$
|
public static final String LAST_SEARCHED_STREET = "last_searched_street"; //$NON-NLS-1$
|
||||||
public static final String LAST_SEARCHED_BUILDING = "last_searched_building"; //$NON-NLS-1$
|
public static final String LAST_SEARCHED_BUILDING = "last_searched_building"; //$NON-NLS-1$
|
||||||
public static final String LAST_SEARCHED_INTERSECTED_STREET = "last_searched_intersected_street"; //$NON-NLS-1$
|
public static final String LAST_SEARCHED_INTERSECTED_STREET = "last_searched_intersected_street"; //$NON-NLS-1$
|
||||||
|
@ -309,6 +310,21 @@ public class OsmandSettings {
|
||||||
return edit.commit();
|
return edit.commit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String getLastSearchedPostcode(Context ctx){
|
||||||
|
SharedPreferences prefs = ctx.getSharedPreferences(SHARED_PREFERENCES_NAME, Context.MODE_WORLD_READABLE);
|
||||||
|
return prefs.getString(lAST_SEARCHED_POSTCODE, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean setLastSearchedPostcode(Context ctx, String postcode){
|
||||||
|
SharedPreferences prefs = ctx.getSharedPreferences(SHARED_PREFERENCES_NAME, Context.MODE_WORLD_READABLE);
|
||||||
|
Editor edit = prefs.edit().putLong(LAST_SEARCHED_CITY, -1).putString(LAST_SEARCHED_STREET, "").putString( //$NON-NLS-1$
|
||||||
|
LAST_SEARCHED_BUILDING, "").putString(lAST_SEARCHED_POSTCODE, postcode); //$NON-NLS-1$
|
||||||
|
if(prefs.contains(LAST_SEARCHED_INTERSECTED_STREET)){
|
||||||
|
edit.putString(LAST_SEARCHED_INTERSECTED_STREET, ""); //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
return edit.commit();
|
||||||
|
}
|
||||||
|
|
||||||
public static Long getLastSearchedCity(Context ctx) {
|
public static Long getLastSearchedCity(Context ctx) {
|
||||||
SharedPreferences prefs = ctx.getSharedPreferences(SHARED_PREFERENCES_NAME, Context.MODE_WORLD_READABLE);
|
SharedPreferences prefs = ctx.getSharedPreferences(SHARED_PREFERENCES_NAME, Context.MODE_WORLD_READABLE);
|
||||||
return prefs.getLong(LAST_SEARCHED_CITY, -1);
|
return prefs.getLong(LAST_SEARCHED_CITY, -1);
|
||||||
|
@ -318,6 +334,7 @@ public class OsmandSettings {
|
||||||
SharedPreferences prefs = ctx.getSharedPreferences(SHARED_PREFERENCES_NAME, Context.MODE_WORLD_READABLE);
|
SharedPreferences prefs = ctx.getSharedPreferences(SHARED_PREFERENCES_NAME, Context.MODE_WORLD_READABLE);
|
||||||
Editor edit = prefs.edit().putLong(LAST_SEARCHED_CITY, cityId).putString(LAST_SEARCHED_STREET, "").putString( //$NON-NLS-1$
|
Editor edit = prefs.edit().putLong(LAST_SEARCHED_CITY, cityId).putString(LAST_SEARCHED_STREET, "").putString( //$NON-NLS-1$
|
||||||
LAST_SEARCHED_BUILDING, ""); //$NON-NLS-1$
|
LAST_SEARCHED_BUILDING, ""); //$NON-NLS-1$
|
||||||
|
edit.remove(lAST_SEARCHED_POSTCODE);
|
||||||
if(prefs.contains(LAST_SEARCHED_INTERSECTED_STREET)){
|
if(prefs.contains(LAST_SEARCHED_INTERSECTED_STREET)){
|
||||||
edit.putString(LAST_SEARCHED_INTERSECTED_STREET, ""); //$NON-NLS-1$
|
edit.putString(LAST_SEARCHED_INTERSECTED_STREET, ""); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,7 @@ import java.util.LinkedHashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.SortedSet;
|
import java.util.TreeMap;
|
||||||
import java.util.TreeSet;
|
import java.util.TreeSet;
|
||||||
|
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
|
@ -21,7 +21,8 @@ import android.database.sqlite.SQLiteDatabase;
|
||||||
|
|
||||||
import com.osmand.data.Building;
|
import com.osmand.data.Building;
|
||||||
import com.osmand.data.City;
|
import com.osmand.data.City;
|
||||||
import com.osmand.data.PostcodeBasedStreet;
|
import com.osmand.data.MapObject;
|
||||||
|
import com.osmand.data.PostCode;
|
||||||
import com.osmand.data.Region;
|
import com.osmand.data.Region;
|
||||||
import com.osmand.data.Street;
|
import com.osmand.data.Street;
|
||||||
import com.osmand.data.City.CityType;
|
import com.osmand.data.City.CityType;
|
||||||
|
@ -41,7 +42,7 @@ public class RegionAddressRepository {
|
||||||
private LinkedHashMap<Long, City> cities = new LinkedHashMap<Long, City>();
|
private LinkedHashMap<Long, City> cities = new LinkedHashMap<Long, City>();
|
||||||
|
|
||||||
private Map<CityType, List<City>> cityTypes = new HashMap<CityType, List<City>>();
|
private Map<CityType, List<City>> cityTypes = new HashMap<CityType, List<City>>();
|
||||||
private SortedSet<String> postCodes = new TreeSet<String>(Collator.getInstance());
|
private Map<String, PostCode> postCodes = new TreeMap<String, PostCode>(Collator.getInstance());
|
||||||
|
|
||||||
private boolean useEnglishNames = false;
|
private boolean useEnglishNames = false;
|
||||||
|
|
||||||
|
@ -86,6 +87,14 @@ public class RegionAddressRepository {
|
||||||
return !cities.isEmpty();
|
return !cities.isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public PostCode getPostcode(String name){
|
||||||
|
if(name == null){
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
preloadPostcodes();
|
||||||
|
return postCodes.get(name.toUpperCase());
|
||||||
|
}
|
||||||
|
|
||||||
public City getCityById(Long id){
|
public City getCityById(Long id){
|
||||||
if(id == -1){
|
if(id == -1){
|
||||||
// do not preload cities for that case
|
// do not preload cities for that case
|
||||||
|
@ -95,18 +104,14 @@ public class RegionAddressRepository {
|
||||||
return cities.get(id);
|
return cities.get(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Street getStreetByName(City city, String name){
|
|
||||||
if(city.isEmptyWithStreets()){
|
public Street getStreetByName(MapObject city, String name) {
|
||||||
preloadStreets(city);
|
preloadStreets(city);
|
||||||
|
if (city instanceof City) {
|
||||||
|
return ((City) city).getStreet(name);
|
||||||
|
} else {
|
||||||
|
return ((PostCode) city).getStreet(name);
|
||||||
}
|
}
|
||||||
if (postCodes.isEmpty()) {
|
|
||||||
preloadPostcodes();
|
|
||||||
}
|
|
||||||
Street street = city.getStreet(name);
|
|
||||||
if (street == null) {
|
|
||||||
street = postCodes.contains(name.toUpperCase()) ? new PostcodeBasedStreet(city, name) : null;
|
|
||||||
}
|
|
||||||
return street;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Building getBuildingByName(Street street, String name){
|
public Building getBuildingByName(Street street, String name){
|
||||||
|
@ -148,15 +153,22 @@ public class RegionAddressRepository {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void fillWithSuggestedBuildings(Street street, String name, List<Building> buildingsToFill){
|
public void fillWithSuggestedBuildings(PostCode postcode, Street street, String name, List<Building> buildingsToFill){
|
||||||
preloadBuildings(street);
|
preloadBuildings(street);
|
||||||
name = name.toLowerCase();
|
name = name.toLowerCase();
|
||||||
int ind = 0;
|
int ind = 0;
|
||||||
if(name.length() == 0){
|
boolean empty = name.length() == 0;
|
||||||
|
if(empty && postcode == null){
|
||||||
buildingsToFill.addAll(street.getBuildings());
|
buildingsToFill.addAll(street.getBuildings());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for (Building building : street.getBuildings()) {
|
for (Building building : street.getBuildings()) {
|
||||||
|
if(postcode != null && !postcode.getName().equals(building.getPostcode())){
|
||||||
|
continue;
|
||||||
|
} else if(empty){
|
||||||
|
buildingsToFill.add(building);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
String bName = useEnglishNames ? building.getEnName() : building.getName();
|
String bName = useEnglishNames ? building.getEnName() : building.getName();
|
||||||
String lowerCase = bName.toLowerCase();
|
String lowerCase = bName.toLowerCase();
|
||||||
if (lowerCase.startsWith(name)) {
|
if (lowerCase.startsWith(name)) {
|
||||||
|
@ -193,30 +205,21 @@ public class RegionAddressRepository {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void fillWithSuggestedStreets(City c, String name, List<Street> streetsToFill){
|
public void fillWithSuggestedStreets(MapObject o, String name, List<Street> streetsToFill){
|
||||||
preloadStreets(c);
|
assert o instanceof PostCode || o instanceof City;
|
||||||
preloadPostcodes();
|
City city = (City) (o instanceof City ? o : null);
|
||||||
|
PostCode post = (PostCode) (o instanceof PostCode ? o : null);
|
||||||
|
preloadStreets(o);
|
||||||
name = name.toLowerCase();
|
name = name.toLowerCase();
|
||||||
|
|
||||||
|
Collection<Street> streets = post == null ? city.getStreets() : post.getStreets() ;
|
||||||
int ind = 0;
|
int ind = 0;
|
||||||
if(name.length() == 0){
|
if(name.length() == 0){
|
||||||
streetsToFill.addAll(c.getStreets());
|
streetsToFill.addAll(streets);
|
||||||
return;
|
return;
|
||||||
} else if (name.length() >= 2 &&
|
|
||||||
Character.isDigit(name.charAt(0)) &&
|
|
||||||
Character.isDigit(name.charAt(1))) {
|
|
||||||
// also try to identify postcodes
|
|
||||||
for (String code : postCodes) {
|
|
||||||
code = code.toLowerCase();
|
|
||||||
if (code.startsWith(name)) {
|
|
||||||
streetsToFill.add(ind++,new PostcodeBasedStreet(c, code));
|
|
||||||
} else {
|
|
||||||
streetsToFill.add(new PostcodeBasedStreet(c, code));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
ind = 0;
|
ind = 0;
|
||||||
for (Street s : c.getStreets()) {
|
for (Street s : streets) {
|
||||||
String sName = useEnglishNames ? s.getEnName() : s.getName();
|
String sName = useEnglishNames ? s.getEnName() : s.getName();
|
||||||
String lowerCase = sName.toLowerCase();
|
String lowerCase = sName.toLowerCase();
|
||||||
if (lowerCase.startsWith(name)) {
|
if (lowerCase.startsWith(name)) {
|
||||||
|
@ -228,7 +231,7 @@ public class RegionAddressRepository {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void fillWithSuggestedCities(String name, List<City> citiesToFill){
|
public void fillWithSuggestedCities(String name, List<MapObject> citiesToFill){
|
||||||
preloadCities();
|
preloadCities();
|
||||||
// essentially index is created that cities towns are first in cities map
|
// essentially index is created that cities towns are first in cities map
|
||||||
int ind = 0;
|
int ind = 0;
|
||||||
|
@ -236,18 +239,13 @@ public class RegionAddressRepository {
|
||||||
Character.isDigit(name.charAt(0)) &&
|
Character.isDigit(name.charAt(0)) &&
|
||||||
Character.isDigit(name.charAt(1))) {
|
Character.isDigit(name.charAt(1))) {
|
||||||
preloadPostcodes();
|
preloadPostcodes();
|
||||||
name = name.toLowerCase();
|
|
||||||
// also try to identify postcodes
|
// also try to identify postcodes
|
||||||
for (String code : postCodes) {
|
String uName = name.toUpperCase();
|
||||||
String lcode = code.toLowerCase();
|
for (String code : postCodes.keySet()) {
|
||||||
// TODO postcode
|
if (code.startsWith(uName)) {
|
||||||
City c = new City(CityType.CITY);
|
citiesToFill.add(ind++, postCodes.get(code));
|
||||||
c.setName(code);
|
} else if(code.contains(uName)){
|
||||||
c.setEnName(code);
|
citiesToFill.add(postCodes.get(code));
|
||||||
if (lcode.startsWith(name)) {
|
|
||||||
citiesToFill.add(ind++,c);
|
|
||||||
} else if(lcode.contains(name)){
|
|
||||||
citiesToFill.add(c);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -346,7 +344,7 @@ public class RegionAddressRepository {
|
||||||
do {
|
do {
|
||||||
String postcode = query.getString(0);
|
String postcode = query.getString(0);
|
||||||
if (postcode != null) {
|
if (postcode != null) {
|
||||||
postCodes.add(postcode);
|
postCodes.put(postcode, new PostCode(postcode));
|
||||||
}
|
}
|
||||||
} while (query.moveToNext());
|
} while (query.moveToNext());
|
||||||
}
|
}
|
||||||
|
@ -357,15 +355,8 @@ public class RegionAddressRepository {
|
||||||
|
|
||||||
public void preloadBuildings(Street street){
|
public void preloadBuildings(Street street){
|
||||||
if (street.getBuildings().isEmpty()) {
|
if (street.getBuildings().isEmpty()) {
|
||||||
Cursor query = null;
|
Cursor query = db.query(IndexBuildingTable.getTable(), IndexConstants.generateColumnNames(IndexBuildingTable.values()), "? = street", //$NON-NLS-1$
|
||||||
if (street instanceof PostcodeBasedStreet) {
|
|
||||||
// this is postcode
|
|
||||||
query = db.query(IndexBuildingTable.getTable(), IndexConstants.generateColumnNames(IndexBuildingTable.values()), "? = postcode", //$NON-NLS-1$
|
|
||||||
new String[] { street.getName().toUpperCase()}, null, null, null);
|
|
||||||
} else {
|
|
||||||
query = db.query(IndexBuildingTable.getTable(), IndexConstants.generateColumnNames(IndexBuildingTable.values()), "? = street", //$NON-NLS-1$
|
|
||||||
new String[] { street.getId() + "" }, null, null, null); //$NON-NLS-1$
|
new String[] { street.getId() + "" }, null, null, null); //$NON-NLS-1$
|
||||||
}
|
|
||||||
log.debug("Start loading buildings for " + street.getName()); //$NON-NLS-1$
|
log.debug("Start loading buildings for " + street.getName()); //$NON-NLS-1$
|
||||||
if (query.moveToFirst()) {
|
if (query.moveToFirst()) {
|
||||||
do {
|
do {
|
||||||
|
@ -375,16 +366,21 @@ public class RegionAddressRepository {
|
||||||
.ordinal()));
|
.ordinal()));
|
||||||
building.setName(query.getString(IndexBuildingTable.NAME.ordinal()));
|
building.setName(query.getString(IndexBuildingTable.NAME.ordinal()));
|
||||||
building.setEnName(query.getString(IndexBuildingTable.NAME_EN.ordinal()));
|
building.setEnName(query.getString(IndexBuildingTable.NAME_EN.ordinal()));
|
||||||
|
building.setPostcode(query.getString(IndexBuildingTable.POSTCODE.ordinal()));
|
||||||
street.registerBuilding(building);
|
street.registerBuilding(building);
|
||||||
} while (query.moveToNext());
|
} while (query.moveToNext());
|
||||||
|
street.sortBuildings();
|
||||||
}
|
}
|
||||||
query.close();
|
query.close();
|
||||||
log.debug("Loaded " + street.getBuildings().size() + " buildings"); //$NON-NLS-1$ //$NON-NLS-2$
|
log.debug("Loaded " + street.getBuildings().size() + " buildings"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void preloadStreets(City city){
|
public void preloadStreets(MapObject o){
|
||||||
if (city.isEmptyWithStreets()) {
|
assert o instanceof PostCode || o instanceof City;
|
||||||
|
City city = (City) (o instanceof City ? o : null);
|
||||||
|
PostCode post = (PostCode) (o instanceof PostCode ? o : null);
|
||||||
|
if (city != null && city.isEmptyWithStreets()) {
|
||||||
log.debug("Start loading streets for " + city.getName()); //$NON-NLS-1$
|
log.debug("Start loading streets for " + city.getName()); //$NON-NLS-1$
|
||||||
Cursor query = db.query(IndexStreetTable.getTable(), IndexConstants.generateColumnNames(IndexStreetTable.values()), "? = city", //$NON-NLS-1$
|
Cursor query = db.query(IndexStreetTable.getTable(), IndexConstants.generateColumnNames(IndexStreetTable.values()), "? = city", //$NON-NLS-1$
|
||||||
new String[] { city.getId() + "" }, null, null, null); //$NON-NLS-1$
|
new String[] { city.getId() + "" }, null, null, null); //$NON-NLS-1$
|
||||||
|
@ -401,6 +397,33 @@ public class RegionAddressRepository {
|
||||||
}
|
}
|
||||||
query.close();
|
query.close();
|
||||||
log.debug("Loaded " + city.getStreets().size() + " streets"); //$NON-NLS-1$ //$NON-NLS-2$
|
log.debug("Loaded " + city.getStreets().size() + " streets"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
|
} else if(post != null && post.isEmptyWithStreets()){
|
||||||
|
log.debug("Start loading streets for " + post.getName()); //$NON-NLS-1$
|
||||||
|
Cursor query = db.rawQuery("SELECT B.CITY, B.ID,B.LATITUDE, B.LONGITUDE, B.NAME, B.NAME_EN FROM building A JOIN street B ON A.street = B.ID WHERE A.postcode = ?", //$NON-NLS-1$
|
||||||
|
new String[] { post.getName() + "" }); //$NON-NLS-1$
|
||||||
|
if (query.moveToFirst()) {
|
||||||
|
do {
|
||||||
|
city = getCityById(query.getLong(0));
|
||||||
|
Street street = null;
|
||||||
|
if(city != null){
|
||||||
|
preloadStreets(city);
|
||||||
|
street = city.getStreet(useEnglishNames ? query.getString(5) : query.getString(4));
|
||||||
|
}
|
||||||
|
if(street == null){
|
||||||
|
street = new Street(city);
|
||||||
|
street.setId(query.getLong(1));
|
||||||
|
street.setLocation(query.getDouble(2), query.getDouble(3));
|
||||||
|
street.setName(query.getString(4));
|
||||||
|
street.setEnName(query.getString(5));
|
||||||
|
if(city != null){
|
||||||
|
city.registerStreet(street, useEnglishNames);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
post.registerStreet(street, useEnglishNames);
|
||||||
|
} while (query.moveToNext());
|
||||||
|
}
|
||||||
|
query.close();
|
||||||
|
log.debug("Loaded " +post.getStreets().size() + " streets"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -194,7 +194,7 @@ public class MapActivity extends Activity implements LocationListener, IMapLocat
|
||||||
float fx = mapView.calcDiffTileX(dx, dy);
|
float fx = mapView.calcDiffTileX(dx, dy);
|
||||||
double latitude = MapUtils.getLatitudeFromTile(mapView.getZoom(), mapView.getYTile() + fy);
|
double latitude = MapUtils.getLatitudeFromTile(mapView.getZoom(), mapView.getYTile() + fy);
|
||||||
double longitude = MapUtils.getLongitudeFromTile(mapView.getZoom(), mapView.getXTile() + fx);
|
double longitude = MapUtils.getLongitudeFromTile(mapView.getZoom(), mapView.getXTile() + fx);
|
||||||
contextMenuPoint(latitude, longitude);
|
contextMenuPoint(latitude, longitude, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -508,7 +508,7 @@ public class MapActivity extends Activity implements LocationListener, IMapLocat
|
||||||
startActivity(settings);
|
startActivity(settings);
|
||||||
return true;
|
return true;
|
||||||
} else if (item.getItemId() == R.id.map_mark_point) {
|
} else if (item.getItemId() == R.id.map_mark_point) {
|
||||||
contextMenuPoint(mapView.getLatitude(), mapView.getLongitude());
|
contextMenuPoint(mapView.getLatitude(), mapView.getLongitude(), true);
|
||||||
return true;
|
return true;
|
||||||
} else if (item.getItemId() == R.id.map_reload_tile) {
|
} else if (item.getItemId() == R.id.map_reload_tile) {
|
||||||
reloadTile(mapView.getZoom(), mapView.getLatitude(), mapView.getLongitude());
|
reloadTile(mapView.getZoom(), mapView.getLatitude(), mapView.getLongitude());
|
||||||
|
@ -542,16 +542,27 @@ public class MapActivity extends Activity implements LocationListener, IMapLocat
|
||||||
builder.create().show();
|
builder.create().show();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void contextMenuPoint(final double latitude, final double longitude){
|
protected void contextMenuPoint(final double latitude, final double longitude, boolean menu){
|
||||||
Builder builder = new AlertDialog.Builder(this);
|
Builder builder = new AlertDialog.Builder(this);
|
||||||
Resources resources = this.getResources();
|
Resources resources = this.getResources();
|
||||||
builder.setItems(new String[]{
|
String[] res;
|
||||||
|
if(menu){
|
||||||
|
res = new String[]{
|
||||||
resources.getString(R.string.context_menu_item_navigate_point),
|
resources.getString(R.string.context_menu_item_navigate_point),
|
||||||
resources.getString(R.string.context_menu_item_add_favorite),
|
resources.getString(R.string.context_menu_item_add_favorite),
|
||||||
resources.getString(R.string.context_menu_item_update_map),
|
|
||||||
resources.getString(R.string.context_menu_item_open_bug),
|
resources.getString(R.string.context_menu_item_open_bug),
|
||||||
resources.getString(R.string.context_menu_item_create_poi)
|
resources.getString(R.string.context_menu_item_create_poi),
|
||||||
}, new DialogInterface.OnClickListener(){
|
};
|
||||||
|
} else {
|
||||||
|
res = new String[]{
|
||||||
|
resources.getString(R.string.context_menu_item_navigate_point),
|
||||||
|
resources.getString(R.string.context_menu_item_add_favorite),
|
||||||
|
resources.getString(R.string.context_menu_item_open_bug),
|
||||||
|
resources.getString(R.string.context_menu_item_create_poi),
|
||||||
|
resources.getString(R.string.context_menu_item_update_map),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
builder.setItems(res, new DialogInterface.OnClickListener(){
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
|
@ -560,12 +571,12 @@ public class MapActivity extends Activity implements LocationListener, IMapLocat
|
||||||
} else if(which == 1){
|
} else if(which == 1){
|
||||||
addFavouritePoint(latitude, longitude);
|
addFavouritePoint(latitude, longitude);
|
||||||
} else if(which == 2){
|
} else if(which == 2){
|
||||||
reloadTile(mapView.getZoom(), latitude, longitude);
|
|
||||||
} else if(which == 3){
|
|
||||||
osmBugsLayer.openBug(MapActivity.this, getLayoutInflater(), mapView, latitude, longitude);
|
osmBugsLayer.openBug(MapActivity.this, getLayoutInflater(), mapView, latitude, longitude);
|
||||||
} else if(which == 4){
|
} else if(which == 3){
|
||||||
EditingPOIActivity activity = new EditingPOIActivity(MapActivity.this);
|
EditingPOIActivity activity = new EditingPOIActivity(MapActivity.this);
|
||||||
activity.showCreateDialog(latitude, longitude);
|
activity.showCreateDialog(latitude, longitude);
|
||||||
|
} else if(which == 4){
|
||||||
|
reloadTile(mapView.getZoom(), latitude, longitude);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -19,6 +19,8 @@ import com.osmand.ResourceManager;
|
||||||
import com.osmand.activities.MapActivity;
|
import com.osmand.activities.MapActivity;
|
||||||
import com.osmand.data.Building;
|
import com.osmand.data.Building;
|
||||||
import com.osmand.data.City;
|
import com.osmand.data.City;
|
||||||
|
import com.osmand.data.MapObject;
|
||||||
|
import com.osmand.data.PostCode;
|
||||||
import com.osmand.data.Street;
|
import com.osmand.data.Street;
|
||||||
import com.osmand.osm.LatLon;
|
import com.osmand.osm.LatLon;
|
||||||
import com.osmand.osm.Node;
|
import com.osmand.osm.Node;
|
||||||
|
@ -35,6 +37,7 @@ public class SearchAddressActivity extends Activity {
|
||||||
|
|
||||||
private RegionAddressRepository region = null;
|
private RegionAddressRepository region = null;
|
||||||
private City city = null;
|
private City city = null;
|
||||||
|
private PostCode postcode = null;
|
||||||
private Street street = null;
|
private Street street = null;
|
||||||
private Building building = null;
|
private Building building = null;
|
||||||
private Street street2 = null;
|
private Street street2 = null;
|
||||||
|
@ -118,6 +121,7 @@ public class SearchAddressActivity extends Activity {
|
||||||
findViewById(R.id.ResetCity).setOnClickListener(new View.OnClickListener(){
|
findViewById(R.id.ResetCity).setOnClickListener(new View.OnClickListener(){
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
|
postcode = null;
|
||||||
city = null;
|
city = null;
|
||||||
street = null;
|
street = null;
|
||||||
street2 = null;
|
street2 = null;
|
||||||
|
@ -129,6 +133,7 @@ public class SearchAddressActivity extends Activity {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
region = null;
|
region = null;
|
||||||
|
postcode = null;
|
||||||
city = null;
|
city = null;
|
||||||
street = null;
|
street = null;
|
||||||
street2 = null;
|
street2 = null;
|
||||||
|
@ -222,12 +227,16 @@ public class SearchAddressActivity extends Activity {
|
||||||
} else {
|
} else {
|
||||||
countryButton.setText(region.getName());
|
countryButton.setText(region.getName());
|
||||||
}
|
}
|
||||||
findViewById(R.id.ResetCity).setEnabled(city != null);
|
findViewById(R.id.ResetCity).setEnabled(postcode != null || city != null);
|
||||||
if(city == null){
|
if(city == null && postcode == null){
|
||||||
cityButton.setText(R.string.choose_city);
|
cityButton.setText(R.string.choose_city);
|
||||||
|
} else {
|
||||||
|
if(postcode != null){
|
||||||
|
cityButton.setText(postcode.getName());
|
||||||
} else {
|
} else {
|
||||||
cityButton.setText(city.getName(region.useEnglishNames()));
|
cityButton.setText(city.getName(region.useEnglishNames()));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
cityButton.setEnabled(region != null);
|
cityButton.setEnabled(region != null);
|
||||||
|
|
||||||
findViewById(R.id.ResetStreet).setEnabled(street != null);
|
findViewById(R.id.ResetStreet).setEnabled(street != null);
|
||||||
|
@ -236,7 +245,7 @@ public class SearchAddressActivity extends Activity {
|
||||||
} else {
|
} else {
|
||||||
streetButton.setText(street.getName(region.useEnglishNames()));
|
streetButton.setText(street.getName(region.useEnglishNames()));
|
||||||
}
|
}
|
||||||
streetButton.setEnabled(city != null);
|
streetButton.setEnabled(city != null || postcode != null);
|
||||||
|
|
||||||
if(radioBuilding){
|
if(radioBuilding){
|
||||||
((RadioButton)findViewById(R.id.RadioBuilding)).setChecked(true);
|
((RadioButton)findViewById(R.id.RadioBuilding)).setChecked(true);
|
||||||
|
@ -247,7 +256,8 @@ public class SearchAddressActivity extends Activity {
|
||||||
|
|
||||||
buildingButton.setEnabled(street != null);
|
buildingButton.setEnabled(street != null);
|
||||||
|
|
||||||
showOnMap.setEnabled(building != null || city != null || street != null);
|
showOnMap.setEnabled(city != null || street != null);
|
||||||
|
navigateTo.setEnabled(city != null || street != null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void loadData(){
|
public void loadData(){
|
||||||
|
@ -255,17 +265,23 @@ public class SearchAddressActivity extends Activity {
|
||||||
if(region.useEnglishNames() != OsmandSettings.usingEnglishNames(this)){
|
if(region.useEnglishNames() != OsmandSettings.usingEnglishNames(this)){
|
||||||
region.setUseEnglishNames(OsmandSettings.usingEnglishNames(this));
|
region.setUseEnglishNames(OsmandSettings.usingEnglishNames(this));
|
||||||
}
|
}
|
||||||
|
String postcodeStr = OsmandSettings.getLastSearchedPostcode(this);
|
||||||
|
if(postcodeStr != null){
|
||||||
|
postcode = region.getPostcode(postcodeStr);
|
||||||
|
} else {
|
||||||
city = region.getCityById(OsmandSettings.getLastSearchedCity(SearchAddressActivity.this));
|
city = region.getCityById(OsmandSettings.getLastSearchedCity(SearchAddressActivity.this));
|
||||||
if (city != null) {
|
}
|
||||||
street = region.getStreetByName(city, OsmandSettings.getLastSearchedStreet(SearchAddressActivity.this));
|
|
||||||
|
if (postcode != null || city != null) {
|
||||||
|
MapObject o = postcode == null ? city : postcode;
|
||||||
|
street = region.getStreetByName(o, OsmandSettings.getLastSearchedStreet(SearchAddressActivity.this));
|
||||||
if (street != null) {
|
if (street != null) {
|
||||||
String str = OsmandSettings.getLastSearchedIntersectedStreet(SearchAddressActivity.this);
|
String str = OsmandSettings.getLastSearchedIntersectedStreet(SearchAddressActivity.this);
|
||||||
radioBuilding = str == null;
|
radioBuilding = str == null;
|
||||||
if(str != null){
|
if(str != null){
|
||||||
street2 = region.getStreetByName(city, str);
|
street2 = region.getStreetByName(o, str);
|
||||||
} else {
|
} else {
|
||||||
building = region.getBuildingByName(street, OsmandSettings
|
building = region.getBuildingByName(street, OsmandSettings.getLastSearchedBuilding(SearchAddressActivity.this));
|
||||||
.getLastSearchedBuilding(SearchAddressActivity.this));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -301,6 +317,7 @@ public class SearchAddressActivity extends Activity {
|
||||||
region = ResourceManager.getResourceManager().getRegionRepository(lastSearchedRegion);
|
region = ResourceManager.getResourceManager().getRegionRepository(lastSearchedRegion);
|
||||||
String progressMsg = null;
|
String progressMsg = null;
|
||||||
// try to determine whether progress dialog & new thread needed
|
// try to determine whether progress dialog & new thread needed
|
||||||
|
|
||||||
if (region != null) {
|
if (region != null) {
|
||||||
Long cityId = OsmandSettings.getLastSearchedCity(this);
|
Long cityId = OsmandSettings.getLastSearchedCity(this);
|
||||||
if (!region.areCitiesPreloaded()) {
|
if (!region.areCitiesPreloaded()) {
|
||||||
|
@ -311,6 +328,7 @@ public class SearchAddressActivity extends Activity {
|
||||||
progressMsg = "Converting native/english names...";
|
progressMsg = "Converting native/english names...";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
postcode = null;
|
||||||
city = null;
|
city = null;
|
||||||
street = null;
|
street = null;
|
||||||
building = null;
|
building = null;
|
||||||
|
|
|
@ -12,18 +12,24 @@ import com.osmand.RegionAddressRepository;
|
||||||
import com.osmand.ResourceManager;
|
import com.osmand.ResourceManager;
|
||||||
import com.osmand.data.Building;
|
import com.osmand.data.Building;
|
||||||
import com.osmand.data.City;
|
import com.osmand.data.City;
|
||||||
|
import com.osmand.data.PostCode;
|
||||||
import com.osmand.data.Street;
|
import com.osmand.data.Street;
|
||||||
|
|
||||||
public class SearchBuildingByNameActivity extends SearchByNameAbstractActivity<Building> {
|
public class SearchBuildingByNameActivity extends SearchByNameAbstractActivity<Building> {
|
||||||
private RegionAddressRepository region;
|
private RegionAddressRepository region;
|
||||||
private City city;
|
private City city;
|
||||||
private Street street;
|
private Street street;
|
||||||
|
private PostCode postcode;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
region = ResourceManager.getResourceManager().getRegionRepository(OsmandSettings.getLastSearchedRegion(this));
|
region = ResourceManager.getResourceManager().getRegionRepository(OsmandSettings.getLastSearchedRegion(this));
|
||||||
if(region != null){
|
if(region != null){
|
||||||
|
postcode = region.getPostcode(OsmandSettings.getLastSearchedPostcode(this));
|
||||||
city = region.getCityById(OsmandSettings.getLastSearchedCity(this));
|
city = region.getCityById(OsmandSettings.getLastSearchedCity(this));
|
||||||
if(city != null){
|
if(postcode != null){
|
||||||
|
street = region.getStreetByName(postcode, OsmandSettings.getLastSearchedStreet(this));
|
||||||
|
} else if(city != null){
|
||||||
street = region.getStreetByName(city, OsmandSettings.getLastSearchedStreet(this));
|
street = region.getStreetByName(city, OsmandSettings.getLastSearchedStreet(this));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -35,7 +41,7 @@ public class SearchBuildingByNameActivity extends SearchByNameAbstractActivity<B
|
||||||
public List<Building> getObjects(String filter) {
|
public List<Building> getObjects(String filter) {
|
||||||
List<Building> l = new ArrayList<Building>();
|
List<Building> l = new ArrayList<Building>();
|
||||||
if(street != null){
|
if(street != null){
|
||||||
region.fillWithSuggestedBuildings(street, filter, l);
|
region.fillWithSuggestedBuildings(postcode, street, filter, l);
|
||||||
}
|
}
|
||||||
return l;
|
return l;
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,10 +11,12 @@ import com.osmand.R;
|
||||||
import com.osmand.RegionAddressRepository;
|
import com.osmand.RegionAddressRepository;
|
||||||
import com.osmand.ResourceManager;
|
import com.osmand.ResourceManager;
|
||||||
import com.osmand.data.City;
|
import com.osmand.data.City;
|
||||||
|
import com.osmand.data.MapObject;
|
||||||
|
import com.osmand.data.PostCode;
|
||||||
import com.osmand.osm.LatLon;
|
import com.osmand.osm.LatLon;
|
||||||
import com.osmand.osm.MapUtils;
|
import com.osmand.osm.MapUtils;
|
||||||
|
|
||||||
public class SearchCityByNameActivity extends SearchByNameAbstractActivity<City> {
|
public class SearchCityByNameActivity extends SearchByNameAbstractActivity<MapObject> {
|
||||||
private RegionAddressRepository region;
|
private RegionAddressRepository region;
|
||||||
private LatLon location;
|
private LatLon location;
|
||||||
|
|
||||||
|
@ -27,8 +29,8 @@ public class SearchCityByNameActivity extends SearchByNameAbstractActivity<City>
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<City> getObjects(String filter) {
|
public List<MapObject> getObjects(String filter) {
|
||||||
List<City> l = new ArrayList<City>();
|
List<MapObject> l = new ArrayList<MapObject>();
|
||||||
if(region != null){
|
if(region != null){
|
||||||
region.fillWithSuggestedCities(filter, l);
|
region.fillWithSuggestedCities(filter, l);
|
||||||
}
|
}
|
||||||
|
@ -36,7 +38,7 @@ public class SearchCityByNameActivity extends SearchByNameAbstractActivity<City>
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateTextView(City obj, TextView txt) {
|
public void updateTextView(MapObject obj, TextView txt) {
|
||||||
LatLon l = obj.getLocation();
|
LatLon l = obj.getLocation();
|
||||||
if (getFilter().length() > 2 && location != null && l != null) {
|
if (getFilter().length() > 2 && location != null && l != null) {
|
||||||
txt.setText(obj.getName(region.useEnglishNames()) + " - " + //$NON-NLS-1$
|
txt.setText(obj.getName(region.useEnglishNames()) + " - " + //$NON-NLS-1$
|
||||||
|
@ -47,10 +49,14 @@ public class SearchCityByNameActivity extends SearchByNameAbstractActivity<City>
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void itemSelected(City obj) {
|
public void itemSelected(MapObject obj) {
|
||||||
|
if (obj instanceof City) {
|
||||||
OsmandSettings.setLastSearchedCity(this, obj.getId());
|
OsmandSettings.setLastSearchedCity(this, obj.getId());
|
||||||
if(region.getCityById(obj.getId()) == null){
|
if (region.getCityById(obj.getId()) == null) {
|
||||||
region.registerCity(obj);
|
region.registerCity((City) obj);
|
||||||
|
}
|
||||||
|
} else if(obj instanceof PostCode){
|
||||||
|
OsmandSettings.setLastSearchedPostcode(this, obj.getName());
|
||||||
}
|
}
|
||||||
finish();
|
finish();
|
||||||
|
|
||||||
|
|
|
@ -12,11 +12,13 @@ import com.osmand.R;
|
||||||
import com.osmand.RegionAddressRepository;
|
import com.osmand.RegionAddressRepository;
|
||||||
import com.osmand.ResourceManager;
|
import com.osmand.ResourceManager;
|
||||||
import com.osmand.data.City;
|
import com.osmand.data.City;
|
||||||
|
import com.osmand.data.PostCode;
|
||||||
import com.osmand.data.Street;
|
import com.osmand.data.Street;
|
||||||
|
|
||||||
public class SearchStreet2ByNameActivity extends SearchByNameAbstractActivity<Street> {
|
public class SearchStreet2ByNameActivity extends SearchByNameAbstractActivity<Street> {
|
||||||
private RegionAddressRepository region;
|
private RegionAddressRepository region;
|
||||||
private City city;
|
private City city;
|
||||||
|
private PostCode postcode;
|
||||||
private Street street1;
|
private Street street1;
|
||||||
volatile private List<Street> initialList = new ArrayList<Street>();
|
volatile private List<Street> initialList = new ArrayList<Street>();
|
||||||
private List<Street> filterList = new ArrayList<Street>();
|
private List<Street> filterList = new ArrayList<Street>();
|
||||||
|
@ -24,9 +26,17 @@ public class SearchStreet2ByNameActivity extends SearchByNameAbstractActivity<St
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
region = ResourceManager.getResourceManager().getRegionRepository(OsmandSettings.getLastSearchedRegion(this));
|
region = ResourceManager.getResourceManager().getRegionRepository(OsmandSettings.getLastSearchedRegion(this));
|
||||||
if(region != null){
|
if(region != null){
|
||||||
|
postcode = region.getPostcode(OsmandSettings.getLastSearchedPostcode(this));
|
||||||
city = region.getCityById(OsmandSettings.getLastSearchedCity(this));
|
city = region.getCityById(OsmandSettings.getLastSearchedCity(this));
|
||||||
if(city != null){
|
if(postcode != null){
|
||||||
|
street1 = region.getStreetByName(postcode, (OsmandSettings.getLastSearchedStreet(this)));
|
||||||
|
if(street1 != null){
|
||||||
|
city = street1.getCity();
|
||||||
|
}
|
||||||
|
} else if(city != null){
|
||||||
street1 = region.getStreetByName(city, (OsmandSettings.getLastSearchedStreet(this)));
|
street1 = region.getStreetByName(city, (OsmandSettings.getLastSearchedStreet(this)));
|
||||||
|
}
|
||||||
|
if(city != null){
|
||||||
startLoadDataInThread("Finding streets...");
|
startLoadDataInThread("Finding streets...");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,17 +11,22 @@ import com.osmand.R;
|
||||||
import com.osmand.RegionAddressRepository;
|
import com.osmand.RegionAddressRepository;
|
||||||
import com.osmand.ResourceManager;
|
import com.osmand.ResourceManager;
|
||||||
import com.osmand.data.City;
|
import com.osmand.data.City;
|
||||||
|
import com.osmand.data.PostCode;
|
||||||
import com.osmand.data.Street;
|
import com.osmand.data.Street;
|
||||||
|
|
||||||
public class SearchStreetByNameActivity extends SearchByNameAbstractActivity<Street> {
|
public class SearchStreetByNameActivity extends SearchByNameAbstractActivity<Street> {
|
||||||
private RegionAddressRepository region;
|
private RegionAddressRepository region;
|
||||||
private City city;
|
private City city;
|
||||||
|
private PostCode postcode;
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
region = ResourceManager.getResourceManager().getRegionRepository(OsmandSettings.getLastSearchedRegion(this));
|
region = ResourceManager.getResourceManager().getRegionRepository(OsmandSettings.getLastSearchedRegion(this));
|
||||||
if(region != null){
|
if(region != null){
|
||||||
|
postcode = region.getPostcode(OsmandSettings.getLastSearchedPostcode(this));
|
||||||
|
if (postcode == null) {
|
||||||
city = region.getCityById(OsmandSettings.getLastSearchedCity(this));
|
city = region.getCityById(OsmandSettings.getLastSearchedCity(this));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
((TextView)findViewById(R.id.Label)).setText(R.string.incremental_search_street);
|
((TextView)findViewById(R.id.Label)).setText(R.string.incremental_search_street);
|
||||||
}
|
}
|
||||||
|
@ -29,8 +34,8 @@ public class SearchStreetByNameActivity extends SearchByNameAbstractActivity<Str
|
||||||
@Override
|
@Override
|
||||||
public List<Street> getObjects(String filter) {
|
public List<Street> getObjects(String filter) {
|
||||||
List<Street> l = new ArrayList<Street>();
|
List<Street> l = new ArrayList<Street>();
|
||||||
if(city != null){
|
if (city != null || postcode != null) {
|
||||||
region.fillWithSuggestedStreets(city, filter, l);
|
region.fillWithSuggestedStreets(postcode == null ? city : postcode, filter, l);
|
||||||
}
|
}
|
||||||
return l;
|
return l;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue