Skip to content

Commit

Permalink
#570 Info with dynamicExtent
Browse files Browse the repository at this point in the history
  • Loading branch information
tariqksoliman committed Jun 28, 2024
1 parent 0bc8a03 commit 3ecd1b7
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 9 deletions.
16 changes: 12 additions & 4 deletions API/Backend/Geodatasets/routes/geodatasets.js
Original file line number Diff line number Diff line change
Expand Up @@ -317,19 +317,27 @@ router.post("/search", function (req, res, next) {
.query(
"SELECT properties, ST_AsGeoJSON(geom) FROM " +
table +
" WHERE properties ->> :key = :value;",
(req.body.last
? " ORDER BY id DESC LIMIT 1;"
: " WHERE properties ->> :key = :value;"),
{
replacements: {
key: req.body.key,
value: req.body.value.replace(/[`;'"]/gi, ""),
value:
typeof req.body.value === "string"
? req.body.value.replace(/[`;'"]/gi, "")
: null,
},
}
)
.then(([results]) => {
let r = [];
for (let i = 0; i < results.length; i++) {
let feature = JSON.parse(results[i].st_asgeojson);
feature.properties = results[i].properties;
let properties = results[i].properties;
let feature = {};
feature.type = "Feature";
feature.properties = properties;
feature.geometry = JSON.parse(results[i].st_asgeojson);
r.push(feature);
}

Expand Down
47 changes: 43 additions & 4 deletions src/essence/Ancillary/Description.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import $ from 'jquery'
import * as d3 from 'd3'
import F_ from '../Basics/Formulae_/Formulae_'
import Dropy from '../../external/Dropy/dropy'
import calls from '../../pre/calls'

import tippy from 'tippy.js'

Expand Down Expand Up @@ -77,7 +78,7 @@ const Description = {
$(`#mainDescPointLinks_global`).empty()
})
},
updateInfo(force) {
updateInfo(force, forceFeature, skipRequery) {
if (force !== true) {
this.waitingOnUpdate = false
if (!this.inited) {
Expand All @@ -100,7 +101,41 @@ const Description = {
l.variables.info.hasOwnProperty('length')
) {
let layers = this.L_.layers.layer[layer]._layers

if (
Object.keys(layers).length === 0 &&
this.L_.layers.data[layer].variables.dynamicExtent
) {
let geodatasetName = this.L_.layers.data[layer].url
if (
skipRequery !== true &&
geodatasetName.indexOf('geodatasets:') === 0
) {
geodatasetName = geodatasetName.replace(
'geodatasets:',
''
)

calls.api(
'geodatasets_search',
{
layer: geodatasetName,
last: true,
},
function (d) {
Description.updateInfo(
false,
d?.body?.[0],
true
)
},
function (d) {}
)
return
}
}
let newInfo = ''

for (let i = 0; i < l.variables.info.length; i++) {
let which =
l.variables.info[i].which != null &&
Expand All @@ -113,8 +148,12 @@ const Description = {
0
)
: Object.keys(layers).length - 1
let feature = layers[Object.keys(layers)[which]]?.feature
if (feature == null) continue
let feature =
forceFeature ||
layers[Object.keys(layers)[which]]?.feature
if (feature == null) {
continue
}

let infoText = F_.bracketReplace(
l.variables.info[i].value,
Expand Down Expand Up @@ -173,7 +212,7 @@ const Description = {
let lat = d3.select(this).attr('lat')
let lng = d3.select(this).attr('lng')

if (lat != null && lng != null) {
if (lat != null && lng != null && lat != 'null' && lng != 'null') {
Description.Map_.map.setView(
[lat, lng],
Description.Map_.mapScaleZoom ||
Expand Down
2 changes: 1 addition & 1 deletion src/essence/Basics/ToolController_/ToolController_.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ let ToolController_ = {
.attr('id', 'toolcontroller_sepdiv')
.style('position', 'absolute')
.style('top', '40px')
.style('left', '0px')
.style('left', '5px')
.style('z-index', '1004')

for (let i = 0; i < tools.length; i++) {
Expand Down

0 comments on commit 3ecd1b7

Please sign in to comment.