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());
}
Aggregations