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
476d68c1
Commit
476d68c1
authored
1 year ago
by
Tor-Einar Skog
Browse files
Options
Downloads
Patches
Plain Diff
Multiparam organizing works
parent
f034e7df
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
spatial/static/spatial/js/slidingMap.js
+42
-28
42 additions, 28 deletions
spatial/static/spatial/js/slidingMap.js
with
42 additions
and
28 deletions
spatial/static/spatial/js/slidingMap.js
+
42
−
28
View file @
476d68c1
...
@@ -7,19 +7,24 @@ let layers = [];
...
@@ -7,19 +7,24 @@ let layers = [];
let
mapserverURL
=
"
https://testvips.nibio.no/cgi-bin/
"
;
let
mapserverURL
=
"
https://testvips.nibio.no/cgi-bin/
"
;
let
modelId
=
"
SEPTREFHUM
"
;
let
modelId
=
"
SEPTREFHUM
"
;
let
today
=
"
2023-
1
0-1
4
"
;
let
today
=
"
2023-0
4
-1
0
"
;
let
todayLayerIndex
=
undefined
;
let
todayLayerIndex
=
undefined
;
let
timestamps
=
undefined
;
let
timestamps
=
undefined
;
let
currentParameter
=
"
WARNING_STATUS
"
;
let
WMSLayersDateBucket
=
{};
function
switchLayer
(
visibleLayer
Index
)
function
switchLayer
(
day
Index
)
{
{
console
.
info
(
"
==>
"
+
visibleLayerIndex
);
console
.
info
(
"
==>
"
+
dayIndex
);
currentTimestamp
=
timestamps
[
dayIndex
];
currentLayer
=
WMSLayersDateBucket
[
currentTimestamp
][
currentParameter
];
currentLayerOrdering
=
currentLayer
[
"
ordering
"
];
for
(
let
i
=
0
;
i
<
layers
.
length
;
i
++
)
for
(
let
i
=
0
;
i
<
layers
.
length
;
i
++
)
{
{
console
.
info
(
i
)
console
.
info
(
i
)
layers
[
i
].
setVisible
(
i
==
visibleLayerIndex
);
layers
[
i
].
setVisible
(
i
==
currentLayerOrdering
);
}
}
setCurrentDate
(
visibleLayer
Index
);
setCurrentDate
(
day
Index
);
}
}
function
setCurrentDate
(
layerIndex
)
function
setCurrentDate
(
layerIndex
)
...
@@ -48,18 +53,20 @@ async function initSlidingMap(lonLat, zoomLevel, mapAttribution) {
...
@@ -48,18 +53,20 @@ async function initSlidingMap(lonLat, zoomLevel, mapAttribution) {
let
result
=
parser
.
read
(
await
response
.
text
());
let
result
=
parser
.
read
(
await
response
.
text
());
let
WMSLayers
=
result
.
Capability
.
Layer
.
Layer
;
let
WMSLayers
=
result
.
Capability
.
Layer
.
Layer
;
// Analyze layers
// Analyze
and organize
layers
let
WMSLayersDateBucket
=
{};
for
(
let
i
=
0
;
i
<
WMSLayers
.
length
;
i
++
){
for
(
let
i
=
0
;
i
<
WMSLayers
.
length
;
i
++
){
// Get only WARNING_STATUS layers for now
// Sort by date ascending
// Sort by date ascending
WMSLayerName
=
WMSLayers
[
i
].
Name
;
let
WMSLayerName
=
WMSLayers
[
i
].
Name
;
if
(
WMSLayerName
.
split
(
"
.
"
)[
1
]
==
"
WARNING_STATUS
"
)
let
WMSLayerParam
=
WMSLayerName
.
split
(
"
.
"
)[
1
]
let
timestamp
=
moment
(
WMSLayerName
.
split
(
"
.
"
)[
2
]).
valueOf
();
if
(
WMSLayersDateBucket
[
timestamp
]
==
undefined
)
{
{
WMSLayersDateBucket
[
moment
(
WMSLayerName
.
split
(
"
.
"
)[
2
]).
valueOf
()]
=
WMSLayers
[
i
];
WMSLayersDateBucket
[
timestamp
]
=
{}
}
}
WMSLayersDateBucket
[
timestamp
][
WMSLayerParam
]
=
WMSLayers
[
i
];
}
}
//console.info(WMSLayersDateBucket);
timestamps
=
Object
.
keys
(
WMSLayersDateBucket
);
timestamps
=
Object
.
keys
(
WMSLayersDateBucket
);
...
@@ -71,23 +78,29 @@ async function initSlidingMap(lonLat, zoomLevel, mapAttribution) {
...
@@ -71,23 +78,29 @@ async function initSlidingMap(lonLat, zoomLevel, mapAttribution) {
let
dateStr
=
moment
(
parseInt
(
timestamps
[
i
])).
format
(
"
YYYY-MM-DD
"
);
let
dateStr
=
moment
(
parseInt
(
timestamps
[
i
])).
format
(
"
YYYY-MM-DD
"
);
if
(
dateStr
==
today
)
if
(
dateStr
==
today
)
{
{
console
.
info
(
"
YESS:
"
+
i
);
todayLayerIndex
=
i
;
todayLayerIndex
=
i
;
}
}
let
timestampLayers
=
WMSLayersDateBucket
[
timestamps
[
i
]];
layers
.
push
(
let
params
=
Object
.
keys
(
timestampLayers
);
new
ol
.
layer
.
Image
({
for
(
let
j
=
0
;
j
<
params
.
length
;
j
++
)
source
:
new
ol
.
source
.
ImageWMS
({
{
url
:
mapserverURL
+
modelId
,
let
currentLayer
=
timestampLayers
[
params
[
j
]];
params
:
{
"
LAYERS
"
:
modelId
+
"
.WARNING_STATUS.
"
+
dateStr
,
"
TRANSPARENT
"
:
"
TRUE
"
},
let
currentLayerParam
=
currentLayer
.
Name
.
split
(
"
.
"
)[
1
];
serverType
:
"
mapserver
"
,
layers
.
push
(
ratio
:
1
,
new
ol
.
layer
.
Image
({
projection
:
ol
.
proj
.
get
(
"
EPSG:25833
"
)
source
:
new
ol
.
source
.
ImageWMS
({
}),
url
:
mapserverURL
+
modelId
,
visible
:
(
i
==
todayLayerIndex
),
params
:
{
"
LAYERS
"
:
modelId
+
"
.
"
+
currentLayerParam
+
"
.
"
+
dateStr
,
"
TRANSPARENT
"
:
"
TRUE
"
},
opacity
:
0.5
serverType
:
"
mapserver
"
,
})
ratio
:
1
,
);
projection
:
ol
.
proj
.
get
(
"
EPSG:25833
"
)
}),
visible
:
false
,
opacity
:
0.5
})
);
currentLayer
[
"
ordering
"
]
=
layers
.
length
-
1
;
}
}
}
let
range
=
document
.
getElementById
(
"
layerDateRange
"
);
let
range
=
document
.
getElementById
(
"
layerDateRange
"
);
...
@@ -95,8 +108,9 @@ async function initSlidingMap(lonLat, zoomLevel, mapAttribution) {
...
@@ -95,8 +108,9 @@ async function initSlidingMap(lonLat, zoomLevel, mapAttribution) {
range
.
max
=
timestamps
.
length
-
1
;
range
.
max
=
timestamps
.
length
-
1
;
range
.
value
=
todayLayerIndex
;
range
.
value
=
todayLayerIndex
;
setCurrentDate
(
todayLayerIndex
);
setCurrentDate
(
todayLayerIndex
);
switchLayer
(
todayLayerIndex
);
//console.info(WMSLayersDateBucket);
// Creating the map
// Creating the map
map
=
new
ol
.
Map
({
map
=
new
ol
.
Map
({
...
...
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