Merge branch 'r3.7'
This commit is contained in:
commit
64c01bbbcc
6 changed files with 3822 additions and 14 deletions
|
@ -778,14 +778,28 @@ public class SearchUICore {
|
||||||
return exportedCities;
|
return exportedCities;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void exportObject(MapObject object) {
|
public void exportObject(SearchPhrase phrase, MapObject object) {
|
||||||
|
double maxDistance = phrase.getSettings().getExportSettings().getMaxDistance();
|
||||||
|
if (maxDistance > 0) {
|
||||||
|
double distance = MapUtils.getDistance(phrase.getSettings().getOriginalLocation(), object.getLocation());
|
||||||
|
if (distance > maxDistance) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
if (exportedObjects == null) {
|
if (exportedObjects == null) {
|
||||||
exportedObjects = new ArrayList<>();
|
exportedObjects = new ArrayList<>();
|
||||||
}
|
}
|
||||||
exportedObjects.add(object);
|
exportedObjects.add(object);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void exportCity(City city) {
|
public void exportCity(SearchPhrase phrase, City city) {
|
||||||
|
double maxDistance = phrase.getSettings().getExportSettings().getMaxDistance();
|
||||||
|
if (maxDistance > 0) {
|
||||||
|
double distance = MapUtils.getDistance(phrase.getSettings().getOriginalLocation(), city.getLocation());
|
||||||
|
if (distance > maxDistance) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
if (exportedCities == null) {
|
if (exportedCities == null) {
|
||||||
exportedCities = new ArrayList<>();
|
exportedCities = new ArrayList<>();
|
||||||
}
|
}
|
||||||
|
|
|
@ -343,7 +343,7 @@ public class SearchCoreFactory {
|
||||||
int limit = 0;
|
int limit = 0;
|
||||||
for (City c : resArray) {
|
for (City c : resArray) {
|
||||||
if (phrase.getSettings().isExportObjects()) {
|
if (phrase.getSettings().isExportObjects()) {
|
||||||
resultMatcher.exportCity(c);
|
resultMatcher.exportCity(phrase, c);
|
||||||
}
|
}
|
||||||
SearchResult res = new SearchResult(phrase);
|
SearchResult res = new SearchResult(phrase);
|
||||||
res.object = c;
|
res.object = c;
|
||||||
|
@ -388,7 +388,7 @@ public class SearchCoreFactory {
|
||||||
@Override
|
@Override
|
||||||
public boolean publish(MapObject object) {
|
public boolean publish(MapObject object) {
|
||||||
if (phrase.getSettings().isExportObjects()) {
|
if (phrase.getSettings().isExportObjects()) {
|
||||||
resultMatcher.exportObject(object);
|
resultMatcher.exportObject(phrase, object);
|
||||||
}
|
}
|
||||||
if (isCancelled()) {
|
if (isCancelled()) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -546,7 +546,7 @@ public class SearchCoreFactory {
|
||||||
@Override
|
@Override
|
||||||
public boolean publish(Amenity object) {
|
public boolean publish(Amenity object) {
|
||||||
if (phrase.getSettings().isExportObjects()) {
|
if (phrase.getSettings().isExportObjects()) {
|
||||||
resultMatcher.exportObject(object);
|
resultMatcher.exportObject(phrase, object);
|
||||||
}
|
}
|
||||||
if (limit++ > LIMIT) {
|
if (limit++ > LIMIT) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -952,7 +952,7 @@ public class SearchCoreFactory {
|
||||||
@Override
|
@Override
|
||||||
public boolean publish(Amenity object) {
|
public boolean publish(Amenity object) {
|
||||||
if (phrase.getSettings().isExportObjects()) {
|
if (phrase.getSettings().isExportObjects()) {
|
||||||
resultMatcher.exportObject(object);
|
resultMatcher.exportObject(phrase, object);
|
||||||
}
|
}
|
||||||
SearchResult res = new SearchResult(phrase);
|
SearchResult res = new SearchResult(phrase);
|
||||||
String poiID = object.getType().getKeyName() + "_" + object.getId();
|
String poiID = object.getType().getKeyName() + "_" + object.getId();
|
||||||
|
|
|
@ -3,30 +3,29 @@ package net.osmand.search.core;
|
||||||
public class SearchExportSettings {
|
public class SearchExportSettings {
|
||||||
private boolean exportEmptyCities;
|
private boolean exportEmptyCities;
|
||||||
private boolean exportBuildings;
|
private boolean exportBuildings;
|
||||||
|
private double maxDistance;
|
||||||
|
|
||||||
public SearchExportSettings() {
|
public SearchExportSettings() {
|
||||||
exportEmptyCities = true;
|
exportEmptyCities = true;
|
||||||
exportBuildings = true;
|
exportBuildings = true;
|
||||||
|
maxDistance = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public SearchExportSettings(boolean exportEmptyCities, boolean exportBuildings) {
|
public SearchExportSettings(boolean exportEmptyCities, boolean exportBuildings, double maxDistance) {
|
||||||
this.exportEmptyCities = exportEmptyCities;
|
this.exportEmptyCities = exportEmptyCities;
|
||||||
this.exportBuildings = exportBuildings;
|
this.exportBuildings = exportBuildings;
|
||||||
|
this.maxDistance = maxDistance;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isExportEmptyCities() {
|
public boolean isExportEmptyCities() {
|
||||||
return exportEmptyCities;
|
return exportEmptyCities;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setExportEmptyCities(boolean exportEmptyCities) {
|
|
||||||
this.exportEmptyCities = exportEmptyCities;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isExportBuildings() {
|
public boolean isExportBuildings() {
|
||||||
return exportBuildings;
|
return exportBuildings;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setExportBuildings(boolean exportBuildings) {
|
public double getMaxDistance() {
|
||||||
this.exportBuildings = exportBuildings;
|
return maxDistance;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,7 @@ public class SearchSettings {
|
||||||
private boolean emptyQueryAllowed;
|
private boolean emptyQueryAllowed;
|
||||||
private boolean sortByName;
|
private boolean sortByName;
|
||||||
private SearchExportSettings exportSettings;
|
private SearchExportSettings exportSettings;
|
||||||
//private SearchExportSettings exportSettings = new SearchExportSettings(false, false);
|
//private SearchExportSettings exportSettings = new SearchExportSettings(false, false, -1);
|
||||||
|
|
||||||
public SearchSettings(SearchSettings s) {
|
public SearchSettings(SearchSettings s) {
|
||||||
if(s != null) {
|
if(s != null) {
|
||||||
|
|
1090
OsmAnd-java/src/test/resources/search/fuel_diesel.json
Normal file
1090
OsmAnd-java/src/test/resources/search/fuel_diesel.json
Normal file
File diff suppressed because it is too large
Load diff
2705
OsmAnd-java/src/test/resources/search/rolandstr.json
Normal file
2705
OsmAnd-java/src/test/resources/search/rolandstr.json
Normal file
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue