use of io.jawg.osmcontributor.model.entities.PoiNodeRef 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.model.entities.PoiNodeRef 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;
}
use of io.jawg.osmcontributor.model.entities.PoiNodeRef in project osm-contributor by jawg.
the class EditPoiManager method onPleaseApplyNodeRefPositionChange.
@Subscribe(threadMode = ThreadMode.ASYNC)
public void onPleaseApplyNodeRefPositionChange(PleaseApplyNodeRefPositionChange event) {
Timber.d("Please apply noderef position change");
LatLng newLatLng = event.getPoiPosition();
// apply changes on the noderef
PoiNodeRef poiNodeRef = poiNodeRefDao.queryForId(event.getPoiId());
poiNodeRef.setOldPoiId(saveOldVersionOfPoiNodeRef(poiNodeRef));
poiNodeRef.setLongitude(newLatLng.getLongitude());
poiNodeRef.setLatitude(newLatLng.getLatitude());
poiNodeRef.setUpdated(true);
poiNodeRefDao.createOrUpdate(poiNodeRef);
}
use of io.jawg.osmcontributor.model.entities.PoiNodeRef in project osm-contributor by jawg.
the class MapFragment method buildEditionPolygon.
private void buildEditionPolygon() {
// Current selected poiNodeRef
PoiNodeRef currentPoiNodeRef = wayMarkerSelected.getPoiNodeRef();
// Polyline related to this poiNodeRef
PolylineOptions currentPolyline = polylinesWays.get(currentPoiNodeRef.getId());
// Item of the poiNodeRef in the polilyne
int indexOfPoiNodeRef = currentPolyline.getPoints().indexOf(new LatLng(currentPoiNodeRef.getLatitude(), currentPoiNodeRef.getLongitude()));
LatLng previousPoint = currentPolyline.getPoints().get(indexOfPoiNodeRef == 0 ? indexOfPoiNodeRef + 1 : indexOfPoiNodeRef - 1);
LatLng nextPoint = currentPolyline.getPoints().get(indexOfPoiNodeRef == currentPolyline.getPoints().size() - 1 ? indexOfPoiNodeRef - 1 : indexOfPoiNodeRef + 1);
editionPolyline = new PolylineOptions().add(previousPoint, currentPolyline.getPoints().get(indexOfPoiNodeRef), nextPoint).alpha(0.4f).width(1.8f).color(Color.parseColor("#F57C00"));
mapboxMap.addPolyline(editionPolyline);
}
use of io.jawg.osmcontributor.model.entities.PoiNodeRef in project osm-contributor by jawg.
the class MapFragment method confirmPosition.
private void confirmPosition() {
LatLng newPoiPosition;
LatLng pos;
switch(mapMode) {
case POI_CREATION:
if (getZoomLevel() < zoomVectorial) {
changeMapZoomSmooth(15d);
}
createPoi();
break;
case NOTE_CREATION:
pos = mapboxMap.getCameraPosition().target;
NoteCommentDialogFragment dialog = NoteCommentDialogFragment.newInstance(pos.getLatitude(), pos.getLongitude());
dialog.show(getActivity().getFragmentManager(), "dialog");
break;
case POI_POSITION_EDITION:
Poi poi = (Poi) markerSelected.getRelatedObject();
newPoiPosition = mapboxMap.getCameraPosition().target;
eventBus.post(new PleaseApplyPoiPositionChange(newPoiPosition, poi.getId()));
markerSelected.setPosition(newPoiPosition);
markerSelected.setIcon(IconFactory.getInstance(getActivity()).fromBitmap(bitmapHandler.getMarkerBitmap(poi.getType(), Poi.computeState(false, false, true))));
poi.setUpdated(true);
mapboxMap.updateMarker(markerSelected);
switchMode(MapMode.DETAIL_POI);
break;
case NODE_REF_POSITION_EDITION:
PoiNodeRef poiNodeRef = wayMarkerSelected.getPoiNodeRef();
newPoiPosition = mapboxMap.getCameraPosition().target;
eventBus.post(new PleaseApplyNodeRefPositionChange(newPoiPosition, poiNodeRef.getId()));
wayMarkerSelected.setPosition(newPoiPosition);
wayMarkerSelected.setIcon(IconFactory.getInstance(getActivity()).fromBitmap(bitmapHandler.getNodeRefBitmap(PoiNodeRef.State.SELECTED)));
removePolyline(editionPolyline);
switchMode(MapMode.WAY_EDITION);
break;
case DETAIL_POI:
getActivity().finish();
break;
default:
break;
}
}
Aggregations