Search in sources :

Example 1 with PoiNoTypeCreated

use of io.jawg.osmcontributor.ui.events.map.PoiNoTypeCreated in project osm-contributor by jawg.

the class EditPoiManager method onPleaseCreateNoTagPoiEvent.

@Subscribe(threadMode = ThreadMode.ASYNC)
public void onPleaseCreateNoTagPoiEvent(PleaseCreateNoTagPoiEvent event) {
    Poi poi = new Poi();
    LatLng latLng = event.getLatLng();
    poi.setLatitude(latLng.getLatitude());
    poi.setLongitude(latLng.getLongitude());
    poi.setType(event.getPoiType());
    List<PoiTag> defaultTags = new ArrayList<>();
    for (PoiTypeTag poiTypeTag : poi.getType().getTags()) {
        if (poiTypeTag.getValue() != null) {
            // default tags should be set in the corresponding POI
            PoiTag poiTag = new PoiTag();
            poiTag.setKey(poiTypeTag.getKey());
            poiTag.setValue(poiTypeTag.getValue());
            defaultTags.add(poiTag);
        }
    }
    poi.setTags(defaultTags);
    poi.setUpdated(true);
    poiManager.savePoi(poi);
    poiManager.updatePoiTypeLastUse(event.getPoiType().getId());
    eventBus.post(new PoiNoTypeCreated());
}
Also used : PoiTag(io.jawg.osmcontributor.model.entities.PoiTag) PoiNoTypeCreated(io.jawg.osmcontributor.ui.events.map.PoiNoTypeCreated) ArrayList(java.util.ArrayList) Poi(io.jawg.osmcontributor.model.entities.Poi) LatLng(com.mapbox.mapboxsdk.geometry.LatLng) PoiTypeTag(io.jawg.osmcontributor.model.entities.PoiTypeTag) Subscribe(org.greenrobot.eventbus.Subscribe)

Aggregations

LatLng (com.mapbox.mapboxsdk.geometry.LatLng)1 Poi (io.jawg.osmcontributor.model.entities.Poi)1 PoiTag (io.jawg.osmcontributor.model.entities.PoiTag)1 PoiTypeTag (io.jawg.osmcontributor.model.entities.PoiTypeTag)1 PoiNoTypeCreated (io.jawg.osmcontributor.ui.events.map.PoiNoTypeCreated)1 ArrayList (java.util.ArrayList)1 Subscribe (org.greenrobot.eventbus.Subscribe)1