diff --git a/DataExtractionOSM/src/net/osmand/binary/BinaryMapIndexReader.java b/DataExtractionOSM/src/net/osmand/binary/BinaryMapIndexReader.java index 4f664a5125..11293c7318 100644 --- a/DataExtractionOSM/src/net/osmand/binary/BinaryMapIndexReader.java +++ b/DataExtractionOSM/src/net/osmand/binary/BinaryMapIndexReader.java @@ -139,10 +139,10 @@ public class BinaryMapIndexReader { for(MapIndex map : mapIndexes){ if(Algoritms.objectEquals(reg.name, map.name)){ if(map.getRoots().size() > 0){ - MapRoot mapRoot = map.getRoots().get(0); + MapRoot mapRoot = map.getRoots().get(map.getRoots().size() - 1); double cy = (MapUtils.get31LatitudeY(mapRoot.getBottom()) + MapUtils.get31LatitudeY(mapRoot.getTop())) / 2; double cx = (MapUtils.get31LongitudeX(mapRoot.getLeft()) + MapUtils.get31LongitudeX(mapRoot.getRight())) / 2; - reg.calculatedCenter = new LatLon(cx, cy); + reg.calculatedCenter = new LatLon(cy, cx); break; } } diff --git a/OsmAnd/src/net/osmand/plus/OsmandSettings.java b/OsmAnd/src/net/osmand/plus/OsmandSettings.java index 62667d22c3..7d0f025122 100644 --- a/OsmAnd/src/net/osmand/plus/OsmandSettings.java +++ b/OsmAnd/src/net/osmand/plus/OsmandSettings.java @@ -864,8 +864,9 @@ public class OsmandSettings { } public boolean setLastSearchedRegion(String region, LatLon l) { - Editor edit = globalPreferences.edit().putString(LAST_SEARCHED_REGION, region).putLong(LAST_SEARCHED_CITY, -1) - .putString(LAST_SEARCHED_CITY_NAME, "").putString(LAST_SEARCHED_STREET,"").putString(LAST_SEARCHED_BUILDING, ""); //$NON-NLS-1$ //$NON-NLS-2$ + Editor edit = globalPreferences.edit().putString(LAST_SEARCHED_REGION, region).putLong(LAST_SEARCHED_CITY, -1). + putString(LAST_SEARCHED_CITY_NAME, "").putString(lAST_SEARCHED_POSTCODE, ""). + putString(LAST_SEARCHED_STREET,"").putString(LAST_SEARCHED_BUILDING, ""); //$NON-NLS-1$ //$NON-NLS-2$ if (globalPreferences.contains(LAST_SEARCHED_INTERSECTED_STREET)) { edit.putString(LAST_SEARCHED_INTERSECTED_STREET, ""); //$NON-NLS-1$ } @@ -878,13 +879,15 @@ public class OsmandSettings { return globalPreferences.getString(lAST_SEARCHED_POSTCODE, null); } - public boolean setLastSearchedPostcode(String postcode){ + public boolean setLastSearchedPostcode(String postcode, LatLon point){ Editor edit = globalPreferences.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(globalPreferences.contains(LAST_SEARCHED_INTERSECTED_STREET)){ edit.putString(LAST_SEARCHED_INTERSECTED_STREET, ""); //$NON-NLS-1$ } - return edit.commit(); + boolean res = edit.commit(); + setLastSearchedPoint(point); + return res; } public Long getLastSearchedCity() { @@ -895,34 +898,40 @@ public class OsmandSettings { return globalPreferences.getString(LAST_SEARCHED_CITY_NAME, ""); } - public boolean setLastSearchedCity(Long cityId, String name) { + public boolean setLastSearchedCity(Long cityId, String name, LatLon point) { Editor edit = globalPreferences.edit().putLong(LAST_SEARCHED_CITY, cityId).putString(LAST_SEARCHED_CITY_NAME, name). putString(LAST_SEARCHED_STREET, "").putString(LAST_SEARCHED_BUILDING, ""); //$NON-NLS-1$ edit.remove(lAST_SEARCHED_POSTCODE); if(globalPreferences.contains(LAST_SEARCHED_INTERSECTED_STREET)){ edit.putString(LAST_SEARCHED_INTERSECTED_STREET, ""); //$NON-NLS-1$ } - return edit.commit(); + boolean res = edit.commit(); + setLastSearchedPoint(point); + return res; } public String getLastSearchedStreet() { return globalPreferences.getString(LAST_SEARCHED_STREET, ""); //$NON-NLS-1$ } - public boolean setLastSearchedStreet(String street) { + public boolean setLastSearchedStreet(String street, LatLon point) { Editor edit = globalPreferences.edit().putString(LAST_SEARCHED_STREET, street).putString(LAST_SEARCHED_BUILDING, ""); //$NON-NLS-1$ if (globalPreferences.contains(LAST_SEARCHED_INTERSECTED_STREET)) { edit.putString(LAST_SEARCHED_INTERSECTED_STREET, ""); //$NON-NLS-1$ } - return edit.commit(); + boolean res = edit.commit(); + setLastSearchedPoint(point); + return res; } public String getLastSearchedBuilding() { return globalPreferences.getString(LAST_SEARCHED_BUILDING, ""); //$NON-NLS-1$ } - public boolean setLastSearchedBuilding(String building) { - return globalPreferences.edit().putString(LAST_SEARCHED_BUILDING, building).remove(LAST_SEARCHED_INTERSECTED_STREET).commit(); + public boolean setLastSearchedBuilding(String building, LatLon point) { + boolean res = globalPreferences.edit().putString(LAST_SEARCHED_BUILDING, building).remove(LAST_SEARCHED_INTERSECTED_STREET).commit(); + setLastSearchedPoint(point); + return res; } public String getLastSearchedIntersectedStreet() { @@ -932,13 +941,11 @@ public class OsmandSettings { return globalPreferences.getString(LAST_SEARCHED_INTERSECTED_STREET, ""); //$NON-NLS-1$ } - public boolean setLastSearchedIntersectedStreet(String street) { + public boolean setLastSearchedIntersectedStreet(String street, LatLon l) { + setLastSearchedPoint(l); return globalPreferences.edit().putString(LAST_SEARCHED_INTERSECTED_STREET, street).commit(); } - public boolean removeLastSearchedIntersectedStreet() { - return globalPreferences.edit().remove(LAST_SEARCHED_INTERSECTED_STREET).commit(); - } public static final String SELECTED_POI_FILTER_FOR_MAP = "selected_poi_filter_for_map"; //$NON-NLS-1$ diff --git a/OsmAnd/src/net/osmand/plus/activities/search/SearchAddressActivity.java b/OsmAnd/src/net/osmand/plus/activities/search/SearchAddressActivity.java index 596b5b73a9..e23b9aa4c0 100644 --- a/OsmAnd/src/net/osmand/plus/activities/search/SearchAddressActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/search/SearchAddressActivity.java @@ -91,10 +91,8 @@ public class SearchAddressActivity extends Activity { @Override public void onClick(View v) { if(radioBuilding){ - osmandSettings.removeLastSearchedIntersectedStreet(); startActivity(new Intent(SearchAddressActivity.this, SearchBuildingByNameActivity.class)); } else { - osmandSettings.setLastSearchedIntersectedStreet(""); //$NON-NLS-1$ startActivity(new Intent(SearchAddressActivity.this, SearchStreet2ByNameActivity.class)); } } @@ -172,23 +170,23 @@ public class SearchAddressActivity extends Activity { } String historyName = null; int zoom = 12; - if (street2 != null && street != null) { - String cityName = postcode != null ? postcode : city; + if (!Algoritms.isEmpty(street2) && !Algoritms.isEmpty(street)) { + String cityName = !Algoritms.isEmpty(postcode) ? postcode : city; historyName = MessageFormat.format(getString(R.string.search_history_int_streets), street, street2, cityName); zoom = 16; - } else if (building != null) { - String cityName = postcode != null ? postcode : city; + } else if (!Algoritms.isEmpty(building)) { + String cityName = !Algoritms.isEmpty(postcode) ? postcode : city; historyName = MessageFormat.format(getString(R.string.search_history_building), building, street, cityName); zoom = 16; - } else if (street != null) { + } else if (!Algoritms.isEmpty(street)) { String cityName = postcode != null ? postcode : city; historyName = MessageFormat.format(getString(R.string.search_history_street), street, cityName); - zoom = 14; - } else if (city != null) { + zoom = 15; + } else if (!Algoritms.isEmpty(city)) { historyName = MessageFormat.format(getString(R.string.search_history_city), city); - zoom = 12; + zoom = 13; } if (navigateTo) { osmandSettings.setPointToNavigate(searchPoint.getLatitude(), searchPoint.getLongitude(), historyName); @@ -226,7 +224,7 @@ public class SearchAddressActivity extends Activity { } else { countryButton.setText(region); } - findViewById(R.id.ResetCity).setEnabled(postcode != null || city != null); + findViewById(R.id.ResetCity).setEnabled(!Algoritms.isEmpty(city) || !Algoritms.isEmpty(postcode)); if(Algoritms.isEmpty(city) && Algoritms.isEmpty(postcode)){ cityButton.setText(R.string.choose_city); } else { @@ -239,7 +237,7 @@ public class SearchAddressActivity extends Activity { cityButton.setEnabled(!Algoritms.isEmpty(region)); findViewById(R.id.ResetStreet).setEnabled(!Algoritms.isEmpty(street)); - if(street == null){ + if(Algoritms.isEmpty(street)){ streetButton.setText(R.string.choose_street); } else { streetButton.setText(street); @@ -269,7 +267,7 @@ public class SearchAddressActivity extends Activity { if (!Algoritms.isEmpty(postcode) || !Algoritms.isEmpty(city)) { street = osmandSettings.getLastSearchedStreet(); - if (Algoritms.isEmpty(street)) { + if (!Algoritms.isEmpty(street)) { String str = osmandSettings.getLastSearchedIntersectedStreet(); radioBuilding = Algoritms.isEmpty(str); if (!radioBuilding) { diff --git a/OsmAnd/src/net/osmand/plus/activities/search/SearchBuildingByNameActivity.java b/OsmAnd/src/net/osmand/plus/activities/search/SearchBuildingByNameActivity.java index cf8195bfc5..b04c774aba 100644 --- a/OsmAnd/src/net/osmand/plus/activities/search/SearchBuildingByNameActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/search/SearchBuildingByNameActivity.java @@ -54,7 +54,7 @@ public class SearchBuildingByNameActivity extends SearchByNameAbstractActivity