/*
* Interactive METEOSAT
* Copyright(c) 2010-2011, Advanced Studies & Research Center
* Author: Vasile Crăciunescu
* vasile.craciunescu@asrc.ro
*
*/
var mapPanel;
var map;
var westPanel;
var infoContainer;
var ir108;
var ir016;
var vis08;
var vis06;
var rgb;
var wv062;
var observatii;
function initializare() {
Ext.QuickTips.init();
//vars
var navigationHistoryControl = new OpenLayers.Control.NavigationHistory();
var loadingpanel = new OpenLayers.Control.LoadingPanel();
var controlZoomBox = new OpenLayers.Control.ZoomBox({CLASS_NAME:'zoomIn'});
var navigation = new OpenLayers.Control.Navigation();
Proj4js.defs["SR-ORG:81"] = "+proj=geos +lon_0=0 +h=35785831 +x_0=0 +y_0=0 +ellps=WGS84 +units=m +no_defs";
var options = {
projection: new OpenLayers.Projection("SR-ORG:81"),
displayProjection: new OpenLayers.Projection("SR-ORG:81"),
units: "m",
//maxResolution: 81331.63057952023519,
//minResolution: 1270.80672780500367,
//resolutions: [1270.80672780500367, 2541.61345561000735, 5083.22691122001470, 10166.45382244002940],
//serverResolutions: [1270.80672780500367, 2541.61345561000735, 5083.22691122001470, 10166.45382244002940, 20332.90764488005880, 40665.81528976011759, 81331.63057952023519],
//numZoomLevels: 3,
maxExtent: new OpenLayers.Bounds(-5434177.816, -5416211.289, 5433761.320, 5416145.259),
controls:
[
new OpenLayers.Control.PanZoomBar(),
new OpenLayers.Control.KeyboardDefaults(),
new OpenLayers.Control.Attribution(),
controlZoomBox,
navigation,
navigationHistoryControl
]
};
map = new OpenLayers.Map('map', options);
map.addControl(loadingpanel);
var zoom = 4;
var lat = 50.5;
var lon = 8;
//layers definition
var naturalearth = new OpenLayers.Layer.TMS(
"Terreno",
"data/base/naturalearth/",
{
type: 'png',
iconCls: "dem_icon",
//zoomOffset: 3,
resolutions: [1270.80672780500367, 2541.61345561000735, 5083.22691122001470, 10166.45382244002940, 20332.90764488005880, 40665.81528976011759, 81331.63057952023519],
serverResolutions: [1270.80672780500367, 2541.61345561000735, 5083.22691122001470, 10166.45382244002940, 20332.90764488005880, 40665.81528976011759, 81331.63057952023519],
getURL: overlay_getTileURL
}
);
var bluemarble = new OpenLayers.Layer.TMS(
"Satellite",
"data/base/bluemarble/",
{
type: 'png',
iconCls: "satellite_icon",
//zoomOffset: 3,
resolutions: [1270.80672780500367, 2541.61345561000735, 5083.22691122001470, 10166.45382244002940, 20332.90764488005880, 40665.81528976011759, 81331.63057952023519],
serverResolutions: [1270.80672780500367, 2541.61345561000735, 5083.22691122001470, 10166.45382244002940, 20332.90764488005880, 40665.81528976011759, 81331.63057952023519],
getURL: overlay_getTileURL
}
);
var blank = new OpenLayers.Layer.Image(
'Nessuno',
'images/blank_background.jpg',
new OpenLayers.Bounds(-5434177.816, -5416211.289, 5433761.320, 5416145.259),
new OpenLayers.Size(800, 800),
{
isBaseLayer: true,
resolutions: [1270.80672780500367, 2541.61345561000735, 5083.22691122001470, 10166.45382244002940, 20332.90764488005880, 40665.81528976011759, 81331.63057952023519],
iconCls: "blank_icon"
}
);
var contur = new OpenLayers.Layer.TileCache(
"Confini e città",
"data/base/",
"contur",
{
iconCls: "overlay_icon",
resolutions: [1270.80672780500367, 2541.61345561000735, 5083.22691122001470, 10166.45382244002940, 20332.90764488005880, 40665.81528976011759, 81331.63057952023519],
serverResolutions: [1270.80672780500367, 2541.61345561000735, 5083.22691122001470, 10166.45382244002940, 20332.90764488005880, 40665.81528976011759, 81331.63057952023519],
isBaseLayer: false
}
);
ir016 = new OpenLayers.Layer.Image(
'NIR 1.6 (2024-04-26 09:00)', 'data/meteosat/geos/ir016_geos.jpg',
new OpenLayers.Bounds(-2252883, 3098669, 4523450, 5442887),
new OpenLayers.Size(1095, 379),
{
resolutions: [2541.6134556100073, 5083.226911220015, 10166.45382244003, 1270.8067278050037],
isBaseLayer: false,
qtip: "Canale spettrale dell\'infrarosso vicino 1.6 μm, banda 3",
iconCls: "grayscale_icon",
attribution: 'EUMETSAT'
}
);
vis08 = new OpenLayers.Layer.Image(
'VIS 0.8 (2024-04-26 09:00)', 'data/meteosat/geos/vis08_geos.jpg',
new OpenLayers.Bounds(-2252883, 3098669, 4523450, 5442887),
new OpenLayers.Size(1095, 379),
{
resolutions: [2541.6134556100073, 5083.226911220015, 10166.45382244003, 1270.8067278050037],
isBaseLayer: false,
qtip: "Canale visibile 0.8 μm, banda 2",
iconCls: "grayscale_icon",
attribution: 'EUMETSAT'
}
);
rgb = new OpenLayers.Layer.Image(
'RBG (2019-11-30 00:00)', 'data/meteosat/geos/rgb_geos.jpg',
new OpenLayers.Bounds(-2252883, 3098669, 4523450, 5442887),
new OpenLayers.Size(2259, 781),
{
resolutions: [2541.6134556100073, 5083.226911220015, 10166.45382244003, 1270.8067278050037],
isBaseLayer: false,
qtip: "Colore naturale RVB: Rosso = NIR 1.6, Verde = VIS 0.8, Blu = VIS 0.6",
iconCls: "rgb_icon",
attribution: 'EUMETSAT'
}
);
ir108 = new OpenLayers.Layer.Image(
'IR 10.8 (2019-11-30 00:00)', 'data/meteosat/geos/ir108_geos.png',
new OpenLayers.Bounds(-2252883, 3098669, 4523450, 5442887),
new OpenLayers.Size(1095, 379),
{
resolutions: [2541.6134556100073, 5083.226911220015, 10166.45382244003, 1270.8067278050037],
isBaseLayer: false,
qtip: "Canale spettrale dell\'infrarosso 10.8 μm",
iconCls: "grayscale_icon",
attribution: 'EUMETSAT'
}
);
vis06 = new OpenLayers.Layer.Image(
'VIS 0.6 (2019-11-30 00:00)', 'data/meteosat/geos/vis06_geos.png',
new OpenLayers.Bounds(-2252883, 3098669, 4523450, 5442887),
new OpenLayers.Size(1095, 379),
{
resolutions: [2541.6134556100073, 5083.226911220015, 10166.45382244003, 1270.8067278050037],
isBaseLayer: false,
qtip: "Canale visibile 0.6 μm, banda 1",
iconCls: "grayscale_icon",
attribution: 'EUMETSAT'
}
);
wv062 = new OpenLayers.Layer.Image(
'WV 6.2 (2019-11-30 00:00)', 'data/meteosat/geos/wv062_geos.png',
new OpenLayers.Bounds(-2252883, 3098669, 4523450, 5442887),
new OpenLayers.Size(1095, 379),
{
resolutions: [2541.6134556100073, 5083.226911220015, 10166.45382244003, 1270.8067278050037],
isBaseLayer: false,
qtip: "Canale del vapore acqueo 6.2 μm",
iconCls: "grayscale_icon",
attribution: 'EUMETSAT'
}
);
ir108.setOpacity(0.75);
vis06.setOpacity(0.75);
wv062.setOpacity(0.75);
rgb.setOpacity(0.75);
ir016.setOpacity(0.75);
vis08.setOpacity(0.75);
var logo_asrc = new OpenLayers.Layer.Vector('ASRC', {
'attribution': ''
});
map.addLayers([logo_asrc, contur, rgb, ir108, wv062, ir016, vis08, vis06, naturalearth, bluemarble, blank]);
var lonLat = new OpenLayers.LonLat(lon, lat).transform(new OpenLayers.Projection("EPSG:4326"), new OpenLayers.Projection("EPSG:900913"));
map.setCenter (lonLat, zoom);
vis06.setVisibility(false);
wv062.setVisibility(false);
ir108.setVisibility(false);
ir016.setVisibility(false);
vis08.setVisibility(false);
blank.setVisibility(false);
bluemarble.setVisibility(false);
naturalearth.setVisibility(true);
var today = new Date();
addGlobeMin('');
addGlobeMax('');
addGlobeMean('');
addObsYahoo('');
addObs('');
//addCapitals();
// Tools panel
var tools = new Ext.Toolbar({
items: [new GeoExt.Action({
control: new OpenLayers.Control.ZoomIn(),
map: map,
iconCls: 'tool_zoom_in',
tooltip: 'Zoom avanti'
}), new GeoExt.Action({
control: new OpenLayers.Control.ZoomOut(),
map: map,
iconCls: 'tool_zoom_out',
tooltip: 'Zoom indietro'
}), new GeoExt.Action({
cls: "execute",
handler: function() {
//map.zoomToExtent(new OpenLayers.Bounds(-2138195.1124842, 2860659.3211315, 3646517.1124842, 6139340.6788685));
var lonLat = new OpenLayers.LonLat(754161, 4500000);
map.setCenter (lonLat, 4);
},
map: map,
iconCls: 'tool_zoom_all',
tooltip: 'Zoom indietro max'
}), new GeoExt.Action({
control: new OpenLayers.Control.ZoomBox(),
map: map,
iconCls: 'tool_zoom_box',
tooltip: 'Zoom box',
enableToggle: true,
toggleGroup: "zoom_pan_toggle",
allowDepress: true,
toggleHandler: function (a, b) {
if (b) {
controlZoomBox.activate();
navigation.deactivate()
} else {
controlZoomBox.deactivate();
navigation.activate()
}
}
}), new GeoExt.Action({
iconCls: 'tool_zoom_previous',
tooltip: 'Zoom precedente',
control: navigationHistoryControl.previous
}), new GeoExt.Action({
iconCls: 'tool_zoom_next',
tooltip: 'Zoom successivo',
control: navigationHistoryControl.next
}), new GeoExt.Action({
control: new OpenLayers.Control.SelectFeature([imObs, imObsYahoo, globeMinObs, globeMaxObs, globeMeanObs], {onSelect: onFeatureSelect, onUnselect: onFeatureUnselect}),
map: map,
iconCls: 'tool_pan',
tooltip: 'Pan mappa',
enableToggle: true,
toggleGroup: "zoom_pan_toggle",
pressed: true,
allowDepress: false
}),
'-',
{
iconCls: 'tool_map_view',
tooltip: 'Passa a Vista Mappa',
text: 'Passa a Vista Mappa',
cls: "execute",
handler: function() {
window.location = 'map_view.php?lang=it';
}
},
{
xtype: 'tbfill'
},
{
xtype: 'datefield',
name: 'archiveDate',
id: 'archiveDate',
minValue:'2010-07-14',
format: 'Y-m-d',
maxValue: today,
emptyText: 'seleziona data',
listeners: {
select: function(frm){
dataSelectata = frm.getValue();
data = dataSelectata.format('Y-m-d');
data2 = dataSelectata.format('d/m/y');
dataCurenta = new Date();
var zi = dataCurenta.getDate();
if (zi < 10)
zi = '0' + zi;
var luna = dataCurenta.getMonth();
luna++;
if (luna < 10)
luna = '0' + luna;
var an = dataCurenta.getFullYear();
dataCurenta = an + "-" + luna + "-" + zi;
var obsDate = dataSelectata.format('Y-m-d');
if (dataCurenta != data)
{
ir108.setUrl('data/meteosat/geos/' + data + '/ir108_geos.jpg');
vis06.setUrl('data/meteosat/geos/' + data + '/vis06_geos.jpg');
wv062.setUrl('data/meteosat/geos/' + data + '/wv062_geos.jpg');
rgb.setUrl('data/meteosat/geos/' + data + '/rgb_geos.jpg');
ir016.setUrl('data/meteosat/geos/' + data + '/ir016_geos.jpg');
vis08.setUrl('data/meteosat/geos/' + data + '/vis08_geos.jpg');
ir108.setName('IR 10.8 ('+ data + ' 09:00)');
vis06.setName('VIS 0.6 ('+ data + ' 09:00)');
wv062.setName('WV 6.2 ('+ data + ' 09:00)');
rgb.setName('RBG ('+ data + ' 09:00)');
ir016.setName('NIR 1.6 ('+ data + ' 09:00)');
vis08.setName('VIS 0.8 ('+ data + ' 09:00)');
globeMinObs.setUrl("get-globe-geojson.php?tempType=min&coordType=geos&date=" + obsDate);
globeMinObs.setName("Temperatura minima GLOBE (" + obsDate + ")");
globeMaxObs.setUrl("get-globe-geojson.php?tempType=max&coordType=geos&date=" + obsDate);
globeMaxObs.setName("Temperatura massima GLOBE (" + obsDate + ")");
globeMeanObs.setUrl("get-globe-geojson.php?tempType=mean&coordType=geos&date=" + obsDate);
globeMeanObs.setName("Temperatura media GLOBE (" + obsDate + ")");
}
else
{
ir108.setUrl('data/meteosat/geos/ir108_geos.png');
vis06.setUrl('data/meteosat/geos/vis06_geos.png');
wv062.setUrl('data/meteosat/geos/wv062_geos.png');
rgb.setUrl('data/meteosat/geos/rgb_geos.jpg');
ir016.setUrl('data/meteosat/geos/ir016_geos.jpg');
vis08.setUrl('data/meteosat/geos/vis08_geos.jpg');
ir108.setName('NIR 10.8 (2019-11-30 00:00)'); vis06.setName('VIS 0.6 (2019-11-30 00:00)'); wv062.setName('WV 6.2 (2019-11-30 00:00)'); rgb.setName('RBG (2019-11-30 00:00)'); ir016.setName('NIR 1.6 (2024-04-26 09:00)'); vis08.setName('VIS 0.8 (2024-04-26 09:00)'); globeMinObs.setUrl("get-globe-geojson.php?tempType=min&coordType=wgs84&date=" + obsDate);
globeMinObs.setName("Temperatura minima GLOBE (ieri)");
globeMaxObs.setUrl("get-globe-geojson.php?tempType=max&coordType=wgs84&date=" + obsDate);
globeMaxObs.setName("Temperatura massima GLOBE (ieri)");
globeMeanObs.setUrl("get-globe-geojson.php?tempType=mean&coordType=wgs84&date=" + obsDate);
globeMeanObs.setName("Temperatura media GLOBE (ieri)");
}
imObs.setUrl("get-geojson.php?lang=it&layerType=im&coordType=geos&date=" + obsDate)
imObs.setName("Osservazioni meteorologiche (" + obsDate + ")");
imObsYahoo.setUrl("get-geojson.php?lang=it&layerType=yahoo&coordType=geos&date=" + obsDate)
imObsYahoo.setName("Yahoo! Meteo (" + obsDate + " 09:00 AM)");
loadObservations(obsDate);
infoPanelText = '
Fare clic sui simboli (mappa o tabella sotto) per ottenere informazioni più dettagliate sulle osservazioni meteorologiche.
';
infoPanelText += '
';
i = 0;
observatii.on('load',function(msg) {
observatii.each(function(msg){
if(i % 2 == 0)
backgroundColor = '#eff3fa';
else
backgroundColor = '#f1f5ec';
infoPanelText += '';
infoPanelText += 'Scuola: ' + msg.get("schoolname") + ' Data: ' + msg.get("date") + ' Ora: ' + msg.get("time") + '
| ';
infoPanelText += ' | ';
infoPanelText += '
';
i++;
});
infoPanelText += '
';
infoPanelText += '
';
infoContainer.body.update(infoPanelText);
})
}}
}]
});
Ext.override(Ext.DatePicker, {
todayText : 'Oggi',
okText : 'Ok',
cancelText : 'Annulla',
todayTip : '{0} (Spacebar)',
minText : 'Questa data è precedente alla data minima',
maxText : 'Questa data è successiva alla data massima',
nextText : 'Mese successivo (Control+destra)',
prevText : 'Mese precedente (Control+sinistra)',
monthYearText : 'Scegli un mese (Control+su/giù per spostarsi tra gli anni)',
monthNames : ['Gennaio', 'Febbraio', 'Marzo', 'Aprile', 'Maggio', 'Giugno ', 'Luglio', 'Agosto', 'Settembre', 'Ottobre', 'Novembre', 'Dicembre'],
dayNames: ['L', 'M', 'M', 'G', 'V', 'S', 'D']
});
//slider
var slider = new GeoExt.LayerOpacitySlider({
width: 165,
decimalPrecision: 1,
increment: 10,
value: 50,
disabled: true,
layer: null,
plugins: new GeoExt.LayerOpacitySliderTip({template: 'Trasparenza: {opacity}%
'}),
listeners: {
change: function (a, b) {
this.layer.setOpacity(b / 100)
}
}
});
//slider adjustment
var sliderAdjust = function (b) {
if (!b.hasListener("radiochange")) {
b.on("radiochange", function (a) {
slider.layer = a.layer;
slider.setValue(a.layer.opacity * 100);
slider.enable()
})
}
};
//mapPanel
mapPanel = new GeoExt.MapPanel({
border: true,
tbar: tools,
region: "center",
map: map,
zoom: 4,
center: [754161, 4500000]
//extent: [-2137442.3517629, 2860659.3211315, 3647269.8732054, 6139340.6788685]
});
var LayerNodeUI = Ext.extend(
GeoExt.tree.LayerNodeUI, new GeoExt.tree.TreeNodeUIEventMixin()
);
var layerList = new GeoExt.tree.LayerContainer({
text: 'Eumetsat',
layerStore: mapPanel.layers,
leaf: false,
expanded: true,
loader: {
filter: function(record) {
return record.get("layer").name.indexOf("Eumetsat") !== -1
}
}
});
var treeConfig = [{
nodeType: "gx_overlaylayercontainer",
text: "Osservazioni",
isLeaf: false,
loader: {
baseAttrs: {
},
filter: function(record) {
var layer = record.get("layer");
this.baseAttrs.iconCls = layer.iconCls;
return (layer.name == "Osservazioni meteorologiche (oggi)" || layer.name == "Yahoo! Meteo (oggi 09:00 AM)" || layer.name == "5 capitals" || layer.name == "Temperatura minima GLOBE (ieri)" || layer.name == "Temperatura massima GLOBE (ieri)" || layer.name == "Temperatura media GLOBE (ieri)")
}
},
expanded: true
},{
nodeType: "gx_overlaylayercontainer",
text: "METEOSAT",
isLeaf: false,
loader: {
baseAttrs: {
radioGroup: "foo",
uiProvider: "use_radio"
},
filter: function(record) {
var layer = record.get("layer");
this.baseAttrs.qtip = layer.qtip;
this.baseAttrs.iconCls = layer.iconCls;
return (layer.name.indexOf("VIS 0.6") !== -1 || layer.name.indexOf("WV") !== -1 || layer.name.indexOf("IR 10.8") !== -1 || layer.name.indexOf("RBG") !== -1 || layer.name.indexOf("NIR 1.6") !== -1 || layer.name.indexOf("VIS 0.8") !== -1)
}
},
expanded: true
},{
nodeType: "gx_overlaylayercontainer",
text: "Overlay",
isLeaf: false,
loader: {
baseAttrs: {
},
filter: function(record) {
var layer = record.get("layer");
this.baseAttrs.qtip = layer.qtip;
this.baseAttrs.iconCls = layer.iconCls;
return (layer.name == "Confini e città")
}
},
expanded: true
},{
nodeType: "gx_baselayercontainer",
text: "Mappe base",
loader: {
baseAttrs: {
},
filter: function(record) {
var layer = record.get("layer");
this.baseAttrs.iconCls = layer.iconCls;
return (layer.name == "Terreno" || layer.name == "Satellite" || layer.name == "Nessuno")
}
},
expanded: true
}];
//tree panel
var tree = new Ext.tree.TreePanel({
plugins: [new GeoExt.plugins.TreeNodeRadioButton({
listeners: {
"radiochange": function(node) {
slider.layer = node.layer;
slider.setValue(node.layer.opacity * 100);
slider.enable()
}
}
})],
width: 298,
loader: new Ext.tree.TreeLoader({
applyLoader: false,
uiProviders: {
"use_radio": LayerNodeUI
}
}),
root: {
nodeType: "async",
children: treeConfig
},
rootVisible: false,
lines: false
});
//layer container
var layersContainer = new Ext.Panel({
autoScroll: true,
border: false,
title: "Livelli",
items: [tree]
});
//legend container
var legendContainer = new Ext.Panel({
autoScroll: true,
contentEl: "legend",
border: false,
title: "Legenda"
});
//help container
var helpContainer = new Ext.Panel({
autoScroll: true,
contentEl: "help",
border: false,
title: "Aiuto"
});
//info container
infoContainer = new Ext.Panel({
autoScroll: true,
contentEl: "info",
border: false,
title: "Info"
});
//credits container
creditsContainer = new Ext.Panel({
autoScroll: true,
contentEl: "credits",
border: false,
title: "Fonti"
});
//left panel
westPanel = new Ext.TabPanel({
border: true,
width: 300,
region: 'west',
activeTab: 0,
collapsible: true,
items: [layersContainer, legendContainer, infoContainer, helpContainer, creditsContainer],
bbar: new Ext.Toolbar({
id: 'opacityToolbar',
height: 26,
style: 'padding-left: 15px;',
items: ['Trasparenza livello: ', slider]
})
});
//viewport
new Ext.Viewport({
layout: "fit",
hideBorders: true,
items: {
layout: "border",
deferredRender: false,
items: [mapPanel, westPanel,{
region: 'north',
contentEl: 'header',
margins: '0 0 5 0'
}]
},
listeners : {
afterlayout: function(){
Ext.get('loader').hide();
Ext.get('loading-mask').hide();
}
}
});
naturalearth.events.on({
moveend: function(e) {
if (e.zoomChanged) {
if (map.getZoom() < 3)
map.zoomIn();
}
}
});
bluemarble.events.on({
moveend: function(e) {
if (e.zoomChanged) {
if (map.getZoom() < 3)
map.zoomIn();
}
}
});
blank.events.on({
moveend: function(e) {
if (e.zoomChanged) {
if (map.getZoom() < 3)
map.zoomIn();
}
}
});
loadObservations ('');
activeTab = westPanel.getActiveTab();
westPanel.activate(2);
westPanel.activate(activeTab.id);
infoPanelText = 'Fare clic sui simboli (mappa o tabella sotto) per ottenere informazioni più dettagliate sulle osservazioni meteorologiche.
';
infoPanelText += '
';
i = 0;
observatii.on('load',function(msg) {
msg.each(function(msg){
if(i % 2 == 0)
backgroundColor = '#eff3fa';
else
backgroundColor = '#f1f5ec';
infoPanelText += '';
infoPanelText += 'Scuola: ' + msg.get("schoolname") + ' Data: ' + msg.get("date") + ' Ora: ' + msg.get("time") + '
| ';
infoPanelText += ' | ';
infoPanelText += '
';
i++;
});
infoPanelText += '
';
infoPanelText += '
';
infoContainer.body.update(infoPanelText);
})
};
function addObs(obsDate)
{
//Style
var style = new OpenLayers.Style(
{
graphicWidth: "${symbolWidth}",
graphicHeight: "${symbolHeight}",
graphicXOffset: "${symbolOffsetX}",
graphicYOffset: "${symbolOffsetY}",
externalGraphic: "${imgName}"
}
);
imObs = new OpenLayers.Layer.GML("Osservazioni meteorologiche (oggi)", "get-geojson.php?lang=it&layerType=im&coordType=geos&date=",
{
format: OpenLayers.Format.GeoJSON,
projection: "SR-ORG:81",
iconCls: "im_icon",
styleMap: new OpenLayers.StyleMap(style)
}
);
map.addLayer(imObs);
imObs.setOpacity(1);
return true;
}
function addGlobeMin(obsDate)
{
//Style
var style = new OpenLayers.Style(
{
graphicWidth: 19,
graphicHeight: 45,
graphicYOffset: -23,
externalGraphic: "${iconMin}"
}
);
globeMinObs = new OpenLayers.Layer.GML("Temperatura minima GLOBE (ieri)", "get-globe-geojson.php?tempType=min&coordType=geos&date=" + obsDate,
{
format: OpenLayers.Format.GeoJSON,
projection: new OpenLayers.Projection("EPSG:4326"),
iconCls: "globemin_icon",
styleMap: new OpenLayers.StyleMap(style)
}
);
map.addLayer(globeMinObs);
globeMinObs.setOpacity(1);
globeMinObs.setVisibility(false);
return true;
}
function addGlobeMean(obsDate)
{
//Style
var style = new OpenLayers.Style(
{
graphicWidth: 19,
graphicHeight: 45,
graphicYOffset: -23,
externalGraphic: "${iconMean}"
}
);
globeMeanObs = new OpenLayers.Layer.GML("Temperatura media GLOBE (ieri)", "get-globe-geojson.php?tempType=mean&coordType=geos&date=" + obsDate,
{
format: OpenLayers.Format.GeoJSON,
projection: new OpenLayers.Projection("EPSG:4326"),
iconCls: "globemean_icon",
styleMap: new OpenLayers.StyleMap(style)
}
);
map.addLayer(globeMeanObs);
globeMeanObs.setOpacity(1);
globeMeanObs.setVisibility(false);
return true;
}
function addGlobeMax(obsDate)
{
//Style
var style = new OpenLayers.Style(
{
graphicWidth: 19,
graphicHeight: 45,
graphicYOffset: -23,
externalGraphic: "${iconMax}"
}
);
globeMaxObs = new OpenLayers.Layer.GML("Temperatura massima GLOBE (ieri)", "get-globe-geojson.php?tempType=max&coordType=geos&date=" + obsDate,
{
format: OpenLayers.Format.GeoJSON,
projection: new OpenLayers.Projection("EPSG:4326"),
iconCls: "globemax_icon",
styleMap: new OpenLayers.StyleMap(style)
}
);
map.addLayer(globeMaxObs);
globeMaxObs.setOpacity(1);
globeMaxObs.setVisibility(false);
return true;
}
function addCapitals()
{
//Style
var style = new OpenLayers.Style(
{
graphicWidth: 21,
graphicHeight: 25,
//graphicXOffset: "${symbolOffsetX}",
graphicYOffset: -21,
externalGraphic: "images/marker1.png"
}
);
imCapitals = new OpenLayers.Layer.GML("5 capitals", "get_5capitals_geojson.php",
{
format: OpenLayers.Format.GeoJSON,
projection: "SR-ORG:81",
iconCls: "yahoo_icon",
styleMap: new OpenLayers.StyleMap(style)
}
);
map.addLayer(imCapitals);
return true;
}
function addObsYahoo(obsDate)
{
//Style
var style = new OpenLayers.Style(
{
graphicWidth: "${symbolWidth}",
graphicHeight: "${symbolHeight}",
graphicXOffset: "${symbolOffsetX}",
graphicYOffset: "${symbolOffsetY}",
externalGraphic: "${imgName}"
}
);
imObsYahoo = new OpenLayers.Layer.GML("Yahoo! Meteo (oggi 09:00 AM)", "get-geojson.php?lang=it&layerType=yahoo&coordType=geos&date=",
{
format: OpenLayers.Format.GeoJSON,
projection: new OpenLayers.Projection("SR-ORG:81"),
iconCls: "yahoo_icon",
styleMap: new OpenLayers.StyleMap(style)
}
);
map.addLayer(imObsYahoo);
imObsYahoo.setVisibility(false);
return true;
}
function overlay_getTileURL(bounds) {
var res = this.map.getResolution();
var x = Math.round((bounds.left - this.maxExtent.left) / (res * this.tileSize.w));
var y = Math.round((bounds.bottom - this.maxExtent.bottom) / (res * this.tileSize.h));
var z = this.map.getZoom();
if (x >= 0 && y >= 0) {
return this.url + z + "/" + x + "/" + y + "." + this.type;
} else {
return "images/none.png";
}
}
// select/unselect functions
function onFeatureSelect(feature) {
selectedFeature = feature;
westPanel.activate(2);
if (feature.attributes.lat < 0)
latType = "Sud";
else
latType = "Nord";
if (feature.attributes.lon < 0)
lonType = "Ovest";
else
lonType = "Est";
LatDeg = Math.floor(feature.attributes.lat);
LatMin = Math.floor((feature.attributes.lat-LatDeg)*60);
LatSec = (Math.round((((feature.attributes.lat - LatDeg) - (LatMin/60)) * 60 * 60) * 100) / 100 );
latDMS = LatDeg + 'º ' + LatMin + '\' ' + LatSec + '"';
LonDeg = Math.floor(feature.attributes.lon);
LonMin = Math.floor((feature.attributes.lon-LonDeg)*60);
LonSec = (Math.round((((feature.attributes.lon - LonDeg) - (LonMin/60)) * 60 * 60) * 100) / 100 );
lonDMS = LonDeg + 'º ' + LonMin + '\' ' + LonSec + '"';
if (feature.attributes.layerType == 'globe')
{
var infoPanelText = '';
infoPanelText += '
Dettagli delle rilevazioni GLOBE della temperatura';
if (feature.attributes.tempType == 'min')
infoPanelText += '
';
if (feature.attributes.tempType == 'max')
infoPanelText += '
';
if (feature.attributes.tempType == 'mean')
infoPanelText += '
';
infoPanelText += '
';
infoPanelText += '
Scuola: ' + feature.attributes.schoolName + '
';
infoPanelText += '
Sito: ' + feature.attributes.siteName + '
';
infoPanelText += '
Latitudine: ' + latDMS + ' ' + latType + '
';
infoPanelText += '
Longitudine: ' + lonDMS + ' ' + lonType + '
';
infoPanelText += '
Data: ' + feature.attributes.date + '
';
infoPanelText += '
temperatura minima: ' + feature.attributes.minTemp + 'º C
';
infoPanelText += '
temperatura massima: ' + feature.attributes.maxTemp + 'º C
';
infoPanelText += '
temperatura media: ' + feature.attributes.meanTemp + 'º C
';
infoPanelText += '
';
}
else
{
var infoPanelText = '
';
infoPanelText += '
Dettagli delle osservazioni meteorologiche';
infoPanelText += '
';
infoPanelText += '
';
if (feature.attributes.layerType == 'im')
{
infoPanelText += '
Località: ' + feature.attributes.location + '
';
infoPanelText += '
Paese Utente: ' + feature.attributes.country + '
';
infoPanelText += '
Città Utente: ' + feature.attributes.city + '
';
infoPanelText += '
Scuola: ' + feature.attributes.schoolname + '
';
}
if (feature.attributes.layerType == 'yahoo')
{
infoPanelText += '
Paese: ' + feature.attributes.country + '
';
infoPanelText += '
Città: ' + feature.attributes.city + '
';
infoPanelText += '
Fonte: Yahoo! Meteo
';
}
infoPanelText += '
Latitudine: ' + latDMS + ' ' + latType + '
';
infoPanelText += '
Longitudine: ' + lonDMS + ' ' + lonType + '
';
infoPanelText += '
Altitudine: ' + feature.attributes.elevation + ' m
';
infoPanelText += '
Data: ' + feature.attributes.date + '
';
infoPanelText += '
Ora: ' + feature.attributes.time + '
';
infoPanelText += '
Condizioni attuali: ' + feature.attributes.cc_name_it + '
';
infoPanelText += '
Direzione del vento: ' + feature.attributes.windDirection + 'º
';
if (feature.attributes.windSpeedUnits == 1)
{
windSpeedKnots = feature.attributes.windSpeed;
windSpeedKnots = roundNumber(windSpeedKnots, 1);
windSpeedM = feature.attributes.windSpeed * 0.514444444;
windSpeedM = roundNumber(windSpeedM, 1);
}
else
{
windSpeedKnots = feature.attributes.windSpeed * 1.94384449;
windSpeedKnots = roundNumber(windSpeedKnots, 1);
windSpeedM = feature.attributes.windSpeed;
windSpeedM = roundNumber(windSpeedM, 1);
}
infoPanelText += '
Velocità del vento: ' + windSpeedKnots + ' Nodi / ' + windSpeedM +' m/s
';
infoPanelText += '
Nuvolosità: ' + feature.attributes.ce_name_it + ' (' + feature.attributes.cloudcName +')
';
infoPanelText += '
Temperatura: ' + feature.attributes.temperature + 'º C
';
infoPanelText += '
Altre osservazioni: ' + feature.attributes.additionalObservations + '
';
infoPanelText += '
Foto:
';
if (feature.attributes.photo == 0)
infoPanelText += '
';
else
infoPanelText += '
';
infoPanelText += '
';
i = 0;
observatii.each(function(msg){
if(i % 2 == 0)
backgroundColor = '#eff3fa';
else
backgroundColor = '#f1f5ec';
infoPanelText += '';
infoPanelText += 'Scuola: ' + msg.get("schoolname") + ' Data: ' + msg.get("date") + ' Ora: ' + msg.get("time") + '
| ';
infoPanelText += ' | ';
infoPanelText += '
';
i++;
});
infoPanelText += '
';
infoPanelText += '
';
}
infoContainer.body.update(infoPanelText);
}
function onFeatureUnselect(feature) {
infoPanelText = '
Fare clic sui simboli (mappa o tabella sotto) per ottenere informazioni più dettagliate sulle osservazioni meteorologiche.
';
infoPanelText += '
';
i = 0;
observatii.each(function(msg){
if(i % 2 == 0)
backgroundColor = '#eff3fa';
else
backgroundColor = '#f1f5ec';
infoPanelText += '';
infoPanelText += 'Scuola: ' + msg.get("schoolname") + ' Data: ' + msg.get("date") + ' Ora: ' + msg.get("time") + '
| ';
infoPanelText += ' | ';
infoPanelText += '
';
i++;
});
infoPanelText += '
';
infoPanelText += '
';
infoContainer.body.update(infoPanelText);
}
function loadObservations(date){
observatii = new Ext.data.JsonStore({
url: 'get-json.php?lang=it&date=' + date,
root: 'features',
successProperty: 'success',
id: 'obsId',
fields: [{name: 'windDirection'}, {name: 'cc_name_it'}, {name: 'lat'}, {name: 'lon'}, {name: 'windSpeed'}, {name: 'elevation'}, {name: 'ce_name_it'}, {name: 'cloudcName'}, {name: 'additionalObservations'}, {name: 'temperature'}, {name: 'schoolname'}, {name: 'imgName'}, {name: 'city'}, {name: 'windSpeedUnits'}, {name: 'country'}, {name: 'location'}, {name: 'date'}, {name: 'time'}, {name: 'photo'}, {name: 'obsId'}]
});
observatii.load();
}
function displayObservationDetails(id){
var selectedObservation = observatii.getById(id);
var infoPanelText = '
';
infoPanelText += '
Dettagli delle osservazioni meteorologiche';
infoPanelText += '
';
infoPanelText += '
';
infoPanelText += '
Località: ' + selectedObservation.get("location") + '
';
infoPanelText += '
Paese Utente: ' + selectedObservation.get("country") + '
';
infoPanelText += '
Città Utente: ' + selectedObservation.get("city") + '
';
infoPanelText += '
Scuola: ' + selectedObservation.get("schoolname") + '
';
if (selectedObservation.get("lat") < 0)
latType = "Sud";
else
latType = "Nord";
if (selectedObservation.get("lon") < 0)
lonType = "Ovest";
else
lonType = "Est";
LatDeg = Math.floor(selectedObservation.get("lat"));
LatMin = Math.floor((selectedObservation.get("lat")-LatDeg)*60);
LatSec = (Math.round((((selectedObservation.get("lat") - LatDeg) - (LatMin/60)) * 60 * 60) * 100) / 100 );
latDMS = LatDeg + 'º ' + LatMin + '\' ' + LatSec + '"';
LonDeg = Math.floor(selectedObservation.get("lon"));
LonMin = Math.floor((selectedObservation.get("lon")-LonDeg)*60);
LonSec = (Math.round((((selectedObservation.get("lon") - LonDeg) - (LonMin/60)) * 60 * 60) * 100) / 100 );
lonDMS = LonDeg + 'º ' + LonMin + '\' ' + LonSec + '"';
infoPanelText += '
Latitudine: ' + latDMS + ' ' + latType + '
';
infoPanelText += '
Longitudine: ' + lonDMS + ' ' + lonType + '
';
infoPanelText += '
Altitudine: ' + selectedObservation.get("elevation") + ' m
';
infoPanelText += '
Data: ' + selectedObservation.get("date") + '
';
infoPanelText += '
Ora: ' + selectedObservation.get("time") + '
';
infoPanelText += '
Condizioni attuali: ' + selectedObservation.get("cc_name_it") + '
';
infoPanelText += '
Direzione del vento: ' + selectedObservation.get("windDirection") + 'º
';
if (selectedObservation.get("windSpeedUnits") == 1)
{
windSpeedKnots = selectedObservation.get("windSpeed");
windSpeedKnots = roundNumber(windSpeedKnots, 1);
windSpeedM = selectedObservation.get("windSpeed") * 0.514444444;
windSpeedM = roundNumber(windSpeedM, 1);
}
else
{
windSpeedKnots = selectedObservation.get("windSpeed") * 1.94384449;
windSpeedKnots = roundNumber(windSpeedKnots, 1);
windSpeedM = selectedObservation.get("windSpeed");
windSpeedM = roundNumber(windSpeedM, 1);
}
infoPanelText += '
Velocità del vento: ' + windSpeedKnots + ' Nodi / ' + windSpeedM +' m/s
';
infoPanelText += '
Nuvolosità: ' + selectedObservation.get("ce_name_it") + ' (' + selectedObservation.get("cloudcName") +')
';
infoPanelText += '
Temperatura: ' + selectedObservation.get("temperature") + 'º C
';
infoPanelText += '
Altre osservazioni: ' + selectedObservation.get("additionalObservations") + '
';
infoPanelText += '
Foto:
';
if (selectedObservation.get("photo") == 0)
infoPanelText += '
';
else
infoPanelText += '
';
infoPanelText += '
';
i = 0;
observatii.each(function(msg){
if(i % 2 == 0)
backgroundColor = '#eff3fa';
else
backgroundColor = '#f1f5ec';
infoPanelText += '';
infoPanelText += 'Scuola: ' + msg.get("schoolname") + ' Data: ' + msg.get("date") + ' Ora: ' + msg.get("time") + '
| ';
infoPanelText += ' | ';
infoPanelText += '
';
i++;
});
infoPanelText += '
';
infoPanelText += '
';
infoContainer.body.update(infoPanelText);
activeTab = westPanel.getActiveTab();
activeTab.body.dom.scrollTop = 0;
}
function roundNumber(num, dec) {
var result = Math.round(num*Math.pow(10,dec))/Math.pow(10,dec);
return result;
}
function dump(arr,level) {
var dumped_text = "";
if(!level) level = 0;
//The padding given at the beginning of the line.
var level_padding = "";
for(var j=0;j
\"" + value + "\"\n";
}
}
} else { //Stings/Chars/Numbers etc.
dumped_text = "===>"+arr+"<===("+typeof(arr)+")";
}
return dumped_text;
}