Skip to content

Commit

Permalink
mmgisAPI.appendLineString returns false if layer was in a blocking state
Browse files Browse the repository at this point in the history
  • Loading branch information
tariqksoliman committed Feb 15, 2024
1 parent 013316b commit 2b2ed34
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 7 deletions.
31 changes: 24 additions & 7 deletions src/essence/Basics/Layers_/Layers_.js
Original file line number Diff line number Diff line change
Expand Up @@ -2531,7 +2531,7 @@ const L_ = {
'` as inputData is invalid: ' +
JSON.stringify(inputData, null, 4)
)
return
return false
}

// Make sure the timeProp exists as a property in the updated data
Expand All @@ -2544,11 +2544,17 @@ const L_ = {
' and does not exist as a property in inputData: ' +
JSON.stringify(lastFeature, null, 4)
)
return
return false
}

if (layerName in L_.layers.layer) {
const updateLayer = L_.layers.layer[layerName]
if (L_._layersBeingMade[layerName] === true) {
console.error(
`ERROR - appendLineString: Cannot make layer ${layerObj.display_name}/${layerObj.name} as it's already being made!`
)
return false
}

var layers = updateLayer.getLayers()
var layersGeoJSON = updateLayer.toGeoJSON(L_.GEOJSON_PRECISION)
Expand All @@ -2564,7 +2570,7 @@ const L_ = {
'` as the feature is not a LineStringfeature: ' +
JSON.stringify(lastFeature, null, 4)
)
return
return false
}

// Make sure the timeProp exists as a property in the feature
Expand All @@ -2588,7 +2594,7 @@ const L_ = {
"` as inputData has the wrong geometry type (must be of type 'LineString'): " +
JSON.stringify(inputData, null, 4)
)
return
return false
}

// Append new data to the end of the last feature
Expand All @@ -2607,7 +2613,7 @@ const L_ = {
"` as inputData has the wrong type (must be of type 'Feature'): " +
JSON.stringify(inputData, null, 4)
)
return
return false
}

const initialOn = L_.layers.on[layerName]
Expand All @@ -2617,7 +2623,16 @@ const L_ = {
}

L_.clearGeoJSONData(updateLayer)
L_.addGeoJSONData(updateLayer, layersGeoJSON)
try {
L_.addGeoJSONData(updateLayer, layersGeoJSON)
} catch (e) {
console.log(e)
console.warn(
'Warning: Unable to append LineString to layer as the layer or input data is invalid: ' +
layerName
)
return false
}

if (initialOn) {
// Reselect activeFeature
Expand All @@ -2634,14 +2649,16 @@ const L_ = {
layerName +
'` as the layer contains no features'
)
return
return false
}
} else {
console.warn(
'Warning: Unable to append to vector layer as it does not exist: ' +
layerName
)
return false
}
return true
},
updateVectorLayer: function (layerName, inputData, keepLastN) {
layerName = L_.asLayerUUID(layerName)
Expand Down
1 change: 1 addition & 0 deletions src/essence/Tools/Draw/DrawTool.js
Original file line number Diff line number Diff line change
Expand Up @@ -556,6 +556,7 @@ var DrawTool = {
if (DrawTool.files[f].is_master)
DrawTool.masterFileIds.push(DrawTool.files[f].id)
}
DrawTool.destroy()
})
}
},
Expand Down

0 comments on commit 2b2ed34

Please sign in to comment.