Search in sources :

Example 1 with NdDto

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

the class PoiMapper method convertDtoToPoi.

public Poi convertDtoToPoi(boolean typeFiltering, List<PoiType> availableTypes, PoiDto dto) {
    List<PoiNodeRef> nodeRefs = new ArrayList<>();
    List<PoiTag> tags = new ArrayList<>();
    PoiType type;
    if (FlavorUtils.isBus()) {
        type = availableTypes.get(0);
    } else {
        type = findType(dto, availableTypes);
    }
    if (type == null && typeFiltering) {
        return null;
    }
    Poi poi = new Poi();
    poi.setType(type);
    poi.setLatitude(dto.getLat());
    poi.setLongitude(dto.getLon());
    poi.setBackendId(dto.getId());
    poi.setVersion(String.valueOf(dto.getVersion()));
    poi.setUpdated(false);
    poi.setUpdateDate(dto.getTimestamp());
    poi.setWay(dto.isWay());
    for (TagDto tagDto : dto.getTagsDtoList()) {
        PoiTag tag = new PoiTag();
        tag.setPoi(poi);
        tag.setKey(tagDto.getKey());
        tag.setValue(tagDto.getValue());
        tags.add(tag);
        if (tag.getKey().equals("name")) {
            poi.setName(tag.getValue());
        }
        if (tag.getKey().equals("level")) {
            poi.setLevel(tag.getValue());
        }
    }
    poi.setTags(tags);
    int counter = 0;
    for (NdDto ndDto : dto.getNdDtoList()) {
        PoiNodeRef nodeRef = new PoiNodeRef();
        nodeRef.setPoi(poi);
        nodeRef.setNodeBackendId(ndDto.getRef());
        nodeRef.setOrdinal(counter++);
        nodeRef.setLatitude(ndDto.getLat());
        nodeRef.setLongitude(ndDto.getLon());
        nodeRef.setUpdated(false);
        nodeRefs.add(nodeRef);
    }
    poi.setNodeRefs(nodeRefs);
    return poi;
}
Also used : PoiTag(io.jawg.osmcontributor.model.entities.PoiTag) NdDto(io.jawg.osmcontributor.rest.dtos.osm.NdDto) ArrayList(java.util.ArrayList) PoiType(io.jawg.osmcontributor.model.entities.PoiType) TagDto(io.jawg.osmcontributor.rest.dtos.osm.TagDto) Poi(io.jawg.osmcontributor.model.entities.Poi) PoiNodeRef(io.jawg.osmcontributor.model.entities.PoiNodeRef)

Example 2 with NdDto

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

the class PoiMapper method convertPoiToWayDto.

public WayDto convertPoiToWayDto(Poi poi, String changeSetId) {
    WayDto wayDto = new WayDto();
    wayDto.setId(poi.getBackendId());
    wayDto.setChangeset(changeSetId);
    if (poi.getVersion() != null) {
        wayDto.setVersion(Integer.parseInt(poi.getVersion()));
    }
    wayDto.setTagsDtoList(poiTagMapper.convertFromPoiTag(poi.getTags()));
    List<NdDto> ndDtos = new ArrayList<>();
    for (PoiNodeRef poiNodeRef : poi.getNodeRefs()) {
        NdDto ndDto = new NdDto();
        ndDto.setRef(poiNodeRef.getNodeBackendId());
    }
    wayDto.setNdDtoList(ndDtos);
    return wayDto;
}
Also used : NdDto(io.jawg.osmcontributor.rest.dtos.osm.NdDto) WayDto(io.jawg.osmcontributor.rest.dtos.osm.WayDto) ArrayList(java.util.ArrayList) PoiNodeRef(io.jawg.osmcontributor.model.entities.PoiNodeRef)

Aggregations

PoiNodeRef (io.jawg.osmcontributor.model.entities.PoiNodeRef)2 NdDto (io.jawg.osmcontributor.rest.dtos.osm.NdDto)2 ArrayList (java.util.ArrayList)2 Poi (io.jawg.osmcontributor.model.entities.Poi)1 PoiTag (io.jawg.osmcontributor.model.entities.PoiTag)1 PoiType (io.jawg.osmcontributor.model.entities.PoiType)1 TagDto (io.jawg.osmcontributor.rest.dtos.osm.TagDto)1 WayDto (io.jawg.osmcontributor.rest.dtos.osm.WayDto)1