Fix poi filter
This commit is contained in:
parent
212c819477
commit
63c7eb1d02
2 changed files with 12 additions and 6 deletions
|
@ -11,6 +11,7 @@ import net.osmand.Algoritms;
|
||||||
import net.osmand.LogUtil;
|
import net.osmand.LogUtil;
|
||||||
import net.osmand.ResultMatcher;
|
import net.osmand.ResultMatcher;
|
||||||
import net.osmand.binary.BinaryMapIndexReader;
|
import net.osmand.binary.BinaryMapIndexReader;
|
||||||
|
import net.osmand.binary.BinaryMapIndexReader.MapIndex;
|
||||||
import net.osmand.binary.BinaryMapIndexReader.SearchPoiTypeFilter;
|
import net.osmand.binary.BinaryMapIndexReader.SearchPoiTypeFilter;
|
||||||
import net.osmand.binary.BinaryMapIndexReader.SearchRequest;
|
import net.osmand.binary.BinaryMapIndexReader.SearchRequest;
|
||||||
import net.osmand.data.Amenity;
|
import net.osmand.data.Amenity;
|
||||||
|
@ -77,8 +78,13 @@ public class AmenityIndexRepositoryBinary implements AmenityIndexRepository {
|
||||||
try {
|
try {
|
||||||
amenities = index.searchPoiByName(req);
|
amenities = index.searchPoiByName(req);
|
||||||
if (log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
log.debug(String.format("Search for %s done in %s ms found %s.", //$NON-NLS-1$
|
String nm = "";
|
||||||
query, System.currentTimeMillis() - now, amenities.size())); //$NON-NLS-1$
|
List<MapIndex> mi = index.getMapIndexes();
|
||||||
|
if(mi.size() > 0) {
|
||||||
|
nm = mi.get(0).getName();
|
||||||
|
}
|
||||||
|
log.debug(String.format("Search for %s done in %s ms found %s (%s).", //$NON-NLS-1$
|
||||||
|
query, System.currentTimeMillis() - now, amenities.size(), nm)); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
log.error("Error searching amenities", e); //$NON-NLS-1$
|
log.error("Error searching amenities", e); //$NON-NLS-1$
|
||||||
|
|
|
@ -136,10 +136,10 @@ public class PoiFilter {
|
||||||
double baseDistX = MapUtils.getDistance(lat, lon, lat, lon - 1);
|
double baseDistX = MapUtils.getDistance(lat, lon, lat, lon - 1);
|
||||||
double distance = distanceToSearchValues[distanceInd] * 1000;
|
double distance = distanceToSearchValues[distanceInd] * 1000;
|
||||||
|
|
||||||
double topLatitude = lat + (distance/ baseDistY );
|
double topLatitude = Math.min(lat + (distance/ baseDistY ), 84.);
|
||||||
double bottomLatitude = lat - (distance/ baseDistY );
|
double bottomLatitude = Math.max(lat - (distance/ baseDistY ), -84.);
|
||||||
double leftLongitude = lon - (distance / baseDistX);
|
double leftLongitude = Math.max(lon - (distance / baseDistX), -180);
|
||||||
double rightLongitude = lon + (distance/ baseDistX);
|
double rightLongitude = Math.min(lon + (distance/ baseDistX), 180);
|
||||||
|
|
||||||
return searchAmenities(lat, lon, topLatitude, bottomLatitude, leftLongitude, rightLongitude, matcher);
|
return searchAmenities(lat, lon, topLatitude, bottomLatitude, leftLongitude, rightLongitude, matcher);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue