Merge pull request #5555 from osmandapp/TransportStopWithPoi
Transport stop with poi
This commit is contained in:
commit
9b5e835a8f
5 changed files with 62 additions and 6 deletions
|
@ -2,6 +2,7 @@ package net.osmand.data;
|
|||
|
||||
public class TransportStop extends MapObject {
|
||||
private int[] referencesToRoutes = null;
|
||||
private Amenity amenity;
|
||||
public int distance;
|
||||
|
||||
public TransportStop(){
|
||||
|
@ -15,4 +16,11 @@ public class TransportStop extends MapObject {
|
|||
this.referencesToRoutes = referencesToRoutes;
|
||||
}
|
||||
|
||||
public Amenity getAmenity() {
|
||||
return amenity;
|
||||
}
|
||||
|
||||
public void setAmenity(Amenity amenity) {
|
||||
this.amenity = amenity;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
package net.osmand.plus.mapcontextmenu.builders;
|
||||
|
||||
import android.view.View;
|
||||
|
||||
import net.osmand.data.Amenity;
|
||||
import net.osmand.data.TransportStop;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.mapcontextmenu.MenuBuilder;
|
||||
|
||||
public class TransportStopMenuBuilder extends MenuBuilder {
|
||||
|
||||
private final TransportStop transportStop;
|
||||
|
||||
public TransportStopMenuBuilder(MapActivity mapActivity, final TransportStop transportStop) {
|
||||
super(mapActivity);
|
||||
this.transportStop = transportStop;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void buildInternal(View view) {
|
||||
Amenity amenity = transportStop.getAmenity();
|
||||
if (amenity != null) {
|
||||
AmenityMenuBuilder builder = new AmenityMenuBuilder(mapActivity, amenity);
|
||||
builder.setLatLon(getLatLon());
|
||||
builder.setLight(light);
|
||||
builder.buildInternal(view);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,13 +1,15 @@
|
|||
package net.osmand.plus.mapcontextmenu.controllers;
|
||||
|
||||
import net.osmand.data.Amenity;
|
||||
import net.osmand.data.LatLon;
|
||||
import net.osmand.data.PointDescription;
|
||||
import net.osmand.data.QuadRect;
|
||||
import net.osmand.data.TransportRoute;
|
||||
import net.osmand.data.TransportStop;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.mapcontextmenu.builders.TransportStopMenuBuilder;
|
||||
import net.osmand.plus.transport.TransportStopRoute;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.mapcontextmenu.MenuBuilder;
|
||||
import net.osmand.plus.mapcontextmenu.MenuController;
|
||||
import net.osmand.plus.resources.TransportIndexRepository;
|
||||
import net.osmand.plus.transport.TransportStopType;
|
||||
|
@ -29,8 +31,8 @@ public class TransportStopController extends MenuController {
|
|||
private TransportStopType topType;
|
||||
|
||||
public TransportStopController(MapActivity mapActivity,
|
||||
PointDescription pointDescription, TransportStop transportStop) {
|
||||
super(new MenuBuilder(mapActivity), pointDescription, mapActivity);
|
||||
PointDescription pointDescription, TransportStop transportStop) {
|
||||
super(new TransportStopMenuBuilder(mapActivity, transportStop), pointDescription, mapActivity);
|
||||
this.transportStop = transportStop;
|
||||
processRoutes();
|
||||
}
|
||||
|
@ -157,4 +159,13 @@ public class TransportStopController extends MenuController {
|
|||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addPlainMenuItems(String typeStr, PointDescription pointDescription, LatLon latLon) {
|
||||
Amenity amenity = transportStop.getAmenity();
|
||||
if (amenity != null) {
|
||||
AmenityMenuController.addTypeMenuItem(amenity, builder);
|
||||
} else {
|
||||
super.addPlainMenuItems(typeStr, pointDescription, latLon);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@ import android.widget.Toast;
|
|||
import net.osmand.AndroidUtils;
|
||||
import net.osmand.PlatformUtil;
|
||||
import net.osmand.data.Amenity;
|
||||
import net.osmand.data.TransportStop;
|
||||
import net.osmand.osm.PoiType;
|
||||
import net.osmand.osm.edit.Node;
|
||||
import net.osmand.plus.ContextMenuAdapter;
|
||||
|
@ -195,7 +196,8 @@ public class OsmEditingPlugin extends OsmandPlugin {
|
|||
} else if (resId == R.string.context_menu_item_modify_note) {
|
||||
modifyOsmNote(mapActivity, (OsmNotesPoint) selectedObj);
|
||||
} else if (resId == R.string.poi_context_menu_modify) {
|
||||
EditPoiDialogFragment.showEditInstance((Amenity) selectedObj, mapActivity);
|
||||
EditPoiDialogFragment.showEditInstance(selectedObj instanceof TransportStop ?
|
||||
((TransportStop) selectedObj).getAmenity() : (Amenity) selectedObj, mapActivity);
|
||||
} else if (resId == R.string.poi_context_menu_modify_osm_change) {
|
||||
final Node entity = ((OpenstreetmapPoint) selectedObj).getEntity();
|
||||
EditPoiDialogFragment.createInstance(entity, false)
|
||||
|
@ -205,8 +207,13 @@ public class OsmEditingPlugin extends OsmandPlugin {
|
|||
}
|
||||
};
|
||||
boolean isEditable = false;
|
||||
if (selectedObj instanceof Amenity) {
|
||||
Amenity amenity = (Amenity) selectedObj;
|
||||
if (selectedObj instanceof Amenity || (selectedObj instanceof TransportStop && ((TransportStop) selectedObj).getAmenity() != null)) {
|
||||
Amenity amenity;
|
||||
if (selectedObj instanceof Amenity) {
|
||||
amenity = (Amenity) selectedObj;
|
||||
} else {
|
||||
amenity = ((TransportStop) selectedObj).getAmenity();
|
||||
}
|
||||
final PoiType poiType = amenity.getType().getPoiTypeByKeyName(amenity.getSubType());
|
||||
isEditable = !amenity.getType().isWiki() && poiType !=null && !poiType.isNotEditableOsm();
|
||||
}
|
||||
|
|
|
@ -760,6 +760,7 @@ public class ContextMenuLayer extends OsmandMapLayer {
|
|||
for (TransportStop transportStop : transportStops) {
|
||||
if (transportStop.getName().startsWith(amenity.getName())) {
|
||||
amenityTransportStops.add(transportStop);
|
||||
transportStop.setAmenity(amenity);
|
||||
}
|
||||
}
|
||||
if (amenityTransportStops.size() > 0) {
|
||||
|
|
Loading…
Reference in a new issue