Commit e44d079c authored by Tomas Pettersson's avatar Tomas Pettersson 🏸

forcing-boundary added

parent 9aa33eda
......@@ -62,7 +62,10 @@ module.exports = function(grunt) {
},
"jquery.inputmask" : {
"main" : "dist/jquery.inputmask.bundle.js"
}
},
"leaflet-forcing-boundary" : {
"main" : ["dist/leaflet-forcing-boundary.js"]
}
}
}
}
......
......@@ -23,6 +23,7 @@
"ion.rangeSlider": "latest",
"leaflet-container-control": "https://git.smhi.se/stw/leaflet-container-control.git",
"leaflet-coordinates-control": "https://git.smhi.se/stw/leaflet-coordinates-control.git",
"leaflet-forcing-boundary": "https://git.smhi.se/stw/leaflet-forcing-boundary.git",
"intro.js": "^2.5.0"
},
"resolutions": {
......
This diff is collapsed.
......@@ -11,6 +11,9 @@ app.use(bodyParser.urlencoded({ extended: true })); // for parsing application/x
var url = '/demo'
require('../bower_components/leaflet-forcing-boundary/src/routes/forcingboundary')(url,app);
app.get('/demo/input', function (req, res) {
res.send(
......
......@@ -86,6 +86,19 @@
padding-bottom: 15px;
}
.oilspill-control .legend-text {
display: inline-block;
position: relative;
left: 5px;
}
.oilspill-control .legend-box {
display: inline-block;
top: 1px;
position: relative;
}
.introjs-helperLayer {
background-color: rgba(255,255,255,0);
}
......
/// <reference path="def/uikit.d.ts" />
/// <reference path="def/leaflet.d.ts" />
/// <reference path="def/moment.d.ts" />
/// <reference path="def/leaflet-forcing-boundary.d.ts" />
/// <reference path="def/reqwest.d.ts" />
var __extends = (this && this.__extends) || (function () {
var extendStatics = Object.setPrototypeOf ||
......@@ -72,11 +73,14 @@ var OilSpillCard = (function () {
}());
var OSLocation = (function (_super) {
__extends(OSLocation, _super);
function OSLocation(id, parentDiv, lang, langData, map, bbox) {
function OSLocation(id, parentDiv, lang, langData, map, forcing) {
var _this = this;
var locationDiv = L.DomUtil.create('div', 'uk-width-1-1 uk-margin-top', parentDiv);
_this = _super.call(this, id, 'Specify time and location', parentDiv, locationDiv) || this;
var self = _this;
if (forcing) {
self.forcingBoundary = new Forcing.Boundary(locationDiv, map, forcing);
}
var form = L.DomUtil.create('form', 'uk-form uk-form-stacked', locationDiv);
form.onsubmit = function (e) {
e.preventDefault();
......@@ -152,6 +156,13 @@ var OSLocation = (function (_super) {
geojson["features"].push(feature);
self.control.addGeoJSON(geojson);
};
var bbox = {};
bbox['s'] = -90;
bbox['n'] = 90;
bbox['w'] = -180;
bbox['e'] = 180;
if (forcing)
bbox = forcing.features[0].properties.bbox;
self.control = new L.Control.Coordinates({
"lang": lang,
"langdata": langData.coordinates,
......@@ -173,6 +184,10 @@ var OSLocation = (function (_super) {
if (self.exitControl)
map.removeControl(self.exitControl);
self.exitControl = null;
var coordinates = [];
coordinates.push([latlngs[0][0].lng, latlngs[0][0].lat]);
if (self.forcingBoundary)
self.forcingBoundary.validate(coordinates);
self.control.showTable();
self.hasPosition = true;
validate();
......@@ -190,6 +205,8 @@ var OSLocation = (function (_super) {
'show': false
});
window.dispatchEvent(toggleevt);
if (self.forcingBoundary)
self.forcingBoundary.show();
self.control.draw();
self.exitControl = new L.Control({ position: 'bottomright' });
self.exitControl.onAdd = function (map) {
......@@ -241,6 +258,8 @@ var OSLocation = (function (_super) {
OilSpillCard.warningMsg('Mandatory fields missing', 'Specify a location by <b>manually entering</b> position or <b>draw</b> on the map.');
return;
}
if (self.forcingBoundary)
self.forcingBoundary.hide();
(self.oncallback && self.oncallback(true));
};
UIkit.ready(function () {
......@@ -296,6 +315,8 @@ var OSLocation = (function (_super) {
var initDate = moment.utc();
self.obsDateInput.value = initDate.format(self.dateFormat);
self.obsTimeInput.value = initDate.startOf('hour').format(self.timeFormat);
if (self.forcingBoundary)
self.forcingBoundary.hide();
self.depthInput.value = '0';
self.control.clear();
self.control.hideTable();
......@@ -918,13 +939,8 @@ var L;
if (options.langdata) {
_this.langData = options.langdata;
}
_this.bbox = {};
_this.bbox['s'] = -90;
_this.bbox['n'] = 90;
_this.bbox['w'] = -180;
_this.bbox['e'] = 180;
if (options.bbox) {
_this.bbox = options.bbox;
if (options.forcing) {
_this.forcing = options.forcing;
}
return _this;
}
......@@ -1024,7 +1040,7 @@ var L;
this.container = L.DomUtil.create('div', 'oilspill-control');
var accordionDiv = L.DomUtil.create('div', 'uk-accordion', this.container);
var locationid = 'oslocationCard';
self.cardMap[locationid] = new OSLocation(locationid, accordionDiv, self.lang, self.langData, self.map, self.bbox);
self.cardMap[locationid] = new OSLocation(locationid, accordionDiv, self.lang, self.langData, self.map, self.forcing);
self.cardMap[locationid].show();
var periodid = 'osperiodCard';
self.cardMap[periodid] = new OSPeriod(periodid, accordionDiv, self.lang, self.map);
......
......@@ -9,7 +9,8 @@
"body-parser": "latest",
"utf8" : "latest",
"request" : "latest",
"moment" : "latest"
"moment" : "latest" ,
"@turf/within" : "latest"
},
"devDependencies": {
"grunt": "^1.0.1",
......
declare namespace Forcing {
export var Boundary: any;
}
\ No newline at end of file
/// <reference path="def/uikit.d.ts" />
/// <reference path="def/leaflet.d.ts" />
/// <reference path="def/moment.d.ts" />
/// <reference path="def/leaflet-forcing-boundary.d.ts" />
/// <reference path="def/reqwest.d.ts" />
var __extends = (this && this.__extends) || (function () {
var extendStatics = Object.setPrototypeOf ||
......@@ -72,11 +73,14 @@ var OilSpillCard = (function () {
}());
var OSLocation = (function (_super) {
__extends(OSLocation, _super);
function OSLocation(id, parentDiv, lang, langData, map, bbox) {
function OSLocation(id, parentDiv, lang, langData, map, forcing) {
var _this = this;
var locationDiv = L.DomUtil.create('div', 'uk-width-1-1 uk-margin-top', parentDiv);
_this = _super.call(this, id, 'Specify time and location', parentDiv, locationDiv) || this;
var self = _this;
if (forcing) {
self.forcingBoundary = new Forcing.Boundary(locationDiv, map, forcing);
}
var form = L.DomUtil.create('form', 'uk-form uk-form-stacked', locationDiv);
form.onsubmit = function (e) {
e.preventDefault();
......@@ -152,6 +156,13 @@ var OSLocation = (function (_super) {
geojson["features"].push(feature);
self.control.addGeoJSON(geojson);
};
var bbox = {};
bbox['s'] = -90;
bbox['n'] = 90;
bbox['w'] = -180;
bbox['e'] = 180;
if (forcing)
bbox = forcing.features[0].properties.bbox;
self.control = new L.Control.Coordinates({
"lang": lang,
"langdata": langData.coordinates,
......@@ -173,6 +184,10 @@ var OSLocation = (function (_super) {
if (self.exitControl)
map.removeControl(self.exitControl);
self.exitControl = null;
var coordinates = [];
coordinates.push([latlngs[0][0].lng, latlngs[0][0].lat]);
if (self.forcingBoundary)
self.forcingBoundary.validate(coordinates);
self.control.showTable();
self.hasPosition = true;
validate();
......@@ -190,6 +205,8 @@ var OSLocation = (function (_super) {
'show': false
});
window.dispatchEvent(toggleevt);
if (self.forcingBoundary)
self.forcingBoundary.show();
self.control.draw();
self.exitControl = new L.Control({ position: 'bottomright' });
self.exitControl.onAdd = function (map) {
......@@ -241,6 +258,8 @@ var OSLocation = (function (_super) {
OilSpillCard.warningMsg('Mandatory fields missing', 'Specify a location by <b>manually entering</b> position or <b>draw</b> on the map.');
return;
}
if (self.forcingBoundary)
self.forcingBoundary.hide();
(self.oncallback && self.oncallback(true));
};
UIkit.ready(function () {
......@@ -296,6 +315,8 @@ var OSLocation = (function (_super) {
var initDate = moment.utc();
self.obsDateInput.value = initDate.format(self.dateFormat);
self.obsTimeInput.value = initDate.startOf('hour').format(self.timeFormat);
if (self.forcingBoundary)
self.forcingBoundary.hide();
self.depthInput.value = '0';
self.control.clear();
self.control.hideTable();
......
This diff is collapsed.
/// <reference path="def/uikit.d.ts" />
/// <reference path="def/leaflet.d.ts" />
/// <reference path="def/moment.d.ts" />
/// <reference path="def/leaflet-forcing-boundary.d.ts" />
/// <reference path="def/reqwest.d.ts" />
class OilSpillCard {
private content: any;
public status: boolean;
......@@ -93,13 +94,18 @@ class OSLocation extends OilSpillCard {
public timeFormat : string;
public datetimeFormat : string;
public hasPosition : boolean;
private forcingBoundary: any;
constructor(id, parentDiv, lang, langData, map, bbox) {
constructor(id, parentDiv, lang, langData, map, forcing) {
var locationDiv = <HTMLDivElement>L.DomUtil.create('div', 'uk-width-1-1 uk-margin-top', parentDiv);
super(id, 'Specify time and location', parentDiv ,locationDiv);
var self = this;
if (forcing) {
self.forcingBoundary = new Forcing.Boundary(locationDiv, map, forcing);
}
var form = <HTMLFormElement>L.DomUtil.create('form', 'uk-form uk-form-stacked', locationDiv);
form.onsubmit = function(e){
e.preventDefault();
......@@ -177,6 +183,15 @@ class OSLocation extends OilSpillCard {
geojson["features"].push(feature);
self.control.addGeoJSON(geojson);
}
var bbox = {};
bbox['s'] = -90;
bbox['n'] = 90;
bbox['w'] = -180;
bbox['e'] = 180;
if (forcing) bbox = forcing.features[0].properties.bbox;
self.control = new L.Control.Coordinates({
"lang": lang,
"langdata": langData.coordinates,
......@@ -197,6 +212,9 @@ class OSLocation extends OilSpillCard {
window.dispatchEvent(toggleevt);
if (self.exitControl) map.removeControl(self.exitControl);
self.exitControl = null;
var coordinates = [];
coordinates.push([latlngs[0][0].lng, latlngs[0][0].lat]);
if (self.forcingBoundary) self.forcingBoundary.validate(coordinates);
self.control.showTable();
self.hasPosition = true;
validate();
......@@ -215,6 +233,7 @@ class OSLocation extends OilSpillCard {
'show': false
});
window.dispatchEvent(toggleevt);
if (self.forcingBoundary) self.forcingBoundary.show();
self.control.draw();
self.exitControl = new L.Control({position: 'bottomright'});
self.exitControl.onAdd = function(map: L.Map) {
......@@ -270,7 +289,7 @@ class OSLocation extends OilSpillCard {
'Specify a location by <b>manually entering</b> position or <b>draw</b> on the map.');
return;
}
if (self.forcingBoundary) self.forcingBoundary.hide();
(self.oncallback && self.oncallback(true));
};
UIkit.ready( function(){
......@@ -335,6 +354,7 @@ class OSLocation extends OilSpillCard {
var initDate = moment.utc();
self.obsDateInput.value = initDate.format(self.dateFormat);
self.obsTimeInput.value = initDate.startOf('hour').format(self.timeFormat);
if (self.forcingBoundary) self.forcingBoundary.hide();
self.depthInput.value = '0';
self.control.clear();
self.control.hideTable();
......
......@@ -86,6 +86,19 @@
padding-bottom: 15px;
}
.oilspill-control .legend-text {
display: inline-block;
position: relative;
left: 5px;
}
.oilspill-control .legend-box {
display: inline-block;
top: 1px;
position: relative;
}
.introjs-helperLayer {
background-color: rgba(255,255,255,0);
}
......
......@@ -31,13 +31,8 @@ var L;
if (options.langdata) {
_this.langData = options.langdata;
}
_this.bbox = {};
_this.bbox['s'] = -90;
_this.bbox['n'] = 90;
_this.bbox['w'] = -180;
_this.bbox['e'] = 180;
if (options.bbox) {
_this.bbox = options.bbox;
if (options.forcing) {
_this.forcing = options.forcing;
}
return _this;
}
......@@ -137,7 +132,7 @@ var L;
this.container = L.DomUtil.create('div', 'oilspill-control');
var accordionDiv = L.DomUtil.create('div', 'uk-accordion', this.container);
var locationid = 'oslocationCard';
self.cardMap[locationid] = new OSLocation(locationid, accordionDiv, self.lang, self.langData, self.map, self.bbox);
self.cardMap[locationid] = new OSLocation(locationid, accordionDiv, self.lang, self.langData, self.map, self.forcing);
self.cardMap[locationid].show();
var periodid = 'osperiodCard';
self.cardMap[periodid] = new OSPeriod(periodid, accordionDiv, self.lang, self.map);
......
This diff is collapsed.
......@@ -21,7 +21,7 @@ module L.Control {
private selectCalculationMode: HTMLSelectElement;
private uncertaintyInput: HTMLInputElement;
private startButton: HTMLButtonElement;
private bbox: any;
private forcing: any;
constructor(options) {
super(options);
......@@ -35,15 +35,9 @@ module L.Control {
if (options.langdata) {
this.langData = options.langdata;
}
this.bbox = {};
this.bbox['s'] = -90;
this.bbox['n'] = 90;
this.bbox['w'] = -180;
this.bbox['e'] = 180;
if (options.bbox) {
this.bbox = options.bbox;
}
if (options.forcing) {
this.forcing = options.forcing;
}
}
......@@ -146,7 +140,7 @@ module L.Control {
this.container = L.DomUtil.create('div', 'oilspill-control');
var accordionDiv = <HTMLDivElement>L.DomUtil.create('div', 'uk-accordion', this.container);
var locationid = 'oslocationCard';
self.cardMap[locationid] = new OSLocation(locationid, accordionDiv, self.lang, self.langData, self.map, self.bbox);
self.cardMap[locationid] = new OSLocation(locationid, accordionDiv, self.lang, self.langData, self.map, self.forcing);
self.cardMap[locationid].show();
var periodid = 'osperiodCard';
self.cardMap[periodid] = new OSPeriod(periodid, accordionDiv, self.lang, self.map);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment