Implement new poi structure
This commit is contained in:
parent
89b5d3de75
commit
3717464598
32 changed files with 595 additions and 621 deletions
|
@ -39,11 +39,11 @@ import net.osmand.binary.BinaryMapRouteReaderAdapter.RouteSubregion;
|
|||
import net.osmand.binary.BinaryMapRouteReaderAdapter.RouteTypeRule;
|
||||
import net.osmand.binary.BinaryMapTransportReaderAdapter.TransportIndex;
|
||||
import net.osmand.data.Amenity;
|
||||
import net.osmand.data.AmenityType;
|
||||
import net.osmand.data.Building;
|
||||
import net.osmand.data.City;
|
||||
import net.osmand.data.MapObject;
|
||||
import net.osmand.data.Street;
|
||||
import net.osmand.osm.PoiCategory;
|
||||
import net.osmand.util.MapUtils;
|
||||
|
||||
import com.google.protobuf.CodedOutputStream;
|
||||
|
@ -841,7 +841,7 @@ public class BinaryInspector {
|
|||
verbose.getZoom(),
|
||||
new SearchPoiTypeFilter() {
|
||||
@Override
|
||||
public boolean accept(AmenityType type, String subcategory) {
|
||||
public boolean accept(PoiCategory type, String subcategory) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -52,7 +52,6 @@ import net.osmand.binary.OsmandOdb.OsmAndMapIndex.MapDataBox;
|
|||
import net.osmand.binary.OsmandOdb.OsmAndMapIndex.MapEncodingRule;
|
||||
import net.osmand.binary.OsmandOdb.OsmAndMapIndex.MapRootLevel;
|
||||
import net.osmand.data.Amenity;
|
||||
import net.osmand.data.AmenityType;
|
||||
import net.osmand.data.Building;
|
||||
import net.osmand.data.City;
|
||||
import net.osmand.data.LatLon;
|
||||
|
@ -60,6 +59,8 @@ import net.osmand.data.MapObject;
|
|||
import net.osmand.data.Street;
|
||||
import net.osmand.data.TransportRoute;
|
||||
import net.osmand.data.TransportStop;
|
||||
import net.osmand.osm.MapPoiTypes;
|
||||
import net.osmand.osm.PoiCategory;
|
||||
import net.osmand.osm.edit.Way;
|
||||
import net.osmand.util.Algorithms;
|
||||
import net.osmand.util.MapUtils;
|
||||
|
@ -1240,7 +1241,7 @@ public class BinaryMapIndexReader {
|
|||
return req.getSearchResults();
|
||||
}
|
||||
|
||||
public Map<AmenityType, List<String> > searchPoiCategoriesByName(String query, Map<AmenityType, List<String> > map) throws IOException {
|
||||
public Map<PoiCategory, List<String> > searchPoiCategoriesByName(String query, Map<PoiCategory, List<String> > map) throws IOException {
|
||||
if (query == null || query.length() == 0) {
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
|
@ -1249,7 +1250,7 @@ public class BinaryMapIndexReader {
|
|||
poiAdapter.initCategories(poiIndex);
|
||||
for (int i = 0; i < poiIndex.categories.size(); i++) {
|
||||
String cat = poiIndex.categories.get(i);
|
||||
AmenityType catType = poiIndex.categoriesType.get(i);
|
||||
PoiCategory catType = poiIndex.categoriesType.get(i);
|
||||
if (CollatorStringMatcher.cmatches(collator, cat, query, StringMatcherMode.CHECK_STARTS_FROM_SPACE)) {
|
||||
map.put(catType, null);
|
||||
} else {
|
||||
|
@ -1495,7 +1496,7 @@ public class BinaryMapIndexReader {
|
|||
|
||||
public static interface SearchPoiTypeFilter {
|
||||
|
||||
public boolean accept(AmenityType type, String subcategory);
|
||||
public boolean accept(PoiCategory type, String subcategory);
|
||||
|
||||
}
|
||||
|
||||
|
@ -1900,14 +1901,15 @@ public class BinaryMapIndexReader {
|
|||
|
||||
private static void testSearchOnthePath(BinaryMapIndexReader reader) throws IOException {
|
||||
float radius = 1000;
|
||||
final MapPoiTypes poiTypes = MapPoiTypes.getDefault();
|
||||
long now = System.currentTimeMillis();
|
||||
println("Searching poi on the path...");
|
||||
final List<Location> locations = readGPX(new File(
|
||||
""));
|
||||
SearchRequest<Amenity> req = buildSearchPoiRequest(locations, radius, new SearchPoiTypeFilter() {
|
||||
@Override
|
||||
public boolean accept(AmenityType type, String subcategory) {
|
||||
if (type == AmenityType.SHOP && subcategory.contains("super")) {
|
||||
public boolean accept(PoiCategory type, String subcategory) {
|
||||
if (type == poiTypes.getPoiCategoryByName("shop") && subcategory.contains("super")) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -2021,7 +2023,7 @@ public class BinaryMapIndexReader {
|
|||
|
||||
SearchRequest<Amenity> req = buildSearchPoiRequest(sleft, sright, stop, sbottom, -1, new SearchPoiTypeFilter() {
|
||||
@Override
|
||||
public boolean accept(AmenityType type, String subcategory) {
|
||||
public boolean accept(PoiCategory type, String subcategory) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -23,6 +23,9 @@ import net.osmand.data.Amenity;
|
|||
import net.osmand.data.Amenity.AmenityRoutePoint;
|
||||
import net.osmand.data.AmenityType;
|
||||
import net.osmand.data.LatLon;
|
||||
import net.osmand.osm.MapPoiTypes;
|
||||
import net.osmand.osm.PoiCategory;
|
||||
import net.osmand.osm.PoiType;
|
||||
import net.osmand.util.Algorithms;
|
||||
import net.osmand.util.MapUtils;
|
||||
import net.sf.junidecode.Junidecode;
|
||||
|
@ -50,7 +53,7 @@ public class BinaryMapPoiReaderAdapter {
|
|||
public static class PoiRegion extends BinaryIndexPart {
|
||||
|
||||
List<String> categories = new ArrayList<String>();
|
||||
List<AmenityType> categoriesType = new ArrayList<AmenityType>();
|
||||
List<PoiCategory> categoriesType = new ArrayList<PoiCategory>();
|
||||
List<List<String> > subcategories = new ArrayList<List<String> >();
|
||||
List<PoiSubType> subTypes = new ArrayList<PoiSubType>();
|
||||
|
||||
|
@ -101,9 +104,12 @@ public class BinaryMapPoiReaderAdapter {
|
|||
private CodedInputStream codedIS;
|
||||
private final BinaryMapIndexReader map;
|
||||
|
||||
private MapPoiTypes poiTypes;
|
||||
|
||||
protected BinaryMapPoiReaderAdapter(BinaryMapIndexReader map){
|
||||
this.codedIS = map.codedIS;
|
||||
this.map = map;
|
||||
this.poiTypes = MapPoiTypes.getDefault();
|
||||
}
|
||||
|
||||
private void skipUnknownField(int t) throws IOException {
|
||||
|
@ -199,7 +205,7 @@ public class BinaryMapPoiReaderAdapter {
|
|||
case OsmandOdb.OsmAndCategoryTable.CATEGORY_FIELD_NUMBER :
|
||||
String cat = codedIS.readString().intern();
|
||||
region.categories.add(cat);
|
||||
region.categoriesType.add(AmenityType.findOrCreateTypeNoReg(cat));
|
||||
region.categoriesType.add(poiTypes.getPoiCategoryByName(cat));
|
||||
region.subcategories.add(new ArrayList<String>());
|
||||
break;
|
||||
case OsmandOdb.OsmAndCategoryTable.SUBCATEGORIES_FIELD_NUMBER :
|
||||
|
@ -615,7 +621,7 @@ public class BinaryMapPoiReaderAdapter {
|
|||
int x = 0;
|
||||
int y = 0;
|
||||
StringBuilder retValue = new StringBuilder();
|
||||
AmenityType amenityType = null;
|
||||
PoiCategory amenityType = null;
|
||||
LinkedList<String> textTags = null;
|
||||
while(true){
|
||||
int t = codedIS.readTag();
|
||||
|
@ -688,7 +694,7 @@ public class BinaryMapPoiReaderAdapter {
|
|||
int cat = codedIS.readUInt32();
|
||||
int subcatId = cat >> SHIFT_BITS_CATEGORY;
|
||||
int catId = cat & CATEGORY_MASK;
|
||||
AmenityType type = AmenityType.OTHER;
|
||||
PoiCategory type = poiTypes.getOtherPoiCategory();
|
||||
String subtype = "";
|
||||
if (catId < region.categoriesType.size()) {
|
||||
type = region.categoriesType.get(catId);
|
||||
|
@ -756,7 +762,7 @@ public class BinaryMapPoiReaderAdapter {
|
|||
// }
|
||||
// break;
|
||||
case OsmandOdb.OsmAndPoiCategories.CATEGORIES_FIELD_NUMBER:
|
||||
AmenityType type = AmenityType.OTHER;
|
||||
PoiCategory type = poiTypes.getOtherPoiCategory();
|
||||
String subcat = "";
|
||||
int cat = codedIS.readUInt32();
|
||||
int subcatId = cat >> SHIFT_BITS_CATEGORY;
|
||||
|
|
|
@ -5,6 +5,7 @@ import java.util.LinkedHashMap;
|
|||
import java.util.Map;
|
||||
|
||||
import net.osmand.Location;
|
||||
import net.osmand.osm.PoiCategory;
|
||||
|
||||
|
||||
public class Amenity extends MapObject {
|
||||
|
@ -16,7 +17,7 @@ public class Amenity extends MapObject {
|
|||
|
||||
private static final long serialVersionUID = 132083949926339552L;
|
||||
private String subType;
|
||||
private AmenityType type;
|
||||
private PoiCategory type;
|
||||
// duplicate for fast access
|
||||
private String openingHours;
|
||||
private Map<String, String> additionalInfo;
|
||||
|
@ -31,7 +32,7 @@ public class Amenity extends MapObject {
|
|||
public Location pointB;
|
||||
}
|
||||
|
||||
public AmenityType getType(){
|
||||
public PoiCategory getType(){
|
||||
return type;
|
||||
}
|
||||
|
||||
|
@ -39,7 +40,7 @@ public class Amenity extends MapObject {
|
|||
return subType;
|
||||
}
|
||||
|
||||
public void setType(AmenityType type) {
|
||||
public void setType(PoiCategory type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
|
|
28
OsmAnd-java/src/net/osmand/osm/AbstractPoiType.java
Normal file
28
OsmAnd-java/src/net/osmand/osm/AbstractPoiType.java
Normal file
|
@ -0,0 +1,28 @@
|
|||
package net.osmand.osm;
|
||||
|
||||
public class AbstractPoiType {
|
||||
|
||||
protected final String keyName;
|
||||
protected final MapPoiTypes registry;
|
||||
|
||||
|
||||
|
||||
public AbstractPoiType(String keyName, MapPoiTypes registry) {
|
||||
this.keyName = keyName;
|
||||
this.registry = registry;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return keyName;
|
||||
}
|
||||
|
||||
public String getKeyName() {
|
||||
return keyName;
|
||||
}
|
||||
|
||||
public String getTranslation() {
|
||||
return registry.getTranslation(this);
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -5,23 +5,37 @@ import java.io.IOException;
|
|||
import java.io.InputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.TreeMap;
|
||||
|
||||
import net.osmand.PlatformUtil;
|
||||
import net.osmand.util.Algorithms;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
|
||||
|
||||
public class MapPoiTypes {
|
||||
private static MapPoiTypes DEFAULT_INSTANCE = null;
|
||||
private static final Log log = PlatformUtil.getLog(MapRenderingTypes.class);
|
||||
private String resourceName;
|
||||
private List<PoiCategory> categories = new ArrayList<PoiCategory>();
|
||||
private PoiCategory otherCategory;
|
||||
|
||||
static final String OSM_WIKI_CATEGORY = "osmwiki";
|
||||
private PoiTranslator poiTranslator = null;
|
||||
|
||||
public MapPoiTypes(String fileName){
|
||||
this.resourceName = fileName;
|
||||
}
|
||||
|
||||
public interface PoiTranslator {
|
||||
|
||||
public String getTranslation(AbstractPoiType type);
|
||||
}
|
||||
|
||||
public static MapPoiTypes getDefault() {
|
||||
if(DEFAULT_INSTANCE == null){
|
||||
DEFAULT_INSTANCE = new MapPoiTypes(null);
|
||||
|
@ -30,6 +44,81 @@ public class MapPoiTypes {
|
|||
return DEFAULT_INSTANCE;
|
||||
}
|
||||
|
||||
|
||||
public static MapPoiTypes initDefault(PoiTranslator pt) {
|
||||
MapPoiTypes df = getDefault();
|
||||
df.setPoiTranslator(pt);
|
||||
return df;
|
||||
}
|
||||
|
||||
|
||||
public PoiCategory getOtherPoiCategory() {
|
||||
return otherCategory;
|
||||
}
|
||||
|
||||
public PoiCategory getUserDefinedCategory() {
|
||||
return otherCategory;
|
||||
}
|
||||
|
||||
public PoiCategory getPoiCategoryByName(String name) {
|
||||
return getPoiCategoryByName(name, false);
|
||||
}
|
||||
|
||||
|
||||
public PoiCategory getPoiCategoryBySubtypeName(String name) {
|
||||
for(PoiCategory pc : categories) {
|
||||
PoiType pt = pc.getPoiTypeByKeyName(name);
|
||||
if(pt != null) {
|
||||
return pc;
|
||||
}
|
||||
}
|
||||
return otherCategory;
|
||||
}
|
||||
|
||||
public Map<String, PoiType> getAllTranslatedNames() {
|
||||
Map<String, PoiType> translation = new TreeMap<String, PoiType>();
|
||||
for(PoiCategory pc : categories) {
|
||||
for(PoiType pt : pc.getPoiTypes()) {
|
||||
translation.put(pt.getTranslation(), pt);
|
||||
}
|
||||
}
|
||||
return translation;
|
||||
}
|
||||
|
||||
public Map<String, PoiType> getAllTranslatedNames(PoiCategory pc) {
|
||||
Map<String, PoiType> translation = new TreeMap<String, PoiType>();
|
||||
for (PoiType pt : pc.getPoiTypes()) {
|
||||
translation.put(pt.getTranslation(), pt);
|
||||
}
|
||||
return translation;
|
||||
}
|
||||
|
||||
public PoiCategory getPoiCategoryByName(String name, boolean create) {
|
||||
if(name.equals("entertainment") && !create) {
|
||||
name = "leisure";
|
||||
}
|
||||
for(PoiCategory p : categories ) {
|
||||
if(p.getName().equals(name)) {
|
||||
return p;
|
||||
}
|
||||
}
|
||||
if(create) {
|
||||
PoiCategory lastCategory = new PoiCategory(this, name, categories.size());
|
||||
categories.add(lastCategory);
|
||||
return lastCategory;
|
||||
}
|
||||
return otherCategory;
|
||||
}
|
||||
|
||||
public PoiTranslator getPoiTranslator() {
|
||||
return poiTranslator;
|
||||
}
|
||||
|
||||
public void setPoiTranslator(PoiTranslator poiTranslator) {
|
||||
this.poiTranslator = poiTranslator;
|
||||
}
|
||||
|
||||
|
||||
protected void init(){
|
||||
InputStream is;
|
||||
try {
|
||||
|
@ -48,7 +137,7 @@ public class MapPoiTypes {
|
|||
if (tok == XmlPullParser.START_TAG) {
|
||||
String name = parser.getName();
|
||||
if (name.equals("poi_category")) {
|
||||
lastCategory = new PoiCategory(this, parser.getAttributeValue("","name"));
|
||||
lastCategory = new PoiCategory(this, parser.getAttributeValue("","name"), categories.size());
|
||||
categories.add(lastCategory);
|
||||
} else if (name.equals("poi_filter")) {
|
||||
PoiFilter tp = new PoiFilter(this, lastCategory,
|
||||
|
@ -65,9 +154,8 @@ public class MapPoiTypes {
|
|||
|
||||
if(lastFilter != null) {
|
||||
lastFilter.addPoiType(tp);
|
||||
} else {
|
||||
lastCategory.addPoiType(tp);
|
||||
}
|
||||
lastCategory.addPoiType(tp);
|
||||
}
|
||||
} else if (tok == XmlPullParser.END_TAG) {
|
||||
String name = parser.getName();
|
||||
|
@ -91,12 +179,22 @@ public class MapPoiTypes {
|
|||
e.printStackTrace();
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
findDefaultOtherCategory();
|
||||
}
|
||||
|
||||
private void findDefaultOtherCategory() {
|
||||
PoiCategory pc = getPoiCategoryByName("user_defined_other");
|
||||
if(pc == null) {
|
||||
throw new IllegalArgumentException("No poi category other");
|
||||
}
|
||||
otherCategory = pc;
|
||||
}
|
||||
|
||||
public List<PoiCategory> getCategories() {
|
||||
return categories;
|
||||
}
|
||||
|
||||
|
||||
private static void print(MapPoiTypes df) {
|
||||
List<PoiCategory> pc = df.getCategories();
|
||||
for(PoiCategory p : pc) {
|
||||
|
@ -120,5 +218,24 @@ public class MapPoiTypes {
|
|||
print(getDefault()) ;
|
||||
}
|
||||
|
||||
public String getTranslation(AbstractPoiType abstractPoiType) {
|
||||
String translation = null;
|
||||
if(poiTranslator != null) {
|
||||
translation = poiTranslator.getTranslation(abstractPoiType);
|
||||
}
|
||||
if(translation != null) {
|
||||
return translation;
|
||||
}
|
||||
return Algorithms.capitalizeFirstLetterAndLowercase(abstractPoiType.getName().replace('_', ' '));
|
||||
}
|
||||
|
||||
|
||||
public boolean isRegisteredType(PoiCategory t) {
|
||||
return getPoiCategoryByName(t.getKeyName()) != otherCategory;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -43,9 +43,6 @@ public class MapRenderingTypes {
|
|||
private static char TAG_DELIMETER = '/'; //$NON-NLS-1$
|
||||
|
||||
private String resourceName = null;
|
||||
private Map<AmenityType, Map<String, String>> amenityTypeNameToTagVal = null;
|
||||
private Map<String, AmenityType> amenityNameToType = null;
|
||||
private Map<String, Map<String, String>> amenityAllTypeNameToTagVal = null;
|
||||
|
||||
protected Map<String, MapRulType> types = null;
|
||||
protected List<MapRulType> typeList = new ArrayList<MapRulType>();
|
||||
|
@ -84,81 +81,6 @@ public class MapRenderingTypes {
|
|||
init();
|
||||
}
|
||||
}
|
||||
|
||||
public void getAmenityTagValue(AmenityType type, String subType, StringBuilder tag, StringBuilder value) {
|
||||
tag.setLength(0);
|
||||
tag.append(type.getDefaultTag());
|
||||
value.setLength(0);
|
||||
value.append(subType);
|
||||
Map<AmenityType, Map<String, String>> m = getAmenityTypeNameToTagVal();
|
||||
if (m.containsKey(type)) {
|
||||
Map<String, String> map = m.get(type);
|
||||
if (map.containsKey(subType)) {
|
||||
String res = map.get(subType);
|
||||
if (res != null) {
|
||||
int i = res.indexOf(' ');
|
||||
if (i != -1) {
|
||||
tag.setLength(0);
|
||||
tag.append(res.substring(0, i));
|
||||
value.setLength(0);
|
||||
value.append(res.substring(i + 1));
|
||||
} else {
|
||||
tag.setLength(0);
|
||||
tag.append(res);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private Map<AmenityType, Map<String, String>> getAmenityTypeNameToTagVal() {
|
||||
if (amenityTypeNameToTagVal == null) {
|
||||
Map<String, MapRulType> types = getEncodingRuleTypes();
|
||||
amenityTypeNameToTagVal = new LinkedHashMap<AmenityType, Map<String, String>>();
|
||||
for(MapRulType type : types.values()){
|
||||
if(type.poiCategory != null && type.targetTagValue == null) {
|
||||
if(!amenityTypeNameToTagVal.containsKey(type.poiCategory)) {
|
||||
amenityTypeNameToTagVal.put(type.poiCategory, new TreeMap<String, String>());
|
||||
}
|
||||
String name = type.getValue();
|
||||
if (name != null) {
|
||||
if (type.poiPrefix != null) {
|
||||
name = type.poiPrefix + name;
|
||||
amenityTypeNameToTagVal.get(type.poiCategory).put(name, type.getTag() + " " + type.getValue());
|
||||
} else {
|
||||
amenityTypeNameToTagVal.get(type.poiCategory).put(name, type.getTag());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return amenityTypeNameToTagVal;
|
||||
}
|
||||
|
||||
private Map<String, Map<String, String>> getAmenityAllTypeNameToTagVal() {
|
||||
if (amenityAllTypeNameToTagVal == null) {
|
||||
Map<String, MapRulType> types = getEncodingRuleTypes();
|
||||
amenityAllTypeNameToTagVal = new LinkedHashMap<String, Map<String, String>>();
|
||||
for(MapRulType type : types.values()){
|
||||
if(type.category != null && type.targetTagValue == null) {
|
||||
if(!amenityAllTypeNameToTagVal.containsKey(type.category)) {
|
||||
amenityAllTypeNameToTagVal.put(type.category, new TreeMap<String, String>());
|
||||
}
|
||||
String name = type.getValue();
|
||||
if (name != null) {
|
||||
if (type.poiPrefix != null) {
|
||||
name = type.poiPrefix + name;
|
||||
amenityAllTypeNameToTagVal.get(type.category).put(name, type.getTag() + " " + type.getValue());
|
||||
} else {
|
||||
amenityAllTypeNameToTagVal.get(type.category).put(name, type.getTag());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return amenityAllTypeNameToTagVal;
|
||||
}
|
||||
|
||||
public Collection<Map<String, String>> splitTagsIntoDifferentObjects(final Map<String, String> tags) {
|
||||
// check open sea maps tags
|
||||
boolean split = splitIsNeeded(tags);
|
||||
|
@ -230,43 +152,6 @@ public class MapRenderingTypes {
|
|||
return value;
|
||||
}
|
||||
|
||||
public Map<String, AmenityType> getAmenityNameToType(){
|
||||
if(amenityNameToType == null){
|
||||
amenityNameToType = new LinkedHashMap<String, AmenityType>();
|
||||
Map<AmenityType, Map<String, String>> map = getAmenityTypeNameToTagVal();
|
||||
Iterator<Entry<AmenityType, Map<String, String>>> iter = map.entrySet().iterator();
|
||||
while(iter.hasNext()){
|
||||
Entry<AmenityType, Map<String, String>> e = iter.next();
|
||||
for(String t : e.getValue().keySet()){
|
||||
if (t != null) {
|
||||
if (amenityNameToType.containsKey(t)) {
|
||||
System.err.println("Conflict " + t + " " + amenityNameToType.get(t) + " <> " + e.getKey());
|
||||
} else {
|
||||
amenityNameToType.put(t, e.getKey());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return amenityNameToType;
|
||||
}
|
||||
|
||||
public Collection<String> getAmenitySubCategories(AmenityType t){
|
||||
Map<AmenityType, Map<String, String>> amenityTypeNameToTagVal = getAmenityTypeNameToTagVal();
|
||||
if(!amenityTypeNameToTagVal.containsKey(t)){
|
||||
return Collections.emptyList();
|
||||
}
|
||||
return amenityTypeNameToTagVal.get(t).keySet();
|
||||
}
|
||||
|
||||
public Collection<String> getAmenityAllSubCategories(AmenityType t){
|
||||
Map<String, Map<String, String>> amenityAllTypeNameToTagVal = getAmenityAllTypeNameToTagVal();
|
||||
if(!amenityAllTypeNameToTagVal.containsKey(t.getCategoryName())){
|
||||
return Collections.emptyList();
|
||||
}
|
||||
return amenityAllTypeNameToTagVal.get(t.getCategoryName()).keySet();
|
||||
}
|
||||
|
||||
public MapRulType getTypeByInternalId(int id) {
|
||||
return typeList.get(id);
|
||||
|
|
|
@ -3,12 +3,16 @@ package net.osmand.osm;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public class PoiCategory extends PoiFilter {
|
||||
|
||||
private List<PoiFilter> poiFilters = new ArrayList<PoiFilter>();
|
||||
private int regId;
|
||||
private String defaultTag;
|
||||
|
||||
public PoiCategory(MapPoiTypes registry, String keyName){
|
||||
public PoiCategory(MapPoiTypes registry, String keyName, int regId) {
|
||||
super(registry, null, keyName);
|
||||
this.regId = regId;
|
||||
}
|
||||
|
||||
public void addPoiType(PoiFilter poi) {
|
||||
|
@ -19,4 +23,28 @@ public class PoiCategory extends PoiFilter {
|
|||
return poiFilters;
|
||||
}
|
||||
|
||||
public String getDefaultTag() {
|
||||
if(defaultTag == null) {
|
||||
return keyName;
|
||||
}
|
||||
return defaultTag;
|
||||
}
|
||||
|
||||
public void setDefaultTag(String defaultTag) {
|
||||
this.defaultTag = defaultTag;
|
||||
}
|
||||
|
||||
|
||||
public boolean isWiki() {
|
||||
return keyName.equals(MapPoiTypes.OSM_WIKI_CATEGORY);
|
||||
}
|
||||
|
||||
public String getKey() {
|
||||
return keyName;
|
||||
}
|
||||
|
||||
public int ordinal() {
|
||||
return regId;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -5,27 +5,23 @@ import java.util.LinkedHashMap;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class PoiFilter {
|
||||
public class PoiFilter extends AbstractPoiType {
|
||||
|
||||
private String keyName;
|
||||
private String translationName;
|
||||
private MapPoiTypes registry;
|
||||
private PoiCategory pc;
|
||||
private List<PoiType> poiTypes = new ArrayList<PoiType>();
|
||||
private Map<String, PoiType> map = new LinkedHashMap<String, PoiType>();
|
||||
private PoiCategory pc;
|
||||
|
||||
public PoiFilter(MapPoiTypes registry, PoiCategory pc, String keyName){
|
||||
this.registry = registry;
|
||||
super(keyName, registry);
|
||||
this.pc = pc;
|
||||
this.keyName = keyName;
|
||||
}
|
||||
|
||||
public PoiCategory getPoiCategory() {
|
||||
return pc;
|
||||
}
|
||||
|
||||
public String getTranslationName() {
|
||||
return translationName;
|
||||
public PoiType getPoiTypeByKeyName(String kn) {
|
||||
return map.get(kn);
|
||||
}
|
||||
|
||||
public void addPoiType(PoiType type) {
|
||||
|
@ -33,7 +29,6 @@ public class PoiFilter {
|
|||
poiTypes.add(type);
|
||||
map.put(type.getName(), type);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public List<PoiType> getPoiTypes() {
|
||||
|
|
|
@ -1,10 +1,14 @@
|
|||
package net.osmand.osm;
|
||||
|
||||
public class PoiType {
|
||||
public class PoiType extends AbstractPoiType {
|
||||
|
||||
|
||||
public PoiType(MapPoiTypes poiTypes, PoiCategory category, String name){
|
||||
super(name, poiTypes);
|
||||
this.category = category;
|
||||
}
|
||||
|
||||
|
||||
private String name;
|
||||
private String translationName;
|
||||
private MapPoiTypes poiTypes;
|
||||
public String getOsmTag() {
|
||||
return osmTag;
|
||||
}
|
||||
|
@ -43,22 +47,10 @@ public class PoiType {
|
|||
private String osmValue;
|
||||
private String osmValue2;
|
||||
|
||||
public PoiType(MapPoiTypes poiTypes, PoiCategory category, String name){
|
||||
this.poiTypes = poiTypes;
|
||||
this.category = category;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public PoiCategory getCategory() {
|
||||
return category;
|
||||
}
|
||||
|
||||
public String getTranslationName() {
|
||||
return translationName;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -12,7 +12,9 @@ import net.osmand.data.City.CityType;
|
|||
import net.osmand.data.LatLon;
|
||||
import net.osmand.data.MapObject;
|
||||
import net.osmand.data.TransportStop;
|
||||
import net.osmand.osm.MapPoiTypes;
|
||||
import net.osmand.osm.MapRenderingTypes;
|
||||
import net.osmand.osm.PoiCategory;
|
||||
import net.osmand.osm.edit.OSMSettings.OSMTagKey;
|
||||
import net.osmand.util.Algorithms;
|
||||
|
||||
|
@ -63,7 +65,7 @@ public class EntityParser {
|
|||
mo.setName(op);
|
||||
}
|
||||
|
||||
public static Amenity parseAmenity(Entity entity, AmenityType type, String subtype, Map<String, String> tagValues,
|
||||
public static Amenity parseAmenity(Entity entity, PoiCategory type, String subtype, Map<String, String> tagValues,
|
||||
MapRenderingTypes types) {
|
||||
Amenity am = new Amenity();
|
||||
parseMapObject(am, entity);
|
||||
|
@ -72,7 +74,8 @@ public class EntityParser {
|
|||
}
|
||||
am.setType(type);
|
||||
am.setSubType(subtype);
|
||||
am.setAdditionalInfo(types.getAmenityAdditionalInfo(tagValues, type, subtype));
|
||||
AmenityType at = AmenityType.findOrCreateTypeNoReg(type.getKeyName());
|
||||
am.setAdditionalInfo(types.getAmenityAdditionalInfo(tagValues, at, subtype));
|
||||
String wbs = getWebSiteURL(entity);
|
||||
if(wbs != null) {
|
||||
am.setAdditionalInfo("website", wbs);
|
||||
|
@ -109,7 +112,7 @@ public class EntityParser {
|
|||
}
|
||||
|
||||
public static List<Amenity> parseAmenities(MapRenderingTypes renderingTypes,
|
||||
Entity entity, List<Amenity> amenitiesList){
|
||||
MapPoiTypes poiTypes, Entity entity, List<Amenity> amenitiesList){
|
||||
amenitiesList.clear();
|
||||
// it could be collection of amenities
|
||||
boolean relation = entity instanceof Relation;
|
||||
|
@ -123,7 +126,8 @@ public class EntityParser {
|
|||
: renderingTypes.getAmenityType(e.getKey(), e.getValue(), hasName );
|
||||
if (type != null) {
|
||||
String subtype = renderingTypes.getAmenitySubtype(e.getKey(), e.getValue());
|
||||
Amenity a = parseAmenity(entity, type, subtype, tags, renderingTypes);
|
||||
PoiCategory pc = poiTypes.getPoiCategoryByName(type.getCategoryName(), true);
|
||||
Amenity a = parseAmenity(entity, pc, subtype, tags, renderingTypes);
|
||||
if (checkAmenitiesToAdd(a, amenitiesList) && !"no".equals(subtype)) {
|
||||
amenitiesList.add(a);
|
||||
}
|
||||
|
|
|
@ -1,5 +1,25 @@
|
|||
<?xml version="1.0" ?>
|
||||
<resources>
|
||||
<!-- categories -->
|
||||
<string name="poi_shop">Shop</string>
|
||||
<string name="poi_emergency">Emergency</string>
|
||||
<string name="poi_transportation">Transportation</string>
|
||||
<string name="poi_man_made">Man made</string>
|
||||
<string name="poi_education">Education</string>
|
||||
<string name="poi_administrative">Administrative</string>
|
||||
<string name="poi_healthcare">Healthcare</string>
|
||||
<string name="poi_office">Office</string>
|
||||
<string name="poi_sport">Sport</string>
|
||||
<string name="poi_tourism">Tourism</string>
|
||||
<string name="poi_entertainment">Leisure</string>
|
||||
<string name="poi_sustenance">Food</string>
|
||||
<string name="poi_service">Service</string>
|
||||
<string name="poi_finance">Finance</string>
|
||||
<string name="poi_natural">Natural</string>
|
||||
<string name="poi_seamark">Nautical</string>
|
||||
<string name="poi_military">Military</string>
|
||||
<string name="poi_osmwiki">Wikipedia</string>
|
||||
<string name="poi_user_defined_other">User defined</string>
|
||||
|
||||
<string name="poi_palaeontological_site">Palaeontological site</string>
|
||||
|
||||
|
@ -640,7 +660,7 @@
|
|||
<string name="poi_seamark_rock">Rock, seamark</string>
|
||||
<string name="poi_seamark_wreck">Wreck, seamark</string>
|
||||
|
||||
<string name="poi_military">Military zone</string>
|
||||
<string name="poi_military_landuse">Military zone</string>
|
||||
<string name="poi_military_airfield">Military airfield</string>
|
||||
<string name="poi_military_bunker">Military bunker</string>
|
||||
<string name="poi_military_barracks">Barracks</string>
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
package net.osmand.plus;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.text.DecimalFormat;
|
||||
import java.text.MessageFormat;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import net.osmand.data.Amenity;
|
||||
import net.osmand.data.AmenityType;
|
||||
import net.osmand.data.City.CityType;
|
||||
import net.osmand.osm.PoiCategory;
|
||||
import net.osmand.osm.PoiType;
|
||||
import net.osmand.plus.OsmandSettings.MetricsConstants;
|
||||
import net.osmand.util.Algorithms;
|
||||
import android.content.Context;
|
||||
|
@ -157,22 +157,10 @@ public class OsmAndFormatter {
|
|||
return "";
|
||||
}
|
||||
|
||||
public static String toPublicString(AmenityType t, Context ctx) {
|
||||
Class<?> cl = R.string.class;
|
||||
try {
|
||||
Field fld = cl.getField("amenity_type_"+t.getCategoryName());
|
||||
if(fld != null) {
|
||||
return ctx.getString((Integer)fld.get(null));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
}
|
||||
return ctx.getString(R.string.amenity_type_user_defined);
|
||||
}
|
||||
|
||||
|
||||
public static String getPoiSimpleFormat(Amenity amenity, Context ctx, boolean en) {
|
||||
return getPoiStringWithoutType(amenity, en,
|
||||
toPublicString(amenity.getType(), ctx) + ": " + amenity.getSubType()); //$NON-NLS-1$
|
||||
amenity.getType().getTranslation() + ": " + amenity.getSubType()); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
public static String getPoiStringWithoutType(Amenity amenity, boolean en) {
|
||||
|
@ -180,12 +168,14 @@ public class OsmAndFormatter {
|
|||
}
|
||||
|
||||
public static String getPoiStringWithoutType(Amenity amenity, boolean en, String defName) {
|
||||
String nm = SpecialPhrases.getSpecialPhrase(amenity.getSubType(), defName);
|
||||
String type =
|
||||
SpecialPhrases.getSpecialPhrase(amenity.getType().getCategoryName() + "_" + amenity.getSubType(),
|
||||
nm);
|
||||
PoiCategory pc = amenity.getType();
|
||||
PoiType pt = pc.getPoiTypeByKeyName(amenity.getSubType());
|
||||
String nm = defName;
|
||||
if (pt != null) {
|
||||
nm = pt.getTranslation();
|
||||
}
|
||||
String n = amenity.getName(en);
|
||||
if (n.indexOf(type) != -1) {
|
||||
if (n.indexOf(nm) != -1) {
|
||||
// type is contained in name e.g.
|
||||
// n = "Bakery the Corner"
|
||||
// type = "Bakery"
|
||||
|
@ -193,9 +183,9 @@ public class OsmAndFormatter {
|
|||
return n;
|
||||
}
|
||||
if (n.length() == 0) {
|
||||
return type;
|
||||
return nm;
|
||||
}
|
||||
return type + " " + n; //$NON-NLS-1$
|
||||
return nm + " " + n; //$NON-NLS-1$
|
||||
}
|
||||
|
||||
public static String getAmenityDescriptionContent(Context ctx, Amenity amenity, boolean shortDescription) {
|
||||
|
@ -204,7 +194,7 @@ public class OsmAndFormatter {
|
|||
String key = e.getKey();
|
||||
String vl = e.getValue();
|
||||
if(Amenity.DESCRIPTION.equals(key)) {
|
||||
if(amenity.getType() == AmenityType.OSMWIKI && shortDescription) {
|
||||
if(amenity.getType().isWiki() && shortDescription) {
|
||||
continue;
|
||||
}
|
||||
} else if(Amenity.OPENING_HOURS.equals(key)) {
|
||||
|
@ -212,17 +202,19 @@ public class OsmAndFormatter {
|
|||
} else if(Amenity.PHONE.equals(key)) {
|
||||
d.append(ctx.getString(R.string.phone) + ": ");
|
||||
} else if(Amenity.WEBSITE.equals(key)) {
|
||||
if(amenity.getType() == AmenityType.OSMWIKI) {
|
||||
if(amenity.getType().isWiki()) {
|
||||
continue;
|
||||
}
|
||||
d.append(ctx.getString(R.string.website) + ": ");
|
||||
} else {
|
||||
vl = SpecialPhrases.getSpecialPhrase(e.getKey() + "_" + e.getValue(), null);
|
||||
if(vl == null){
|
||||
vl = SpecialPhrases.getSpecialPhrase(e.getKey(),
|
||||
Algorithms.capitalizeFirstLetterAndLowercase(e.getKey())) + ": ";
|
||||
vl += SpecialPhrases.getSpecialPhrase(e.getValue(), e.getValue());
|
||||
PoiCategory pc = amenity.getType();
|
||||
PoiType pt = pc.getPoiTypeByKeyName(e.getKey());
|
||||
if (pt != null) {
|
||||
vl = pt.getTranslation();
|
||||
} else {
|
||||
vl = Algorithms.capitalizeFirstLetterAndLowercase(e.getKey());
|
||||
}
|
||||
vl += ": " + e.getValue();
|
||||
}
|
||||
d.append(vl).append('\n');
|
||||
}
|
||||
|
|
|
@ -8,26 +8,25 @@ import java.io.FileWriter;
|
|||
import java.io.IOException;
|
||||
import java.io.PrintStream;
|
||||
import java.lang.Thread.UncaughtExceptionHandler;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
import android.support.v7.app.ActionBar;
|
||||
import android.support.v7.app.ActionBarActivity;
|
||||
import net.osmand.IndexConstants;
|
||||
import net.osmand.PlatformUtil;
|
||||
import net.osmand.access.AccessibilityPlugin;
|
||||
import net.osmand.access.AccessibleAlertBuilder;
|
||||
import net.osmand.access.AccessibleToast;
|
||||
import net.osmand.osm.AbstractPoiType;
|
||||
import net.osmand.osm.MapPoiTypes;
|
||||
import net.osmand.plus.access.AccessibilityMode;
|
||||
import net.osmand.plus.activities.DayNightHelper;
|
||||
import net.osmand.plus.activities.MainMenuActivity;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.activities.SavingTrackHelper;
|
||||
import net.osmand.plus.activities.SettingsActivity;
|
||||
import net.osmand.plus.api.SQLiteAPI;
|
||||
import net.osmand.plus.api.SQLiteAPIImpl;
|
||||
import net.osmand.plus.download.DownloadActivity;
|
||||
import net.osmand.plus.helpers.AvoidSpecificRoads;
|
||||
import net.osmand.plus.helpers.WaypointHelper;
|
||||
import net.osmand.plus.monitoring.LiveMonitoringHelper;
|
||||
|
@ -60,8 +59,6 @@ import android.content.Intent;
|
|||
import android.content.pm.PackageInfo;
|
||||
import android.content.pm.PackageManager.NameNotFoundException;
|
||||
import android.content.res.Configuration;
|
||||
import android.graphics.Shader.TileMode;
|
||||
import android.graphics.drawable.BitmapDrawable;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Build;
|
||||
import android.os.Handler;
|
||||
|
@ -88,6 +85,7 @@ public class OsmandApplication extends Application {
|
|||
|
||||
ResourceManager resourceManager = null;
|
||||
PoiFiltersHelper poiFilters = null;
|
||||
MapPoiTypes poiTypes = null;
|
||||
RoutingHelper routingHelper = null;
|
||||
FavouritesDbHelper favorites = null;
|
||||
CommandPlayer player = null;
|
||||
|
@ -158,6 +156,7 @@ public class OsmandApplication extends Application {
|
|||
|
||||
applyTheme(this);
|
||||
|
||||
poiTypes = initPoiTypes();
|
||||
routingHelper = new RoutingHelper(this, player);
|
||||
taskManager = new OsmAndTaskManager(this);
|
||||
resourceManager = new ResourceManager(this);
|
||||
|
@ -175,7 +174,6 @@ public class OsmandApplication extends Application {
|
|||
// if(!osmandSettings.FOLLOW_THE_ROUTE.get()) {
|
||||
// targetPointsHelper.clearPointToNavigate(false);
|
||||
// }
|
||||
|
||||
checkPreferredLocale();
|
||||
startApplication();
|
||||
if (LOG.isDebugEnabled()) {
|
||||
|
@ -191,6 +189,32 @@ public class OsmandApplication extends Application {
|
|||
|
||||
}
|
||||
|
||||
public MapPoiTypes getPoiTypes() {
|
||||
if(poiTypes == null) {
|
||||
throw new IllegalStateException("State exception");
|
||||
}
|
||||
return poiTypes;
|
||||
}
|
||||
|
||||
private MapPoiTypes initPoiTypes() {
|
||||
return MapPoiTypes.initDefault(new MapPoiTypes.PoiTranslator() {
|
||||
|
||||
@Override
|
||||
public String getTranslation(AbstractPoiType type) {
|
||||
try {
|
||||
Field f = R.string.class.getField("poi_" + type.getKeyName());
|
||||
if (f != null) {
|
||||
Integer in = (Integer) f.get(null);
|
||||
return getString(in);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
System.err.println(e.getMessage());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void createInUiThread() {
|
||||
new Toast(this); // activate in UI thread to avoid further exceptions
|
||||
new AsyncTask<View, Void, Void>() {
|
||||
|
@ -546,13 +570,6 @@ public class OsmandApplication extends Application {
|
|||
List<String> warnings = new ArrayList<String>();
|
||||
try {
|
||||
favorites.loadFavorites();
|
||||
try {
|
||||
SpecialPhrases.setLanguage(this, osmandSettings);
|
||||
} catch (IOException e) {
|
||||
LOG.error("I/O exception", e);
|
||||
warnings.add("Error while reading the special phrases. Restart OsmAnd if possible");
|
||||
}
|
||||
|
||||
if (!"qnx".equals(System.getProperty("os.name"))) {
|
||||
if (osmandSettings.USE_OPENGL_RENDER.get()) {
|
||||
boolean success = false;
|
||||
|
|
|
@ -334,7 +334,6 @@ public abstract class OsmandPlugin {
|
|||
for (OsmandPlugin plugin : getEnabledPlugins()) {
|
||||
plugin.optionsMenuFragment(activity, fragment, optionsMenuAdapter);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,100 +0,0 @@
|
|||
package net.osmand.plus;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.HashMap;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
import net.osmand.PlatformUtil;
|
||||
import net.osmand.util.Algorithms;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
|
||||
|
||||
public class SpecialPhrases {
|
||||
|
||||
|
||||
private static Map<String,String> m;
|
||||
private static final Log log = PlatformUtil.getLog(SpecialPhrases.class);
|
||||
|
||||
/**
|
||||
* Use this method to query a special phrase for a certain subtype
|
||||
*
|
||||
* If the language isn't set yet, a nullpointer exception will be thrown
|
||||
*
|
||||
* @param value the subtype to query
|
||||
* @return the special phrase according to the asked key, or "null" if the key isn't found
|
||||
*/
|
||||
public static String getSpecialPhrase(String value, String defValue) {
|
||||
if (m == null) {
|
||||
// do not throw exception because OsmAndApplication is not always initiliazed before
|
||||
// this call
|
||||
log.warn("The language has not been set for special phrases");
|
||||
return value;
|
||||
|
||||
}
|
||||
String specialValue = m.get(value);
|
||||
if (Algorithms.isEmpty(specialValue)) {
|
||||
specialValue = defValue;
|
||||
}
|
||||
return specialValue == null ? null : specialValue.replace('_', ' ');
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the special phrases to a certain language.
|
||||
* This method needs to be used before the getSpecialPhrase method
|
||||
*
|
||||
* @param lang the language to use
|
||||
* @throws IOException when reading the text file failed
|
||||
*/
|
||||
public static void setLanguage(OsmandApplication ctx, OsmandSettings settings) throws IOException {
|
||||
String lang = getPreferredLanguage(settings).getLanguage();
|
||||
m = new HashMap<String, String>();
|
||||
// The InputStream opens the resourceId and sends it to the buffer
|
||||
InputStream is = null;
|
||||
BufferedReader br = null;
|
||||
try {
|
||||
try {
|
||||
is = ctx.getAssets().open("specialphrases/specialphrases_" + lang + ".txt");
|
||||
} catch (IOException ex) {
|
||||
// second try: default to English, if this fails, the error is thrown outside
|
||||
is = ctx.getAssets().open("specialphrases/specialphrases_en.txt");
|
||||
}
|
||||
br = new BufferedReader(new InputStreamReader(is));
|
||||
String readLine = null;
|
||||
|
||||
// While the BufferedReader readLine is not null
|
||||
while ((readLine = br.readLine()) != null) {
|
||||
String[] arr = readLine.split(",");
|
||||
if (arr != null && arr.length == 2) {
|
||||
m.put(arr[0], arr[1]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} finally {
|
||||
Algorithms.closeStream(is);
|
||||
Algorithms.closeStream(br);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the preferred language
|
||||
* @param set the OsmandSettings used
|
||||
* @return ENGLISH if English names are chosen in the settings, Locale.getDefault otherwise
|
||||
*/
|
||||
public static Locale getPreferredLanguage(OsmandSettings set){
|
||||
if (set.usingEnglishNames()) {
|
||||
return Locale.ENGLISH;
|
||||
}
|
||||
return Locale.getDefault();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -6,33 +6,47 @@ package net.osmand.plus.activities;
|
|||
|
||||
import java.text.Collator;
|
||||
import java.text.MessageFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Comparator;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import android.support.v4.view.MenuItemCompat;
|
||||
import android.view.*;
|
||||
import android.widget.*;
|
||||
import net.osmand.access.AccessibleToast;
|
||||
import net.osmand.data.AmenityType;
|
||||
import net.osmand.data.LatLon;
|
||||
import net.osmand.osm.MapRenderingTypes;
|
||||
import net.osmand.plus.OsmAndFormatter;
|
||||
import net.osmand.osm.PoiCategory;
|
||||
import net.osmand.osm.PoiType;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.SpecialPhrases;
|
||||
import net.osmand.plus.activities.search.SearchActivity;
|
||||
import net.osmand.plus.activities.search.SearchPOIActivity;
|
||||
import net.osmand.plus.poi.PoiLegacyFilter;
|
||||
import net.osmand.plus.poi.PoiFiltersHelper;
|
||||
import net.osmand.plus.poi.PoiLegacyFilter;
|
||||
import net.osmand.util.Algorithms;
|
||||
import android.app.AlertDialog;
|
||||
import android.app.AlertDialog.Builder;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.view.MenuItemCompat;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.EditText;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.LinearLayout.LayoutParams;
|
||||
import android.widget.ListView;
|
||||
import android.widget.ScrollView;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -62,9 +76,9 @@ public class EditPOIFilterActivity extends OsmandListActivity {
|
|||
|
||||
if (filter != null) {
|
||||
getSupportActionBar().setSubtitle(filter.getName());
|
||||
setListAdapter(new AmenityAdapter(AmenityType.getCategories()));
|
||||
setListAdapter(new AmenityAdapter( ((OsmandApplication) getApplication()).getPoiTypes().getCategories()));
|
||||
} else {
|
||||
setListAdapter(new AmenityAdapter(new AmenityType[0]));
|
||||
setListAdapter(new AmenityAdapter(new ArrayList<PoiCategory>()));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -189,7 +203,7 @@ public class EditPOIFilterActivity extends OsmandListActivity {
|
|||
builder.create().show();
|
||||
}
|
||||
|
||||
private void showDialog(final AmenityType amenity) {
|
||||
private void showDialog(final PoiCategory poiCategory) {
|
||||
ListView lv = EditPOIFilterActivity.this.getListView();
|
||||
final int index = lv.getFirstVisiblePosition();
|
||||
View v = lv.getChildAt(0);
|
||||
|
@ -197,28 +211,26 @@ public class EditPOIFilterActivity extends OsmandListActivity {
|
|||
Builder builder = new AlertDialog.Builder(this);
|
||||
ScrollView scroll = new ScrollView(this);
|
||||
ListView listView = new ListView(this);
|
||||
|
||||
final LinkedHashSet<String> subCategories = new LinkedHashSet<String>(MapRenderingTypes.getDefault().getAmenitySubCategories(amenity));
|
||||
Set<String> acceptedCategories = filter.getAcceptedSubtypes(amenity);
|
||||
final LinkedHashMap<String, String> subCategories = new LinkedHashMap<String, String>();
|
||||
Set<String> acceptedCategories = filter.getAcceptedSubtypes(poiCategory);
|
||||
if (acceptedCategories != null) {
|
||||
for (String s : acceptedCategories) {
|
||||
if (!subCategories.contains(s)) {
|
||||
subCategories.add(s);
|
||||
}
|
||||
for(String s : acceptedCategories) {
|
||||
subCategories.put(s, Algorithms.capitalizeFirstLetterAndLowercase(s));
|
||||
}
|
||||
}
|
||||
for(PoiType pt : poiCategory.getPoiTypes()) {
|
||||
subCategories.put(pt.getKeyName(), pt.getTranslation());
|
||||
}
|
||||
|
||||
final String[] array = subCategories.toArray(new String[0]);
|
||||
final String[] array = subCategories.keySet().toArray(new String[0]);
|
||||
final Collator cl = Collator.getInstance();
|
||||
cl.setStrength(Collator.SECONDARY);
|
||||
Arrays.sort(array, 0, array.length, new Comparator<String>() {
|
||||
|
||||
@Override
|
||||
public int compare(String object1, String object2) {
|
||||
String v1 = SpecialPhrases.getSpecialPhrase(object1, object1);
|
||||
String v2 = SpecialPhrases.getSpecialPhrase(object2, object2);
|
||||
v1 = SpecialPhrases.getSpecialPhrase(amenity.getDefaultTag()+"_"+object1, v1);
|
||||
v2 = SpecialPhrases.getSpecialPhrase(amenity.getDefaultTag()+"_"+object2, v2);
|
||||
String v1 = subCategories.get(object1);
|
||||
String v2 = subCategories.get(object2);
|
||||
return cl.compare(v1, v2);
|
||||
}
|
||||
});
|
||||
|
@ -227,9 +239,7 @@ public class EditPOIFilterActivity extends OsmandListActivity {
|
|||
|
||||
for (int i = 0; i < array.length; i++) {
|
||||
final String subcategory = array[i];
|
||||
String name = SpecialPhrases.getSpecialPhrase(subcategory, subcategory);
|
||||
visibleNames[i] = SpecialPhrases.getSpecialPhrase(amenity.getDefaultTag()+"_"+subcategory,
|
||||
name);
|
||||
visibleNames[i] = subCategories.get(subcategory);
|
||||
if (acceptedCategories == null) {
|
||||
selected[i] = true;
|
||||
} else {
|
||||
|
@ -250,11 +260,11 @@ public class EditPOIFilterActivity extends OsmandListActivity {
|
|||
}
|
||||
}
|
||||
if (subCategories.size() == accepted.size()) {
|
||||
filter.selectSubTypesToAccept(amenity, null);
|
||||
filter.selectSubTypesToAccept(poiCategory, null);
|
||||
} else if(accepted.size() == 0){
|
||||
filter.setTypeToAccept(amenity, false);
|
||||
filter.setTypeToAccept(poiCategory, false);
|
||||
} else {
|
||||
filter.selectSubTypesToAccept(amenity, accepted);
|
||||
filter.selectSubTypesToAccept(poiCategory, accepted);
|
||||
}
|
||||
helper.editPoiFilter(filter);
|
||||
ListView lv = EditPOIFilterActivity.this.getListView();
|
||||
|
@ -267,7 +277,7 @@ public class EditPOIFilterActivity extends OsmandListActivity {
|
|||
builder.setPositiveButton(EditPOIFilterActivity.this.getText(R.string.default_buttons_selectall), new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
filter.selectSubTypesToAccept(amenity, null);
|
||||
filter.selectSubTypesToAccept(poiCategory, null);
|
||||
helper.editPoiFilter(filter);
|
||||
ListView lv = EditPOIFilterActivity.this.getListView();
|
||||
AmenityAdapter la = (AmenityAdapter) EditPOIFilterActivity.this.getListAdapter();
|
||||
|
@ -298,8 +308,8 @@ public class EditPOIFilterActivity extends OsmandListActivity {
|
|||
showDialog(getListAdapter().getItem(position));
|
||||
}
|
||||
|
||||
class AmenityAdapter extends ArrayAdapter<AmenityType> {
|
||||
AmenityAdapter(AmenityType[] amenityTypes) {
|
||||
class AmenityAdapter extends ArrayAdapter<PoiCategory> {
|
||||
AmenityAdapter(List<PoiCategory> amenityTypes) {
|
||||
super(EditPOIFilterActivity.this, R.layout.editing_poi_filter_list, amenityTypes);
|
||||
}
|
||||
|
||||
|
@ -310,18 +320,18 @@ public class EditPOIFilterActivity extends OsmandListActivity {
|
|||
if (row == null) {
|
||||
row = inflater.inflate(R.layout.editing_poi_filter_list, parent, false);
|
||||
}
|
||||
AmenityType model = getItem(position);
|
||||
PoiCategory model = getItem(position);
|
||||
|
||||
CheckBox check = (CheckBox) row.findViewById(R.id.filter_poi_check);
|
||||
check.setChecked(filter.isTypeAccepted(model));
|
||||
|
||||
TextView text = (TextView) row.findViewById(R.id.filter_poi_label);
|
||||
text.setText(OsmAndFormatter.toPublicString(model, getMyApplication()));
|
||||
text.setText(model.getTranslation());
|
||||
addRowListener(model, text, check);
|
||||
return (row);
|
||||
}
|
||||
|
||||
private void addRowListener(final AmenityType model, final TextView text, final CheckBox check) {
|
||||
private void addRowListener(final PoiCategory model, final TextView text, final CheckBox check) {
|
||||
text.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
|
|
|
@ -10,14 +10,13 @@ import net.osmand.CallbackWithObject;
|
|||
import net.osmand.ResultMatcher;
|
||||
import net.osmand.StateChangedListener;
|
||||
import net.osmand.access.AccessibleToast;
|
||||
import net.osmand.data.AmenityType;
|
||||
import net.osmand.map.ITileSource;
|
||||
import net.osmand.map.TileSourceManager.TileSourceTemplate;
|
||||
import net.osmand.osm.PoiCategory;
|
||||
import net.osmand.plus.ContextMenuAdapter;
|
||||
import net.osmand.plus.ContextMenuAdapter.Item;
|
||||
import net.osmand.plus.GPXUtilities.GPXFile;
|
||||
import net.osmand.plus.GPXUtilities.WptPt;
|
||||
import net.osmand.plus.OsmAndFormatter;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.OsmandPlugin;
|
||||
import net.osmand.plus.OsmandSettings;
|
||||
|
@ -25,8 +24,8 @@ import net.osmand.plus.OsmandSettings.CommonPreference;
|
|||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.SQLiteTileSource;
|
||||
import net.osmand.plus.helpers.GpxUiHelper;
|
||||
import net.osmand.plus.poi.PoiLegacyFilter;
|
||||
import net.osmand.plus.poi.PoiFiltersHelper;
|
||||
import net.osmand.plus.poi.PoiLegacyFilter;
|
||||
import net.osmand.plus.rastermaps.OsmandRasterMapsPlugin;
|
||||
import net.osmand.plus.render.MapVectorLayer;
|
||||
import net.osmand.plus.render.RenderingIcons;
|
||||
|
@ -283,11 +282,11 @@ public class MapActivityLayers {
|
|||
it.reg();
|
||||
userDefined.add(f);
|
||||
}
|
||||
final AmenityType[] categories = AmenityType.getCategories();
|
||||
for(AmenityType t : categories){
|
||||
Item it = adapter.item(OsmAndFormatter.toPublicString(t, activity.getMyApplication()));
|
||||
if(RenderingIcons.containsBigIcon(t.toString().toLowerCase())) {
|
||||
it.icon(RenderingIcons.getBigIconResourceId(t.toString().toLowerCase()));
|
||||
final List<PoiCategory> categories = getApplication().getPoiTypes().getCategories();
|
||||
for(PoiCategory t : categories){
|
||||
Item it = adapter.item(t.getTranslation());
|
||||
if(RenderingIcons.containsBigIcon(t.getKeyName())) {
|
||||
it.icon(RenderingIcons.getBigIconResourceId(t.getKeyName()));
|
||||
}
|
||||
it.reg();
|
||||
}
|
||||
|
@ -312,7 +311,7 @@ public class MapActivityLayers {
|
|||
} else if (which <= userDefined.size() + 1) {
|
||||
filterId = userDefined.get(which - 2).getFilterId();
|
||||
} else {
|
||||
filterId = PoiFiltersHelper.getOsmDefinedFilterId(categories[which - userDefined.size() - 2]);
|
||||
filterId = PoiFiltersHelper.getOsmDefinedFilterId(categories.get(which - userDefined.size() - 2));
|
||||
}
|
||||
getApplication().getSettings().setPoiFilterForMap(filterId);
|
||||
PoiLegacyFilter f = poiFilters.getFilterById(filterId);
|
||||
|
|
|
@ -12,7 +12,6 @@ import java.util.List;
|
|||
import net.osmand.ResultMatcher;
|
||||
import net.osmand.access.AccessibleToast;
|
||||
import net.osmand.data.Amenity;
|
||||
import net.osmand.data.AmenityType;
|
||||
import net.osmand.data.City;
|
||||
import net.osmand.data.LatLon;
|
||||
import net.osmand.data.MapObject;
|
||||
|
@ -276,7 +275,7 @@ public class GeoIntentActivity extends OsmandListActivity {
|
|||
}
|
||||
|
||||
Amenity point = new Amenity();
|
||||
((Amenity) point).setType(AmenityType.USER_DEFINED);
|
||||
((Amenity) point).setType(getMyApplication().getPoiTypes().getUserDefinedCategory());
|
||||
((Amenity) point).setSubType("");
|
||||
point.setLocation(lat, lon);
|
||||
point.setName("Lat: " + lat + ",Lon:" + lon);
|
||||
|
@ -380,7 +379,7 @@ public class GeoIntentActivity extends OsmandListActivity {
|
|||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private static class GeoPointSearch implements MyService {
|
||||
private class GeoPointSearch implements MyService {
|
||||
private final MapObject point;
|
||||
private final int zoom;
|
||||
|
||||
|
@ -400,7 +399,7 @@ public class GeoIntentActivity extends OsmandListActivity {
|
|||
final Amenity amenity = new Amenity();
|
||||
amenity.setLocation(lat, lon);
|
||||
amenity.setName(name);
|
||||
amenity.setType(AmenityType.USER_DEFINED);
|
||||
amenity.setType(getMyApplication().getPoiTypes().getUserDefinedCategory());
|
||||
amenity.setSubType("");
|
||||
|
||||
this.point = amenity;
|
||||
|
|
|
@ -4,10 +4,6 @@
|
|||
package net.osmand.plus.activities.search;
|
||||
|
||||
|
||||
import android.graphics.PorterDuff;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.support.v7.widget.PopupMenu;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
import gnu.trove.set.hash.TLongHashSet;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
@ -23,12 +19,9 @@ import net.osmand.ResultMatcher;
|
|||
import net.osmand.access.AccessibleToast;
|
||||
import net.osmand.access.NavigationInfo;
|
||||
import net.osmand.data.Amenity;
|
||||
import net.osmand.data.AmenityType;
|
||||
import net.osmand.data.LatLon;
|
||||
import net.osmand.osm.MapRenderingTypes;
|
||||
import net.osmand.plus.ContextMenuAdapter;
|
||||
import net.osmand.plus.ContextMenuAdapter.Item;
|
||||
import net.osmand.plus.ContextMenuAdapter.OnContextMenuClick;
|
||||
import net.osmand.osm.PoiCategory;
|
||||
import net.osmand.osm.PoiType;
|
||||
import net.osmand.plus.OsmAndConstants;
|
||||
import net.osmand.plus.OsmAndFormatter;
|
||||
import net.osmand.plus.OsmAndLocationProvider.OsmAndCompassListener;
|
||||
|
@ -38,7 +31,6 @@ import net.osmand.plus.OsmandSettings;
|
|||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.activities.EditPOIFilterActivity;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.activities.MapActivityActions;
|
||||
import net.osmand.plus.activities.OsmandListActivity;
|
||||
import net.osmand.plus.dialogs.DirectionsDialogs;
|
||||
import net.osmand.plus.poi.NameFinderPoiFilter;
|
||||
|
@ -55,6 +47,8 @@ import android.app.AlertDialog.Builder;
|
|||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.hardware.Sensor;
|
||||
import android.hardware.SensorManager;
|
||||
import android.os.AsyncTask;
|
||||
|
@ -62,12 +56,12 @@ import android.os.AsyncTask.Status;
|
|||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.support.v4.view.MenuItemCompat;
|
||||
import android.support.v7.widget.PopupMenu;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
import android.text.Editable;
|
||||
import android.text.Spannable;
|
||||
import android.text.SpannableString;
|
||||
import android.text.TextWatcher;
|
||||
import android.text.method.LinkMovementMethod;
|
||||
import android.text.style.ForegroundColorSpan;
|
||||
import android.text.util.Linkify;
|
||||
import android.view.Gravity;
|
||||
import android.view.LayoutInflater;
|
||||
|
@ -77,7 +71,6 @@ import android.view.MenuItem.OnMenuItemClickListener;
|
|||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.ViewGroup.LayoutParams;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.ArrayAdapter;
|
||||
|
@ -387,7 +380,7 @@ public class SearchPOIActivity extends OsmandListActivity implements OsmAndCompa
|
|||
private void showPoiCategoriesByNameFilter(String query, net.osmand.Location loc){
|
||||
OsmandApplication app = (OsmandApplication) getApplication();
|
||||
if(loc != null){
|
||||
Map<AmenityType, List<String>> map = app.getResourceManager().searchAmenityCategoriesByName(query, loc.getLatitude(), loc.getLongitude());
|
||||
Map<PoiCategory, List<String>> map = app.getResourceManager().searchAmenityCategoriesByName(query, loc.getLatitude(), loc.getLongitude());
|
||||
if(!map.isEmpty()){
|
||||
PoiLegacyFilter filter = ((OsmandApplication)getApplication()).getPoiFilters().getFilterById(PoiLegacyFilter.CUSTOM_FILTER_ID);
|
||||
if(filter != null){
|
||||
|
@ -401,13 +394,13 @@ public class SearchPOIActivity extends OsmandListActivity implements OsmAndCompa
|
|||
}
|
||||
}
|
||||
|
||||
private String typesToString(Map<AmenityType, List<String>> map) {
|
||||
private String typesToString(Map<PoiCategory, List<String>> map) {
|
||||
StringBuilder b = new StringBuilder();
|
||||
int count = 0;
|
||||
Iterator<Entry<AmenityType, List<String>>> iterator = map.entrySet().iterator();
|
||||
Iterator<Entry<PoiCategory, List<String>>> iterator = map.entrySet().iterator();
|
||||
while(iterator.hasNext() && count < 4){
|
||||
Entry<AmenityType, List<String>> e = iterator.next();
|
||||
b.append("\n").append(OsmAndFormatter.toPublicString(e.getKey(), getMyApplication())).append(" - ");
|
||||
Entry<PoiCategory, List<String>> e = iterator.next();
|
||||
b.append("\n").append(e.getKey().getTranslation()).append(" - ");
|
||||
if(e.getValue() == null){
|
||||
b.append("...");
|
||||
} else {
|
||||
|
@ -833,14 +826,17 @@ public class SearchPOIActivity extends OsmandListActivity implements OsmAndCompa
|
|||
direction.setImageResource(R.drawable.closed_poi);
|
||||
}
|
||||
}
|
||||
StringBuilder tag = new StringBuilder();
|
||||
StringBuilder value = new StringBuilder();
|
||||
MapRenderingTypes.getDefault().getAmenityTagValue(amenity.getType(), amenity.getSubType(),
|
||||
tag, value);
|
||||
if(RenderingIcons.containsBigIcon(tag + "_" + value)) {
|
||||
icon.setImageResource(RenderingIcons.getBigIconResourceId(tag + "_" + value));
|
||||
} else if(RenderingIcons.containsBigIcon(value.toString())) {
|
||||
icon.setImageResource(RenderingIcons.getBigIconResourceId(value.toString()));
|
||||
PoiType st = amenity.getType().getPoiTypeByKeyName(amenity.getSubType());
|
||||
if (st != null) {
|
||||
if (RenderingIcons.containsBigIcon(st.getKeyName())) {
|
||||
icon.setImageResource(RenderingIcons.getBigIconResourceId(st.getKeyName()));
|
||||
} else if (RenderingIcons.containsBigIcon(st.getOsmTag() + "_" + st.getOsmValue())) {
|
||||
icon.setImageResource(RenderingIcons.getBigIconResourceId(st.getOsmTag() + "_" + st.getOsmValue()));
|
||||
} else if (RenderingIcons.containsBigIcon(st.getOsmTag() + "_" + st.getOsmValue())) {
|
||||
icon.setImageResource(RenderingIcons.getBigIconResourceId(st.getOsmValue()));
|
||||
} else {
|
||||
icon.setImageDrawable(null);
|
||||
}
|
||||
} else {
|
||||
icon.setImageDrawable(null);
|
||||
}
|
||||
|
|
|
@ -4,7 +4,6 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
|
||||
import net.osmand.CallbackWithObject;
|
||||
import net.osmand.binary.BinaryMapRouteReaderAdapter.RouteRegion;
|
||||
import net.osmand.binary.RouteDataObject;
|
||||
import net.osmand.data.LatLon;
|
||||
import net.osmand.plus.OsmAndFormatter;
|
||||
|
|
|
@ -18,11 +18,11 @@ import net.osmand.binary.RouteDataObject;
|
|||
import net.osmand.data.Amenity;
|
||||
import net.osmand.data.Amenity.AmenityRoutePoint;
|
||||
import net.osmand.data.LocationPoint;
|
||||
import net.osmand.osm.MapRenderingTypes;
|
||||
import net.osmand.osm.PoiType;
|
||||
import net.osmand.plus.OsmAndFormatter;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.OsmandSettings.MetricsConstants;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.TargetPointsHelper.TargetPoint;
|
||||
import net.osmand.plus.activities.IntermediatePointsDialog;
|
||||
import net.osmand.plus.base.FavoriteImageDrawable;
|
||||
|
@ -675,14 +675,17 @@ public class WaypointHelper {
|
|||
public Drawable getDrawable(Context uiCtx, OsmandApplication app) {
|
||||
if(type == POI) {
|
||||
Amenity amenity = ((AmenityLocationPoint) point).a;
|
||||
StringBuilder tag = new StringBuilder();
|
||||
StringBuilder value = new StringBuilder();
|
||||
MapRenderingTypes.getDefault().getAmenityTagValue(amenity.getType(), amenity.getSubType(),
|
||||
tag, value);
|
||||
if(RenderingIcons.containsBigIcon(tag + "_" + value)) {
|
||||
return uiCtx.getResources().getDrawable(RenderingIcons.getBigIconResourceId(tag + "_" + value));
|
||||
} else if(RenderingIcons.containsBigIcon(value.toString())) {
|
||||
return uiCtx.getResources().getDrawable(RenderingIcons.getBigIconResourceId(value.toString()));
|
||||
PoiType st = amenity.getType().getPoiTypeByKeyName(amenity.getSubType());
|
||||
if (st != null) {
|
||||
if (RenderingIcons.containsBigIcon(st.getKeyName())) {
|
||||
return uiCtx.getResources().getDrawable(
|
||||
RenderingIcons.getBigIconResourceId(st.getKeyName()));
|
||||
} else if (RenderingIcons.containsBigIcon(st.getOsmTag() + "_" + st.getOsmValue())) {
|
||||
return uiCtx.getResources().getDrawable(
|
||||
RenderingIcons.getBigIconResourceId(st.getOsmTag() + "_" + st.getOsmValue()));
|
||||
} else if (RenderingIcons.containsBigIcon(st.getOsmTag() + "_" + st.getOsmValue())) {
|
||||
return uiCtx.getResources().getDrawable(RenderingIcons.getBigIconResourceId(st.getOsmValue()));
|
||||
}
|
||||
}
|
||||
return null;
|
||||
} else if(type == TARGETS) {
|
||||
|
|
|
@ -4,13 +4,16 @@ import java.text.MessageFormat;
|
|||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
|
||||
import net.osmand.access.AccessibleToast;
|
||||
import net.osmand.data.Amenity;
|
||||
import net.osmand.data.AmenityType;
|
||||
import net.osmand.osm.MapPoiTypes;
|
||||
import net.osmand.osm.MapRenderingTypes;
|
||||
import net.osmand.osm.PoiCategory;
|
||||
import net.osmand.osm.PoiType;
|
||||
import net.osmand.osm.edit.EntityInfo;
|
||||
import net.osmand.osm.edit.EntityParser;
|
||||
import net.osmand.osm.edit.Node;
|
||||
|
@ -86,11 +89,15 @@ public class EditingPOIActivity implements DialogProvider {
|
|||
|
||||
private static Bundle dialogBundle = new Bundle();
|
||||
private OsmandSettings settings;
|
||||
private MapPoiTypes poiTypes;
|
||||
private Map<String, PoiType> allTranslatedSubTypes;
|
||||
|
||||
|
||||
public EditingPOIActivity(MapActivity uiContext){
|
||||
this.ctx = uiContext;
|
||||
|
||||
poiTypes = uiContext.getMyApplication().getPoiTypes();
|
||||
allTranslatedSubTypes = poiTypes.getAllTranslatedNames();
|
||||
settings = ((OsmandApplication) uiContext.getApplication()).getSettings();
|
||||
if (settings.OFFLINE_EDITION.get() || !settings.isInternetConnectionAvailable(true)) {
|
||||
this.openstreetmapUtil = new OpenstreetmapLocalUtil(ctx);
|
||||
|
@ -127,11 +134,11 @@ public class EditingPOIActivity implements DialogProvider {
|
|||
public void showCreateDialog(double latitude, double longitude){
|
||||
Node n = new Node(latitude, longitude, -1);
|
||||
n.putTag(OSMTagKey.OPENING_HOURS.getValue(), ""); //$NON-NLS-1$
|
||||
showPOIDialog(DIALOG_CREATE_POI, n, AmenityType.OTHER, "");
|
||||
showPOIDialog(DIALOG_CREATE_POI, n, poiTypes.getOtherPoiCategory(), "");
|
||||
}
|
||||
|
||||
private void showPOIDialog(int dialogID, Node n, AmenityType type, String subType) {
|
||||
Amenity a = EntityParser.parseAmenity(n, type, subType, null, MapRenderingTypes.getDefault());
|
||||
private void showPOIDialog(int dialogID, Node n, PoiCategory type, String subType) {
|
||||
Amenity a = EntityParser.parseAmenity(n, type, subType, null, MapRenderingTypes.getDefault());
|
||||
dialogBundle.putSerializable(KEY_AMENITY, a);
|
||||
dialogBundle.putSerializable(KEY_AMENITY_NODE, n);
|
||||
ctx.showDialog(dialogID);
|
||||
|
@ -269,7 +276,13 @@ public class EditingPOIActivity implements DialogProvider {
|
|||
} else {
|
||||
value.setHint("Value");
|
||||
}
|
||||
Set<String> subCategories = MapRenderingTypes.getDefault().getAmenityNameToType().keySet();
|
||||
Set<String> subCategories = new LinkedHashSet<String>();
|
||||
// could be osm values
|
||||
// for (String s : poiTypes.getAllTranslatedNames().keySet()) {
|
||||
// if (!subCategories.contains(s)) {
|
||||
// subCategories.add(s);
|
||||
// }
|
||||
// } ;
|
||||
ArrayAdapter<Object> valueAdapter = new ArrayAdapter<Object>(ctx, R.layout.list_textview, subCategories.toArray());
|
||||
value.setThreshold(1);
|
||||
value.setAdapter(valueAdapter);
|
||||
|
@ -374,11 +387,11 @@ public class EditingPOIActivity implements DialogProvider {
|
|||
public void afterTextChanged(Editable s) {
|
||||
String str = s.toString();
|
||||
a.setSubType(str);
|
||||
AmenityType t = MapRenderingTypes.getDefault().getAmenityNameToType().get(str);
|
||||
if(t != null && a.getType() != t){
|
||||
a.setType(t);
|
||||
typeButton.setText(OsmAndFormatter.toPublicString(t, ctx.getMyApplication()));
|
||||
updateSubTypesAdapter(t);
|
||||
PoiType st = allTranslatedSubTypes.get(str);
|
||||
if(st != null && a.getType() != st.getCategory() && st.getCategory() != null){
|
||||
a.setType(st.getCategory());
|
||||
typeButton.setText(st.getCategory().getTranslation());
|
||||
updateSubTypesAdapter(st.getCategory());
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -448,11 +461,16 @@ public class EditingPOIActivity implements DialogProvider {
|
|||
final String msg = n.getId() == -1 ? resources.getString(R.string.poi_action_add) : resources
|
||||
.getString(R.string.poi_action_change);
|
||||
OsmPoint.Action action = n.getId() == -1 ? OsmPoint.Action.CREATE : OsmPoint.Action.MODIFY;
|
||||
StringBuilder tag = new StringBuilder();
|
||||
StringBuilder value = new StringBuilder();
|
||||
String subType = typeText.getText().toString();
|
||||
MapRenderingTypes.getDefault().getAmenityTagValue(a.getType(), subType, tag, value);
|
||||
n.putTag(tag.toString(), value.toString());
|
||||
if(allTranslatedSubTypes.get(subType) != null) {
|
||||
PoiType pt = allTranslatedSubTypes.get(subType);
|
||||
n.putTag(pt.getOsmTag() , pt.getOsmValue());
|
||||
if(pt.getOsmTag2() != null) {
|
||||
n.putTag(pt.getOsmTag2(), pt.getOsmValue2());
|
||||
}
|
||||
} else {
|
||||
n.putTag(a.getType().getDefaultTag(), subType);
|
||||
}
|
||||
String name = nameText.getText().toString();
|
||||
if(name.length() > 0) {
|
||||
n.putTag(OSMTagKey.NAME.getValue(), name);
|
||||
|
@ -508,11 +526,10 @@ public class EditingPOIActivity implements DialogProvider {
|
|||
}
|
||||
}
|
||||
|
||||
private void updateSubTypesAdapter(AmenityType t){
|
||||
|
||||
Set<String> subCategories = new LinkedHashSet<String>(MapRenderingTypes.getDefault().getAmenityAllSubCategories(t));
|
||||
for(String s : MapRenderingTypes.getDefault().getAmenityNameToType().keySet()){
|
||||
if(!subCategories.contains(s)){
|
||||
private void updateSubTypesAdapter(PoiCategory poiCategory) {
|
||||
Set<String> subCategories = new LinkedHashSet<String>(poiTypes.getAllTranslatedNames(poiCategory).keySet());
|
||||
for (String s : poiTypes.getAllTranslatedNames().keySet()) {
|
||||
if (!subCategories.contains(s)) {
|
||||
subCategories.add(s);
|
||||
}
|
||||
}
|
||||
|
@ -522,7 +539,7 @@ public class EditingPOIActivity implements DialogProvider {
|
|||
|
||||
private void updateType(Amenity a){
|
||||
typeText.setText(a.getSubType());
|
||||
typeButton.setText(OsmAndFormatter.toPublicString(a.getType(), ctx.getMyApplication()));
|
||||
typeButton.setText(a.getType().getTranslation());
|
||||
updateSubTypesAdapter(a.getType());
|
||||
}
|
||||
|
||||
|
@ -602,63 +619,62 @@ public class EditingPOIActivity implements DialogProvider {
|
|||
public Dialog onCreateDialog(int id) {
|
||||
Bundle args = dialogBundle;
|
||||
switch (id) {
|
||||
case DIALOG_CREATE_POI:
|
||||
case DIALOG_EDIT_POI:
|
||||
return createPOIDialog(id,args);
|
||||
case DIALOG_DELETE_POI:
|
||||
return createDeleteDialog(args);
|
||||
case DIALOG_SUB_CATEGORIES: {
|
||||
Builder builder = new AlertDialog.Builder(ctx);
|
||||
final Amenity a = (Amenity) args.getSerializable(KEY_AMENITY);
|
||||
final String[] subCats = MapRenderingTypes.getDefault().getAmenityAllSubCategories(a.getType()).
|
||||
toArray(new String[0]);
|
||||
builder.setItems(subCats, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
typeText.setText(subCats[which]);
|
||||
a.setSubType(subCats[which]);
|
||||
ctx.removeDialog(DIALOG_SUB_CATEGORIES);
|
||||
}
|
||||
});
|
||||
builder.setOnCancelListener(new DialogInterface.OnCancelListener() {
|
||||
@Override
|
||||
public void onCancel(DialogInterface dialog) {
|
||||
ctx.removeDialog(DIALOG_SUB_CATEGORIES);
|
||||
}
|
||||
});
|
||||
return builder.create();
|
||||
}
|
||||
case DIALOG_POI_TYPES: {
|
||||
final Amenity a = (Amenity) args.getSerializable(KEY_AMENITY);
|
||||
Builder builder = new AlertDialog.Builder(ctx);
|
||||
final AmenityType[] categories = AmenityType.getCategories();
|
||||
String[] vals = new String[categories.length];
|
||||
for(int i=0; i<vals.length; i++){
|
||||
vals[i] = OsmAndFormatter.toPublicString(categories[i], ctx.getMyApplication());
|
||||
case DIALOG_CREATE_POI:
|
||||
case DIALOG_EDIT_POI:
|
||||
return createPOIDialog(id, args);
|
||||
case DIALOG_DELETE_POI:
|
||||
return createDeleteDialog(args);
|
||||
case DIALOG_SUB_CATEGORIES: {
|
||||
Builder builder = new AlertDialog.Builder(ctx);
|
||||
final Amenity a = (Amenity) args.getSerializable(KEY_AMENITY);
|
||||
final String[] subCats = poiTypes.getAllTranslatedNames(a.getType()).keySet().toArray(new String[0]);
|
||||
builder.setItems(subCats, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
typeText.setText(subCats[which]);
|
||||
a.setSubType(subCats[which]);
|
||||
ctx.removeDialog(DIALOG_SUB_CATEGORIES);
|
||||
}
|
||||
builder.setItems(vals, new Dialog.OnClickListener(){
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
AmenityType aType = categories[which];
|
||||
if(aType != a.getType()){
|
||||
a.setType(aType);
|
||||
a.setSubType(""); //$NON-NLS-1$
|
||||
updateType(a);
|
||||
}
|
||||
ctx.removeDialog(DIALOG_POI_TYPES);
|
||||
}
|
||||
});
|
||||
builder.setOnCancelListener(new DialogInterface.OnCancelListener() {
|
||||
@Override
|
||||
public void onCancel(DialogInterface dialog) {
|
||||
ctx.removeDialog(DIALOG_POI_TYPES);
|
||||
}
|
||||
});
|
||||
return builder.create();
|
||||
}
|
||||
case DIALOG_OPENING_HOURS: {
|
||||
return createOpenHoursDlg();
|
||||
});
|
||||
builder.setOnCancelListener(new DialogInterface.OnCancelListener() {
|
||||
@Override
|
||||
public void onCancel(DialogInterface dialog) {
|
||||
ctx.removeDialog(DIALOG_SUB_CATEGORIES);
|
||||
}
|
||||
});
|
||||
return builder.create();
|
||||
}
|
||||
case DIALOG_POI_TYPES: {
|
||||
final Amenity a = (Amenity) args.getSerializable(KEY_AMENITY);
|
||||
Builder builder = new AlertDialog.Builder(ctx);
|
||||
final List<PoiCategory> categories = poiTypes.getCategories();
|
||||
String[] vals = new String[categories.size()];
|
||||
for (int i = 0; i < vals.length; i++) {
|
||||
vals[i] = categories.get(i).getTranslation();
|
||||
}
|
||||
builder.setItems(vals, new Dialog.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
PoiCategory aType = categories.get(which);
|
||||
if (aType != a.getType()) {
|
||||
a.setType(aType);
|
||||
a.setSubType(""); //$NON-NLS-1$
|
||||
updateType(a);
|
||||
}
|
||||
ctx.removeDialog(DIALOG_POI_TYPES);
|
||||
}
|
||||
});
|
||||
builder.setOnCancelListener(new DialogInterface.OnCancelListener() {
|
||||
@Override
|
||||
public void onCancel(DialogInterface dialog) {
|
||||
ctx.removeDialog(DIALOG_POI_TYPES);
|
||||
}
|
||||
});
|
||||
return builder.create();
|
||||
}
|
||||
case DIALOG_OPENING_HOURS: {
|
||||
return createOpenHoursDlg();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -1,11 +1,8 @@
|
|||
package net.osmand.plus.osmedit;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import net.osmand.PlatformUtil;
|
||||
import net.osmand.data.Amenity;
|
||||
import net.osmand.data.AmenityType;
|
||||
import net.osmand.osm.MapRenderingTypes;
|
||||
import net.osmand.osm.PoiType;
|
||||
import net.osmand.osm.edit.EntityInfo;
|
||||
import net.osmand.osm.edit.Node;
|
||||
import net.osmand.osm.edit.OSMSettings.OSMTagKey;
|
||||
|
@ -52,7 +49,8 @@ public class OpenstreetmapLocalUtil implements OpenstreetmapUtil {
|
|||
|
||||
@Override
|
||||
public Node loadNode(Amenity n) {
|
||||
if(n.getId() % 2 == 1){
|
||||
PoiType st = n.getType().getPoiTypeByKeyName(n.getSubType());
|
||||
if(n.getId() % 2 == 1 || st == null){
|
||||
// that's way id
|
||||
return null;
|
||||
}
|
||||
|
@ -62,10 +60,8 @@ public class OpenstreetmapLocalUtil implements OpenstreetmapUtil {
|
|||
Node entity = new Node(n.getLocation().getLatitude(),
|
||||
n.getLocation().getLongitude(),
|
||||
nodeId);
|
||||
StringBuilder tag = new StringBuilder();
|
||||
StringBuilder value = new StringBuilder();
|
||||
MapRenderingTypes.getDefault().getAmenityTagValue(n.getType(), n.getSubType(), tag, value);
|
||||
entity.putTag(tag.toString(), value.toString());
|
||||
entity.putTag(st.getOsmTag(), st.getOsmValue());
|
||||
entity.putTag(st.getOsmTag2(), st.getOsmValue2());
|
||||
entity.putTag(OSMTagKey.NAME.getValue(), n.getName());
|
||||
entity.putTag(OSMTagKey.OPENING_HOURS.getValue(), n.getOpeningHours());
|
||||
|
||||
|
|
|
@ -27,10 +27,9 @@ public class OpenstreetmapPoint extends OsmPoint implements Serializable {
|
|||
}
|
||||
|
||||
public String getType() {
|
||||
String type = AmenityType.valueToString(AmenityType.OTHER);
|
||||
for(String k : entity.getTagKeySet()){
|
||||
if (!OSMTagKey.NAME.getValue().equals(k) &&
|
||||
!OSMTagKey.OPENING_HOURS.getValue().equals(k)) {
|
||||
String type = "amenity";
|
||||
for (String k : entity.getTagKeySet()) {
|
||||
if (!OSMTagKey.NAME.getValue().equals(k) && !OSMTagKey.OPENING_HOURS.getValue().equals(k)) {
|
||||
type = k;
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -2,7 +2,6 @@ package net.osmand.plus.poi;
|
|||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.ArrayList;
|
||||
|
@ -11,11 +10,10 @@ import java.util.List;
|
|||
import net.osmand.PlatformUtil;
|
||||
import net.osmand.ResultMatcher;
|
||||
import net.osmand.data.Amenity;
|
||||
import net.osmand.data.AmenityType;
|
||||
import net.osmand.osm.MapPoiTypes;
|
||||
import net.osmand.osm.io.NetworkUtils;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.R.string;
|
||||
import net.osmand.util.MapUtils;
|
||||
import net.sf.junidecode.Junidecode;
|
||||
|
||||
|
@ -85,6 +83,7 @@ public class NameFinderPoiFilter extends PoiLegacyFilter {
|
|||
int eventType;
|
||||
int namedDepth= 0;
|
||||
Amenity a = null;
|
||||
MapPoiTypes poiTypes = ((OsmandApplication) getApplication()).getPoiTypes();
|
||||
while ((eventType = parser.next()) != XmlPullParser.END_DOCUMENT) {
|
||||
if (eventType == XmlPullParser.START_TAG) {
|
||||
if (parser.getName().equals("searchresults")) { //$NON-NLS-1$
|
||||
|
@ -106,7 +105,7 @@ public class NameFinderPoiFilter extends PoiLegacyFilter {
|
|||
String name = parser.getAttributeValue("", "display_name"); //$NON-NLS-1$//$NON-NLS-2$
|
||||
a.setName(name);
|
||||
a.setEnName(Junidecode.unidecode(name));
|
||||
a.setType(AmenityType.OTHER);
|
||||
a.setType(poiTypes.getOtherPoiCategory());
|
||||
a.setSubType(parser.getAttributeValue("", "type")); //$NON-NLS-1$//$NON-NLS-2$
|
||||
if (matcher == null || matcher.publish(a)) {
|
||||
searchedAmenities.add(a);
|
||||
|
|
|
@ -10,10 +10,10 @@ import java.util.LinkedHashSet;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import net.osmand.data.AmenityType;
|
||||
import net.osmand.osm.MapPoiTypes;
|
||||
import net.osmand.osm.PoiCategory;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.R.string;
|
||||
import net.osmand.plus.api.SQLiteAPI.SQLiteConnection;
|
||||
import net.osmand.plus.api.SQLiteAPI.SQLiteCursor;
|
||||
import net.osmand.plus.api.SQLiteAPI.SQLiteStatement;
|
||||
|
@ -39,9 +39,11 @@ public class PoiFiltersHelper {
|
|||
private static final String UDF_PARKING = "parking";
|
||||
|
||||
private static final String[] DEL = new String[] {};
|
||||
private MapPoiTypes poiTypes;
|
||||
|
||||
public PoiFiltersHelper(OsmandApplication application){
|
||||
this.application = application;
|
||||
poiTypes = application.getPoiTypes();
|
||||
}
|
||||
public NameFinderPoiFilter getNameFinderPOIFilter() {
|
||||
if(nameFinderPOIFilter == null){
|
||||
|
@ -73,14 +75,14 @@ public class PoiFiltersHelper {
|
|||
return findPoiFilter(filterId, getUserDefinedPoiFilters(), getTopStandardFilters(), getOsmDefinedPoiFilters());
|
||||
}
|
||||
|
||||
private void putAll(Map<AmenityType, LinkedHashSet<String>> types, AmenityType tp){
|
||||
types.put(tp, null);
|
||||
private void putAll(Map<PoiCategory, LinkedHashSet<String>> types, String tp) {
|
||||
types.put(poiTypes.getPoiCategoryByName(tp), null);
|
||||
}
|
||||
|
||||
private void putValues(Map<AmenityType, LinkedHashSet<String>> types, AmenityType tp,String... vls){
|
||||
private void putValues(Map<PoiCategory, LinkedHashSet<String>> types, String p, String... vls) {
|
||||
LinkedHashSet<String> list = new LinkedHashSet<String>();
|
||||
Collections.addAll(list, vls);
|
||||
types.put(tp, list);
|
||||
Collections.addAll(list, vls);
|
||||
types.put(poiTypes.getPoiCategoryByName(p), list);
|
||||
}
|
||||
|
||||
private List<PoiLegacyFilter> getUserDefinedDefaultFilters() {
|
||||
|
@ -108,35 +110,35 @@ public class PoiFiltersHelper {
|
|||
return filters;
|
||||
}
|
||||
|
||||
private Map<AmenityType, LinkedHashSet<String>> configureDefaultUserDefinedFilter(Map<AmenityType, LinkedHashSet<String>> types, String key) {
|
||||
private Map<PoiCategory, LinkedHashSet<String>> configureDefaultUserDefinedFilter(Map<PoiCategory, LinkedHashSet<String>> types, String key) {
|
||||
if(types == null) {
|
||||
types = new LinkedHashMap<AmenityType, LinkedHashSet<String>>();
|
||||
types = new LinkedHashMap<PoiCategory, LinkedHashSet<String>>();
|
||||
}
|
||||
if(UDF_ACCOMMODATION.equals(key)){
|
||||
putValues(types, AmenityType.TOURISM, "camp_site",
|
||||
putValues(types, "tourism", "camp_site",
|
||||
"caravan_site","picnic_site","alpine_hut", "chalet","guest_house",
|
||||
"hostel", "hotel","motel");
|
||||
} else if (UDF_CAR_AID.equals(key)) {
|
||||
putValues(types, AmenityType.TRANSPORTATION, "fuel", "car_wash", "car_repair","car", "car_sharing");
|
||||
putValues(types, AmenityType.SHOP, "fuel", "car_wash", "car_repair","car", "car_parts");
|
||||
putValues(types, "transportation", "fuel", "car_wash", "car_repair","car", "car_sharing");
|
||||
putValues(types, "shop", "fuel", "car_wash", "car_repair","car", "car_parts");
|
||||
} else if (UDF_FOOD_SHOP.equals(key)) {
|
||||
putValues(types, AmenityType.SHOP, "alcohol", "bakery", "beverages", "butcher", "convenience", "department_store",
|
||||
putValues(types, "shop", "alcohol", "bakery", "beverages", "butcher", "convenience", "department_store",
|
||||
"convenience", "farm", "general", "ice_cream", "kiosk", "seafood", "supermarket", "variety_store");
|
||||
} else if(UDF_FOR_TOURISTS.equals(key)){
|
||||
putAll(types, AmenityType.HISTORIC);
|
||||
putAll(types, AmenityType.TOURISM);
|
||||
putAll(types, AmenityType.FINANCE);
|
||||
putAll(types, AmenityType.OSMWIKI);
|
||||
putValues(types, AmenityType.OTHER, "place_of_worship", "internet_access_wlan", "internet_access_wired",
|
||||
putAll(types, "historic");
|
||||
putAll(types, "tourism");
|
||||
putAll(types, "finance");
|
||||
putAll(types, "osmwiki");
|
||||
putValues(types, "other", "place_of_worship", "internet_access_wlan", "internet_access_wired",
|
||||
"internet_access_terminal", "internet_access_public", "internet_access_service",
|
||||
"embassy", "marketplace", "post_office", "telephone", "toilets", "emergency_phone");
|
||||
} else if(UDF_FUEL.equals(key)){
|
||||
putValues(types, AmenityType.TRANSPORTATION, "fuel");
|
||||
putValues(types, "transportation", "fuel");
|
||||
} else if (UDF_PARKING.equals(key)) {
|
||||
putValues(types, AmenityType.TRANSPORTATION, "parking",
|
||||
putValues(types, "transportation", "parking",
|
||||
"bicycle_parking");
|
||||
} else if (UDF_PUBLIC_TRANSPORT.equals(key)) {
|
||||
putValues(types, AmenityType.TRANSPORTATION, "public_transport_stop_position", "public_transport_platform",
|
||||
putValues(types, "transportation", "public_transport_stop_position", "public_transport_platform",
|
||||
"public_transport_station",
|
||||
// railway
|
||||
"railway_platform", "railway_station", "halt", "tram_stop", "subway_entrance", "railway_buffer_stop",
|
||||
|
@ -151,19 +153,19 @@ public class PoiFiltersHelper {
|
|||
// "rail", "tram", "light_rail", "subway", "railway_narrow_gauge", "railway_monorail", "railway_funicular"
|
||||
);
|
||||
} else if (UDF_RESTAURANTS.equals(key)) {
|
||||
putValues(types, AmenityType.SUSTENANCE, "restaurant",
|
||||
putValues(types, "sustenance", "restaurant",
|
||||
"cafe", "food_court", "fast_food", "pub", "bar", "biergarten");
|
||||
} else if (UDF_SIGHTSEEING.equals(key)) {
|
||||
putAll(types, AmenityType.HISTORIC);
|
||||
putValues(types, AmenityType.TOURISM, "attraction",
|
||||
putAll(types, "historic");
|
||||
putValues(types, "tourism", "attraction",
|
||||
"artwork","zoo","theme_park", "museum","viewpoint");
|
||||
putAll(types, AmenityType.OSMWIKI);
|
||||
putValues(types, AmenityType.OTHER, "place_of_worship");
|
||||
putAll(types, "osmwiki");
|
||||
putValues(types, "other", "place_of_worship");
|
||||
} else if (UDF_EMERGENCY.equals(key)) {
|
||||
putAll(types, AmenityType.HEALTHCARE);
|
||||
putAll(types, AmenityType.EMERGENCY);
|
||||
putAll(types, "healthcare");
|
||||
putAll(types, "emergency");
|
||||
} else if (UDF_ENTERTAINMENT.equals(key)) {
|
||||
putAll(types, AmenityType.ENTERTAINMENT);
|
||||
putAll(types, "entertainment");
|
||||
}
|
||||
return types;
|
||||
}
|
||||
|
@ -194,7 +196,7 @@ public class PoiFiltersHelper {
|
|||
if (cacheTopStandardFilters == null) {
|
||||
cacheTopStandardFilters = new ArrayList<PoiLegacyFilter>();
|
||||
PoiLegacyFilter filter = new PoiLegacyFilter(application.getString(R.string.poi_filter_custom_filter),
|
||||
PoiLegacyFilter.CUSTOM_FILTER_ID, new LinkedHashMap<AmenityType, LinkedHashSet<String>>(), application); //$NON-NLS-1$
|
||||
PoiLegacyFilter.CUSTOM_FILTER_ID, new LinkedHashMap<PoiCategory, LinkedHashSet<String>>(), application); //$NON-NLS-1$
|
||||
filter.setStandardFilter(true);
|
||||
cacheTopStandardFilters.add(filter);
|
||||
cacheTopStandardFilters.add(new PoiLegacyFilter(null, application));
|
||||
|
@ -205,8 +207,8 @@ public class PoiFiltersHelper {
|
|||
return Collections.unmodifiableList(cacheTopStandardFilters);
|
||||
}
|
||||
|
||||
public static String getOsmDefinedFilterId(AmenityType t){
|
||||
return PoiLegacyFilter.STD_PREFIX + t;
|
||||
public static String getOsmDefinedFilterId(PoiCategory t){
|
||||
return PoiLegacyFilter.STD_PREFIX + t.getKeyName();
|
||||
}
|
||||
|
||||
public void updateFilters(boolean onlyAddFilters){
|
||||
|
@ -219,7 +221,7 @@ public class PoiFiltersHelper {
|
|||
public List<PoiLegacyFilter> getOsmDefinedPoiFilters(){
|
||||
if(cacheOsmDefinedFilters == null){
|
||||
cacheOsmDefinedFilters = new ArrayList<PoiLegacyFilter>();
|
||||
for(AmenityType t : AmenityType.getCategories()){
|
||||
for(PoiCategory t : poiTypes.getCategories()){
|
||||
cacheOsmDefinedFilters.add(new PoiLegacyFilter(t, application));
|
||||
}
|
||||
final Collator instance = Collator.getInstance();
|
||||
|
@ -394,18 +396,18 @@ public class PoiFiltersHelper {
|
|||
if(!addOnlyCategories){
|
||||
db.execSQL("INSERT INTO " + FILTER_NAME + " VALUES (?, ?, ?)",new Object[]{p.getName(), p.getFilterId(), p.getFilterByName()}); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
}
|
||||
Map<AmenityType, LinkedHashSet<String>> types = p.getAcceptedTypes();
|
||||
Map<PoiCategory, LinkedHashSet<String>> types = p.getAcceptedTypes();
|
||||
SQLiteStatement insertCategories = db.compileStatement("INSERT INTO " + CATEGORIES_NAME + " VALUES (?, ?, ?)"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
for(AmenityType a : types.keySet()){
|
||||
for(PoiCategory a : types.keySet()){
|
||||
if(types.get(a) == null){
|
||||
insertCategories.bindString(1, p.getFilterId());
|
||||
insertCategories.bindString(2, AmenityType.valueToString(a));
|
||||
insertCategories.bindString(2, a.getTranslation());
|
||||
insertCategories.bindNull(3);
|
||||
insertCategories.execute();
|
||||
} else {
|
||||
for(String s : types.get(a)){
|
||||
insertCategories.bindString(1, p.getFilterId());
|
||||
insertCategories.bindString(2, AmenityType.valueToString(a));
|
||||
insertCategories.bindString(2, a.getTranslation());
|
||||
insertCategories.bindString(3, s);
|
||||
insertCategories.execute();
|
||||
}
|
||||
|
@ -422,15 +424,15 @@ public class PoiFiltersHelper {
|
|||
if(conn != null){
|
||||
SQLiteCursor query = conn.rawQuery("SELECT " + CATEGORIES_FILTER_ID +", " + CATEGORIES_COL_CATEGORY +"," + CATEGORIES_COL_SUBCATEGORY +" FROM " + //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
|
||||
CATEGORIES_NAME, null);
|
||||
Map<String, Map<AmenityType, LinkedHashSet<String>>> map = new LinkedHashMap<String, Map<AmenityType,LinkedHashSet<String>>>();
|
||||
Map<String, Map<PoiCategory, LinkedHashSet<String>>> map = new LinkedHashMap<String, Map<PoiCategory,LinkedHashSet<String>>>();
|
||||
if(query.moveToFirst()){
|
||||
do {
|
||||
String filterId = query.getString(0);
|
||||
if(!map.containsKey(filterId)){
|
||||
map.put(filterId, new LinkedHashMap<AmenityType, LinkedHashSet<String>>());
|
||||
map.put(filterId, new LinkedHashMap<PoiCategory, LinkedHashSet<String>>());
|
||||
}
|
||||
Map<AmenityType, LinkedHashSet<String>> m = map.get(filterId);
|
||||
AmenityType a = AmenityType.findOrCreateTypeNoReg(query.getString(1));
|
||||
Map<PoiCategory, LinkedHashSet<String>> m = map.get(filterId);
|
||||
PoiCategory a = poiTypes.getPoiCategoryByName(query.getString(1));
|
||||
String subCategory = query.getString(2);
|
||||
if(subCategory == null){
|
||||
m.put(a, null);
|
||||
|
@ -450,7 +452,8 @@ public class PoiFiltersHelper {
|
|||
do {
|
||||
String filterId = query.getString(0);
|
||||
if(map.containsKey(filterId)){
|
||||
PoiLegacyFilter filter = new PoiLegacyFilter(query.getString(1), filterId, map.get(filterId), application);
|
||||
PoiLegacyFilter filter = new PoiLegacyFilter(query.getString(1), filterId,
|
||||
map.get(filterId), application);
|
||||
filter.setFilterByName(query.getString(2));
|
||||
list.add(filter);
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package net.osmand.plus.poi;
|
||||
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashMap;
|
||||
|
@ -9,10 +10,10 @@ import java.util.Map;
|
|||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
|
||||
import net.osmand.IndexConstants;
|
||||
import net.osmand.ResultMatcher;
|
||||
import net.osmand.data.Amenity;
|
||||
import net.osmand.data.AmenityType;
|
||||
import net.osmand.osm.MapPoiTypes;
|
||||
import net.osmand.osm.PoiCategory;
|
||||
import net.osmand.plus.OsmAndFormatter;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.R;
|
||||
|
@ -26,7 +27,8 @@ public class PoiLegacyFilter {
|
|||
public final static String CUSTOM_FILTER_ID = USER_PREFIX + "custom_id"; //$NON-NLS-1$
|
||||
public final static String BY_NAME_FILTER_ID = USER_PREFIX + "by_name"; //$NON-NLS-1$
|
||||
|
||||
private Map<AmenityType, LinkedHashSet<String>> acceptedTypes = new LinkedHashMap<AmenityType, LinkedHashSet<String>>();
|
||||
private Map<PoiCategory, LinkedHashSet<String>> acceptedTypes = new LinkedHashMap<PoiCategory,
|
||||
LinkedHashSet<String>>();
|
||||
private String filterByName = null;
|
||||
|
||||
protected String filterId;
|
||||
|
@ -39,15 +41,16 @@ public class PoiLegacyFilter {
|
|||
protected int distanceInd = 1;
|
||||
// in kilometers
|
||||
protected double[] distanceToSearchValues = new double[] {1, 2, 5, 10, 20, 50, 100, 200, 500 };
|
||||
private final MapPoiTypes poiTypes;
|
||||
|
||||
|
||||
// constructor for standard filters
|
||||
public PoiLegacyFilter(AmenityType type, OsmandApplication application){
|
||||
public PoiLegacyFilter(PoiCategory type, OsmandApplication application){
|
||||
this.app = application;
|
||||
isStandardFilter = true;
|
||||
filterId = STD_PREFIX + type;
|
||||
name = type == null ? application.getString(R.string.poi_filter_closest_poi) : OsmAndFormatter.toPublicString(type,
|
||||
application); //$NON-NLS-1$
|
||||
poiTypes = application.getPoiTypes();
|
||||
name = type == null ? application.getString(R.string.poi_filter_closest_poi) : type.getTranslation(); //$NON-NLS-1$
|
||||
if(type == null){
|
||||
initSearchAll();
|
||||
} else {
|
||||
|
@ -56,9 +59,10 @@ public class PoiLegacyFilter {
|
|||
}
|
||||
|
||||
// constructor for user defined filters
|
||||
public PoiLegacyFilter(String name, String filterId, Map<AmenityType, LinkedHashSet<String>> acceptedTypes, OsmandApplication app){
|
||||
public PoiLegacyFilter(String name, String filterId, Map<PoiCategory, LinkedHashSet<String>> acceptedTypes, OsmandApplication app){
|
||||
this.app = app;
|
||||
isStandardFilter = false;
|
||||
poiTypes = app.getPoiTypes();
|
||||
if(filterId == null){
|
||||
filterId = USER_PREFIX + name.replace(' ', '_').toLowerCase();
|
||||
}
|
||||
|
@ -88,7 +92,7 @@ public class PoiLegacyFilter {
|
|||
}
|
||||
|
||||
private void initSearchAll(){
|
||||
for(AmenityType t : AmenityType.getCategories()){
|
||||
for(PoiCategory t : poiTypes.getCategories()){
|
||||
acceptedTypes.put(t, null);
|
||||
}
|
||||
distanceToSearchValues = new double[] {0.5, 1, 2, 5, 10, 20, 50, 100};
|
||||
|
@ -191,20 +195,20 @@ public class PoiLegacyFilter {
|
|||
* @param type
|
||||
* @return null if all subtypes are accepted/ empty list if type is not accepted at all
|
||||
*/
|
||||
public Set<String> getAcceptedSubtypes(AmenityType type){
|
||||
public Set<String> getAcceptedSubtypes(PoiCategory type){
|
||||
if(!acceptedTypes.containsKey(type)){
|
||||
return Collections.emptySet();
|
||||
}
|
||||
return acceptedTypes.get(type);
|
||||
}
|
||||
|
||||
public boolean isTypeAccepted(AmenityType t){
|
||||
public boolean isTypeAccepted(PoiCategory t){
|
||||
return acceptedTypes.containsKey(t);
|
||||
}
|
||||
|
||||
public boolean acceptTypeSubtype(AmenityType t, String subtype){
|
||||
if(!AmenityType.isRegisteredType(t)) {
|
||||
t = AmenityType.USER_DEFINED;
|
||||
public boolean acceptTypeSubtype(PoiCategory t, String subtype){
|
||||
if(!poiTypes.isRegisteredType(t)) {
|
||||
t = poiTypes.getOtherPoiCategory();
|
||||
}
|
||||
if(!acceptedTypes.containsKey(t)){
|
||||
return false;
|
||||
|
@ -217,12 +221,12 @@ public class PoiLegacyFilter {
|
|||
}
|
||||
|
||||
public void clearFilter(){
|
||||
acceptedTypes = new LinkedHashMap<AmenityType, LinkedHashSet<String>>();
|
||||
acceptedTypes = new LinkedHashMap<PoiCategory, LinkedHashSet<String>>();
|
||||
}
|
||||
|
||||
public boolean areAllTypesAccepted(){
|
||||
if(AmenityType.getCategoriesSize() == acceptedTypes.size()){
|
||||
for(AmenityType a : acceptedTypes.keySet()){
|
||||
if(poiTypes.getCategories().size() == acceptedTypes.size()){
|
||||
for(PoiCategory a : acceptedTypes.keySet()){
|
||||
if(acceptedTypes.get(a) != null){
|
||||
return false;
|
||||
}
|
||||
|
@ -233,7 +237,7 @@ public class PoiLegacyFilter {
|
|||
}
|
||||
|
||||
|
||||
public void setTypeToAccept(AmenityType type, boolean accept){
|
||||
public void setTypeToAccept(PoiCategory type, boolean accept){
|
||||
if(accept){
|
||||
acceptedTypes.put(type, new LinkedHashSet<String>());
|
||||
} else {
|
||||
|
@ -241,11 +245,11 @@ public class PoiLegacyFilter {
|
|||
}
|
||||
}
|
||||
|
||||
public void setMapToAccept(Map<AmenityType, List<String>> newMap) {
|
||||
Iterator<Entry<AmenityType, List<String>>> iterator = newMap.entrySet().iterator();
|
||||
public void setMapToAccept(Map<PoiCategory, List<String>> newMap) {
|
||||
Iterator<Entry<PoiCategory, List<String>>> iterator = newMap.entrySet().iterator();
|
||||
acceptedTypes.clear();
|
||||
while(iterator.hasNext()){
|
||||
Entry<AmenityType, List<String>> e = iterator.next();
|
||||
Entry<PoiCategory, List<String>> e = iterator.next();
|
||||
if(e.getValue() == null){
|
||||
acceptedTypes.put(e.getKey(), null);
|
||||
} else {
|
||||
|
@ -254,49 +258,13 @@ public class PoiLegacyFilter {
|
|||
}
|
||||
}
|
||||
|
||||
public String buildSqlWhereFilter(){
|
||||
if(areAllTypesAccepted()){
|
||||
return null;
|
||||
}
|
||||
assert IndexConstants.POI_TABLE != null : "use constants here to show table usage "; //$NON-NLS-1$
|
||||
if(acceptedTypes.size() == 0){
|
||||
return "1 > 1"; //$NON-NLS-1$
|
||||
}
|
||||
StringBuilder b = new StringBuilder();
|
||||
b.append("("); //$NON-NLS-1$
|
||||
boolean first = true;
|
||||
for(AmenityType a : acceptedTypes.keySet()){
|
||||
if(first){
|
||||
first = false;
|
||||
} else {
|
||||
b.append(" OR "); //$NON-NLS-1$
|
||||
}
|
||||
b.append("(type = '").append(AmenityType.valueToString(a)).append("'"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
if(acceptedTypes.get(a) != null){
|
||||
LinkedHashSet<String> list = acceptedTypes.get(a);
|
||||
b.append(" AND subtype IN ("); //$NON-NLS-1$
|
||||
boolean bfirst = true;
|
||||
for(String s : list){
|
||||
if(bfirst){
|
||||
bfirst = false;
|
||||
} else {
|
||||
b.append(", "); //$NON-NLS-1$
|
||||
}
|
||||
b.append("'").append(s).append("'"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
}
|
||||
b.append(")"); //$NON-NLS-1$
|
||||
}
|
||||
b.append(")"); //$NON-NLS-1$
|
||||
}
|
||||
b.append(")"); //$NON-NLS-1$
|
||||
return b.toString();
|
||||
|
||||
|
||||
public Map<PoiCategory, LinkedHashSet<String>> getAcceptedTypes(){
|
||||
return new LinkedHashMap<PoiCategory, LinkedHashSet<String>>(acceptedTypes);
|
||||
}
|
||||
|
||||
public Map<AmenityType, LinkedHashSet<String>> getAcceptedTypes(){
|
||||
return new LinkedHashMap<AmenityType, LinkedHashSet<String>>(acceptedTypes);
|
||||
}
|
||||
|
||||
public void selectSubTypesToAccept(AmenityType t, LinkedHashSet<String> accept){
|
||||
public void selectSubTypesToAccept(PoiCategory t, LinkedHashSet<String> accept){
|
||||
acceptedTypes.put(t, accept);
|
||||
}
|
||||
|
||||
|
|
|
@ -7,10 +7,9 @@ import java.util.List;
|
|||
|
||||
import net.osmand.ResultMatcher;
|
||||
import net.osmand.data.Amenity;
|
||||
import net.osmand.data.AmenityType;
|
||||
import net.osmand.osm.PoiCategory;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.R.string;
|
||||
import net.osmand.util.MapUtils;
|
||||
|
||||
public class SearchByNameFilter extends PoiLegacyFilter {
|
||||
|
@ -22,7 +21,7 @@ public class SearchByNameFilter extends PoiLegacyFilter {
|
|||
private String query = ""; //$NON-NLS-1$
|
||||
|
||||
public SearchByNameFilter(OsmandApplication application) {
|
||||
super(application.getString(R.string.poi_filter_by_name), FILTER_ID, new LinkedHashMap<AmenityType, LinkedHashSet<String>>(), application);
|
||||
super(application.getString(R.string.poi_filter_by_name), FILTER_ID, new LinkedHashMap<PoiCategory, LinkedHashSet<String>>(), application);
|
||||
this.distanceToSearchValues = new double[] {100, 1000, 5000};
|
||||
this.isStandardFilter = true;
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@ import net.osmand.binary.BinaryMapIndexReader.MapIndex;
|
|||
import net.osmand.binary.BinaryMapIndexReader.SearchPoiTypeFilter;
|
||||
import net.osmand.binary.BinaryMapIndexReader.SearchRequest;
|
||||
import net.osmand.data.Amenity;
|
||||
import net.osmand.data.AmenityType;
|
||||
import net.osmand.osm.PoiCategory;
|
||||
import net.osmand.plus.poi.PoiLegacyFilter;
|
||||
import net.osmand.util.MapUtils;
|
||||
|
||||
|
@ -49,7 +49,7 @@ public class AmenityIndexRepositoryBinary implements AmenityIndexRepository {
|
|||
}
|
||||
|
||||
|
||||
public synchronized Map<AmenityType, List<String>> searchAmenityCategoriesByName(String query, Map<AmenityType, List<String>> map) {
|
||||
public synchronized Map<PoiCategory, List<String>> searchAmenityCategoriesByName(String query, Map<PoiCategory, List<String>> map) {
|
||||
try {
|
||||
return index.searchPoiCategoriesByName(query, map);
|
||||
} catch (IOException e) {
|
||||
|
@ -87,7 +87,7 @@ public class AmenityIndexRepositoryBinary implements AmenityIndexRepository {
|
|||
long now = System.currentTimeMillis();
|
||||
SearchPoiTypeFilter poiTypeFilter = new SearchPoiTypeFilter(){
|
||||
@Override
|
||||
public boolean accept(AmenityType type, String subcategory) {
|
||||
public boolean accept(PoiCategory type, String subcategory) {
|
||||
return filter.acceptTypeSubtype(type, subcategory);
|
||||
}
|
||||
};
|
||||
|
@ -112,7 +112,7 @@ public class AmenityIndexRepositoryBinary implements AmenityIndexRepository {
|
|||
long now = System.currentTimeMillis();
|
||||
SearchPoiTypeFilter poiTypeFilter = new SearchPoiTypeFilter(){
|
||||
@Override
|
||||
public boolean accept(AmenityType type, String subcategory) {
|
||||
public boolean accept(PoiCategory type, String subcategory) {
|
||||
return filter.acceptTypeSubtype(type, subcategory);
|
||||
}
|
||||
};
|
||||
|
|
|
@ -27,7 +27,6 @@ import net.osmand.ResultMatcher;
|
|||
import net.osmand.binary.BinaryMapIndexReader;
|
||||
import net.osmand.binary.CachedOsmandIndexes;
|
||||
import net.osmand.data.Amenity;
|
||||
import net.osmand.data.AmenityType;
|
||||
import net.osmand.data.LatLon;
|
||||
import net.osmand.data.RotatedTileBox;
|
||||
import net.osmand.data.TransportStop;
|
||||
|
@ -35,6 +34,7 @@ import net.osmand.map.ITileSource;
|
|||
import net.osmand.map.MapTileDownloader;
|
||||
import net.osmand.map.MapTileDownloader.DownloadRequest;
|
||||
import net.osmand.map.OsmandRegions;
|
||||
import net.osmand.osm.PoiCategory;
|
||||
import net.osmand.plus.BusyIndicator;
|
||||
import net.osmand.plus.OsmAndFormatter;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
|
@ -812,8 +812,8 @@ public class ResourceManager {
|
|||
return amenities;
|
||||
}
|
||||
|
||||
public Map<AmenityType, List<String>> searchAmenityCategoriesByName(String searchQuery, double lat, double lon) {
|
||||
Map<AmenityType, List<String>> map = new LinkedHashMap<AmenityType, List<String>>();
|
||||
public Map<PoiCategory, List<String>> searchAmenityCategoriesByName(String searchQuery, double lat, double lon) {
|
||||
Map<PoiCategory, List<String>> map = new LinkedHashMap<PoiCategory, List<String>>();
|
||||
for (AmenityIndexRepository index : amenityRepositories) {
|
||||
if (index instanceof AmenityIndexRepositoryBinary) {
|
||||
if (index.checkContains(lat, lon)) {
|
||||
|
|
|
@ -8,11 +8,11 @@ import net.osmand.PlatformUtil;
|
|||
import net.osmand.ResultMatcher;
|
||||
import net.osmand.access.AccessibleToast;
|
||||
import net.osmand.data.Amenity;
|
||||
import net.osmand.data.AmenityType;
|
||||
import net.osmand.data.LatLon;
|
||||
import net.osmand.data.QuadRect;
|
||||
import net.osmand.data.RotatedTileBox;
|
||||
import net.osmand.osm.MapRenderingTypes;
|
||||
import net.osmand.osm.MapPoiTypes;
|
||||
import net.osmand.osm.PoiType;
|
||||
import net.osmand.plus.ContextMenuAdapter;
|
||||
import net.osmand.plus.ContextMenuAdapter.OnContextMenuClick;
|
||||
import net.osmand.plus.OsmAndFormatter;
|
||||
|
@ -21,7 +21,6 @@ import net.osmand.plus.activities.MapActivity;
|
|||
import net.osmand.plus.poi.PoiLegacyFilter;
|
||||
import net.osmand.plus.render.RenderingIcons;
|
||||
import net.osmand.plus.resources.ResourceManager;
|
||||
import net.osmand.plus.routing.RouteCalculationResult;
|
||||
import net.osmand.plus.routing.RoutingHelper;
|
||||
import net.osmand.plus.routing.RoutingHelper.IRouteInformationListener;
|
||||
import net.osmand.plus.views.MapTextLayer.MapTextProvider;
|
||||
|
@ -206,6 +205,7 @@ public class POIMapLayer extends OsmandMapLayer implements ContextMenuLayer.ICon
|
|||
data.queryNewData(tileBox);
|
||||
objects = data.getResults();
|
||||
if (objects != null) {
|
||||
MapPoiTypes poiTypes = view.getApplication().getPoiTypes();
|
||||
int r = getRadiusPoi(tileBox);
|
||||
for (Amenity o : objects) {
|
||||
int x = (int) tileBox.getPixXFromLatLon(o.getLocation().getLatitude(), o.getLocation()
|
||||
|
@ -215,13 +215,15 @@ public class POIMapLayer extends OsmandMapLayer implements ContextMenuLayer.ICon
|
|||
canvas.drawCircle(x, y, r, pointAltUI);
|
||||
canvas.drawCircle(x, y, r, point);
|
||||
String id = null;
|
||||
StringBuilder tag = new StringBuilder();
|
||||
StringBuilder value = new StringBuilder();
|
||||
MapRenderingTypes.getDefault().getAmenityTagValue(o.getType(), o.getSubType(), tag, value);
|
||||
if (RenderingIcons.containsIcon(tag + "_" + value)) {
|
||||
id = tag + "_" + value;
|
||||
} else if (RenderingIcons.containsIcon(tag.toString())) {
|
||||
id = tag.toString();
|
||||
PoiType st = o.getType().getPoiTypeByKeyName(o.getSubType());
|
||||
if (st != null) {
|
||||
if (RenderingIcons.containsIcon(st.getKeyName())) {
|
||||
id = st.getKeyName();
|
||||
} else if (RenderingIcons.containsIcon(st.getOsmTag() + "_" + st.getOsmValue())) {
|
||||
id = st.getOsmTag() + "_" + st.getOsmValue();
|
||||
} else if (RenderingIcons.containsIcon(st.getOsmValue())) {
|
||||
id = st.getOsmValue();
|
||||
}
|
||||
}
|
||||
if (id != null) {
|
||||
Bitmap bmp = RenderingIcons.getIcon(view.getContext(), id);
|
||||
|
@ -301,7 +303,7 @@ public class POIMapLayer extends OsmandMapLayer implements ContextMenuLayer.ICon
|
|||
Builder bs = new AlertDialog.Builder(view.getContext());
|
||||
bs.setTitle(OsmAndFormatter.getPoiSimpleFormat(a, view.getApplication(),
|
||||
view.getSettings().usingEnglishNames()));
|
||||
if (a.getType() == AmenityType.OSMWIKI) {
|
||||
if (a.getType().isWiki()) {
|
||||
bs.setMessage(a.getDescription());
|
||||
} else {
|
||||
bs.setMessage(OsmAndFormatter.getAmenityDescriptionContent(view.getApplication(), a, false));
|
||||
|
|
Loading…
Reference in a new issue