Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
V
VIPSWeb
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
VIPS
VIPSWeb
Commits
19255407
Commit
19255407
authored
1 year ago
by
Tor-Einar Skog
Browse files
Options
Downloads
Patches
Plain Diff
Pulling data from all layers when user clicks on map
parent
cf54c138
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
spatial/static/spatial/js/gridmap.js
+83
-58
83 additions, 58 deletions
spatial/static/spatial/js/gridmap.js
spatial/templates/spatial/index.html
+1
-1
1 addition, 1 deletion
spatial/templates/spatial/index.html
with
84 additions
and
59 deletions
spatial/static/spatial/js/gridmap.js
+
83
−
58
View file @
19255407
...
...
@@ -51,6 +51,25 @@ function getCurrentVisibleOLLayer()
return
layers
[
currentWMSLayer
[
"
ordering
"
]];
}
/**
* Used by displayQueryResult() to retrieve values from query templates when user clicks on the map
*
* @returns a list of the OpenLayers layers that are available for the current timestamp.
*
*/
function
getLayersForCurrentTimestamp
()
{
layerParams
=
WMSLayersDateBucket
[
currentTimestamp
];
paramIdList
=
Object
.
keys
(
layerParams
);
let
layersForCurrentTimestamp
=
[];
for
(
let
i
=
0
;
i
<
paramIdList
.
length
;
i
++
)
{
layersForCurrentTimestamp
.
push
(
layers
[
WMSLayersDateBucket
[
currentTimestamp
][
paramIdList
[
i
]][
"
ordering
"
]]);
}
return
layersForCurrentTimestamp
;
}
async
function
initGridMap
(
inputModelId
,
mapAttribution
)
{
modelId
=
inputModelId
;
...
...
@@ -212,70 +231,76 @@ async function displayQueryResult(evt)
let
coordinate
=
proj4
(
map
.
getView
().
getProjection
().
getCode
(),
'
EPSG:25833
'
,
evt
.
coordinate
)
let
currentWMSLayer
=
WMSLayersDateBucket
[
currentTimestamp
][
currentParameter
];
let
currentLayer
=
getCurrentVisibleOLLayer
();
//console.info(currentLayer);
const
url
=
currentLayer
.
getSource
().
getGetFeatureInfoUrl
(
coordinate
,
map
.
getView
().
getResolution
(),
currentWMSLayer
.
CRS
[
0
],
{
'
INFO_FORMAT
'
:
'
text/xml
'
}
);
//console.info(url);
let
response
=
await
fetch
(
url
);
let
responseXML
=
await
response
.
text
();
// User clicked outside of layer extent
if
(
responseXML
.
trim
().
length
==
0
)
// Need to get all layers for today, and combine results from querying all layers
let
layersForCurrentTimestamp
=
getLayersForCurrentTimestamp
();
let
warningStatus
=
null
;
let
parameters
=
{};
for
(
let
i
=
0
;
i
<
layersForCurrentTimestamp
.
length
;
i
++
)
{
return
;
}
let
currentLayer
=
layersForCurrentTimestamp
[
i
];
const
url
=
currentLayer
.
getSource
().
getGetFeatureInfoUrl
(
coordinate
,
map
.
getView
().
getResolution
(),
currentWMSLayer
.
CRS
[
0
],
{
'
INFO_FORMAT
'
:
'
text/xml
'
}
);
const
parser
=
new
DOMParser
();
const
xmlDOM
=
parser
.
parseFromString
(
responseXML
,
"
text/xml
"
);
const
result
=
xmlDOM
.
getElementsByTagName
(
"
vipsResult
"
)[
0
]
if
(
result
)
{
// We may or may not have warning status included
let
warningStatus
=
xmlDOM
.
getElementsByTagName
(
"
warningStatus
"
).
length
==
1
?
xmlDOM
.
getElementsByTagName
(
"
warningStatus
"
)[
0
].
getAttribute
(
"
value
"
)
:
null
;
if
(
warningStatus
==
-
1
)
{
return
;
}
let
parameters
=
{};
let
parameterElements
=
xmlDOM
.
getElementsByTagName
(
"
parameter
"
);
for
(
let
i
=
0
;
i
<
parameterElements
.
length
;
i
++
)
let
response
=
await
fetch
(
url
);
let
responseXML
=
await
response
.
text
();
// User clicked outside of layer extent
if
(
responseXML
.
trim
().
length
==
0
)
{
parameters
[
parameterElements
[
i
].
getAttribute
(
"
name
"
)]
=
parameterElements
[
i
].
getAttribute
(
"
value
"
)
;
continue
;
}
//console.info("warningStatus = " + warningStatus);
//console.info(parameters);
let
warningStatusTitle
=
warningStatus
==
0
?
"
N/A
"
:
warningStatus
==
1
?
"
Missing data
"
:
warningStatus
==
2
?
"
No risk
"
:
warningStatus
==
3
?
"
Possible risk
"
:
warningStatus
==
4
?
"
High risk
"
:
""
;
let
paramHTML
=
"
<ul>
"
;
paramCodes
=
Object
.
keys
(
parameters
);
for
(
let
i
=
0
;
i
<
paramCodes
.
length
;
i
++
)
{
paramHTML
+=
"
<li>
"
+
paramCodes
[
i
]
+
"
=
"
+
parameters
[
paramCodes
[
i
]]
+
"
</li>
"
const
parser
=
new
DOMParser
();
const
xmlDOM
=
parser
.
parseFromString
(
responseXML
,
"
text/xml
"
);
const
result
=
xmlDOM
.
getElementsByTagName
(
"
vipsResult
"
)[
0
]
if
(
result
)
{
// We may or may not have warning status included
warningStatus
=
warningStatus
==
null
?
(
xmlDOM
.
getElementsByTagName
(
"
warningStatus
"
).
length
==
1
?
xmlDOM
.
getElementsByTagName
(
"
warningStatus
"
)[
0
].
getAttribute
(
"
value
"
)
:
null
)
:
warningStatus
;
// User clicked on invisible/invalid part of the layer
if
(
warningStatus
==
-
1
)
{
continue
;
}
let
parameterElements
=
xmlDOM
.
getElementsByTagName
(
"
parameter
"
);
for
(
let
i
=
0
;
i
<
parameterElements
.
length
;
i
++
)
{
parameters
[
parameterElements
[
i
].
getAttribute
(
"
name
"
)]
=
parameterElements
[
i
].
getAttribute
(
"
value
"
);
}
}
paramHTML
+=
"
</ul>
"
;
// Render results
// TODO: Handle click outside layer
popup
.
setPosition
(
evt
.
coordinate
);
$
(
popupElement
).
popover
({
'
placement
'
:
'
top
'
,
'
animation
'
:
false
,
'
html
'
:
true
,
'
content
'
:
'
<h4>
'
+
warningStatusTitle
+
'
</h4>
'
+
paramHTML
});
$
(
popupElement
).
popover
(
'
show
'
);
}
else
{
alert
(
"
An error occured. No model data was returned from the server. This is what the server returned:
"
+
responseXML
);
// User clicked outside of layers contents
if
(
warningStatus
==
null
)
{
return
;
}
let
warningStatusTitle
=
warningStatus
==
0
?
"
N/A
"
:
warningStatus
==
1
?
"
Missing data
"
:
warningStatus
==
2
?
"
No risk
"
:
warningStatus
==
3
?
"
Possible risk
"
:
warningStatus
==
4
?
"
High risk
"
:
""
;
let
paramHTML
=
"
<ul>
"
;
paramCodes
=
Object
.
keys
(
parameters
);
for
(
let
i
=
0
;
i
<
paramCodes
.
length
;
i
++
)
{
paramHTML
+=
"
<li>
"
+
paramCodes
[
i
]
+
"
=
"
+
parameters
[
paramCodes
[
i
]]
+
"
</li>
"
}
paramHTML
+=
"
</ul>
"
;
// Render results
popup
.
setPosition
(
evt
.
coordinate
);
$
(
popupElement
).
popover
({
'
placement
'
:
'
top
'
,
'
animation
'
:
false
,
'
html
'
:
true
,
'
content
'
:
'
<h4>
'
+
warningStatusTitle
+
'
</h4>
'
+
paramHTML
});
$
(
popupElement
).
popover
(
'
show
'
);
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
spatial/templates/spatial/index.html
+
1
−
1
View file @
19255407
...
...
@@ -31,7 +31,7 @@
{% if available_grid_models|length > 0 %}
<ul>
{% for model in available_grid_models %}
<li><a
href=
"gridmap/{{model.model_id}}/"
>
{{ model.model_name }}
</a></li>
<li><a
href=
"gridmap/{{model.model_id}}/"
>
{{
get_text_i18n
model.model_name }}
</a></li>
{% endfor %}
</ul>
{% else %}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment