Fix geocoding

This commit is contained in:
max-klaus 2020-09-21 17:07:05 +03:00
parent 55dc681600
commit dcc3c09d75
2 changed files with 36 additions and 11 deletions

View file

@ -334,14 +334,16 @@ public class GeocodingUtilities {
boolean eqStreet = Algorithms.stringsEqual(gr1.streetName, gr2.streetName);
if (eqStreet) {
boolean sameObj = false;
if (gr1.building != null && gr2.building != null) {
if (Algorithms.stringsEqual(gr1.building.getName(), gr2.building.getName())) {
// same building
if (gr1.city != null && gr2.city != null) {
if (gr1.building != null && gr2.building != null) {
if (Algorithms.stringsEqual(gr1.building.getName(), gr2.building.getName())) {
// same building
sameObj = true;
}
} else if (gr1.building == null && gr2.building == null) {
// same street
sameObj = true;
}
} else if (gr1.building == null && gr2.building == null) {
// same street
sameObj = true;
}
if (sameObj) {
double cityDist1 = MapUtils.getDistance(gr1.searchPoint, gr1.city.getLocation());

View file

@ -25,7 +25,6 @@ import org.apache.commons.logging.Log;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.concurrent.ExecutorService;
@ -154,7 +153,7 @@ public class CurrentPositionHelper {
// single synchronized method
private synchronized void processGeocoding(@NonNull Location loc,
@Nullable ResultMatcher<GeocodingResult> geoCoding,
@Nullable final ResultMatcher<GeocodingResult> geoCoding,
boolean storeFound,
boolean allowEmptyNames,
@Nullable final ResultMatcher<RouteDataObject> result,
@ -164,6 +163,21 @@ public class CurrentPositionHelper {
boolean cancelPreviousSearch) {
if (cancelPreviousSearch && request != requestNumber.get()) {
if (geoCoding != null) {
app.runInUIThread(new Runnable() {
@Override
public void run() {
geoCoding.publish(null);
}
});
} else if (result != null) {
app.runInUIThread(new Runnable() {
@Override
public void run() {
result.publish(null);
}
});
}
return;
}
@ -172,9 +186,18 @@ public class CurrentPositionHelper {
if (storeFound) {
lastAskedLocation = loc;
lastFound = gr == null || gr.isEmpty() ? null : gr.get(0).point.getRoad();
} else if(geoCoding != null) {
justifyResult(gr, geoCoding);
} else if(result != null) {
} else if (geoCoding != null) {
try {
justifyResult(gr, geoCoding);
} catch (Exception e) {
app.runInUIThread(new Runnable() {
@Override
public void run() {
geoCoding.publish(null);
}
});
}
} else if (result != null) {
app.runInUIThread(new Runnable() {
@Override
public void run() {