Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

show deleted ways #310

Merged
merged 1 commit into from
Jun 9, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 16 additions & 13 deletions app/utils/edits-to-geojson.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import _find from 'lodash.find'
import { addIconUrl } from '../utils/add-icon-url'
import _cloneDeep from 'lodash.clonedeep'

export default function editsToGeojson (edits) {
const editsGeojson = {
Expand All @@ -11,19 +12,21 @@ export default function editsToGeojson (edits) {
if (!_find(editsGeojson.features, { 'id': e.id })) {
// set tag information for this feature

// Add feature to editsGeojson. If feature was deleted and is pending
// upload, add a property to flag this.
const feature =
e.type === 'delete'
? {
...e.oldFeature,
properties: {
...e.oldFeature.properties,
pendingDeleteUpload: true
}
}
: e.newFeature

// Add feature to editsGeojson.
let feature
if (e.type === 'delete') {
// If feature was deleted and is pending
// upload, add a property to flag this.
feature = _cloneDeep(e.oldFeature)
feature.properties.pendingDeleteUpload = true
} else if (e.type === 'modify' && e.newFeature.geometry.type !== 'Point' && e.newFeature.geometry.coordinates.length < 2) {
// this is a special case when one of two nodes of a way is deleted, then the way itself is deleted.
// in the edits this is considered as a modify operation because it may involve other sharedways. Read for more https://github.com/developmentseed/observe/issues/296
feature = _cloneDeep(e.oldFeature)
feature.properties.pendingDeleteUpload = true
} else {
feature = e.newFeature
}
// add this feature to the editsGeojson
editsGeojson.features.push(addIconUrl(feature))
}
Expand Down