Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
67d58defcd
5 changed files with 69 additions and 49 deletions
|
@ -7,6 +7,7 @@ import net.osmand.ResultMatcher;
|
||||||
import net.osmand.binary.BinaryMapIndexReader;
|
import net.osmand.binary.BinaryMapIndexReader;
|
||||||
import net.osmand.data.Amenity;
|
import net.osmand.data.Amenity;
|
||||||
import net.osmand.data.LatLon;
|
import net.osmand.data.LatLon;
|
||||||
|
import net.osmand.osm.AbstractPoiType;
|
||||||
import net.osmand.osm.MapPoiTypes;
|
import net.osmand.osm.MapPoiTypes;
|
||||||
import net.osmand.search.core.CustomSearchPoiFilter;
|
import net.osmand.search.core.CustomSearchPoiFilter;
|
||||||
import net.osmand.search.core.ObjectType;
|
import net.osmand.search.core.ObjectType;
|
||||||
|
@ -220,6 +221,8 @@ public class SearchUICore {
|
||||||
}
|
}
|
||||||
return MapUtils.getDistance(r1.location, r2.location) < similarityRadius;
|
return MapUtils.getDistance(r1.location, r2.location) < similarityRadius;
|
||||||
}
|
}
|
||||||
|
} else if (r1.object != null && r2.object != null) {
|
||||||
|
return r1.object == r2.object;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,20 +1,7 @@
|
||||||
package net.osmand.search.core;
|
package net.osmand.search.core;
|
||||||
|
|
||||||
import gnu.trove.list.array.TIntArrayList;
|
import com.jwetherell.openmap.common.LatLonPoint;
|
||||||
|
import com.jwetherell.openmap.common.UTMPoint;
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.Comparator;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.LinkedHashMap;
|
|
||||||
import java.util.LinkedHashSet;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Map.Entry;
|
|
||||||
import java.util.TreeMap;
|
|
||||||
import java.util.TreeSet;
|
|
||||||
|
|
||||||
import net.osmand.CollatorStringMatcher.StringMatcherMode;
|
import net.osmand.CollatorStringMatcher.StringMatcherMode;
|
||||||
import net.osmand.ResultMatcher;
|
import net.osmand.ResultMatcher;
|
||||||
|
@ -44,8 +31,20 @@ import net.osmand.util.GeoPointParserUtil;
|
||||||
import net.osmand.util.GeoPointParserUtil.GeoParsedPoint;
|
import net.osmand.util.GeoPointParserUtil.GeoParsedPoint;
|
||||||
import net.osmand.util.MapUtils;
|
import net.osmand.util.MapUtils;
|
||||||
|
|
||||||
import com.jwetherell.openmap.common.LatLonPoint;
|
import java.io.IOException;
|
||||||
import com.jwetherell.openmap.common.UTMPoint;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.Comparator;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.LinkedHashMap;
|
||||||
|
import java.util.LinkedHashSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Map.Entry;
|
||||||
|
import java.util.TreeMap;
|
||||||
|
|
||||||
|
import gnu.trove.list.array.TIntArrayList;
|
||||||
|
|
||||||
|
|
||||||
public class SearchCoreFactory {
|
public class SearchCoreFactory {
|
||||||
|
@ -533,35 +532,43 @@ public class SearchCoreFactory {
|
||||||
categories = types.getCategories(false);
|
categories = types.getCategories(false);
|
||||||
}
|
}
|
||||||
// results.clear();
|
// results.clear();
|
||||||
TreeMap<String, AbstractPoiType> results = new TreeMap<String, AbstractPoiType>() ;
|
List<AbstractPoiType> results = new ArrayList<AbstractPoiType>() ;
|
||||||
NameStringMatcher nm = phrase.getNameStringMatcher();
|
NameStringMatcher nm = phrase.getNameStringMatcher();
|
||||||
for (PoiFilter pf : topVisibleFilters) {
|
for (PoiFilter pf : topVisibleFilters) {
|
||||||
if (!phrase.isUnknownSearchWordPresent() || nm.matches(pf.getTranslation())) {
|
if (!phrase.isUnknownSearchWordPresent() || nm.matches(pf.getTranslation())) {
|
||||||
results.put(pf.getTranslation(), pf);
|
results.add(pf);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (phrase.isUnknownSearchWordPresent()) {
|
if (phrase.isUnknownSearchWordPresent()) {
|
||||||
for (PoiCategory c : categories) {
|
for (PoiCategory c : categories) {
|
||||||
if (!phrase.isUnknownSearchWordPresent() || nm.matches(c.getTranslation())) {
|
if (!results.contains(c) && nm.matches(c.getTranslation())) {
|
||||||
results.put(c.getTranslation(), c);
|
results.add(c);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Iterator<Entry<String, PoiType>> it = translatedNames.entrySet().iterator();
|
Iterator<Entry<String, PoiType>> it = translatedNames.entrySet().iterator();
|
||||||
while (it.hasNext()) {
|
while (it.hasNext()) {
|
||||||
Entry<String, PoiType> e = it.next();
|
Entry<String, PoiType> e = it.next();
|
||||||
if (e.getValue().getCategory() != types.getOtherMapCategory()
|
PoiType pt = e.getValue();
|
||||||
&& (nm.matches(e.getKey()) || nm.matches(e.getValue().getTranslation()))) {
|
if (pt.getCategory() != types.getOtherMapCategory()) {
|
||||||
results.put(e.getValue().getTranslation(), e.getValue());
|
if (!results.contains(pt) && (nm.matches(e.getKey()) || nm.matches(pt.getTranslation()))) {
|
||||||
|
results.add(pt);
|
||||||
|
}
|
||||||
|
List<PoiType> additionals = pt.getPoiAdditionals();
|
||||||
|
if (additionals != null) {
|
||||||
|
for (PoiType a : additionals) {
|
||||||
|
if (!a.isReference() && !results.contains(a) && (nm.matches(a.getKeyName()) || nm.matches(a.getTranslation()))) {
|
||||||
|
results.add(a);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Iterator<Entry<String, AbstractPoiType>> it = results.entrySet().iterator();
|
}
|
||||||
while(it.hasNext()) {
|
}
|
||||||
Entry<String, AbstractPoiType> p = it.next();
|
}
|
||||||
|
for (AbstractPoiType pt : results) {
|
||||||
SearchResult res = new SearchResult(phrase);
|
SearchResult res = new SearchResult(phrase);
|
||||||
res.localeName = p.getKey();
|
res.localeName = pt.getTranslation();
|
||||||
res.object = p.getValue();
|
res.object = pt;
|
||||||
res.priority = SEARCH_AMENITY_TYPE_PRIORITY;
|
res.priority = SEARCH_AMENITY_TYPE_PRIORITY + (pt instanceof PoiCategory ? 0.0 : 0.1);
|
||||||
res.priorityDistance = 0;
|
res.priorityDistance = 0;
|
||||||
res.objectType = ObjectType.POI_TYPE;
|
res.objectType = ObjectType.POI_TYPE;
|
||||||
resultMatcher.publish(res);
|
resultMatcher.publish(res);
|
||||||
|
|
|
@ -36,6 +36,7 @@ import android.widget.ListView;
|
||||||
import android.widget.ProgressBar;
|
import android.widget.ProgressBar;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
import net.osmand.AndroidUtils;
|
import net.osmand.AndroidUtils;
|
||||||
import net.osmand.Location;
|
import net.osmand.Location;
|
||||||
import net.osmand.ResultMatcher;
|
import net.osmand.ResultMatcher;
|
||||||
|
@ -43,6 +44,7 @@ import net.osmand.data.LatLon;
|
||||||
import net.osmand.data.PointDescription;
|
import net.osmand.data.PointDescription;
|
||||||
import net.osmand.osm.AbstractPoiType;
|
import net.osmand.osm.AbstractPoiType;
|
||||||
import net.osmand.osm.PoiCategory;
|
import net.osmand.osm.PoiCategory;
|
||||||
|
import net.osmand.osm.PoiType;
|
||||||
import net.osmand.plus.AppInitializer;
|
import net.osmand.plus.AppInitializer;
|
||||||
import net.osmand.plus.AppInitializer.AppInitializeListener;
|
import net.osmand.plus.AppInitializer.AppInitializeListener;
|
||||||
import net.osmand.plus.GPXUtilities;
|
import net.osmand.plus.GPXUtilities;
|
||||||
|
@ -611,16 +613,16 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
|
||||||
}
|
}
|
||||||
|
|
||||||
public void show() {
|
public void show() {
|
||||||
paused = false;
|
|
||||||
if (useMapCenter) {
|
if (useMapCenter) {
|
||||||
LatLon mapCenter = getMapActivity().getMapView().getCurrentRotatedTileBox().getCenterLatLon();
|
LatLon mapCenter = getMapActivity().getMapView().getCurrentRotatedTileBox().getCenterLatLon();
|
||||||
SearchSettings ss = searchUICore.getSearchSettings().setOriginalLocation(
|
SearchSettings ss = searchUICore.getSearchSettings().setOriginalLocation(
|
||||||
new LatLon(mapCenter.getLatitude(), mapCenter.getLongitude()));
|
new LatLon(mapCenter.getLatitude(), mapCenter.getLongitude()));
|
||||||
searchUICore.updateSettings(ss);
|
searchUICore.updateSettings(ss);
|
||||||
updateUseMapCenterUI();
|
updateUseMapCenterUI();
|
||||||
forceUpdateLocationUI(mapCenter, null);
|
updateLocationUI(mapCenter, null);
|
||||||
}
|
}
|
||||||
getDialog().show();
|
getDialog().show();
|
||||||
|
paused = false;
|
||||||
hidden = false;
|
hidden = false;
|
||||||
if (interruptedSearch) {
|
if (interruptedSearch) {
|
||||||
interruptedSearch = false;
|
interruptedSearch = false;
|
||||||
|
@ -1142,6 +1144,26 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
|
||||||
}
|
}
|
||||||
|
|
||||||
public void completeQueryWithObject(SearchResult sr) {
|
public void completeQueryWithObject(SearchResult sr) {
|
||||||
|
if (sr.object instanceof PoiType && ((PoiType) sr.object).isAdditional()) {
|
||||||
|
PoiType additional = (PoiType) sr.object;
|
||||||
|
AbstractPoiType parent = additional.getParentType();
|
||||||
|
if (parent != null) {
|
||||||
|
PoiUIFilter custom = app.getPoiFilters().getFilterById(PoiUIFilter.STD_PREFIX + parent.getKeyName());
|
||||||
|
if (custom != null) {
|
||||||
|
custom.clearFilter();
|
||||||
|
custom.updateTypesToAccept(parent);
|
||||||
|
custom.setFilterByName(additional.getKeyName().replace('_', ':').toLowerCase());
|
||||||
|
|
||||||
|
SearchPhrase phrase = searchUICore.getPhrase();
|
||||||
|
sr = new SearchResult(phrase);
|
||||||
|
sr.localeName = custom.getName();
|
||||||
|
sr.object = custom;
|
||||||
|
sr.priority = SEARCH_AMENITY_TYPE_PRIORITY;
|
||||||
|
sr.priorityDistance = 0;
|
||||||
|
sr.objectType = ObjectType.POI_TYPE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
searchUICore.selectSearchResult(sr);
|
searchUICore.selectSearchResult(sr);
|
||||||
String txt = searchUICore.getPhrase().getText(true);
|
String txt = searchUICore.getPhrase().getText(true);
|
||||||
searchQuery = txt;
|
searchQuery = txt;
|
||||||
|
@ -1326,20 +1348,6 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void forceUpdateLocationUI(LatLon latLon, Float heading) {
|
|
||||||
if (latLon != null) {
|
|
||||||
if (mainSearchFragment != null) {
|
|
||||||
mainSearchFragment.updateLocation(latLon, heading);
|
|
||||||
}
|
|
||||||
if (historySearchFragment != null) {
|
|
||||||
historySearchFragment.updateLocation(latLon, heading);
|
|
||||||
}
|
|
||||||
if (categoriesSearchFragment != null) {
|
|
||||||
categoriesSearchFragment.updateLocation(latLon, heading);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void updateUseMapCenterUI() {
|
private void updateUseMapCenterUI() {
|
||||||
if (!paused && !cancelPrev) {
|
if (!paused && !cancelPrev) {
|
||||||
if (mainSearchFragment != null) {
|
if (mainSearchFragment != null) {
|
||||||
|
|
|
@ -11,6 +11,7 @@ import android.widget.CheckBox;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import net.osmand.AndroidUtils;
|
import net.osmand.AndroidUtils;
|
||||||
import net.osmand.Location;
|
import net.osmand.Location;
|
||||||
import net.osmand.data.Amenity;
|
import net.osmand.data.Amenity;
|
||||||
|
@ -405,7 +406,6 @@ public class QuickSearchListAdapter extends ArrayAdapter<QuickSearchListItem> {
|
||||||
private void updateDistanceDirection(View view, QuickSearchListItem listItem) {
|
private void updateDistanceDirection(View view, QuickSearchListItem listItem) {
|
||||||
TextView distanceText = (TextView) view.findViewById(R.id.distance);
|
TextView distanceText = (TextView) view.findViewById(R.id.distance);
|
||||||
ImageView direction = (ImageView) view.findViewById(R.id.direction);
|
ImageView direction = (ImageView) view.findViewById(R.id.direction);
|
||||||
/*
|
|
||||||
SearchPhrase phrase = listItem.getSearchResult().requiredSearchPhrase;
|
SearchPhrase phrase = listItem.getSearchResult().requiredSearchPhrase;
|
||||||
LatLon loc = location;
|
LatLon loc = location;
|
||||||
if(phrase != null && useMapCenter) {
|
if(phrase != null && useMapCenter) {
|
||||||
|
@ -414,8 +414,7 @@ public class QuickSearchListAdapter extends ArrayAdapter<QuickSearchListItem> {
|
||||||
loc = ol;
|
loc = ol;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
DashLocationFragment.updateLocationView(useMapCenter, loc,
|
||||||
DashLocationFragment.updateLocationView(useMapCenter, location,
|
|
||||||
heading, direction, distanceText,
|
heading, direction, distanceText,
|
||||||
listItem.getSearchResult().location.getLatitude(),
|
listItem.getSearchResult().location.getLatitude(),
|
||||||
listItem.getSearchResult().location.getLongitude(),
|
listItem.getSearchResult().location.getLongitude(),
|
||||||
|
|
|
@ -266,6 +266,9 @@ public class QuickSearchListItem {
|
||||||
((PoiType) abstractPoiType).getOsmTag() + "_" + ((PoiType) abstractPoiType).getOsmValue())) {
|
((PoiType) abstractPoiType).getOsmTag() + "_" + ((PoiType) abstractPoiType).getOsmValue())) {
|
||||||
return ((PoiType) abstractPoiType).getOsmTag() + "_" + ((PoiType) abstractPoiType).getOsmValue();
|
return ((PoiType) abstractPoiType).getOsmTag() + "_" + ((PoiType) abstractPoiType).getOsmValue();
|
||||||
}
|
}
|
||||||
|
if (abstractPoiType instanceof PoiType && ((PoiType) abstractPoiType).getParentType() != null) {
|
||||||
|
return getPoiTypeIconName(((PoiType) abstractPoiType).getParentType());
|
||||||
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue