Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
38affee113
14 changed files with 238 additions and 61 deletions
|
@ -0,0 +1,43 @@
|
||||||
|
package net.osmand.core.samples.android.sample1.adapters;
|
||||||
|
|
||||||
|
import net.osmand.core.jni.Building;
|
||||||
|
import net.osmand.core.jni.Street;
|
||||||
|
import net.osmand.core.jni.StreetGroup;
|
||||||
|
import net.osmand.core.samples.android.sample1.MapUtils;
|
||||||
|
import net.osmand.core.samples.android.sample1.SampleApplication;
|
||||||
|
import net.osmand.core.samples.android.sample1.search.objects.BuildingSearchObject;
|
||||||
|
|
||||||
|
public class BuildingSearchListItem extends SearchListPositionItem {
|
||||||
|
private String nameStr;
|
||||||
|
private String typeStr;
|
||||||
|
|
||||||
|
public BuildingSearchListItem(SampleApplication app, BuildingSearchObject searchObject) {
|
||||||
|
super(app, searchObject);
|
||||||
|
|
||||||
|
nameStr = searchObject.getName(MapUtils.LANGUAGE);
|
||||||
|
|
||||||
|
Building building = searchObject.getBuilding();
|
||||||
|
|
||||||
|
Street street = building.getStreet();
|
||||||
|
if (street != null) {
|
||||||
|
StreetGroup streetGroup = street.getStreetGroup();
|
||||||
|
if (streetGroup != null) {
|
||||||
|
typeStr = streetGroup.getNativeName() + ", " + street.getNativeName();
|
||||||
|
} else {
|
||||||
|
typeStr = street.getNativeName();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
typeStr = "Building";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getName() {
|
||||||
|
return nameStr;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getTypeName() {
|
||||||
|
return typeStr;
|
||||||
|
}
|
||||||
|
}
|
|
@ -9,10 +9,10 @@ public class CitySearchListItem extends SearchListPositionItem{
|
||||||
private String nameStr;
|
private String nameStr;
|
||||||
private String typeStr;
|
private String typeStr;
|
||||||
|
|
||||||
public CitySearchListItem(SampleApplication app, CitySearchObject searchItem) {
|
public CitySearchListItem(SampleApplication app, CitySearchObject searchObject) {
|
||||||
super(app, searchItem);
|
super(app, searchObject);
|
||||||
|
|
||||||
nameStr = searchItem.getName(MapUtils.LANGUAGE);
|
nameStr = searchObject.getName(MapUtils.LANGUAGE);
|
||||||
typeStr = "City";
|
typeStr = "City";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,9 +26,9 @@ public class PoiSearchListItem extends SearchListPositionItem {
|
||||||
private String nameStr;
|
private String nameStr;
|
||||||
private String typeStr;
|
private String typeStr;
|
||||||
|
|
||||||
public PoiSearchListItem(SampleApplication app, PoiSearchObject searchItem) {
|
public PoiSearchListItem(SampleApplication app, PoiSearchObject searchObject) {
|
||||||
super(app, searchItem);
|
super(app, searchObject);
|
||||||
amenity = parseAmenity(searchItem);
|
amenity = parseAmenity(searchObject);
|
||||||
nameStr = amenity.getName(MapUtils.LANGUAGE);
|
nameStr = amenity.getName(MapUtils.LANGUAGE);
|
||||||
typeStr = getTypeStr();
|
typeStr = getTypeStr();
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,10 +10,10 @@ public class PostcodeSearchListItem extends SearchListPositionItem {
|
||||||
private String nameStr;
|
private String nameStr;
|
||||||
private String typeStr;
|
private String typeStr;
|
||||||
|
|
||||||
public PostcodeSearchListItem(SampleApplication app, PostcodeSearchObject searchItem) {
|
public PostcodeSearchListItem(SampleApplication app, PostcodeSearchObject searchObject) {
|
||||||
super(app, searchItem);
|
super(app, searchObject);
|
||||||
|
|
||||||
nameStr = searchItem.getNativeName();
|
nameStr = searchObject.getNativeName();
|
||||||
typeStr = "Postcode";
|
typeStr = "Postcode";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,10 +3,12 @@ package net.osmand.core.samples.android.sample1.adapters;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
|
|
||||||
import net.osmand.core.samples.android.sample1.SampleApplication;
|
import net.osmand.core.samples.android.sample1.SampleApplication;
|
||||||
|
import net.osmand.core.samples.android.sample1.search.objects.BuildingSearchObject;
|
||||||
import net.osmand.core.samples.android.sample1.search.objects.CitySearchObject;
|
import net.osmand.core.samples.android.sample1.search.objects.CitySearchObject;
|
||||||
import net.osmand.core.samples.android.sample1.search.objects.PoiSearchObject;
|
import net.osmand.core.samples.android.sample1.search.objects.PoiSearchObject;
|
||||||
import net.osmand.core.samples.android.sample1.search.objects.PostcodeSearchObject;
|
import net.osmand.core.samples.android.sample1.search.objects.PostcodeSearchObject;
|
||||||
import net.osmand.core.samples.android.sample1.search.objects.SearchObject;
|
import net.osmand.core.samples.android.sample1.search.objects.SearchObject;
|
||||||
|
import net.osmand.core.samples.android.sample1.search.objects.StreetIntersectionSearchObject;
|
||||||
import net.osmand.core.samples.android.sample1.search.objects.StreetSearchObject;
|
import net.osmand.core.samples.android.sample1.search.objects.StreetSearchObject;
|
||||||
import net.osmand.core.samples.android.sample1.search.objects.VillageSearchObject;
|
import net.osmand.core.samples.android.sample1.search.objects.VillageSearchObject;
|
||||||
|
|
||||||
|
@ -20,18 +22,22 @@ public class SearchListItem {
|
||||||
this.searchObject = searchObject;
|
this.searchObject = searchObject;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static SearchListItem buildListItem(SampleApplication app, SearchObject item) {
|
public static SearchListItem buildListItem(SampleApplication app, SearchObject searchObject) {
|
||||||
switch (item.getType()) {
|
switch (searchObject.getType()) {
|
||||||
case POI:
|
case POI:
|
||||||
return new PoiSearchListItem(app, (PoiSearchObject) item);
|
return new PoiSearchListItem(app, (PoiSearchObject) searchObject);
|
||||||
|
case BUILDING:
|
||||||
|
return new BuildingSearchListItem(app, (BuildingSearchObject) searchObject);
|
||||||
|
case STREET_INTERSECTION:
|
||||||
|
return new StreetIntersectionSearchListItem(app, (StreetIntersectionSearchObject) searchObject);
|
||||||
case STREET:
|
case STREET:
|
||||||
return new StreetSearchListItem(app, (StreetSearchObject) item);
|
return new StreetSearchListItem(app, (StreetSearchObject) searchObject);
|
||||||
case CITY:
|
case CITY:
|
||||||
return new CitySearchListItem(app, (CitySearchObject) item);
|
return new CitySearchListItem(app, (CitySearchObject) searchObject);
|
||||||
case VILLAGE:
|
case VILLAGE:
|
||||||
return new VillageSearchListItem(app, (VillageSearchObject) item);
|
return new VillageSearchListItem(app, (VillageSearchObject) searchObject);
|
||||||
case POSTCODE:
|
case POSTCODE:
|
||||||
return new PostcodeSearchListItem(app, (PostcodeSearchObject) item);
|
return new PostcodeSearchListItem(app, (PostcodeSearchObject) searchObject);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,43 @@
|
||||||
|
package net.osmand.core.samples.android.sample1.adapters;
|
||||||
|
|
||||||
|
import net.osmand.core.jni.Street;
|
||||||
|
import net.osmand.core.jni.StreetGroup;
|
||||||
|
import net.osmand.core.jni.StreetIntersection;
|
||||||
|
import net.osmand.core.samples.android.sample1.MapUtils;
|
||||||
|
import net.osmand.core.samples.android.sample1.SampleApplication;
|
||||||
|
import net.osmand.core.samples.android.sample1.search.objects.StreetIntersectionSearchObject;
|
||||||
|
|
||||||
|
public class StreetIntersectionSearchListItem extends SearchListPositionItem {
|
||||||
|
private String nameStr;
|
||||||
|
private String typeStr;
|
||||||
|
|
||||||
|
public StreetIntersectionSearchListItem(SampleApplication app, StreetIntersectionSearchObject searchObject) {
|
||||||
|
super(app, searchObject);
|
||||||
|
|
||||||
|
nameStr = searchObject.getName(MapUtils.LANGUAGE);
|
||||||
|
|
||||||
|
StreetIntersection streetIntersection = searchObject.getStreetIntersection();
|
||||||
|
|
||||||
|
Street street = streetIntersection.getStreet();
|
||||||
|
if (street != null) {
|
||||||
|
StreetGroup streetGroup = street.getStreetGroup();
|
||||||
|
if (streetGroup != null) {
|
||||||
|
typeStr = streetGroup.getNativeName() + ", " + street.getNativeName();
|
||||||
|
} else {
|
||||||
|
typeStr = street.getNativeName();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
typeStr = "Street intersection";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getName() {
|
||||||
|
return nameStr;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getTypeName() {
|
||||||
|
return typeStr;
|
||||||
|
}
|
||||||
|
}
|
|
@ -10,12 +10,12 @@ public class StreetSearchListItem extends SearchListPositionItem {
|
||||||
private String nameStr;
|
private String nameStr;
|
||||||
private String typeStr;
|
private String typeStr;
|
||||||
|
|
||||||
public StreetSearchListItem(SampleApplication app, StreetSearchObject searchItem) {
|
public StreetSearchListItem(SampleApplication app, StreetSearchObject searchObject) {
|
||||||
super(app, searchItem);
|
super(app, searchObject);
|
||||||
|
|
||||||
nameStr = searchItem.getName(MapUtils.LANGUAGE);
|
nameStr = searchObject.getName(MapUtils.LANGUAGE);
|
||||||
|
|
||||||
StreetGroup streetGroup = searchItem.getStreet().getStreetGroup();
|
StreetGroup streetGroup = searchObject.getStreet().getStreetGroup();
|
||||||
if (streetGroup != null) {
|
if (streetGroup != null) {
|
||||||
typeStr = streetGroup.getNativeName() + " — " + getTypeStr(streetGroup);
|
typeStr = streetGroup.getNativeName() + " — " + getTypeStr(streetGroup);
|
||||||
} else {
|
} else {
|
||||||
|
@ -26,17 +26,9 @@ public class StreetSearchListItem extends SearchListPositionItem {
|
||||||
private String getTypeStr(StreetGroup streetGroup) {
|
private String getTypeStr(StreetGroup streetGroup) {
|
||||||
String typeStr;
|
String typeStr;
|
||||||
if (streetGroup.getSubtype() != ObfAddressStreetGroupSubtype.Unknown) {
|
if (streetGroup.getSubtype() != ObfAddressStreetGroupSubtype.Unknown) {
|
||||||
try {
|
typeStr = streetGroup.getSubtype().name();
|
||||||
typeStr = streetGroup.getSubtype().name();
|
|
||||||
} catch (IllegalArgumentException e) {
|
|
||||||
typeStr = "Out of subtype";
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
try {
|
typeStr = streetGroup.getType().name();
|
||||||
typeStr = streetGroup.getType().name();
|
|
||||||
} catch (IllegalArgumentException e) {
|
|
||||||
typeStr = "Out of type";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return typeStr;
|
return typeStr;
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,10 +10,10 @@ public class VillageSearchListItem extends SearchListPositionItem{
|
||||||
private String nameStr;
|
private String nameStr;
|
||||||
private String typeStr;
|
private String typeStr;
|
||||||
|
|
||||||
public VillageSearchListItem(SampleApplication app, VillageSearchObject searchItem) {
|
public VillageSearchListItem(SampleApplication app, VillageSearchObject searchObject) {
|
||||||
super(app, searchItem);
|
super(app, searchObject);
|
||||||
|
|
||||||
nameStr = searchItem.getName(MapUtils.LANGUAGE);
|
nameStr = searchObject.getName(MapUtils.LANGUAGE);
|
||||||
typeStr = "Village";
|
typeStr = "Village";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -11,6 +11,7 @@ import net.osmand.core.jni.Street;
|
||||||
import net.osmand.core.jni.StreetGroup;
|
import net.osmand.core.jni.StreetGroup;
|
||||||
import net.osmand.core.jni.Utilities;
|
import net.osmand.core.jni.Utilities;
|
||||||
import net.osmand.core.samples.android.sample1.search.objects.PoiSearchObject;
|
import net.osmand.core.samples.android.sample1.search.objects.PoiSearchObject;
|
||||||
|
import net.osmand.core.samples.android.sample1.search.objects.PostcodeSearchObject;
|
||||||
import net.osmand.core.samples.android.sample1.search.objects.SearchObject;
|
import net.osmand.core.samples.android.sample1.search.objects.SearchObject;
|
||||||
import net.osmand.core.samples.android.sample1.search.objects.SearchObject.SearchObjectType;
|
import net.osmand.core.samples.android.sample1.search.objects.SearchObject.SearchObjectType;
|
||||||
import net.osmand.core.samples.android.sample1.search.objects.SearchPositionObject;
|
import net.osmand.core.samples.android.sample1.search.objects.SearchPositionObject;
|
||||||
|
@ -96,7 +97,25 @@ public class SearchScope {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setupAddressSearchCriteria(AddressesByNameSearch.Criteria criteria) {
|
public void setupAddressSearchCriteria(AddressesByNameSearch.Criteria criteria) {
|
||||||
// not implemented
|
if (objectTokens.containsKey(SearchObjectType.STREET)) {
|
||||||
|
StreetSearchObject streetSearchObject =
|
||||||
|
(StreetSearchObject) objectTokens.get(SearchObjectType.STREET).getSearchObject();
|
||||||
|
criteria.setAddressFilter(streetSearchObject.getStreet());
|
||||||
|
if (objectTokens.containsKey(SearchObjectType.POSTCODE)) {
|
||||||
|
PostcodeSearchObject postcodeSearchObject =
|
||||||
|
(PostcodeSearchObject) objectTokens.get(SearchObjectType.POSTCODE).getSearchObject();
|
||||||
|
criteria.setPostcode(postcodeSearchObject.getNativeName());
|
||||||
|
}
|
||||||
|
} else if (objectTokens.containsKey(SearchObjectType.CITY)) {
|
||||||
|
criteria.setAddressFilter(((StreetGroupSearchObject) objectTokens.get(SearchObjectType.CITY)
|
||||||
|
.getSearchObject()).getStreetGroup());
|
||||||
|
} else if (objectTokens.containsKey(SearchObjectType.VILLAGE)) {
|
||||||
|
criteria.setAddressFilter(((StreetGroupSearchObject) objectTokens.get(SearchObjectType.VILLAGE)
|
||||||
|
.getSearchObject()).getStreetGroup());
|
||||||
|
} else if (objectTokens.containsKey(SearchObjectType.POSTCODE)) {
|
||||||
|
criteria.setAddressFilter(((StreetGroupSearchObject) objectTokens.get(SearchObjectType.POSTCODE)
|
||||||
|
.getSearchObject()).getStreetGroup());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean processPoiSearchObject(PoiSearchObject poiSearchObject) {
|
public boolean processPoiSearchObject(PoiSearchObject poiSearchObject) {
|
||||||
|
@ -117,7 +136,7 @@ public class SearchScope {
|
||||||
@Override
|
@Override
|
||||||
public int compare(SearchObject lhs, SearchObject rhs) {
|
public int compare(SearchObject lhs, SearchObject rhs) {
|
||||||
int res = Double.compare(lhs.getPriority(), rhs.getPriority());
|
int res = Double.compare(lhs.getPriority(), rhs.getPriority());
|
||||||
if (res == 0 && lhs.isSortByName() && rhs.isSortByName()) {
|
if (res == 0) {
|
||||||
return lhs.getName(lang).compareToIgnoreCase(rhs.getName(lang));
|
return lhs.getName(lang).compareToIgnoreCase(rhs.getName(lang));
|
||||||
} else {
|
} else {
|
||||||
return res;
|
return res;
|
||||||
|
@ -170,25 +189,27 @@ public class SearchScope {
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean processSearchObject(SearchObject searchObject) {
|
private boolean processSearchObject(SearchObject searchObject) {
|
||||||
double priority = 0d;
|
double priority = 0.0;
|
||||||
boolean sortByName = false;
|
|
||||||
switch (searchObject.getType()) {
|
switch (searchObject.getType()) {
|
||||||
|
case BUILDING:
|
||||||
|
priority = 3.0;
|
||||||
|
break;
|
||||||
case POI:
|
case POI:
|
||||||
priority = getPriorityByDistance(10, ((PoiSearchObject) searchObject).getDistance());
|
priority = getPriorityByDistance(10.0, ((PoiSearchObject) searchObject).getDistance());
|
||||||
break;
|
break;
|
||||||
case CITY:
|
case CITY:
|
||||||
case VILLAGE:
|
case VILLAGE:
|
||||||
case POSTCODE:
|
case POSTCODE:
|
||||||
float cityType = getCityType((StreetGroupSearchObject) searchObject);
|
double cityType = getCityType((StreetGroupSearchObject) searchObject);
|
||||||
priority = (getPriorityByDistance(citySelected
|
priority = (getPriorityByDistance(citySelected
|
||||||
? 20f : 7f + cityType, ((StreetGroupSearchObject) searchObject).getDistance()));
|
? 20.0 : 7.0 + cityType, ((StreetGroupSearchObject) searchObject).getDistance()));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case STREET:
|
case STREET:
|
||||||
StreetSearchObject streetSearchObject = (StreetSearchObject) searchObject;
|
StreetSearchObject streetSearchObject = (StreetSearchObject) searchObject;
|
||||||
Street street = streetSearchObject.getStreet();
|
Street street = streetSearchObject.getStreet();
|
||||||
if (!citySelected) {
|
if (!citySelected) {
|
||||||
priority = getPriorityByDistance(9f, streetSearchObject.getDistance());
|
priority = getPriorityByDistance(9.0, streetSearchObject.getDistance());
|
||||||
} else {
|
} else {
|
||||||
boolean streetFromSelectedCity = false;
|
boolean streetFromSelectedCity = false;
|
||||||
for (SearchToken st : objectTokens.values()) {
|
for (SearchToken st : objectTokens.values()) {
|
||||||
|
@ -209,33 +230,31 @@ public class SearchScope {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (streetFromSelectedCity) {
|
if (streetFromSelectedCity) {
|
||||||
priority = 3f;
|
priority = 3.0;
|
||||||
sortByName = true;
|
|
||||||
} else {
|
} else {
|
||||||
priority = getPriorityByDistance(9f, streetSearchObject.getDistance());
|
priority = getPriorityByDistance(9.0, streetSearchObject.getDistance());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
searchObject.setPriority(priority);
|
searchObject.setPriority(priority);
|
||||||
searchObject.setSortByName(sortByName);
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private float getCityType(StreetGroupSearchObject searchObject) {
|
private double getCityType(StreetGroupSearchObject searchObject) {
|
||||||
if (searchObject.getStreetGroup().getType() == ObfAddressStreetGroupType.CityOrTown) {
|
if (searchObject.getStreetGroup().getType() == ObfAddressStreetGroupType.CityOrTown) {
|
||||||
if (searchObject.getStreetGroup().getSubtype() == ObfAddressStreetGroupSubtype.City) {
|
if (searchObject.getStreetGroup().getSubtype() == ObfAddressStreetGroupSubtype.City) {
|
||||||
return 1f;
|
return 1.0;
|
||||||
} else if (searchObject.getStreetGroup().getSubtype() == ObfAddressStreetGroupSubtype.Town) {
|
} else if (searchObject.getStreetGroup().getSubtype() == ObfAddressStreetGroupSubtype.Town) {
|
||||||
return 1.5f;
|
return 1.5;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 2.5f;
|
return 2.5;
|
||||||
}
|
}
|
||||||
|
|
||||||
private double getPriorityByDistance(double priority, double distance) {
|
private double getPriorityByDistance(double priority, double distance) {
|
||||||
return priority + 1d - (1d / (1d + distance));
|
return priority + 1.0 - (1.0 / (1.0 + distance));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateDistance(SearchPositionObject item) {
|
private void updateDistance(SearchPositionObject item) {
|
||||||
|
|
|
@ -0,0 +1,31 @@
|
||||||
|
package net.osmand.core.samples.android.sample1.search.objects;
|
||||||
|
|
||||||
|
import net.osmand.core.jni.Building;
|
||||||
|
import net.osmand.core.jni.PointI;
|
||||||
|
import net.osmand.core.jni.QStringStringHash;
|
||||||
|
|
||||||
|
public class BuildingSearchObject extends SearchPositionObject {
|
||||||
|
|
||||||
|
public BuildingSearchObject(Building building) {
|
||||||
|
super(SearchObjectType.BUILDING, building);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Building getBuilding() {
|
||||||
|
return (Building) getInternalObject();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PointI getPosition31() {
|
||||||
|
return getBuilding().getPosition31();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getNativeName() {
|
||||||
|
return getBuilding().getNativeName();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected QStringStringHash getLocalizedNames() {
|
||||||
|
return getBuilding().getLocalizedNames();
|
||||||
|
}
|
||||||
|
}
|
|
@ -9,6 +9,7 @@ public abstract class SearchObject {
|
||||||
VILLAGE,
|
VILLAGE,
|
||||||
POSTCODE,
|
POSTCODE,
|
||||||
STREET,
|
STREET,
|
||||||
|
STREET_INTERSECTION,
|
||||||
BUILDING,
|
BUILDING,
|
||||||
POI_TYPE,
|
POI_TYPE,
|
||||||
POI_FILTER,
|
POI_FILTER,
|
||||||
|
@ -20,7 +21,6 @@ public abstract class SearchObject {
|
||||||
private Object internalObject;
|
private Object internalObject;
|
||||||
|
|
||||||
private double priority;
|
private double priority;
|
||||||
private boolean sortByName;
|
|
||||||
|
|
||||||
protected SearchObject(SearchObjectType type, Object internalObject) {
|
protected SearchObject(SearchObjectType type, Object internalObject) {
|
||||||
this.type = type;
|
this.type = type;
|
||||||
|
@ -67,14 +67,6 @@ public abstract class SearchObject {
|
||||||
this.priority = priority;
|
this.priority = priority;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isSortByName() {
|
|
||||||
return sortByName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setSortByName(boolean sortByName) {
|
|
||||||
this.sortByName = sortByName;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected abstract QStringStringHash getLocalizedNames();
|
protected abstract QStringStringHash getLocalizedNames();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -1,16 +1,25 @@
|
||||||
package net.osmand.core.samples.android.sample1.search.objects;
|
package net.osmand.core.samples.android.sample1.search.objects;
|
||||||
|
|
||||||
import net.osmand.core.jni.Address;
|
import net.osmand.core.jni.Address;
|
||||||
|
import net.osmand.core.jni.Building;
|
||||||
import net.osmand.core.jni.OsmAndCoreJNI;
|
import net.osmand.core.jni.OsmAndCoreJNI;
|
||||||
import net.osmand.core.jni.Street;
|
import net.osmand.core.jni.Street;
|
||||||
import net.osmand.core.jni.StreetGroup;
|
import net.osmand.core.jni.StreetGroup;
|
||||||
|
import net.osmand.core.jni.StreetIntersection;
|
||||||
|
|
||||||
public class SearchObjectsHelper {
|
public class SearchObjectsHelper {
|
||||||
|
|
||||||
public static SearchPositionObject getAddressObject(Address address) {
|
public static SearchPositionObject getAddressObject(Address address) {
|
||||||
|
|
||||||
switch (address.getAddressType()) {
|
switch (address.getAddressType()) {
|
||||||
//todo add Building type to Address class
|
case Building:
|
||||||
|
BuildingInternal building = new BuildingInternal(address);
|
||||||
|
return new BuildingSearchObject(building);
|
||||||
|
|
||||||
|
case StreetIntersection:
|
||||||
|
StreetIntercestionInternal streetIntersection = new StreetIntercestionInternal(address);
|
||||||
|
return new StreetIntersectionSearchObject(streetIntersection);
|
||||||
|
|
||||||
case Street:
|
case Street:
|
||||||
StreetInternal street = new StreetInternal(address);
|
StreetInternal street = new StreetInternal(address);
|
||||||
return new StreetSearchObject(street);
|
return new StreetSearchObject(street);
|
||||||
|
@ -30,6 +39,18 @@ public class SearchObjectsHelper {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static class BuildingInternal extends Building {
|
||||||
|
public BuildingInternal(Address address) {
|
||||||
|
super(OsmAndCoreJNI.Street_SWIGSmartPtrUpcast(Address.getCPtr(address)), false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class StreetIntercestionInternal extends StreetIntersection {
|
||||||
|
public StreetIntercestionInternal(Address address) {
|
||||||
|
super(OsmAndCoreJNI.Street_SWIGSmartPtrUpcast(Address.getCPtr(address)), false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static class StreetInternal extends Street {
|
private static class StreetInternal extends Street {
|
||||||
public StreetInternal(Address address) {
|
public StreetInternal(Address address) {
|
||||||
super(OsmAndCoreJNI.Street_SWIGSmartPtrUpcast(Address.getCPtr(address)), false);
|
super(OsmAndCoreJNI.Street_SWIGSmartPtrUpcast(Address.getCPtr(address)), false);
|
||||||
|
|
|
@ -0,0 +1,31 @@
|
||||||
|
package net.osmand.core.samples.android.sample1.search.objects;
|
||||||
|
|
||||||
|
import net.osmand.core.jni.PointI;
|
||||||
|
import net.osmand.core.jni.QStringStringHash;
|
||||||
|
import net.osmand.core.jni.StreetIntersection;
|
||||||
|
|
||||||
|
public class StreetIntersectionSearchObject extends SearchPositionObject {
|
||||||
|
|
||||||
|
public StreetIntersectionSearchObject(StreetIntersection streetIntersection) {
|
||||||
|
super(SearchObjectType.STREET_INTERSECTION, streetIntersection);
|
||||||
|
}
|
||||||
|
|
||||||
|
public StreetIntersection getStreetIntersection() {
|
||||||
|
return (StreetIntersection) getInternalObject();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PointI getPosition31() {
|
||||||
|
return getStreetIntersection().getPosition31();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getNativeName() {
|
||||||
|
return getStreetIntersection().getNativeName();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected QStringStringHash getLocalizedNames() {
|
||||||
|
return getStreetIntersection().getLocalizedNames();
|
||||||
|
}
|
||||||
|
}
|
|
@ -148,7 +148,6 @@ public class CoreSearchRequest extends SearchRequest {
|
||||||
// Setup Addresses by name search
|
// Setup Addresses by name search
|
||||||
AddressesByNameSearch addrByNameSearch = new AddressesByNameSearch(searchScope.getObfsCollection());
|
AddressesByNameSearch addrByNameSearch = new AddressesByNameSearch(searchScope.getObfsCollection());
|
||||||
final AddressesByNameSearch.Criteria addrByNameCriteria = new AddressesByNameSearch.Criteria();
|
final AddressesByNameSearch.Criteria addrByNameCriteria = new AddressesByNameSearch.Criteria();
|
||||||
//todo implement StreetGroup and Street parameters in AddressesByNameSearch.Criteria and apply them here
|
|
||||||
addrByNameCriteria.setName(keyword);
|
addrByNameCriteria.setName(keyword);
|
||||||
if (searchScope.getObfAreaFilter() != null) {
|
if (searchScope.getObfAreaFilter() != null) {
|
||||||
addrByNameCriteria.setObfInfoAreaFilter(new NullableAreaI(searchScope.getObfAreaFilter()));
|
addrByNameCriteria.setObfInfoAreaFilter(new NullableAreaI(searchScope.getObfAreaFilter()));
|
||||||
|
|
Loading…
Reference in a new issue