use of io.jawg.osmcontributor.rest.dtos.osm.TagDto in project osm-contributor by jawg.
the class PoiMapperTest method tagDto.
private TagDto tagDto(String key1, String value) {
TagDto tagDto = new TagDto();
tagDto.setKey(key1);
tagDto.setValue(value);
return tagDto;
}
use of io.jawg.osmcontributor.rest.dtos.osm.TagDto in project osm-contributor by jawg.
the class PoiMapperTest method getNodeDto.
private NodeDto getNodeDto(String... tags) {
NodeDto nodeDto = new NodeDto();
nodeDto.setLat(1.0);
nodeDto.setLon(1.0);
List<TagDto> tagDtos = new ArrayList<>();
if (tags.length % 2 != 0) {
throw new AssertionError("Malformed tags ! Array must be an even number");
}
for (int i = 0; i < tags.length; i += 2) {
tagDtos.add(tagDto(tags[i], tags[i + 1]));
}
nodeDto.setTagsDtoList(tagDtos);
return nodeDto;
}
use of io.jawg.osmcontributor.rest.dtos.osm.TagDto 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;
}
use of io.jawg.osmcontributor.rest.dtos.osm.TagDto in project osm-contributor by jawg.
the class PoiTagMapper method convertFromPoiTag.
public List<TagDto> convertFromPoiTag(Collection<PoiTag> poiTags) {
List<TagDto> result = new ArrayList<>();
for (PoiTag tag : poiTags) {
TagDto tagDto = new TagDto();
tagDto.setKey(tag.getKey());
tagDto.setValue(tag.getValue());
result.add(tagDto);
}
return result;
}
use of io.jawg.osmcontributor.rest.dtos.osm.TagDto in project osm-contributor by jawg.
the class OsmBackend method initializeTransaction.
/**
* {@inheritDoc}
*/
@Override
public String initializeTransaction(String comment) {
final OsmDto osmDto = new OsmDto();
ChangeSetDto changeSetDto = new ChangeSetDto();
List<TagDto> tagDtos = new ArrayList<>();
osmDto.setChangeSetDto(changeSetDto);
tagDtos.add(new TagDto(comment, "comment"));
tagDtos.add(new TagDto(BuildConfig.APP_NAME + " " + BuildConfig.VERSION_NAME, "created_by"));
changeSetDto.setTagDtoList(tagDtos);
Call<ResponseBody> callChangeSet;
if (loginPreferences.retrieveOAuthParams() != null) {
callChangeSet = osmRestClient.addChangeSet(AuthenticationRequestInterceptor.getOAuthRequest(loginPreferences, BuildConfig.BASE_OSM_URL + "changeset/create", Verb.PUT).getOAuthHeader(), osmDto);
} else {
callChangeSet = osmRestClient.addChangeSet(osmDto);
}
try {
Response<ResponseBody> response = callChangeSet.execute();
if (response.isSuccessful() && response.body() != null) {
return response.body().string();
}
} catch (IOException e) {
Timber.e("Retrofit error, couldn't create Changeset!");
}
bus.post(new SyncUploadRetrofitErrorEvent(-1L));
return null;
}
Aggregations