Search in sources :

Example 11 with PoiNodeRef

use of io.jawg.osmcontributor.model.entities.PoiNodeRef in project osm-contributor by jawg.

the class EditPoiManager method saveOldVersionOfPoiNodeRef.

private Long saveOldVersionOfPoiNodeRef(PoiNodeRef poiNodeRef) {
    if (poiNodeRefDao.countForBackendId(poiNodeRef.getNodeBackendId()) == 1) {
        PoiNodeRef old = poiNodeRef.getCopy();
        old.setOld(true);
        poiNodeRefDao.createOrUpdate(old);
        return old.getId();
    }
    return poiNodeRef.getOldPoiId();
}
Also used : PoiNodeRef(io.jawg.osmcontributor.model.entities.PoiNodeRef)

Example 12 with PoiNodeRef

use of io.jawg.osmcontributor.model.entities.PoiNodeRef in project osm-contributor by jawg.

the class PoiManager method onPleaseRevertPoiNodeRefEvent.

@Subscribe(threadMode = ThreadMode.ASYNC)
public void onPleaseRevertPoiNodeRefEvent(PleaseRevertPoiNodeRefEvent event) {
    PoiNodeRef poiNodeRef = revertPoiNodeRef(event.getIdToRevert());
    bus.post(new RevertFinishedEvent(poiNodeRef, LocationMarkerView.MarkerType.NODE_REF));
}
Also used : PoiNodeRef(io.jawg.osmcontributor.model.entities.PoiNodeRef) RevertFinishedEvent(io.jawg.osmcontributor.model.events.RevertFinishedEvent) Subscribe(org.greenrobot.eventbus.Subscribe)

Example 13 with PoiNodeRef

use of io.jawg.osmcontributor.model.entities.PoiNodeRef in project osm-contributor by jawg.

the class OSMSyncWayManager method downloadPoiForWayEdition.

/**
 * {@inheritDoc}
 */
@Override
public List<Poi> downloadPoiForWayEdition(List<Long> ids) {
    // get noderefs to update
    List<PoiNodeRef> poiNodeRefs = poiNodeRefDao.queryByPoiNodeRefIds(ids);
    // get Pois corresponding to noderefs to update
    List<Poi> pois = getPoiWaysToUpdate();
    List<PoiNodeRef> poiNodeRefsToSave = new ArrayList<>();
    Map<String, PoiNodeRef> poiNodeRefMap = new HashMap<>();
    for (PoiNodeRef poiNodeRef : poiNodeRefs) {
        poiNodeRefMap.put(poiNodeRef.getNodeBackendId(), poiNodeRef);
    }
    // apply new lat lng to poi
    for (Poi poi : pois) {
        PoiNodeRef poiNodeRef = poiNodeRefMap.get(poi.getBackendId());
        if (poiNodeRef != null) {
            poi.setLatitude(poiNodeRef.getLatitude());
            poi.setLongitude(poiNodeRef.getLongitude());
            poi.setUpdated(true);
            poiNodeRef.setUpdated(false);
            Long oldId = poiNodeRef.getOldPoiId();
            if (oldId != null) {
                poiNodeRefDao.deleteById(oldId);
            }
            poiNodeRef.setOldPoiId(null);
            poiNodeRefsToSave.add(poiNodeRef);
        }
    }
    // save changes
    pois = poiManager.savePois(pois);
    poiManager.savePoiNodeRefs(poiNodeRefsToSave);
    return pois;
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Poi(io.jawg.osmcontributor.model.entities.Poi) PoiNodeRef(io.jawg.osmcontributor.model.entities.PoiNodeRef)

Aggregations

PoiNodeRef (io.jawg.osmcontributor.model.entities.PoiNodeRef)13 Poi (io.jawg.osmcontributor.model.entities.Poi)5 ArrayList (java.util.ArrayList)4 LatLng (com.mapbox.mapboxsdk.geometry.LatLng)3 Subscribe (org.greenrobot.eventbus.Subscribe)3 PoiTag (io.jawg.osmcontributor.model.entities.PoiTag)2 Way (io.jawg.osmcontributor.model.entities.Way)2 NdDto (io.jawg.osmcontributor.rest.dtos.osm.NdDto)2 PolylineOptions (com.mapbox.mapboxsdk.annotations.PolylineOptions)1 PoiType (io.jawg.osmcontributor.model.entities.PoiType)1 PoisToUpdateLoadedEvent (io.jawg.osmcontributor.model.events.PoisToUpdateLoadedEvent)1 RevertFinishedEvent (io.jawg.osmcontributor.model.events.RevertFinishedEvent)1 TagDto (io.jawg.osmcontributor.rest.dtos.osm.TagDto)1 WayDto (io.jawg.osmcontributor.rest.dtos.osm.WayDto)1 NoteCommentDialogFragment (io.jawg.osmcontributor.ui.dialogs.NoteCommentDialogFragment)1 PleaseApplyNodeRefPositionChange (io.jawg.osmcontributor.ui.events.edition.PleaseApplyNodeRefPositionChange)1 PleaseApplyPoiPositionChange (io.jawg.osmcontributor.ui.events.edition.PleaseApplyPoiPositionChange)1 WayMarkerOptions (io.jawg.osmcontributor.ui.utils.views.map.marker.WayMarkerOptions)1 PoiUpdateWrapper (io.jawg.osmcontributor.utils.upload.PoiUpdateWrapper)1 HashMap (java.util.HashMap)1