Merge remote-tracking branch 'origin/master'

This commit is contained in:
Weblate 2015-04-11 10:12:57 +02:00
commit 6001a488e3
9 changed files with 153 additions and 37 deletions

View file

@ -65,15 +65,15 @@ public class BinaryInspector {
// test cases show info
if(args.length == 1 && "test".equals(args[0])) {
in.inspector(new String[]{
// "-vpoi",
"-vmap",// "-vmapobjects",
"-vpoi",
// "-vmap",// "-vmapobjects",
// "-vrouting",
// "-vaddress", "-vcities","-vstreetgroups",
// "-vstreets", "-vbuildings", "-vintersections",
"-zoom=16",
// "-bbox=1.74,51.17,1.75,51.16",
"-vstats",
"/Users/victorshcherb/osmand/maps/Netherlands_europe_2.obf"
// "-vstats",
// "/Users/victorshcherb/osmand/maps/Netherlands_europe_2.obf"
// "/Users/victorshcherb/osmand/maps/World_basemap_2.obf"
});
} else {
@ -1047,7 +1047,7 @@ public class BinaryInspector {
PoiSubType st = p.subTypes.get(i);
println("\t\t\t" + st.name + " " + (st.text ? "text":(" encoded " + st.possibleValues.size())));
}
req.poiTypeFilter = null;//for test only
// req.poiTypeFilter = null;//for test only
index.searchPoi(p, req);
}

View file

@ -1,12 +1,16 @@
package net.osmand.osm;
import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
public abstract class AbstractPoiType {
protected final String keyName;
protected final MapPoiTypes registry;
private List<PoiType> poiAdditionals = null;
public AbstractPoiType(String keyName, MapPoiTypes registry) {
this.keyName = keyName;
@ -21,6 +25,20 @@ public abstract class AbstractPoiType {
return registry.getTranslation(this);
}
public void addPoiAdditional(PoiType tp) {
if(poiAdditionals == null) {
poiAdditionals = new ArrayList<PoiType>();
}
poiAdditionals.add(tp);
}
public List<PoiType> getPoiAdditionals() {
if(poiAdditionals == null) {
return Collections.emptyList();
}
return poiAdditionals;
}
public abstract Map<PoiCategory, LinkedHashSet<String>> putTypes(Map<PoiCategory, LinkedHashSet<String>> acceptedTypes);

View file

@ -258,6 +258,10 @@ public class MapPoiTypes {
tp.setOsmValue2(parser.getAttributeValue("","value2"));
if(lastType != null) {
lastType.addPoiAdditional(tp);
} else if(lastFilter != null) {
lastFilter.addPoiAdditional(tp);
} else if(lastCategory != null) {
lastCategory.addPoiAdditional(tp);
}
} else if(name.equals("poi_type")){
PoiType tp = new PoiType(this,

View file

@ -1,9 +1,6 @@
package net.osmand.osm;
import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
public class PoiType extends AbstractPoiType {
@ -14,7 +11,7 @@ public class PoiType extends AbstractPoiType {
private String osmTag2;
private String osmValue;
private String osmValue2;
private List<PoiType> poiAdditionals = null;
public PoiType(MapPoiTypes poiTypes, PoiCategory category, String name) {
super(name, poiTypes);
@ -81,20 +78,6 @@ public class PoiType extends AbstractPoiType {
return category;
}
public void addPoiAdditional(PoiType tp) {
if(poiAdditionals == null) {
poiAdditionals = new ArrayList<PoiType>();
}
poiAdditionals.add(tp);
}
public List<PoiType> getPoiAdditionals() {
if(poiAdditionals == null) {
return Collections.emptyList();
}
return poiAdditionals;
}
public Map<PoiCategory, LinkedHashSet<String>> putTypes(Map<PoiCategory, LinkedHashSet<String>> acceptedTypes) {
PoiType rt = getReferenceType();
PoiType poiType = rt != null ? rt : this;

View file

@ -11,6 +11,7 @@ import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
import java.util.StringTokenizer;
@ -657,6 +658,24 @@ public class OsmandSettings {
}
return super.setValue(prefs, val);
};
protected DrivingRegion getDefaultValue() {
Locale df = Locale.getDefault();
if(df == null) {
return DrivingRegion.EUROPE_ASIA;
}
if(df.getCountry().equalsIgnoreCase(Locale.US.getCountry())) {
return DrivingRegion.US;
} else if(df.getCountry().equalsIgnoreCase(Locale.CANADA.getCountry())) {
return DrivingRegion.CANADA;
} else if(df.getCountry().equalsIgnoreCase(Locale.JAPAN.getCountry())) {
return DrivingRegion.JAPAN;
// potentially wrong in europe
// } else if(df.getCountry().equalsIgnoreCase(Locale.UK.getCountry())) {
// return DrivingRegion.UK_AND_OTHERS;
}
return DrivingRegion.EUROPE_ASIA;
};
}.makeGlobal().cache();
// this value string is synchronized with settings_pref.xml preference name

View file

@ -201,12 +201,14 @@ public class FavoritesListFragment extends ListFragment implements SearchActivit
TextView distanceText = (TextView) row.findViewById(R.id.distance);
ImageView icon = (ImageView) row.findViewById(R.id.favourite_icon);
ImageView direction = (ImageView) row.findViewById(R.id.direction);
ImageView giImage= (ImageView)row.findViewById(R.id.group_image);
direction.setVisibility(View.VISIBLE);
final FavouritePoint favorite = getItem(position);
if (!favorite.getCategory().isEmpty()) {
row.findViewById(R.id.group_image).setVisibility(View.VISIBLE);
giImage.setVisibility(View.VISIBLE);
giImage.setImageDrawable(app.getIconsCache().getContentIcon(R.drawable.ic_small_group));
} else {
row.findViewById(R.id.group_image).setVisibility(View.GONE);
giImage.setVisibility(View.GONE);
}
((TextView) row.findViewById(R.id.group_name)).setText(favorite.getCategory());
@ -216,7 +218,7 @@ public class FavoritesListFragment extends ListFragment implements SearchActivit
name.setText(getName(favorite));
final CheckBox ch = (CheckBox) row.findViewById(R.id.check_item);
row.findViewById(R.id.favourite_icon).setVisibility(View.VISIBLE);
icon.setVisibility(View.VISIBLE);
ch.setVisibility(View.GONE);
return row;
}

View file

@ -11,6 +11,8 @@ import java.util.Calendar;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
import net.osmand.Location;
import net.osmand.ResultMatcher;
@ -342,6 +344,16 @@ public class SearchPOIActivity extends OsmandListActivity implements OsmAndCompa
});
addFilter(optionsMenu, getString(R.string.shared_string_open).toLowerCase());
addFilter(optionsMenu, "24/7");
Map<String, PoiType> poiAdditionals = f.getPoiAdditionals();
if(poiAdditionals != null) {
TreeMap<String, PoiType> adds = new TreeMap<String, PoiType>();
for(PoiType vtype : poiAdditionals.values()) {
adds.put(vtype.getTranslation().replace(' ', ':').toLowerCase(), vtype);
}
for(String vtype : adds.keySet()) {
addFilter(optionsMenu, vtype);
}
}
optionsMenu.show();
}

View file

@ -1325,6 +1325,15 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
} else {
v.findViewById(R.id.read_section).setVisibility(View.VISIBLE);
v.findViewById(R.id.unknown_section).setVisibility(View.GONE);
ImageView distanceI = (ImageView) v.findViewById(R.id.distance_icon);
distanceI.setVisibility(View.VISIBLE);
distanceI.setImageDrawable(app.getIconsCache().getContentIcon(R.drawable.ic_small_distance));
ImageView pointsI = (ImageView) v.findViewById(R.id.points_icon);
pointsI.setVisibility(View.VISIBLE);
pointsI.setImageDrawable(app.getIconsCache().getContentIcon(R.drawable.ic_small_point));
ImageView timeI = (ImageView) v.findViewById(R.id.time_icon);
timeI.setVisibility(View.VISIBLE);
timeI.setImageDrawable(app.getIconsCache().getContentIcon(R.drawable.ic_small_time));
TextView time = (TextView) v.findViewById(R.id.time);
TextView distance = (TextView) v.findViewById(R.id.distance);
TextView pointsCount = (TextView) v.findViewById(R.id.points_count);

View file

@ -4,10 +4,13 @@ package net.osmand.plus.poi;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import net.osmand.CollatorStringMatcher;
@ -20,6 +23,7 @@ import net.osmand.data.LatLon;
import net.osmand.osm.AbstractPoiType;
import net.osmand.osm.MapPoiTypes;
import net.osmand.osm.PoiCategory;
import net.osmand.osm.PoiFilter;
import net.osmand.osm.PoiType;
import net.osmand.plus.OsmAndFormatter;
import net.osmand.plus.OsmandApplication;
@ -39,6 +43,7 @@ public class PoiLegacyFilter implements SearchPoiTypeFilter {
private Map<PoiCategory, LinkedHashSet<String>> acceptedTypes = new LinkedHashMap<PoiCategory,
LinkedHashSet<String>>();
private Map<String, PoiType> poiAdditionals = new HashMap<String, PoiType>();
protected String filterId;
protected String name;
@ -65,8 +70,9 @@ public class PoiLegacyFilter implements SearchPoiTypeFilter {
name = type == null ? application.getString(R.string.poi_filter_closest_poi) : type.getTranslation(); //$NON-NLS-1$
if (type == null) {
initSearchAll();
updatePoiAdditionals();
} else {
type.putTypes(acceptedTypes);
updateTypesToAccept(type);
}
}
@ -94,8 +100,11 @@ public class PoiLegacyFilter implements SearchPoiTypeFilter {
} else {
this.acceptedTypes.putAll(acceptedTypes);
}
updatePoiAdditionals();
}
public String getFilterByName() {
return filterByName;
}
@ -245,6 +254,7 @@ public class PoiLegacyFilter implements SearchPoiTypeFilter {
String[] items = filter.split(" ");
boolean allTime = false;
boolean open = false;
Map<PoiType, String> poiAdditionalsFilter = null;
for(String s : items) {
s = s.trim();
if(!Algorithms.isEmpty(s)){
@ -252,16 +262,21 @@ public class PoiLegacyFilter implements SearchPoiTypeFilter {
allTime = true;
} else if(getNameTokenOpen().equalsIgnoreCase(s)){
open = true;
} else if(poiAdditionals.containsKey(s.toLowerCase())) {
if(poiAdditionalsFilter == null) {
poiAdditionalsFilter = new LinkedHashMap<PoiType, String>();
}
poiAdditionalsFilter.put(poiAdditionals.get(s.toLowerCase()), null);
} else {
nmFilter.append(s).append(" ");
}
}
}
return getNameFilterInternal(nmFilter, allTime, open);
return getNameFilterInternal(nmFilter, allTime, open, poiAdditionalsFilter);
}
private AmenityNameFilter getNameFilterInternal(StringBuilder nmFilter,
final boolean allTime, final boolean open) {
final boolean allTime, final boolean open, final Map<PoiType, String> poiAdditionals) {
final CollatorStringMatcher sm =
nmFilter.length() > 0 ?
new CollatorStringMatcher(nmFilter.toString().trim(), StringMatcherMode.CHECK_CONTAINS) : null;
@ -276,6 +291,18 @@ public class PoiLegacyFilter implements SearchPoiTypeFilter {
return false;
}
}
if(poiAdditionals != null) {
Iterator<Entry<PoiType, String>> it = poiAdditionals.entrySet().iterator();
while(it.hasNext()) {
Entry<PoiType, String> e = it.next();
String inf = a.getAdditionalInfo(e.getKey().getKeyName());
if(inf == null) {
return false;
} else if(e.getValue() != null && !e.getValue().equalsIgnoreCase(inf)) {
return false;
}
}
}
if (allTime) {
if (!"24/7".equalsIgnoreCase(a.getOpeningHours())) {
return false;
@ -388,6 +415,7 @@ public class PoiLegacyFilter implements SearchPoiTypeFilter {
public void clearFilter() {
acceptedTypes = new LinkedHashMap<PoiCategory, LinkedHashSet<String>>();
poiAdditionals.clear();
}
public boolean areAllTypesAccepted(){
@ -403,22 +431,45 @@ public class PoiLegacyFilter implements SearchPoiTypeFilter {
}
public void setTypeToAccept(PoiCategory type, boolean accept){
if(accept){
acceptedTypes.put(type, new LinkedHashSet<String>());
} else {
acceptedTypes.remove(type);
}
}
public void updateTypesToAccept(AbstractPoiType pt) {
acceptedTypes.clear();
pt.putTypes(acceptedTypes);
poiAdditionals.clear();
fillPoiAdditionals(pt);
}
private void fillPoiAdditionals(AbstractPoiType pt) {
for(PoiType add : pt.getPoiAdditionals()) {
poiAdditionals.put(add.getKeyName().replace('_', ':').replace(' ', ':'), add);
poiAdditionals.put(add.getTranslation().replace(' ', ':').toLowerCase(), add);
}
if(pt instanceof PoiFilter && !(pt instanceof PoiCategory)) {
for(PoiType ps : ((PoiFilter) pt).getPoiTypes()) {
fillPoiAdditionals(ps);
}
}
}
private void updatePoiAdditionals() {
Iterator<Entry<PoiCategory, LinkedHashSet<String>>> e = acceptedTypes.entrySet().iterator();
poiAdditionals.clear();
while(e.hasNext()) {
Entry<PoiCategory, LinkedHashSet<String>> pc = e.next();
fillPoiAdditionals(pc.getKey());
if(pc.getValue() != null) {
for(String s : pc.getValue()) {
PoiType subtype = poiTypes.getPoiTypeByKey(s);
fillPoiAdditionals(subtype);
}
}
}
}
public void updateTypesToAccept(PoiLegacyFilter f) {
acceptedTypes.clear();
acceptedTypes.putAll(f.acceptedTypes);
poiAdditionals.clear();
poiAdditionals.putAll(f.poiAdditionals);
}
@ -428,12 +479,27 @@ public class PoiLegacyFilter implements SearchPoiTypeFilter {
public void selectSubTypesToAccept(PoiCategory t, LinkedHashSet<String> accept){
acceptedTypes.put(t, accept);
fillPoiAdditionals(t);
}
public void setTypeToAccept(PoiCategory poiCategory, boolean b) {
if(b) {
acceptedTypes.put(poiCategory, null);
} else {
acceptedTypes.remove(poiCategory);
}
updatePoiAdditionals();
}
public String getFilterId(){
return filterId;
}
public Map<String, PoiType> getPoiAdditionals() {
return poiAdditionals;
}
public String getSimplifiedId(){
if(filterId.startsWith(STD_PREFIX)) {
return filterId.substring(STD_PREFIX.length()).toLowerCase();
@ -483,4 +549,7 @@ public class PoiLegacyFilter implements SearchPoiTypeFilter {
public boolean accept(Amenity a) ;
}
}