Update utilities
This commit is contained in:
parent
ead2616cc9
commit
d7b99427ef
4 changed files with 33 additions and 41 deletions
|
@ -117,7 +117,7 @@ public class GeocodingUtilities {
|
|||
}
|
||||
|
||||
public double getDistance() {
|
||||
if(dist == -1) {
|
||||
if(dist == -1 && connectionPoint != null && searchPoint != null) {
|
||||
dist = MapUtils.getDistance(connectionPoint, searchPoint);
|
||||
}
|
||||
return dist;
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
3. All your modified/created strings are in the top of the file (to make easier find what\'s translated).
|
||||
PLEASE: Have a look at http://code.google.com/p/osmand/wiki/UIConsistency, it may really improve your and our work :-) Thx - Hardy
|
||||
-->
|
||||
|
||||
<string name="no_address_determined">No address determined</string>
|
||||
<string name="shared_string_near">Near</string>
|
||||
<string name="shared_string_hide">Hide</string>
|
||||
<string name="av_video_quality_low">Lowest resolution</string>
|
||||
|
|
|
@ -91,8 +91,8 @@ public class CurrentPositionHelper {
|
|||
double minBuildingDistance = 0;
|
||||
for (GeocodingResult r : res) {
|
||||
Collection<RegionAddressRepository> rar = app.getResourceManager().getAddressRepositories();
|
||||
RegionAddressRepository foundRepo = null;
|
||||
for(RegionAddressRepository repo : rar) {
|
||||
RegionAddressRepository foundRepo = null;
|
||||
for (RegionAddressRepository repo : rar) {
|
||||
BinaryMapIndexReader reader = repo.getFile();
|
||||
for (RouteRegion rb : reader.getRoutingIndexes()) {
|
||||
if (r.regionFP == rb.getFilePointer() && r.regionLen == rb.getLength()) {
|
||||
|
@ -100,15 +100,15 @@ public class CurrentPositionHelper {
|
|||
break;
|
||||
}
|
||||
}
|
||||
if(foundRepo != null) {
|
||||
if (foundRepo != null) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (foundRepo != null) {
|
||||
List<GeocodingResult> justified = foundRepo.justifyReverseGeocodingSearch(r, minBuildingDistance);
|
||||
if(!justified.isEmpty()) {
|
||||
if (!justified.isEmpty()) {
|
||||
double md = justified.get(0).getDistance();
|
||||
if(minBuildingDistance == 0){
|
||||
if (minBuildingDistance == 0) {
|
||||
minBuildingDistance = md;
|
||||
} else {
|
||||
minBuildingDistance = Math.min(md, minBuildingDistance);
|
||||
|
@ -120,14 +120,12 @@ public class CurrentPositionHelper {
|
|||
}
|
||||
}
|
||||
Collections.sort(complete, GeocodingUtilities.DISTANCE_COMPARATOR);
|
||||
if(complete.size() > 0) {
|
||||
final GeocodingResult rts = complete.get(0);
|
||||
app.runInUIThread(new Runnable() {
|
||||
public void run() {
|
||||
result.publish(rts);
|
||||
}
|
||||
});
|
||||
}
|
||||
final GeocodingResult rts = complete.size() > 0 ? complete.get(0) : new GeocodingResult();
|
||||
app.runInUIThread(new Runnable() {
|
||||
public void run() {
|
||||
result.publish(rts);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private static double getOrthogonalDistance(RouteDataObject r, Location loc){
|
||||
|
|
|
@ -143,57 +143,51 @@ public abstract class MenuTitleController {
|
|||
OsmandSettings settings = getMapActivity().getMyApplication().getSettings();
|
||||
String lang = settings.MAP_PREFERRED_LOCALE.get();
|
||||
String geocodingResult = "";
|
||||
if(object.building != null) {
|
||||
if (object.building != null) {
|
||||
String bldName = object.building.getName(lang);
|
||||
if(!Algorithms.isEmpty(object.buildingInterpolation)) {
|
||||
if (!Algorithms.isEmpty(object.buildingInterpolation)) {
|
||||
bldName = object.buildingInterpolation;
|
||||
}
|
||||
geocodingResult = object.street.getName(lang) + " " + bldName + ", "
|
||||
+ object.city.getName(lang);
|
||||
} else if(object.street != null) {
|
||||
} else if (object.street != null) {
|
||||
geocodingResult = object.street.getName(lang) + ", " + object.city.getName(lang);
|
||||
} else if(object.city != null) {
|
||||
} else if (object.city != null) {
|
||||
geocodingResult = object.city.getName(lang);
|
||||
} else if(object.point != null) {
|
||||
} else if (object.point != null) {
|
||||
RouteDataObject rd = object.point.getRoad();
|
||||
String sname = rd.getName(lang);
|
||||
if(Algorithms.isEmpty(sname)) {
|
||||
if (Algorithms.isEmpty(sname)) {
|
||||
sname = "";
|
||||
}
|
||||
String ref = rd.getRef();
|
||||
if(!Algorithms.isEmpty(ref)) {
|
||||
if(!Algorithms.isEmpty(sname)) {
|
||||
if (!Algorithms.isEmpty(ref)) {
|
||||
if (!Algorithms.isEmpty(sname)) {
|
||||
sname += ", ";
|
||||
}
|
||||
sname += ref;
|
||||
}
|
||||
geocodingResult = sname;
|
||||
}
|
||||
|
||||
|
||||
streetStr = geocodingResult;
|
||||
|
||||
if (!Algorithms.isEmpty(streetStr) && object.getDistance() > 100) {
|
||||
streetStr = getMapActivity().getString(R.string.shared_string_near) + " " + streetStr;
|
||||
} else {
|
||||
streetStr = getMapActivity().getString(R.string.no_address_determined);
|
||||
}
|
||||
|
||||
//FIXME: "No address determined" supposed to replace "Address is not known yet" once reverse geocoding yields no result
|
||||
//if (Algorithms.isEmpty(streetStr)) {
|
||||
// streetStr = "No address determined";
|
||||
//}
|
||||
|
||||
if (!Algorithms.isEmpty(streetStr)) {
|
||||
MenuController menuController = getMenuController();
|
||||
if (menuController == null || menuController.displayStreetNameInTitle()) {
|
||||
nameStr = streetStr;
|
||||
getPointDescription().setName(nameStr);
|
||||
MenuController menuController = getMenuController();
|
||||
if (menuController == null || menuController.displayStreetNameInTitle()) {
|
||||
nameStr = streetStr;
|
||||
getPointDescription().setName(nameStr);
|
||||
}
|
||||
getMapActivity().runOnUiThread(new Runnable() {
|
||||
public void run() {
|
||||
refreshMenuTitle();
|
||||
}
|
||||
getMapActivity().runOnUiThread(new Runnable() {
|
||||
public void run() {
|
||||
refreshMenuTitle();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
return true;
|
||||
|
|
Loading…
Reference in a new issue