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
feedcb28
Commit
feedcb28
authored
1 year ago
by
Tor-Einar Skog
Browse files
Options
Downloads
Patches
Plain Diff
Refactor function renderWEatherData out to ipmdblib.js
parent
61c62d6e
No related branches found
No related tags found
2 merge requests
!13
Saddlegallmidge form idec 372
,
!12
feat: Add test page (spatial) with mapserver layer in openlayers map
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
ipmd/static/ipmd/js/ipmdlib.js
+35
-7
35 additions, 7 deletions
ipmd/static/ipmd/js/ipmdlib.js
ipmd/templates/ipmd/saddlegallmidgeform.html
+0
-22
0 additions, 22 deletions
ipmd/templates/ipmd/saddlegallmidgeform.html
with
35 additions
and
29 deletions
ipmd/static/ipmd/js/ipmdlib.js
+
35
−
7
View file @
feedcb28
...
...
@@ -190,6 +190,34 @@ function getPragmaticWeatherParameterList(requestedParameters, availableParamete
}
/**
* Displays the weather data in a table
* @param {Object} weatherData the weatherData in IPM Decisions format
* @param {HTMLElement} container the element to render to
* @param {String} tableClass for styling the table, e.g. using Bootstrap
*/
function
renderWeatherData
(
weatherData
,
container
,
tableClass
){
let
dates
=
getDateArray
(
weatherData
.
timeStart
,
weatherData
.
interval
,
weatherData
.
locationWeatherData
[
0
].
length
);
let
html
=
"
<table
"
+
(
tableClass
!=
undefined
?
"
class=
\"
"
+
tableClass
+
"
\"
"
:
""
)
+
"
><thead><tr><th>Time</th>
"
;
weatherData
.
weatherParameters
.
forEach
(
function
(
weatherParameterId
){
html
+=
"
<th>
"
+
getWeatherParameter
(
weatherParameterId
).
name
+
"
</th>
"
;
});
html
+=
"
</tr></thead>
"
html
+=
"
<tbody>
"
;
//console.info("Weatherdata length: " + weatherData.locationWeatherData[0].data.length);
for
(
let
i
=
0
;
i
<
weatherData
.
locationWeatherData
[
0
].
data
.
length
;
i
++
)
{
html
+=
"
<tr><td>
"
+
moment
(
dates
[
i
]).
format
(
"
YYYY-MM-DD HH:mm:ss
"
)
+
"
</td>
"
;
weatherData
.
locationWeatherData
[
0
].
data
[
i
].
forEach
(
function
(
val
){
html
+=
"
<td>
"
+
val
+
"
</td>
"
;})
html
+=
"
</tr>
"
;
}
html
+=
"
</tbody>
"
;
html
+=
"
</table>
"
;
container
.
innerHTML
=
html
;
}
/**
* Merges the two datasets. Keeping the primaryData if both sets have data for same time and parameter
* If a merge operation is not possible, primaryData is returned unchanged
...
...
@@ -364,15 +392,14 @@ async function initDataSourceMap(containerId, geoJson, countryCodeList)
map
=
null
;
}
//console.info(countryCodeList);
//console.info(geoJson);
// If no data, no map
if
((
geoJson
==
undefined
||
geoJson
==
null
||
geoJson
.
features
.
length
==
0
)
&&
(
countryCodeList
==
null
||
countryCodeList
.
length
==
0
))
{
document
.
getElementById
(
containerId
).
innerHTML
=
"
NO GEODATA PROVIDED BY WEATHER DATA SOURCE
"
;
return
;
}
else
{
else
{
document
.
getElementById
(
containerId
).
innerHTML
=
""
;
}
...
...
@@ -398,8 +425,8 @@ async function initDataSourceMap(containerId, geoJson, countryCodeList)
// center to correct map projection)
var
view
=
new
ol
.
View
({
center
:
ol
.
proj
.
transform
([
10
,
65
],
'
EPSG:4326
'
,
map
.
getView
().
getProjection
().
getCode
()),
zoom
:
7
,
maxZoom
:
7
zoom
:
7
//
,
//
maxZoom: 7
});
map
.
setView
(
view
);
...
...
@@ -416,7 +443,6 @@ async function initDataSourceMap(containerId, geoJson, countryCodeList)
});
}
// If not, we have to get geoJson mapped to the countries
else
if
(
countryCodeList
!=
undefined
&&
countryCodeList
!=
null
&&
countryCodeList
.
length
>
0
)
{
let
countryBoundaries
=
await
getCountryBoundaries
(
countryCodeList
);
...
...
@@ -429,16 +455,18 @@ async function initDataSourceMap(containerId, geoJson, countryCodeList)
if
(
drawnFeatures
!=
undefined
)
{
//console.info(drawnFeatures);
// Create an empty layer
var
featureOverlay
=
new
ol
.
layer
.
Vector
({
source
:
new
ol
.
source
.
Vector
({
features
:
features
})
});
// Add the stations or area
featureOverlay
.
getSource
().
addFeatures
(
drawnFeatures
);
featureOverlay
.
setMap
(
map
);
// Fit the features to the extent of the map
extent
=
featureOverlay
.
getSource
().
getExtent
();
map
.
getView
().
fit
(
extent
,
map
.
getSize
());
}
...
...
This diff is collapsed.
Click to expand it.
ipmd/templates/ipmd/saddlegallmidgeform.html
+
0
−
22
View file @
feedcb28
...
...
@@ -380,28 +380,6 @@
renderWeatherData
(
weatherData
,
document
.
getElementById
(
"
weatherData
"
),
"
table table-striped
"
)
}
function
renderWeatherData
(
weatherData
,
container
,
tableClass
){
let
dates
=
getDateArray
(
weatherData
.
timeStart
,
weatherData
.
interval
,
weatherData
.
locationWeatherData
[
0
].
length
);
let
html
=
"
<table
"
+
(
tableClass
!=
undefined
?
"
class=
\"
"
+
tableClass
+
"
\"
"
:
""
)
+
"
><thead><tr><th>Time</th>
"
;
weatherData
.
weatherParameters
.
forEach
(
function
(
weatherParameterId
){
html
+=
"
<th>
"
+
getWeatherParameter
(
weatherParameterId
).
name
+
"
</th>
"
;
});
html
+=
"
</tr></thead>
"
html
+=
"
<tbody>
"
;
//console.info("Weatherdata length: " + weatherData.locationWeatherData[0].data.length);
for
(
let
i
=
0
;
i
<
weatherData
.
locationWeatherData
[
0
].
data
.
length
;
i
++
)
{
html
+=
"
<tr><td>
"
+
moment
(
dates
[
i
]).
format
(
"
YYYY-MM-DD HH:mm:ss
"
)
+
"
</td>
"
;
weatherData
.
locationWeatherData
[
0
].
data
[
i
].
forEach
(
function
(
val
){
html
+=
"
<td>
"
+
val
+
"
</td>
"
;})
html
+=
"
</tr>
"
;
}
html
+=
"
</tbody>
"
;
html
+=
"
</table>
"
;
container
.
innerHTML
=
html
;
}
// Mock result!!! Waiting for ADAS to fix CORS issue
...
...
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