use of net.osmand.plus.plugins.osmedit.data.OsmPoint in project Osmand by osmandapp.
the class ShareOsmPointsAsyncTask method saveGpxFile.
private String saveGpxFile(OsmPoint[] points) {
GPXFile gpx = new GPXFile(Version.getFullVersion(app));
for (OsmPoint point : points) {
if (point.getGroup() == Group.POI) {
OpenstreetmapPoint p = (OpenstreetmapPoint) point;
WptPt wpt = new WptPt();
wpt.name = p.getTagsString();
wpt.lat = p.getLatitude();
wpt.lon = p.getLongitude();
wpt.desc = "id: " + p.getId() + " node" + " " + OsmPoint.stringAction.get(p.getAction());
gpx.addPoint(wpt);
} else if (point.getGroup() == Group.BUG) {
OsmNotesPoint p = (OsmNotesPoint) point;
WptPt wpt = new WptPt();
wpt.name = p.getText();
wpt.lat = p.getLatitude();
wpt.lon = p.getLongitude();
wpt.desc = "id: " + p.getId() + " note" + " " + OsmPoint.stringAction.get(p.getAction());
gpx.addPoint(wpt);
}
}
Exception exception = GPXUtilities.writeGpxFile(srcFile, gpx);
if (exception != null) {
return exception.getMessage();
}
return null;
}
use of net.osmand.plus.plugins.osmedit.data.OsmPoint in project Osmand by osmandapp.
the class MenuController method getMenuController.
public static MenuController getMenuController(@NonNull MapActivity mapActivity, @NonNull LatLon latLon, @NonNull PointDescription pointDescription, @Nullable Object object, @NonNull MenuType menuType) {
MenuController menuController = null;
if (object != null) {
if (object instanceof Amenity) {
menuController = new AmenityMenuController(mapActivity, pointDescription, (Amenity) object);
} else if (object instanceof FavouritePoint) {
if (pointDescription.isParking() || (FavouritePoint.SpecialPointType.PARKING.equals(((FavouritePoint) object).getSpecialPointType()))) {
menuController = new ParkingPositionMenuController(mapActivity, pointDescription, (FavouritePoint) object);
} else {
menuController = new FavouritePointMenuController(mapActivity, pointDescription, (FavouritePoint) object);
}
} else if (object instanceof SearchHistoryHelper.HistoryEntry) {
menuController = new HistoryMenuController(mapActivity, pointDescription, (SearchHistoryHelper.HistoryEntry) object);
} else if (object instanceof TargetPoint) {
menuController = new TargetPointMenuController(mapActivity, pointDescription, (TargetPoint) object);
} else if (object instanceof Recording) {
menuController = new AudioVideoNoteMenuController(mapActivity, pointDescription, (Recording) object);
} else if (object instanceof OsmPoint) {
menuController = new EditPOIMenuController(mapActivity, pointDescription, (OsmPoint) object);
} else if (object instanceof WptPt) {
menuController = WptPtMenuController.getInstance(mapActivity, pointDescription, (WptPt) object);
} else if (object instanceof DownloadMapObject) {
menuController = new MapDataMenuController(mapActivity, pointDescription, (DownloadMapObject) object);
} else if (object instanceof OpenStreetNote) {
menuController = new OsmBugMenuController(mapActivity, pointDescription, (OpenStreetNote) object);
} else if (object instanceof GpxDisplayItem) {
menuController = new GpxItemMenuController(mapActivity, pointDescription, (GpxDisplayItem) object);
} else if (object instanceof MapMarker) {
menuController = new MapMarkerMenuController(mapActivity, pointDescription, (MapMarker) object);
} else if (object instanceof TransportStopRoute) {
menuController = new TransportRouteController(mapActivity, pointDescription, (TransportStopRoute) object);
} else if (object instanceof TransportStop) {
menuController = new TransportStopController(mapActivity, pointDescription, (TransportStop) object);
} else if (object instanceof AidlMapPointWrapper) {
menuController = new AMapPointMenuController(mapActivity, pointDescription, (AidlMapPointWrapper) object);
} else if (object instanceof LatLon) {
if (pointDescription.isMyLocation()) {
menuController = new MyLocationMenuController(mapActivity, pointDescription);
}
} else if (object instanceof AvoidSpecificRoads.AvoidRoadInfo) {
menuController = new ImpassibleRoadsMenuController(mapActivity, pointDescription, (AvoidSpecificRoads.AvoidRoadInfo) object);
} else if (object instanceof RenderedObject) {
menuController = new RenderedObjectMenuController(mapActivity, pointDescription, (RenderedObject) object);
} else if (object instanceof MapillaryImage) {
menuController = new MapillaryMenuController(mapActivity, pointDescription, (MapillaryImage) object);
} else if (object instanceof SelectedGpxPoint) {
menuController = new SelectedGpxMenuController(mapActivity, pointDescription, (SelectedGpxPoint) object);
} else if (object instanceof Pair && ((Pair<?, ?>) object).second instanceof SelectedGpxPoint) {
menuController = new SelectedGpxMenuController(mapActivity, pointDescription, (SelectedGpxPoint) ((Pair<?, ?>) object).second);
}
}
if (menuController == null) {
menuController = new PointDescriptionMenuController(mapActivity, pointDescription);
}
menuController.menuType = menuType;
menuController.setLatLon(latLon);
menuController.onCreated();
return menuController;
}
use of net.osmand.plus.plugins.osmedit.data.OsmPoint in project Osmand by osmandapp.
the class OsmEditsLayer method drawPoint.
private void drawPoint(Canvas canvas, OsmPoint osmPoint, float x, float y) {
float textScale = getTextScale();
int iconId = getIconId(osmPoint);
BackgroundType backgroundType = DEFAULT_BACKGROUND_TYPE;
if (osmPoint.getGroup() == OsmPoint.Group.BUG) {
backgroundType = BackgroundType.COMMENT;
}
PointImageDrawable pointImageDrawable = PointImageDrawable.getOrCreate(ctx, ContextCompat.getColor(ctx, R.color.created_poi_icon_color), true, false, iconId, backgroundType);
pointImageDrawable.setAlpha(0.8f);
int offsetY = backgroundType.getOffsetY(ctx, textScale);
pointImageDrawable.drawPoint(canvas, x, y - offsetY, textScale, false);
}
use of net.osmand.plus.plugins.osmedit.data.OsmPoint in project Osmand by osmandapp.
the class OsmEditsLayer method getObjectName.
@Override
public PointDescription getObjectName(Object o) {
if (o instanceof OsmPoint) {
OsmPoint point = (OsmPoint) o;
String name = "";
String type = "";
if (point.getGroup() == OsmPoint.Group.POI) {
name = ((OpenstreetmapPoint) point).getName();
type = PointDescription.POINT_TYPE_OSM_NOTE;
} else if (point.getGroup() == OsmPoint.Group.BUG) {
name = ((OsmNotesPoint) point).getText();
type = PointDescription.POINT_TYPE_OSM_BUG;
}
return new PointDescription(type, name);
}
return null;
}
use of net.osmand.plus.plugins.osmedit.data.OsmPoint in project Osmand by osmandapp.
the class OsmEditsLayer method getIconId.
public int getIconId(OsmPoint osmPoint) {
if (osmPoint.getGroup() == OsmPoint.Group.POI) {
OpenstreetmapPoint osmP = (OpenstreetmapPoint) osmPoint;
int iconResId = 0;
String poiTranslation = osmP.getEntity().getTag(Entity.POI_TYPE_TAG);
if (poiTranslation != null && ctx != null) {
Map<String, PoiType> poiTypeMap = app.getPoiTypes().getAllTranslatedNames(false);
PoiType poiType = poiTypeMap.get(poiTranslation.toLowerCase());
if (poiType != null) {
String id = null;
if (RenderingIcons.containsBigIcon(poiType.getIconKeyName())) {
id = poiType.getIconKeyName();
} else if (RenderingIcons.containsBigIcon(poiType.getOsmTag() + "_" + poiType.getOsmValue())) {
id = poiType.getOsmTag() + "_" + poiType.getOsmValue();
}
if (id != null) {
iconResId = RenderingIcons.getBigIconResourceId(id);
}
}
}
if (iconResId == 0) {
iconResId = R.drawable.ic_action_info_dark;
}
return iconResId;
} else if (osmPoint.getGroup() == OsmPoint.Group.BUG) {
return R.drawable.mm_special_symbol_plus;
} else {
return 0;
}
}
Aggregations