Skip to content

Commit

Permalink
Fix no data dynamicExtent responses
Browse files Browse the repository at this point in the history
  • Loading branch information
tariqksoliman committed May 8, 2024
1 parent 7924a7d commit b939040
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 20 deletions.
21 changes: 21 additions & 0 deletions src/essence/Basics/Formulae_/Formulae_.js
Original file line number Diff line number Diff line change
Expand Up @@ -1522,6 +1522,27 @@ var Formulae_ = {
})
return g
},
parseIntoGeoJSON(data) {
let d
// []
if (Array.isArray(data) && data.length === 0) {
d = { type: 'FeatureCollection', features: [] }
}
// [<FeatureCollection>]
else if (
Array.isArray(data) &&
data[0] &&
data[0].type === 'FeatureCollection'
) {
const nextData = { type: 'FeatureCollection', features: [] }
data.forEach((fc) => {
if (fc.type === 'FeatureCollection')
nextData.features = nextData.features.concat(fc.features)
})
d = nextData
}
return d == null ? data : d
},
// Gets all tiles with tile xyz at zoom z
tilesWithin(xyz, z) {
let tiles = []
Expand Down
7 changes: 6 additions & 1 deletion src/essence/Basics/Layers_/LayerCapturer.js
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,10 @@ export const captureVector = (layerObj, options, cb, dynamicCb) => {
L_.clearVectorLayer(layerObj.name)
}
})
cb({ type: 'FeatureCollection', features: [] }, true)
cb(
{ type: 'FeatureCollection', check: true, features: [] },
true
)
break
case 'api':
break
Expand Down Expand Up @@ -277,6 +280,8 @@ export const captureVector = (layerObj, options, cb, dynamicCb) => {
delete data.Features
}

data = F_.parseIntoGeoJSON(data)

const lastLoc = _layerRequestLastLoc[layerObj.name]
const nowLoc = L_.Map_.map.getCenter()

Expand Down
6 changes: 6 additions & 0 deletions src/essence/Basics/Layers_/Layers_.js
Original file line number Diff line number Diff line change
Expand Up @@ -2738,6 +2738,12 @@ const L_ = {
syncSublayerData: async function (layerName, onlyClear) {
layerName = L_.asLayerUUID(layerName)

if (
L_.layers.layer[layerName] == null ||
L_.layers.layer[layerName] == false
)
return

try {
let geojson = L_.layers.layer[layerName].toGeoJSON(
L_.GEOJSON_PRECISION
Expand Down
20 changes: 1 addition & 19 deletions src/essence/Basics/Map_/Map_.js
Original file line number Diff line number Diff line change
Expand Up @@ -814,25 +814,7 @@ async function makeVectorLayer(
)

function add(data, allowInvalid) {
// []
if (Array.isArray(data) && data.length === 0) {
data = { type: 'FeatureCollection', features: [] }
}
// [<FeatureCollection>]
else if (
Array.isArray(data) &&
data[0] &&
data[0].type === 'FeatureCollection'
) {
const nextData = { type: 'FeatureCollection', features: [] }
data.forEach((fc) => {
if (fc.type === 'FeatureCollection')
nextData.features = nextData.features.concat(
fc.features
)
})
data = nextData
}
data = F_.parseIntoGeoJSON(data)

let invalidGeoJSONTrace = gjv.valid(data, true)
const allowableErrors = [`position must only contain numbers`]
Expand Down

0 comments on commit b939040

Please sign in to comment.