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