Search in sources :

Example 6 with NodeDto

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

the class PoiMapper method convertPoiToNodeDto.

/**
 * @param poi         the poi to convert
 * @param changeSetId an optional changeSetId to be added to the created NodeDto
 * @return the converted NodeDto
 */
public NodeDto convertPoiToNodeDto(Poi poi, String changeSetId) {
    NodeDto nodeDto = new NodeDto();
    nodeDto.setLat(poi.getLatitude());
    nodeDto.setLon(poi.getLongitude());
    nodeDto.setId(poi.getBackendId());
    nodeDto.setChangeset(changeSetId);
    if (poi.getVersion() != null) {
        nodeDto.setVersion(Integer.parseInt(poi.getVersion()));
    }
    nodeDto.setTagsDtoList(poiTagMapper.convertFromPoiTag(poi.getTags()));
    return nodeDto;
}
Also used : NodeDto(io.jawg.osmcontributor.rest.dtos.osm.NodeDto)

Example 7 with NodeDto

use of io.jawg.osmcontributor.rest.dtos.osm.NodeDto 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

NodeDto (io.jawg.osmcontributor.rest.dtos.osm.NodeDto)7 OsmDto (io.jawg.osmcontributor.rest.dtos.osm.OsmDto)5 WayDto (io.jawg.osmcontributor.rest.dtos.osm.WayDto)4 IOException (java.io.IOException)4 ResponseBody (okhttp3.ResponseBody)3 ArrayList (java.util.ArrayList)2 Poi (io.jawg.osmcontributor.model.entities.Poi)1 TagDto (io.jawg.osmcontributor.rest.dtos.osm.TagDto)1