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

#570 Info with dynamicExtent #571

Merged
merged 1 commit into from
Jun 28, 2024
Merged
Show file tree
Hide file tree
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
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
Loading