Merge remote-tracking branch 'origin/master'

This commit is contained in:
Weblate 2015-11-29 16:00:22 +01:00
commit 9317384d65

View file

@ -173,7 +173,7 @@ public class GeocodingUtilities {
GeocodingResult rs = new GeocodingResult(r); GeocodingResult rs = new GeocodingResult(r);
rs.street = (Street) object; rs.street = (Street) object;
rs.city = rs.street.getCity(); rs.city = rs.street.getCity();
if(d > THRESHOLD_STREET_CHANGE_CONNECTION_POINT) { if(d < THRESHOLD_STREET_CHANGE_CONNECTION_POINT) {
rs.connectionPoint = rs.street.getLocation(); rs.connectionPoint = rs.street.getLocation();
} }
streetsList.add(rs); streetsList.add(rs);
@ -192,12 +192,15 @@ public class GeocodingUtilities {
final List<GeocodingResult> res = new ArrayList<GeocodingResult>(); final List<GeocodingResult> res = new ArrayList<GeocodingResult>();
// FIXME interpolation // FIXME interpolation
for(GeocodingResult s : streetsList) { if(streetsList.size() == 0) {
res.add(r);
} else {
for (GeocodingResult s : streetsList) {
final List<GeocodingResult> streetBuildings = new ArrayList<GeocodingResult>(); final List<GeocodingResult> streetBuildings = new ArrayList<GeocodingResult>();
reader.preloadBuildings(s.street, null); reader.preloadBuildings(s.street, null);
log.info("Preload buildings " + s.street.getName() + " " + s.city.getName() + " " + s.street.getId()); log.info("Preload buildings " + s.street.getName() + " " + s.city.getName() + " " + s.street.getId());
for(Building b : s.street.getBuildings()) { for (Building b : s.street.getBuildings()) {
if(MapUtils.getDistance(b.getLocation(), r.searchPoint) < DISTANCE_BULDING_PROXIMITY) { if (MapUtils.getDistance(b.getLocation(), r.searchPoint) < DISTANCE_BULDING_PROXIMITY) {
GeocodingResult bld = new GeocodingResult(s); GeocodingResult bld = new GeocodingResult(s);
bld.building = b; bld.building = b;
bld.connectionPoint = b.getLocation(); bld.connectionPoint = b.getLocation();
@ -205,16 +208,17 @@ public class GeocodingUtilities {
} }
} }
Collections.sort(streetBuildings, DISTANCE_COMPARATOR); Collections.sort(streetBuildings, DISTANCE_COMPARATOR);
if(streetBuildings.size() > 0) { if (streetBuildings.size() > 0) {
Iterator<GeocodingResult> it = streetBuildings.iterator(); Iterator<GeocodingResult> it = streetBuildings.iterator();
if(knownMinBuidlingDistance == 0) { if (knownMinBuidlingDistance == 0) {
GeocodingResult firstBld = it.next(); GeocodingResult firstBld = it.next();
knownMinBuidlingDistance = firstBld.getDistance(); knownMinBuidlingDistance = firstBld.getDistance();
res.add(firstBld); res.add(firstBld);
} }
while(it.hasNext()) { while (it.hasNext()) {
GeocodingResult nextBld = it.next(); GeocodingResult nextBld = it.next();
if(nextBld.getDistance() > knownMinBuidlingDistance * THRESHOLD_MULTIPLIER_SKIP_BUILDINGS_AFTER) { if (nextBld.getDistance() > knownMinBuidlingDistance
* THRESHOLD_MULTIPLIER_SKIP_BUILDINGS_AFTER) {
break; break;
} }
res.add(nextBld); res.add(nextBld);
@ -222,6 +226,7 @@ public class GeocodingUtilities {
} }
res.add(s); res.add(s);
} }
}
Collections.sort(res, DISTANCE_COMPARATOR); Collections.sort(res, DISTANCE_COMPARATOR);
return res; return res;
} }