use of io.jawg.osmcontributor.model.entities.Poi in project osm-contributor by jawg.
the class PoiManager method loadPoiForCreation.
/**
* Send a {@link PoiForEditionLoadedEvent} containing the suggestions for the PoiTypeTags and a new Poi to complete.
*
* @param event Event containing the position, level and PoiType of the Poi to create.
*/
private void loadPoiForCreation(PleaseLoadPoiForCreationEvent event) {
Poi poi = new Poi();
Set<Double> level = new HashSet<>();
level.add(event.getLevel());
poi.setLevel(level);
poi.setLatitude(event.getLat());
poi.setLongitude(event.getLng());
poi.setType(poiTypeDao.queryForId(event.getPoiType()));
Map<String, String> defaultTags = new HashMap<>();
for (PoiTypeTag poiTypeTag : poi.getType().getTags()) {
if (poiTypeTag.getValue() != null) {
// default tags should be set in the corresponding POI
defaultTags.put(poiTypeTag.getKey(), poiTypeTag.getValue());
}
}
poi.applyChanges(defaultTags);
bus.post(new PoiForEditionLoadedEvent(poi, suggestionsForTagsValue(poi.getType().getTags())));
}
use of io.jawg.osmcontributor.model.entities.Poi in project osm-contributor by jawg.
the class PoiManager method onPleaseLoadPoisToUpdateEvent.
@Subscribe(threadMode = ThreadMode.ASYNC)
public void onPleaseLoadPoisToUpdateEvent(PleaseLoadPoisToUpdateEvent event) {
List<Poi> updatedPois = poiDao.queryForAllUpdated();
List<Poi> newPois = poiDao.queryForAllNew();
List<Poi> toDeletePois = poiDao.queryToDelete();
List<PoiNodeRef> wayPoiNodeRef = poiNodeRefDao.queryAllToUpdate();
List<PoiUpdateWrapper> allPois = new ArrayList<>();
for (Poi p : updatedPois) {
Long oldPoiId = p.getOldPoiId();
if (oldPoiId != null) {
allPois.add(new PoiUpdateWrapper(true, p, poiDao.queryForId(oldPoiId), null, PoiUpdateWrapper.PoiAction.UPDATE));
}
}
for (Poi p : newPois) {
allPois.add(new PoiUpdateWrapper(true, p, null, null, PoiUpdateWrapper.PoiAction.CREATE));
}
for (Poi p : toDeletePois) {
allPois.add(new PoiUpdateWrapper(true, p, poiDao.queryForId(p.getOldPoiId()), null, PoiUpdateWrapper.PoiAction.DELETED));
}
for (PoiNodeRef p : wayPoiNodeRef) {
allPois.add(new PoiUpdateWrapper(false, null, null, p, PoiUpdateWrapper.PoiAction.UPDATE));
}
bus.post(new PoisToUpdateLoadedEvent(allPois));
}
use of io.jawg.osmcontributor.model.entities.Poi in project osm-contributor by jawg.
the class PoiManager method onPleaseRevertPoiEvent.
@Subscribe(threadMode = ThreadMode.ASYNC)
public void onPleaseRevertPoiEvent(PleaseRevertPoiEvent event) {
Poi poi = revertPoi(event.getIdToRevert());
bus.post(new RevertFinishedEvent(poi, LocationMarkerView.MarkerType.POI));
}
use of io.jawg.osmcontributor.model.entities.Poi in project osm-contributor by jawg.
the class MapFragmentPresenter method setIcon.
private void setIcon(LocationMarkerViewOptions markerOptions, Object relatedObject, boolean selected) {
Bitmap bitmap;
if (relatedObject instanceof Poi) {
Poi poi = (Poi) relatedObject;
bitmap = mapFragment.getBitmapHandler().getMarkerBitmap(poi.getType(), Poi.computeState(selected, false, poi.getUpdated()));
} else {
Note note = (Note) relatedObject;
bitmap = mapFragment.getBitmapHandler().getNoteBitmap(Note.computeState(note, selected, false));
}
if (bitmap != null) {
markerOptions.icon(IconFactory.getInstance(mapFragment.getActivity()).fromBitmap(bitmap));
}
}
use of io.jawg.osmcontributor.model.entities.Poi in project osm-contributor by jawg.
the class MapFragmentPresenter method impacteLoadedPoi.
private void impacteLoadedPoi(List<Poi> pois) {
List<MapElement> mapElements = new ArrayList<>(pois.size());
for (Poi poi : pois) {
mapElements.add(poi);
}
onLoaded(mapElements, LocationMarkerView.MarkerType.POI);
}
Aggregations