/**
* Author : Gerald Fenoy
*
* Copyright (c) 2015 GeoLabs SARL
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
* This work was supported by a grant from the European Union's 7th Framework Programme (2007-2013)
* provided for the project PublicaMundi (GA no. 609608).
*/
require(['bootstrap', 'notify']);
define([
'module', 'jquery', 'zoo', 'xml2json','ol'
], function(module, $, Zoo, X2JS,ol) {
var zoo = new Zoo({
url: module.config().url,
delay: module.config().delay,
});
var mymodal = $('#myModal');
var mynotify = $('.top-right');
function notify(text, type) {
mynotify.notify({
message: { text: text },
type: type,
}).show();
}
var wm;
var layer;
var basic_counter = 0,
table_counter = 0,
form_counter = 0,
parent_counter = 0,
child_counter = 0;
var initialize = function() {
wm = new WindowManager({
container: "#windowPane",
windowTemplate: $('#basic_window_template').html()
});
window.wm = wm;
$(function(){
$('.sidebar-left .slide-submenu').on('click',function() {
var thisEl = $(this);
thisEl.closest('.sidebar-body').fadeOut('slide',function(){
$('.mini-submenu-left').fadeIn();
applyMargins();
});
});
$('.mini-submenu-left').on('click',function() {
var thisEl = $(this);
$('.sidebar-left .sidebar-body').toggle('slide');
thisEl.hide();
applyMargins();
});
map = new ol.Map({
layers: new ol.Collection(),
target: 'map',
view: new ol.View({
center: [260047.557702813,6051682.54296228],
//extent: [240047.557702813,6234682.54296228,281304.353234602,6267347.78149257],
zoom: 6
})
});
layerLS=new ol.layer.Tile({
source: new ol.source.OSM()
});
map.addLayer(layerLS);
var main_url="http://www.zoo-project.org/cgi-bin/mapserv?map=/var/www/demo.zoo-project.org/htdocs/mapserver/mntfr.map";
var wmsSource=new ol.source.TileWMS({
url: main_url,
ratio: 1,
params: {'LAYERS': 'zoowpsmnt',"VERSION":"1.1.1"},
serverType: 'mapserver'
});
var layer0=new ol.layer.Tile({
source: wmsSource
});
map.addLayer(layer0);
var vector = new ol.layer.Vector({
source: source,
style: new ol.style.Style({
fill: new ol.style.Fill({
color: 'rgba(255, 255, 255, 0.2)'
}),
stroke: new ol.style.Stroke({
color: '#ffcc33',
width: 2
}),
image: new ol.style.Circle({
radius: 7,
fill: new ol.style.Fill({
color: '#ffcc33'
})
})
})
});
map.addLayer(vector);
layer = new ol.layer.Vector({
map: map,
source: new ol.source.Vector({
features: new ol.Collection(),
useSpatialIndex: false // optional, might improve performance
}),
//style: style1,
updateWhileAnimating: true, // optional, for instant visual feedback
updateWhileInteracting: true // optional, for instant visual feedback
});
map.addLayer(layer);
$(window).on("resize", applyMargins);
applyInitialUIState();
applyMargins();
});
}
var draw;
var source = new ol.source.Vector({wrapX: false});
function addInteraction() {
var geometryFunction, maxPoints;
draw = new ol.interaction.Draw({
source: source,
type: /** @type {ol.geom.GeometryType} */ "LineString",
geometryFunction: geometryFunction,
maxPoints: maxPoints
});
draw.on("drawstart",function(e){
clearAll();
});
draw.on("drawend",function(e){
});
source.on("addfeature",function(e){
var format=new ol.format.GeoJSON();
var fobj=format.writeFeaturesObject([source.getFeatures()[0]],
{dataProjection: 'EPSG:4326',
featureProjection: 'EPSG:3857'});
simpleProcessing(JSON.stringify(fobj.features[0].geometry));
});
map.addInteraction(draw);
}
function clearAll(){
if(win){
win.close();
win=null;
}
clearAllFeatures();
}
function clearAllFeatures(){
if(layer.getSource().getFeatures().length>0)
layer.getSource().removeFeature(layer.getSource().getFeatures()[0]);
source.clear();
}
function deactivateDrawTool(){
clearAll();
map.removeInteraction(draw);
}
function activateDrawTool(){
deactivateDrawTool();
addInteraction();
};
var win;
function simpleProcessing(geomString) {
notify('Running GdalExtractProfile service','info');
zoo.execute({
identifier: "raster-tools.GdalExtractProfile",
dataInputs: [{"identifier":"Geometry","value":geomString,"dataType":"string"},
{"identifier":"RasterFile","value":"topofr.tif","dataType":"string"}],
dataOutputs: [{"identifier":"Profile","type":"raw"}],
type: 'POST',
storeExecuteResponse: false,
success: function(data) {
notify('GdalExtractProfile service run successfully','success');
//var reg=new RegExp("[;]", "g");
//var tmp=data.split(reg);
var tmp0=JSON.parse(data);
var tmp=tmp0.coordinates;
var idxs=new Array();
var values= new Array();
points=new Array();
for(var i=0;i