Merge remote-tracking branch 'origin/master'

This commit is contained in:
Weblate 2015-01-31 15:28:17 +01:00
commit eadaa603ed
4 changed files with 94 additions and 8 deletions

View file

@ -25,6 +25,7 @@ public class MapPoiTypes {
public static MapPoiTypes getDefault() {
if(DEFAULT_INSTANCE == null){
DEFAULT_INSTANCE = new MapPoiTypes(null);
DEFAULT_INSTANCE.init();
}
return DEFAULT_INSTANCE;
}
@ -46,15 +47,26 @@ public class MapPoiTypes {
while ((tok = parser.next()) != XmlPullParser.END_DOCUMENT) {
if (tok == XmlPullParser.START_TAG) {
String name = parser.getName();
if (name.equals("category")) {
if (name.equals("poi_category")) {
lastCategory = new PoiCategory(this, parser.getAttributeValue("","name"));
categories.add(lastCategory);
} else if (name.equals("poi_filter")) {
PoiFilter tp = new PoiFilter(this, lastCategory,
parser.getAttributeValue("", "name"));
lastFilter = tp;
lastCategory.addPoiType(tp);
} else if(name.equals("poi_type")){
PoiType tp = new PoiType(this,
lastCategory, parser.getAttributeValue("","name"));
lastCategory.addPoiType(tp);
tp.setOsmTag(parser.getAttributeValue("","tag"));
tp.setOsmValue(parser.getAttributeValue("","value"));
tp.setOsmTag2(parser.getAttributeValue("","tag2"));
tp.setOsmValue2(parser.getAttributeValue("","value2"));
if(lastFilter != null) {
lastFilter.addPoiType(tp);
} else {
lastCategory.addPoiType(tp);
}
}
} else if (tok == XmlPullParser.END_TAG) {
@ -81,7 +93,32 @@ public class MapPoiTypes {
}
}
public static void main(String[] args) {
getDefault() ;
public List<PoiCategory> getCategories() {
return categories;
}
private static void print(MapPoiTypes df) {
List<PoiCategory> pc = df.getCategories();
for(PoiCategory p : pc) {
System.out.println("Category " + p.getName());
for(PoiFilter f : p.getPoiFilters()) {
System.out.println(" Filter " + f.getName());
print(" ", f);
}
print(" ", p);
}
}
private static void print(String indent, PoiFilter f) {
for(PoiType pt : f.getPoiTypes()) {
System.out.println(indent + " Type " + pt.getName());
}
}
public static void main(String[] args) {
print(getDefault()) ;
}
}

View file

@ -8,12 +8,15 @@ public class PoiCategory extends PoiFilter {
private List<PoiFilter> poiFilters = new ArrayList<PoiFilter>();
public PoiCategory(MapPoiTypes registry, String keyName){
super(registry, keyName);
super(registry, null, keyName);
}
public void addPoiType(PoiFilter poi) {
poiFilters.add(poi);
}
public List<PoiFilter> getPoiFilters() {
return poiFilters;
}
}

View file

@ -11,13 +11,19 @@ public class PoiFilter {
private String translationName;
private MapPoiTypes registry;
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, String keyName){
public PoiFilter(MapPoiTypes registry, PoiCategory pc, String keyName){
this.registry = registry;
this.pc = pc;
this.keyName = keyName;
}
public PoiCategory getPoiCategory() {
return pc;
}
public String getTranslationName() {
return translationName;
}

View file

@ -5,12 +5,52 @@ public class PoiType {
private String name;
private String translationName;
private MapPoiTypes poiTypes;
public String getOsmTag() {
return osmTag;
}
public void setOsmTag(String osmTag) {
this.osmTag = osmTag;
}
public String getOsmTag2() {
return osmTag2;
}
public void setOsmTag2(String osmTag2) {
this.osmTag2 = osmTag2;
}
public String getOsmValue() {
return osmValue;
}
public void setOsmValue(String osmValue) {
this.osmValue = osmValue;
}
public String getOsmValue2() {
return osmValue2;
}
public void setOsmValue2(String osmValue2) {
this.osmValue2 = osmValue2;
}
private PoiCategory category;
private String osmTag;
private String osmTag2;
private String osmValue;
private String osmValue2;
public PoiType(MapPoiTypes poiTypes, PoiCategory category, String name){
this.poiTypes = poiTypes;
this.category = category;
name = name;
this.name = name;
}
public PoiCategory getCategory() {
return category;
}
public String getTranslationName() {