Search in sources :

Example 6 with PoiCategory

use of net.osmand.osm.PoiCategory in project Osmand by osmandapp.

the class MenuBuilder method processNearstWiki.

protected boolean processNearstWiki() {
    if (showNearestWiki && latLon != null) {
        QuadRect rect = MapUtils.calculateLatLonBbox(latLon.getLatitude(), latLon.getLongitude(), 250);
        nearestWiki = app.getResourceManager().searchAmenities(new BinaryMapIndexReader.SearchPoiTypeFilter() {

            @Override
            public boolean accept(PoiCategory type, String subcategory) {
                return type.isWiki();
            }

            @Override
            public boolean isEmpty() {
                return false;
            }
        }, rect.top, rect.left, rect.bottom, rect.right, -1, null);
        Collections.sort(nearestWiki, new Comparator<Amenity>() {

            @Override
            public int compare(Amenity o1, Amenity o2) {
                double d1 = MapUtils.getDistance(latLon, o1.getLocation());
                double d2 = MapUtils.getDistance(latLon, o2.getLocation());
                return Double.compare(d1, d2);
            }
        });
        Long id = objectId;
        List<Amenity> wikiList = new ArrayList<>();
        for (Amenity wiki : nearestWiki) {
            String lng = wiki.getContentLanguage("content", preferredMapAppLang, "en");
            if (wiki.getId().equals(id) || (!lng.equals("en") && !lng.equals(preferredMapAppLang))) {
                wikiList.add(wiki);
            }
        }
        nearestWiki.removeAll(wikiList);
        return true;
    }
    return false;
}
Also used : Amenity(net.osmand.data.Amenity) PoiCategory(net.osmand.osm.PoiCategory) ArrayList(java.util.ArrayList) QuadRect(net.osmand.data.QuadRect)

Example 7 with PoiCategory

use of net.osmand.osm.PoiCategory in project Osmand by osmandapp.

the class OsmAndFormatter method getPoiStringWithoutType.

public static String getPoiStringWithoutType(Amenity amenity, String locale, boolean transliterate) {
    PoiCategory pc = amenity.getType();
    PoiType pt = pc.getPoiTypeByKeyName(amenity.getSubType());
    String nm = amenity.getSubType();
    if (pt != null) {
        nm = pt.getTranslation();
    } else if (nm != null) {
        nm = Algorithms.capitalizeFirstLetterAndLowercase(nm.replace('_', ' '));
    }
    String n = amenity.getName(locale, transliterate);
    if (n.indexOf(nm) != -1) {
        // no need to repeat this
        return n;
    }
    if (n.length() == 0) {
        return nm;
    }
    // $NON-NLS-1$
    return nm + " " + n;
}
Also used : PoiCategory(net.osmand.osm.PoiCategory) AbstractPoiType(net.osmand.osm.AbstractPoiType) PoiType(net.osmand.osm.PoiType)

Example 8 with PoiCategory

use of net.osmand.osm.PoiCategory in project Osmand by osmandapp.

the class PoiTypeDialogFragment method onCreateDialog.

@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    MapPoiTypes poiTypes = ((OsmandApplication) getActivity().getApplication()).getPoiTypes();
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    final List<PoiCategory> categories = new ArrayList<PoiCategory>();
    ArrayList<String> vals = new ArrayList<>();
    for (PoiCategory category : poiTypes.getCategories(false)) {
        if (!category.isNotEditableOsm()) {
            vals.add(category.getTranslation());
            categories.add(category);
        }
    }
    builder.setItems(vals.toArray(new String[vals.size()]), new Dialog.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            PoiCategory aType = categories.get(which);
            onItemSelectListener.select(aType);
            dismiss();
        }
    });
    return builder.create();
}
Also used : AlertDialog(android.support.v7.app.AlertDialog) OsmandApplication(net.osmand.plus.OsmandApplication) DialogInterface(android.content.DialogInterface) ArrayList(java.util.ArrayList) MapPoiTypes(net.osmand.osm.MapPoiTypes) PoiCategory(net.osmand.osm.PoiCategory) AlertDialog(android.support.v7.app.AlertDialog) Dialog(android.app.Dialog) NonNull(android.support.annotation.NonNull)

Example 9 with PoiCategory

use of net.osmand.osm.PoiCategory in project Osmand by osmandapp.

the class PoiUIFilter method fillPoiAdditionals.

private void fillPoiAdditionals(AbstractPoiType pt, boolean allFromCategory) {
    for (PoiType add : pt.getPoiAdditionals()) {
        poiAdditionals.put(add.getKeyName().replace('_', ':').replace(' ', ':'), add);
        poiAdditionals.put(add.getTranslation().replace(' ', ':').toLowerCase(), add);
    }
    if (pt instanceof PoiCategory && allFromCategory) {
        for (PoiFilter pf : ((PoiCategory) pt).getPoiFilters()) {
            fillPoiAdditionals(pf, true);
        }
        for (PoiType ps : ((PoiCategory) pt).getPoiTypes()) {
            fillPoiAdditionals(ps, false);
        }
    } else if (pt instanceof PoiFilter && !(pt instanceof PoiCategory)) {
        for (PoiType ps : ((PoiFilter) pt).getPoiTypes()) {
            fillPoiAdditionals(ps, false);
        }
    }
}
Also used : PoiFilter(net.osmand.osm.PoiFilter) CustomSearchPoiFilter(net.osmand.search.core.CustomSearchPoiFilter) PoiCategory(net.osmand.osm.PoiCategory) AbstractPoiType(net.osmand.osm.AbstractPoiType) PoiType(net.osmand.osm.PoiType)

Example 10 with PoiCategory

use of net.osmand.osm.PoiCategory in project Osmand by osmandapp.

the class AmenityMenuController method getTypeStr.

public static String getTypeStr(Amenity amenity) {
    PoiCategory pc = amenity.getType();
    PoiType pt = pc.getPoiTypeByKeyName(amenity.getSubType());
    String typeStr = amenity.getSubType();
    if (pt != null) {
        typeStr = pt.getTranslation();
    } else if (typeStr != null) {
        typeStr = Algorithms.capitalizeFirstLetterAndLowercase(typeStr.replace('_', ' '));
    }
    return typeStr;
}
Also used : PoiCategory(net.osmand.osm.PoiCategory) PoiType(net.osmand.osm.PoiType)

Aggregations

PoiCategory (net.osmand.osm.PoiCategory)29 PoiType (net.osmand.osm.PoiType)11 Amenity (net.osmand.data.Amenity)9 AbstractPoiType (net.osmand.osm.AbstractPoiType)9 MapPoiTypes (net.osmand.osm.MapPoiTypes)6 View (android.view.View)5 NonNull (android.support.annotation.NonNull)4 AdapterView (android.widget.AdapterView)4 TextView (android.widget.TextView)4 BinaryMapIndexReader (net.osmand.binary.BinaryMapIndexReader)4 QuadRect (net.osmand.data.QuadRect)4 OsmandApplication (net.osmand.plus.OsmandApplication)4 DialogInterface (android.content.DialogInterface)3 AlertDialog (android.support.v7.app.AlertDialog)3 AutoCompleteTextView (android.widget.AutoCompleteTextView)3 Button (android.widget.Button)3 PoiFilter (net.osmand.osm.PoiFilter)3 CustomSearchPoiFilter (net.osmand.search.core.CustomSearchPoiFilter)3 Intent (android.content.Intent)2 Bundle (android.os.Bundle)2