Search in sources :

Example 11 with OsmDto

use of io.jawg.osmcontributor.rest.dtos.osm.OsmDto in project osm-contributor by jawg.

the class PoiLoader method loadAndSavePoisFromBackend.

private void loadAndSavePoisFromBackend(MapArea toLoadArea, boolean clean) {
    loadingStatus = LOADING_FROM_SERVER;
    publishProgress();
    loadedElements = 0L;
    nodeDtos.clear();
    osmDtos = backend.getPoisDtosInBox(toLoadArea.getBox());
    for (OsmDto osmDto : osmDtos) {
        killIfNeeded();
        if (osmDto != null) {
            List<NodeDto> nodeDtoList = osmDto.getNodeDtoList();
            if (nodeDtoList != null) {
                nodeDtos.addAll(nodeDtoList);
            }
            List<WayDto> wayDtoList = osmDto.getWayDtoList();
            if (wayDtoList != null) {
                nodeDtos.addAll(wayDtoList);
            }
        }
    }
    osmDtos.clear();
    loadingStatus = MAPPING_POIS;
    totalsElements = nodeDtos.size();
    if (clean) {
        cleanArea(toLoadArea);
    }
    savePoisInDB();
}
Also used : OsmDto(io.jawg.osmcontributor.rest.dtos.osm.OsmDto) WayDto(io.jawg.osmcontributor.rest.dtos.osm.WayDto) NodeDto(io.jawg.osmcontributor.rest.dtos.osm.NodeDto)

Aggregations

OsmDto (io.jawg.osmcontributor.rest.dtos.osm.OsmDto)11 IOException (java.io.IOException)9 NodeDto (io.jawg.osmcontributor.rest.dtos.osm.NodeDto)5 WayDto (io.jawg.osmcontributor.rest.dtos.osm.WayDto)4 ResponseBody (okhttp3.ResponseBody)4 ArrayList (java.util.ArrayList)3 Poi (io.jawg.osmcontributor.model.entities.Poi)2 NoteDto (io.jawg.osmcontributor.rest.dtos.osm.NoteDto)2 NonNull (android.support.annotation.NonNull)1 Note (io.jawg.osmcontributor.model.entities.Note)1 PoiType (io.jawg.osmcontributor.model.entities.PoiType)1 ChangeSetDto (io.jawg.osmcontributor.rest.dtos.osm.ChangeSetDto)1 PermissionDto (io.jawg.osmcontributor.rest.dtos.osm.PermissionDto)1 TagDto (io.jawg.osmcontributor.rest.dtos.osm.TagDto)1 SyncConflictingNoteErrorEvent (io.jawg.osmcontributor.rest.events.error.SyncConflictingNoteErrorEvent)1 SyncDownloadRetrofitErrorEvent (io.jawg.osmcontributor.rest.events.error.SyncDownloadRetrofitErrorEvent)1 SyncUploadNoteRetrofitErrorEvent (io.jawg.osmcontributor.rest.events.error.SyncUploadNoteRetrofitErrorEvent)1 SyncUploadRetrofitErrorEvent (io.jawg.osmcontributor.rest.events.error.SyncUploadRetrofitErrorEvent)1 OAuthRequest (io.jawg.osmcontributor.rest.security.OAuthRequest)1 Map (java.util.Map)1