use of io.jawg.osmcontributor.model.entities.PoiNodeRef in project osm-contributor by jawg.
the class WayMapper method poisToWays.
public static Set<Way> poisToWays(List<Poi> pois) {
Set<Way> ways = new HashSet<>();
if (pois != null && !pois.isEmpty()) {
for (Poi poi : pois) {
Way way = new Way(poi);
for (PoiNodeRef nodeRef : poi.getNodeRefs()) {
// Properties of a node in way edition
way.add(nodeRef);
}
ways.add(way);
}
}
return ways;
}
use of io.jawg.osmcontributor.model.entities.PoiNodeRef in project osm-contributor by jawg.
the class MapFragment method updateVectorials.
public void updateVectorials(Set<Way> ways, TreeSet<Double> levels) {
for (Way way : ways) {
mapboxMap.addPolyline(way.getPolylineOptions());
for (PoiNodeRef poiNodeRef : way.getPoiNodeRefs()) {
WayMarkerOptions wayMarkerOptions = new WayMarkerOptions().position(poiNodeRef.getPosition()).poiNodeRef(poiNodeRef).icon(IconFactory.getInstance(getActivity()).fromBitmap(bitmapHandler.getNodeRefBitmap(PoiNodeRef.State.NONE)));
addWayMarker(wayMarkerOptions);
markersNodeRef.put(poiNodeRef.getId(), wayMarkerOptions);
polylinesWays.put(poiNodeRef.getId(), way.getPolylineOptions());
}
}
}
use of io.jawg.osmcontributor.model.entities.PoiNodeRef in project osm-contributor by jawg.
the class PoiManager method savePoiNoTransaction.
/**
* Method saving a poi and all the associated foreign collections without transaction management.
* <p/>
* Do not call the DAO directly to save a poi, use this method.
*
* @param poi The poi to save
* @return The saved poi
* @see #savePoi(Poi)
*/
private Poi savePoiNoTransaction(Poi poi) {
List<PoiTag> poiTagsToRemove = poiTagDao.queryByPoiId(poi.getId());
poiTagsToRemove.removeAll(poi.getTags());
for (PoiTag poiTag : poiTagsToRemove) {
poiTagDao.delete(poiTag);
}
List<PoiNodeRef> poiNodeRefsToRemove = poiNodeRefDao.queryByPoiId(poi.getId());
poiNodeRefsToRemove.removeAll(poi.getNodeRefs());
for (PoiNodeRef poiNodeRef : poiNodeRefsToRemove) {
poiNodeRefDao.delete(poiNodeRef);
}
poiDao.createOrUpdate(poi);
if (poi.getTags() != null) {
for (PoiTag poiTag : poi.getTags()) {
poiTag.setPoi(poi);
poiTagDao.createOrUpdate(poiTag);
}
}
if (poi.getNodeRefs() != null) {
for (PoiNodeRef poiNodeRef : poi.getNodeRefs()) {
poiNodeRef.setPoi(poi);
poiNodeRefDao.createOrUpdate(poiNodeRef);
}
}
return poi;
}
use of io.jawg.osmcontributor.model.entities.PoiNodeRef 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.PoiNodeRef in project osm-contributor by jawg.
the class PoiManager method revertPoiNodeRef.
/**
* Get the backup data and put it back in the active NodeRefPoi
*
* @param poiNodeRefId The Id of the PoiNodeRef to revert.
*/
private PoiNodeRef revertPoiNodeRef(Long poiNodeRefId) {
PoiNodeRef poiNodeRef = poiNodeRefDao.queryForId(poiNodeRefId);
PoiNodeRef backup;
Long oldId = poiNodeRef.getOldPoiId();
if (oldId != null) {
backup = poiNodeRefDao.queryForId(oldId);
poiNodeRef.setLatitude(backup.getLatitude());
poiNodeRef.setLongitude(backup.getLongitude());
poiNodeRefDao.deleteById(oldId);
}
poiNodeRef.setUpdated(false);
poiNodeRef.setOld(false);
poiNodeRef.setOldPoiId(null);
poiNodeRefDao.createOrUpdate(poiNodeRef);
return poiNodeRef;
}
Aggregations