Fix latLon formatting in search
This commit is contained in:
parent
6173a2b4a6
commit
a11dd191ae
1 changed files with 9 additions and 3 deletions
|
@ -33,6 +33,7 @@ import net.osmand.util.LocationParser.ParsedOpenLocationCode;
|
||||||
import net.osmand.util.MapUtils;
|
import net.osmand.util.MapUtils;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.text.DecimalFormat;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
@ -1407,6 +1408,7 @@ public class SearchCoreFactory {
|
||||||
private LatLon olcPhraseLocation;
|
private LatLon olcPhraseLocation;
|
||||||
private ParsedOpenLocationCode cachedParsedCode;
|
private ParsedOpenLocationCode cachedParsedCode;
|
||||||
private final List<String> citySubTypes = Arrays.asList("city", "town", "village");
|
private final List<String> citySubTypes = Arrays.asList("city", "town", "village");
|
||||||
|
private final DecimalFormat latLonFormatter = new DecimalFormat("#.0####");
|
||||||
|
|
||||||
public SearchLocationAndUrlAPI() {
|
public SearchLocationAndUrlAPI() {
|
||||||
super(ObjectType.LOCATION, ObjectType.PARTIAL_LOCATION);
|
super(ObjectType.LOCATION, ObjectType.PARTIAL_LOCATION);
|
||||||
|
@ -1498,7 +1500,7 @@ public class SearchCoreFactory {
|
||||||
sp.priority = SEARCH_LOCATION_PRIORITY;
|
sp.priority = SEARCH_LOCATION_PRIORITY;
|
||||||
|
|
||||||
sp.object = sp.location = ll;
|
sp.object = sp.location = ll;
|
||||||
sp.localeName = ((float) sp.location.getLatitude()) + ", <input> ";
|
sp.localeName = formatLatLon(sp.location.getLatitude()) + ", <input> ";
|
||||||
sp.objectType = ObjectType.PARTIAL_LOCATION;
|
sp.objectType = ObjectType.PARTIAL_LOCATION;
|
||||||
resultMatcher.publish(sp);
|
resultMatcher.publish(sp);
|
||||||
}
|
}
|
||||||
|
@ -1510,7 +1512,7 @@ public class SearchCoreFactory {
|
||||||
SearchResult sp = new SearchResult(phrase);
|
SearchResult sp = new SearchResult(phrase);
|
||||||
sp.priority = SEARCH_LOCATION_PRIORITY;
|
sp.priority = SEARCH_LOCATION_PRIORITY;
|
||||||
sp.object = sp.location = l;
|
sp.object = sp.location = l;
|
||||||
sp.localeName = ((float) sp.location.getLatitude()) + ", " + ((float) sp.location.getLongitude());
|
sp.localeName = formatLatLon(sp.location.getLatitude()) + ", " + formatLatLon(sp.location.getLongitude());
|
||||||
sp.objectType = ObjectType.LOCATION;
|
sp.objectType = ObjectType.LOCATION;
|
||||||
sp.wordsSpan = lw;
|
sp.wordsSpan = lw;
|
||||||
resultMatcher.publish(sp);
|
resultMatcher.publish(sp);
|
||||||
|
@ -1525,7 +1527,7 @@ public class SearchCoreFactory {
|
||||||
sp.object = pnt;
|
sp.object = pnt;
|
||||||
sp.wordsSpan = text;
|
sp.wordsSpan = text;
|
||||||
sp.location = new LatLon(pnt.getLatitude(), pnt.getLongitude());
|
sp.location = new LatLon(pnt.getLatitude(), pnt.getLongitude());
|
||||||
sp.localeName = ((float)pnt.getLatitude()) +", " + ((float) pnt.getLongitude());
|
sp.localeName = formatLatLon(pnt.getLatitude()) +", " + formatLatLon(pnt.getLongitude());
|
||||||
if (pnt.getZoom() > 0) {
|
if (pnt.getZoom() > 0) {
|
||||||
sp.preferredZoom = pnt.getZoom();
|
sp.preferredZoom = pnt.getZoom();
|
||||||
}
|
}
|
||||||
|
@ -1555,6 +1557,10 @@ public class SearchCoreFactory {
|
||||||
}
|
}
|
||||||
return cachedParsedCode == null ? SEARCH_LOCATION_PRIORITY : SEARCH_MAX_PRIORITY;
|
return cachedParsedCode == null ? SEARCH_LOCATION_PRIORITY : SEARCH_MAX_PRIORITY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String formatLatLon(double latLon) {
|
||||||
|
return latLonFormatter.format(latLon);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String stripBraces(String localeName) {
|
private static String stripBraces(String localeName) {
|
||||||
|
|
Loading…
Reference in a new issue