Merge pull request #915 from jtrax/bugfixes
Added more elements in the predefined list of POI types and fixed issue
This commit is contained in:
commit
b1b70ccb82
3 changed files with 62 additions and 23 deletions
|
@ -45,6 +45,7 @@ public class MapRenderingTypes {
|
||||||
private String resourceName = null;
|
private String resourceName = null;
|
||||||
private Map<AmenityType, Map<String, String>> amenityTypeNameToTagVal = null;
|
private Map<AmenityType, Map<String, String>> amenityTypeNameToTagVal = null;
|
||||||
private Map<String, AmenityType> amenityNameToType = 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>();
|
||||||
|
@ -133,7 +134,31 @@ public class MapRenderingTypes {
|
||||||
}
|
}
|
||||||
return amenityTypeNameToTagVal;
|
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);
|
||||||
|
@ -234,7 +259,15 @@ public class MapRenderingTypes {
|
||||||
}
|
}
|
||||||
return amenityTypeNameToTagVal.get(t).keySet();
|
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);
|
||||||
}
|
}
|
||||||
|
@ -383,6 +416,7 @@ public class MapRenderingTypes {
|
||||||
XmlPullParser parser = PlatformUtil.newXMLPullParser();
|
XmlPullParser parser = PlatformUtil.newXMLPullParser();
|
||||||
int tok;
|
int tok;
|
||||||
parser.setInput(is, "UTF-8");
|
parser.setInput(is, "UTF-8");
|
||||||
|
String parentCategory = null;
|
||||||
String poiParentCategory = null;
|
String poiParentCategory = null;
|
||||||
String poiParentPrefix = null;
|
String poiParentPrefix = null;
|
||||||
String order = null;
|
String order = null;
|
||||||
|
@ -390,12 +424,13 @@ public class MapRenderingTypes {
|
||||||
if (tok == XmlPullParser.START_TAG) {
|
if (tok == XmlPullParser.START_TAG) {
|
||||||
String name = parser.getName();
|
String name = parser.getName();
|
||||||
if (name.equals("category")) { //$NON-NLS-1$
|
if (name.equals("category")) { //$NON-NLS-1$
|
||||||
|
parentCategory = parser.getAttributeValue("","name");
|
||||||
poiParentCategory = parser.getAttributeValue("","poi_category");
|
poiParentCategory = parser.getAttributeValue("","poi_category");
|
||||||
poiParentPrefix = parser.getAttributeValue("","poi_prefix");
|
poiParentPrefix = parser.getAttributeValue("","poi_prefix");
|
||||||
order = parser.getAttributeValue("","order");
|
order = parser.getAttributeValue("","order");
|
||||||
parseCategoryFromXml(parser, poiParentCategory, poiParentPrefix);
|
parseCategoryFromXml(parser, poiParentCategory, poiParentPrefix);
|
||||||
} else if (name.equals("type")) {
|
} else if (name.equals("type")) {
|
||||||
parseTypeFromXML(parser, poiParentCategory, poiParentPrefix, order);
|
parseTypeFromXML(parser, parentCategory, poiParentCategory, poiParentPrefix, order);
|
||||||
} else if (name.equals("routing_type")) {
|
} else if (name.equals("routing_type")) {
|
||||||
parseRouteTagFromXML(parser);
|
parseRouteTagFromXML(parser);
|
||||||
}
|
}
|
||||||
|
@ -421,11 +456,11 @@ public class MapRenderingTypes {
|
||||||
protected void parseRouteTagFromXML(XmlPullParser parser) {
|
protected void parseRouteTagFromXML(XmlPullParser parser) {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected MapRulType parseTypeFromXML(XmlPullParser parser, String poiParentCategory, String poiParentPrefix, String parentOrder) {
|
protected MapRulType parseTypeFromXML(XmlPullParser parser, String parentCategory, String poiParentCategory, String poiParentPrefix, String parentOrder) {
|
||||||
return parseBaseRuleType(parser, poiParentCategory, poiParentPrefix, parentOrder, true);
|
return parseBaseRuleType(parser, parentCategory, poiParentCategory, poiParentPrefix, parentOrder, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected MapRulType parseBaseRuleType(XmlPullParser parser, String poiParentCategory, String poiParentPrefix, String parentOrder, boolean filterOnlyMap) {
|
protected MapRulType parseBaseRuleType(XmlPullParser parser, String parentCategory, String poiParentCategory, String poiParentPrefix, String parentOrder, boolean filterOnlyMap) {
|
||||||
String tag = lc(parser.getAttributeValue("", "tag"));
|
String tag = lc(parser.getAttributeValue("", "tag"));
|
||||||
String value = lc(parser.getAttributeValue("", "value"));
|
String value = lc(parser.getAttributeValue("", "value"));
|
||||||
String additional = parser.getAttributeValue("", "additional");
|
String additional = parser.getAttributeValue("", "additional");
|
||||||
|
@ -473,6 +508,7 @@ public class MapRenderingTypes {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
rtype.category = parentCategory;
|
||||||
if (poiParentCategory != null && poiParentCategory.length() > 0) {
|
if (poiParentCategory != null && poiParentCategory.length() > 0) {
|
||||||
rtype.poiCategory = AmenityType.getAndRegisterType(poiParentCategory);
|
rtype.poiCategory = AmenityType.getAndRegisterType(poiParentCategory);
|
||||||
rtype.poiSpecified = true;
|
rtype.poiSpecified = true;
|
||||||
|
@ -666,6 +702,7 @@ public class MapRenderingTypes {
|
||||||
protected int order = 50;
|
protected int order = 50;
|
||||||
protected Set<TagValuePattern> applyToTagValue = null;
|
protected Set<TagValuePattern> applyToTagValue = null;
|
||||||
|
|
||||||
|
protected String category = null;
|
||||||
protected String poiPrefix;
|
protected String poiPrefix;
|
||||||
protected AmenityType poiCategory;
|
protected AmenityType poiCategory;
|
||||||
// poi_category was specially removed for one tag/value, to skip unnecessary objects
|
// poi_category was specially removed for one tag/value, to skip unnecessary objects
|
||||||
|
|
|
@ -527,22 +527,24 @@ public class DownloadIndexesThread {
|
||||||
|
|
||||||
private void prepareFilesToUpdate() {
|
private void prepareFilesToUpdate() {
|
||||||
List<IndexItem> filtered = getCachedIndexFiles();
|
List<IndexItem> filtered = getCachedIndexFiles();
|
||||||
itemsToUpdate.clear();
|
if (filtered != null) {
|
||||||
for (IndexItem item : filtered) {
|
itemsToUpdate.clear();
|
||||||
String sfName = item.getTargetFileName();
|
for (IndexItem item : filtered) {
|
||||||
java.text.DateFormat format = uiActivity.getMyApplication().getResourceManager().getDateFormat();
|
String sfName = item.getTargetFileName();
|
||||||
String date = item.getDate(format);
|
java.text.DateFormat format = uiActivity.getMyApplication().getResourceManager().getDateFormat();
|
||||||
String indexactivateddate = indexActivatedFileNames.get(sfName);
|
String date = item.getDate(format);
|
||||||
String indexfilesdate = indexFileNames.get(sfName);
|
String indexactivateddate = indexActivatedFileNames.get(sfName);
|
||||||
if (date != null &&
|
String indexfilesdate = indexFileNames.get(sfName);
|
||||||
!date.equals(indexactivateddate) &&
|
if (date != null &&
|
||||||
!date.equals(indexfilesdate) &&
|
!date.equals(indexactivateddate) &&
|
||||||
indexActivatedFileNames.containsKey(sfName)) {
|
!date.equals(indexfilesdate) &&
|
||||||
itemsToUpdate.add(item);
|
indexActivatedFileNames.containsKey(sfName)) {
|
||||||
|
itemsToUpdate.add(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (uiActivity != null){
|
||||||
|
uiActivity.updateDownloadList(itemsToUpdate);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if (uiActivity != null){
|
|
||||||
uiActivity.updateDownloadList(itemsToUpdate);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -506,7 +506,7 @@ public class EditingPOIActivity implements DialogProvider {
|
||||||
|
|
||||||
private void updateSubTypesAdapter(AmenityType t){
|
private void updateSubTypesAdapter(AmenityType t){
|
||||||
|
|
||||||
Set<String> subCategories = new LinkedHashSet<String>(MapRenderingTypes.getDefault().getAmenitySubCategories(t));
|
Set<String> subCategories = new LinkedHashSet<String>(MapRenderingTypes.getDefault().getAmenityAllSubCategories(t));
|
||||||
for(String s : MapRenderingTypes.getDefault().getAmenityNameToType().keySet()){
|
for(String s : MapRenderingTypes.getDefault().getAmenityNameToType().keySet()){
|
||||||
if(!subCategories.contains(s)){
|
if(!subCategories.contains(s)){
|
||||||
subCategories.add(s);
|
subCategories.add(s);
|
||||||
|
@ -606,7 +606,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().getAmenitySubCategories(a.getType()).
|
final String[] subCats = MapRenderingTypes.getDefault().getAmenityAllSubCategories(a.getType()).
|
||||||
toArray(new String[0]);
|
toArray(new String[0]);
|
||||||
builder.setItems(subCats, new DialogInterface.OnClickListener() {
|
builder.setItems(subCats, new DialogInterface.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in a new issue