Fix geocoding
This commit is contained in:
parent
55dc681600
commit
dcc3c09d75
2 changed files with 36 additions and 11 deletions
|
@ -334,14 +334,16 @@ public class GeocodingUtilities {
|
||||||
boolean eqStreet = Algorithms.stringsEqual(gr1.streetName, gr2.streetName);
|
boolean eqStreet = Algorithms.stringsEqual(gr1.streetName, gr2.streetName);
|
||||||
if (eqStreet) {
|
if (eqStreet) {
|
||||||
boolean sameObj = false;
|
boolean sameObj = false;
|
||||||
if (gr1.building != null && gr2.building != null) {
|
if (gr1.city != null && gr2.city != null) {
|
||||||
if (Algorithms.stringsEqual(gr1.building.getName(), gr2.building.getName())) {
|
if (gr1.building != null && gr2.building != null) {
|
||||||
// same building
|
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;
|
sameObj = true;
|
||||||
}
|
}
|
||||||
} else if (gr1.building == null && gr2.building == null) {
|
|
||||||
// same street
|
|
||||||
sameObj = true;
|
|
||||||
}
|
}
|
||||||
if (sameObj) {
|
if (sameObj) {
|
||||||
double cityDist1 = MapUtils.getDistance(gr1.searchPoint, gr1.city.getLocation());
|
double cityDist1 = MapUtils.getDistance(gr1.searchPoint, gr1.city.getLocation());
|
||||||
|
|
|
@ -25,7 +25,6 @@ import org.apache.commons.logging.Log;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.ExecutorService;
|
import java.util.concurrent.ExecutorService;
|
||||||
|
@ -154,7 +153,7 @@ public class CurrentPositionHelper {
|
||||||
|
|
||||||
// single synchronized method
|
// single synchronized method
|
||||||
private synchronized void processGeocoding(@NonNull Location loc,
|
private synchronized void processGeocoding(@NonNull Location loc,
|
||||||
@Nullable ResultMatcher<GeocodingResult> geoCoding,
|
@Nullable final ResultMatcher<GeocodingResult> geoCoding,
|
||||||
boolean storeFound,
|
boolean storeFound,
|
||||||
boolean allowEmptyNames,
|
boolean allowEmptyNames,
|
||||||
@Nullable final ResultMatcher<RouteDataObject> result,
|
@Nullable final ResultMatcher<RouteDataObject> result,
|
||||||
|
@ -164,6 +163,21 @@ public class CurrentPositionHelper {
|
||||||
boolean cancelPreviousSearch) {
|
boolean cancelPreviousSearch) {
|
||||||
|
|
||||||
if (cancelPreviousSearch && request != requestNumber.get()) {
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -172,9 +186,18 @@ public class CurrentPositionHelper {
|
||||||
if (storeFound) {
|
if (storeFound) {
|
||||||
lastAskedLocation = loc;
|
lastAskedLocation = loc;
|
||||||
lastFound = gr == null || gr.isEmpty() ? null : gr.get(0).point.getRoad();
|
lastFound = gr == null || gr.isEmpty() ? null : gr.get(0).point.getRoad();
|
||||||
} else if(geoCoding != null) {
|
} else if (geoCoding != null) {
|
||||||
justifyResult(gr, geoCoding);
|
try {
|
||||||
} else if(result != null) {
|
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() {
|
app.runInUIThread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
|
Loading…
Reference in a new issue