Fix clothes and other duplicate poi types in poi search
This commit is contained in:
parent
5afba1e0f9
commit
57b288481a
2 changed files with 21 additions and 8 deletions
|
@ -1,7 +1,9 @@
|
|||
package net.osmand.osm;
|
||||
|
||||
import net.osmand.CollatorStringMatcher;
|
||||
import net.osmand.PlatformUtil;
|
||||
import net.osmand.StringMatcher;
|
||||
import net.osmand.CollatorStringMatcher.StringMatcherMode;
|
||||
import net.osmand.data.Amenity;
|
||||
import net.osmand.util.Algorithms;
|
||||
|
||||
|
@ -166,8 +168,8 @@ public class MapPoiTypes {
|
|||
return translation;
|
||||
}
|
||||
|
||||
public Map<String, AbstractPoiType> getAllTypesTranslatedNames(StringMatcher matcher) {
|
||||
Map<String, AbstractPoiType> tm = new TreeMap<String, AbstractPoiType>(Collator.getInstance());
|
||||
public List<AbstractPoiType> getAllTypesTranslatedNames(StringMatcher matcher) {
|
||||
List<AbstractPoiType> tm = new ArrayList<AbstractPoiType>();
|
||||
for (PoiCategory pc : categories) {
|
||||
if(pc == otherMapCategory) {
|
||||
continue;
|
||||
|
@ -187,9 +189,9 @@ public class MapPoiTypes {
|
|||
return tm;
|
||||
}
|
||||
|
||||
private void addIf(Map<String, AbstractPoiType> tm, AbstractPoiType pc, StringMatcher matcher) {
|
||||
private void addIf(List<AbstractPoiType> tm, AbstractPoiType pc, StringMatcher matcher) {
|
||||
if(matcher.matches(pc.getTranslation()) || matcher.matches(pc.getKeyName().replace('_', ' '))) {
|
||||
tm.put(pc.getTranslation(), pc);
|
||||
tm.add(pc);
|
||||
}
|
||||
List<PoiType> additionals = pc.getPoiAdditionals();
|
||||
if (additionals != null) {
|
||||
|
@ -502,10 +504,10 @@ public class MapPoiTypes {
|
|||
List<PoiFilter> lf = DEFAULT_INSTANCE.getTopVisibleFilters();
|
||||
for(PoiFilter l : lf) {
|
||||
System.out.println("----------------- " + l.getKeyName());
|
||||
print("", l);
|
||||
// print("", l);
|
||||
Map<PoiCategory, LinkedHashSet<String>> m =
|
||||
l.putTypes(new LinkedHashMap<PoiCategory, LinkedHashSet<String>>());
|
||||
System.out.println(m);
|
||||
// System.out.println(m);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -3,7 +3,10 @@
|
|||
*/
|
||||
package net.osmand.plus.activities.search;
|
||||
|
||||
import java.text.Collator;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
@ -139,9 +142,17 @@ public class SearchPoiFilterFragment extends OsmAndListFragment implements Searc
|
|||
filters.add(pf);
|
||||
}
|
||||
}
|
||||
Map<String, AbstractPoiType> res =
|
||||
List<AbstractPoiType> res =
|
||||
app.getPoiTypes().getAllTypesTranslatedNames(new CollatorStringMatcher(s, StringMatcherMode.CHECK_STARTS_FROM_SPACE));
|
||||
for(AbstractPoiType p : res.values()) {
|
||||
final Collator inst = Collator.getInstance();
|
||||
Collections.sort(res, new Comparator<AbstractPoiType>() {
|
||||
@Override
|
||||
public int compare(AbstractPoiType lhs, AbstractPoiType rhs) {
|
||||
return inst.compare(lhs.getTranslation(), rhs.getTranslation());
|
||||
}
|
||||
|
||||
});
|
||||
for(AbstractPoiType p : res) {
|
||||
filters.add(p);
|
||||
}
|
||||
filters.add(poiFilters.getSearchByNamePOIFilter());
|
||||
|
|
Loading…
Reference in a new issue