use of net.osmand.data.Amenity in project Osmand by osmandapp.
the class BinaryMapIndexReader method testSearchOnthePath.
private static void testSearchOnthePath(BinaryMapIndexReader reader) throws IOException {
float radius = 1000;
final MapPoiTypes poiTypes = MapPoiTypes.getDefault();
long now = System.currentTimeMillis();
println("Searching poi on the path...");
final List<Location> locations = readGPX(new File("/Users/victorshcherb/osmand/maps/2015-03-07_19-07_Sat.gpx"));
SearchRequest<Amenity> req = buildSearchPoiRequest(locations, radius, new SearchPoiTypeFilter() {
@Override
public boolean accept(PoiCategory type, String subcategory) {
if (type == poiTypes.getPoiCategoryByName("shop") && subcategory.contains("super")) {
return true;
}
return false;
}
@Override
public boolean isEmpty() {
return false;
}
}, null);
req.zoom = -1;
List<Amenity> results = reader.searchPoi(req);
int k = 0;
println("Search done in " + (System.currentTimeMillis() - now) + " ms ");
now = System.currentTimeMillis();
for (Amenity a : results) {
final float dds = dist(a.getLocation(), locations);
if (dds <= radius) {
println("+ " + a.getType() + " " + a.getSubType() + " Dist " + dds + " (=" + (float) a.getRoutePoint().deviateDistance + ") " + a.getName() + " " + a.getLocation());
k++;
} else {
println(a.getType() + " " + a.getSubType() + " Dist " + dds + " " + a.getName() + " " + a.getLocation());
}
}
println("Filtered in " + (System.currentTimeMillis() - now) + "ms " + k + " of " + results.size());
}
use of net.osmand.data.Amenity in project Osmand by osmandapp.
the class MapMarkersLayer method collectObjectsFromPoint.
@Override
public void collectObjectsFromPoint(PointF point, RotatedTileBox tileBox, List<Object> o, boolean unknownLocation) {
if (tileBox.getZoom() < 3) {
return;
}
amenities.clear();
OsmandApplication app = map.getMyApplication();
int r = getDefaultRadiusPoi(tileBox);
boolean selectMarkerOnSingleTap = app.getSettings().SELECT_MARKER_ON_SINGLE_TAP.get();
for (MapMarker marker : app.getMapMarkersHelper().getMapMarkers()) {
if ((!unknownLocation && selectMarkerOnSingleTap) || !isSynced(marker)) {
LatLon latLon = marker.point;
if (latLon != null) {
int x = (int) tileBox.getPixXFromLatLon(latLon.getLatitude(), latLon.getLongitude());
int y = (int) tileBox.getPixYFromLatLon(latLon.getLatitude(), latLon.getLongitude());
if (calculateBelongs((int) point.x, (int) point.y, x, y, r)) {
if (!unknownLocation && selectMarkerOnSingleTap) {
o.add(marker);
} else {
if (isMarkerOnFavorite(marker) || isMarkerOnWaypoint(marker)) {
continue;
}
Amenity mapObj = getMapObjectByMarker(marker);
if (mapObj != null) {
amenities.add(mapObj);
o.add(mapObj);
} else {
o.add(marker);
}
}
}
}
}
}
}
use of net.osmand.data.Amenity in project Osmand by osmandapp.
the class MapContextMenu method buttonWaypointPressed.
public void buttonWaypointPressed() {
MapMarker marker = getMapMarker();
if (marker != null) {
RenameMarkerBottomSheetDialogFragment.showInstance(mapActivity.getSupportFragmentManager(), marker);
} else if (pointDescription.isMapMarker()) {
hide();
MapActivity.clearPrevActivityIntent();
MapMarkersDialogFragment.showInstance(mapActivity);
} else {
String mapObjectName = null;
if (object instanceof Amenity) {
Amenity amenity = (Amenity) object;
mapObjectName = amenity.getName() + "_" + amenity.getType().getKeyName();
}
mapActivity.getMapActions().addMapMarker(latLon.getLatitude(), latLon.getLongitude(), getPointDescriptionForMarker(), mapObjectName);
}
close();
}
use of net.osmand.data.Amenity 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;
}
use of net.osmand.data.Amenity in project Osmand by osmandapp.
the class MenuBuilder method getCollapsableWikiView.
protected CollapsableView getCollapsableWikiView(Context context, boolean collapsed) {
LinearLayout view = (LinearLayout) buildCollapsableContentView(context, collapsed, true);
for (final Amenity wiki : nearestWiki) {
TextViewEx button = buildButtonInCollapsableView(context, false, false);
String name = wiki.getName(preferredMapAppLang, transliterateNames);
button.setText(name);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
LatLon latLon = new LatLon(wiki.getLocation().getLatitude(), wiki.getLocation().getLongitude());
PointDescription pointDescription = mapActivity.getMapLayers().getPoiMapLayer().getObjectName(wiki);
mapActivity.getContextMenu().show(latLon, pointDescription, wiki);
}
});
view.addView(button);
}
return new CollapsableView(view, this, collapsed);
}
Aggregations