var revAggID = 0 var sessTime = Date.now() var layersList = [] var layersList2 = [] //layer per mappa secondaria var layersOverview = [] var layersOverview2 = [] var RealGlobMaxZoom = 20 var startcenter = undefined var startzoom = undefined var dircom = undefined; var campiPHP = []; function grigio(context) { var canvas = context.canvas; var width = canvas.width; var height = canvas.height; var inputData = context.getImageData(0, 0, width, height).data; var output = context.createImageData(width, height); var outputData = output.data; for (var pixelY = 0; pixelY < height; ++pixelY) { var pixelsAbove = pixelY * width; for (var pixelX = 0; pixelX < width; ++pixelX) { var r = 0, g = 0, b = 0, a = 0; var inputIndex = (pixelY * width + pixelX) * 4; r = inputData[inputIndex] ; g = inputData[inputIndex + 1] ; b = inputData[inputIndex + 2] ; a = inputData[inputIndex + 3] ; var outputIndex = (pixelsAbove + pixelX) * 4; var gr = 0.2989 * r + 0.587 * g + 0.114 * b //calcolo grigio outputData[outputIndex] = gr; outputData[outputIndex + 1] = gr; outputData[outputIndex + 2] = gr; outputData[outputIndex + 3] = a; } } context.putImageData(output, 0, 0); } function creaLayerSfondo(titolo,url,attr,maxzoomlev,nome,dominio,gruppo){ if (url==undefined) {url=""} if (titolo.indexOf("WMS")==0) { var sourceParam={ params: { 'TILED': true }, serverType: 'geoserver', attributions: attr, url: url } if (titolo.indexOf("WMSCROSS_")==0) { sourceParam['crossOrigin']='Anonymous'; sourceParam['params']['LAYERS']=titolo.replace("WMSCROSS_",""); } else { sourceParam['params']['LAYERS']=titolo.replace("WMS_",""); } return new ol.layer.Tile({ title: titolo, name: nome, dominio: dominio, gruppo: gruppo, baserif: '', maxzoomlev: maxzoomlev, type: 'base', source: new ol.source.TileWMS(sourceParam) }) } else if (titolo.indexOf("Bing")==0) { return new ol.layer.Tile({ title: titolo, name: nome, //crossOrigin: "Anonymous", dominio: dominio, gruppo: gruppo, baserif: '', maxzoomlev: maxzoomlev, type: 'base', source: new ol.source.BingMaps({ maxZoom: 19, imagerySet: titolo.replace("Bing",""), key: url }) }) } else if (titolo.indexOf("OSM")==0) { return new ol.layer.Tile({ title: titolo, name: nome, //crossOrigin: "Anonymous", dominio: dominio, gruppo: gruppo, baserif: '', maxzoomlev: maxzoomlev, type: 'base', source: new ol.source.OSM() }) } else { nome = nome!=='' ? nome : titolo url=url.indexOf('?')>0 ? url+'&rev'+rev : url+'?rev'+rev return new ol.layer.Tile({ opacity: 1, preload: Infinity, title: titolo, name: nome, //crossOrigin: "Anonymous", dominio: dominio, gruppo: gruppo, baserif: '', maxzoomlev: maxzoomlev, type: 'base', useInterimTilesOnError: true, source: new ol.source.XYZ({ maxZoom: maxzoomlev, url: url, //url: 'immstd.php?imm='+url.replace("?","&"), attributions: attr }) }); } } function creaLayerVettorialeImg(baserif, titolo,file,stile,nome,datoRW){ if (dircom==undefined) { if (file == 'auto') { file = './layers/'+baserif+'/geojson/'+titolo+'.geojson' } else if (file == 'autojs') { file = './layers/'+baserif+'/geojson/'+titolo+'.js' } } else { if (file == 'auto') { file = '../' + dircom + '/layers/'+baserif+'/geojson/'+titolo+'.geojson' } else if (file == 'autojs') { file = '../' + dircom + '/layers/'+baserif+'/geojson/'+titolo+'.js' } } nome = nome!=='' ? nome : titolo if (file.indexOf('{z}')>0) { var tilePixels = new ol.proj.Projection({ code: 'TILE_PIXELS', units: 'tile-pixels' }); var stringaurl=file.split("|") return new ol.layer.VectorTile({ source: new ol.source.VectorTile({ format: new ol.format.MVT({ defaultDataProjection:tilePixels }), tileGrid: ol.tilegrid.createXYZ({maxZoom: 18}), tilePixelRatio: 16, url: stringaurl[0].indexOf('?')>0 ? stringaurl[0] +'&rev'+rev : stringaurl[0] +'?rev'+rev, }), phpgeo: stringaurl[1], preload: Infinity, useInterimTilesOnError: true, renderMode: 'image', title: baserif+titolo, name: nome, ReadWrite: datoRW, baserif: baserif, }) } else { if (file.indexOf('php')>-1) { var settings = { loader: function(extent, resolution, projection) { var url = file.indexOf('?')>0 ? file +'&rev'+rev : file +'?rev'+rev var vectorSource= this var format=new ol.format.GeoJSON() $.ajax(url+"&t="+revAggID+'_'+sessTime,{dataType:'json'}).then(function(response) { var features = format.readFeatures(response, {featureProjection: 'EPSG:3857'}); vectorSource.addFeatures(features); }); } } } else { var settings = { format: new ol.format.GeoJSON(), url: file.indexOf('?')>0 ? file +'&rev'+rev : file +'?rev'+rev, } } return new ol.layer.Image({ source: new ol.source.ImageVector({ source: new ol.source.Vector(settings), style: stile }), title: baserif+titolo, name: nome, ReadWrite: datoRW, baserif: baserif, }); } } function creaLayerVettoriale(baserif, titolo,file,stile,nome,datoRW){ if (dircom==undefined) { if (file == 'auto') { file = './layers/'+baserif+'/geojson/'+titolo+'.geojson' } else if (file == 'autojs') { file = './layers/'+baserif+'/geojson/'+titolo+'.js' } } else { if (file == 'auto') { file = '../' + dircom + '/layers/'+baserif+'/geojson/'+titolo+'.geojson' } else if (file == 'autojs') { file = '../' + dircom + '/layers/'+baserif+'/geojson/'+titolo+'.js' } } nome = nome!=='' ? nome : titolo if (file.indexOf('php')>-1) { var settings = { loader: function(extent, resolution, projection) { var url = file.indexOf('?')>0 ? file +'&rev'+rev : file +'?rev'+rev var vectorSource= this var format=new ol.format.GeoJSON() $.ajax(url+"&t="+revAggID+'_'+sessTime,{dataType:'json'}).then(function(response) { var features = format.readFeatures(response, {featureProjection: 'EPSG:3857'}); vectorSource.addFeatures(features); }); } } } else { var settings = { format: new ol.format.GeoJSON(), url: file.indexOf('?')>0 ? file +'&rev'+rev : file +'?rev'+rev, } } return new ol.layer.Vector({ source: new ol.source.Vector(settings), style: stile, title: baserif+titolo, name: nome, ReadWrite: datoRW, baserif: baserif, }); } function stileTrasp(tipo){ return creaStile('rgba(160,160,160,0)',0,'rgba(160,160,160,0)',0) /*if (tipo=='A') { return creaStile('rgba(160,160,160,0)',1,'rgba(160,160,160,0)',5) } else if (tipo=='L') { return creaStile('rgb(160,160,160)',10,'rgba(160,160,160,0)',5) } else if (tipo=='P') { return creaStile('rgba(160,160,160,0)',10,'rgb(160,160,160)',10) }*/ } function creaStile(ColBordo,SpessBordo,ColFill,RaggioSimb,SpessBordoSimb){ if (typeof(ColBordo) == "function") { return ColBordo; } SpessBordoSimb = SpessBordoSimb==undefined ? SpessBordo : SpessBordoSimb RaggioSimb = RaggioSimb==undefined ? 5 : RaggioSimb return new ol.style.Style({ fill: new ol.style.Fill({ color: ColFill }), stroke: new ol.style.Stroke({ color: ColBordo, width: SpessBordo }), image: new ol.style.Circle({ radius: RaggioSimb, stroke: new ol.style.Stroke({ color: ColBordo, width: SpessBordoSimb }), fill: new ol.style.Fill({ color: ColFill }) }) }) } var StileInvisibile=creaStile('rgba(255,255,255,0.1)',5,'rgba(255,255,255,0)',10) if(rev==undefined) {var rev=0} //CICLI CARICAMENTO LISTA LAYER function caricaLayer(lista,overview) { //Prima carica layer ricercabili non visibili if (!overview) { for (var i=0;i