var glSosOffering = ''; var glSosName = ''; var glSosDataStore = null; var glSosLayer = null; var glSosUrl = ''; var glSosOfferings = null; var glSosMarkers = null; var glSosSelectedFeature = null; var glStatusDlg = null; var dlgWidth = 0; var dlgHeight = 0; function CreateStatusDialog(caption, msg) { CloseStatusDialog(); glStatusDlg = Ext.MessageBox.wait(msg, caption); } function CloseStatusDialog() { if (glStatusDlg) { glStatusDlg.hide(); glStatusDlg = null; } } function sosSaveLoaded(ret) { var q = Ext.DomQuery; CloseStatusDialog(); var values = q.selectValue('swe_values', ret.responseXML, ''); if (values == '') return; var conn = new Ext.data.Connection( { timeout : 120000 } ); conn.request({ url: 'savecsv.asp', method: 'POST', params: { text: values }, success: function(a, b, c) { var frame = frames['hidden-download-frame']; if (frame == null) frame = parent.frames['hidden-download-frame']; if (frame == null) frame = parent.parent.frames['hidden-download-frame']; if (frame == null) window.open('downloadcsv.asp?name=data.csv&file=' + 'temp/data.csv'); else frame.location = 'downloadcsv.asp?name=data.csv&file=' + 'temp/data.csv'; }, failure: function() { CloseStatusDialog(); alert('get features failed'); } }); } function sosPlotLoaded(ret) { var q = Ext.DomQuery; CloseStatusDialog(); var values = q.selectValue('swe_values', ret.responseXML, ''); if (values == '') return; var data = new google.visualization.DataTable(); data.addColumn('string', 'Date'); data.addColumn('number', glSosOffering); arvals = new Array(); var readings = values.split(';'); for (var i=0; i \n'; xml += '\n'; xml += '\n'; xml += 'urn:ogc:data:time:iso8601\n'; xml += '\n'; xml += ''+startdate+'\n'; xml += ''+enddate+'\n'; xml += '\n'; xml += '\n'; xml += '\n'; xml += ''+property+'\n'; xml += ' '+featureid+' \n'; xml += 'text/xml;subtype="om/1.0.0"\n'; xml += '\n'; CreateStatusDialog("SAEON - SOS", "Loading Section: GetObservations"); var conn = new Ext.data.Connection( { timeout : 120000 } ); conn.request({ url: 'tear_ns.asp?URL=' + escape(url), method: 'POST', success: sosSaveLoaded, params: xml, failure: function() { CloseStatusDialog(); alert('get features failed'); } }); } function doSosPlot(url, featureid, offering, property, startdate, enddate) { if (url.indexOf('?') == -1) url += '?'; glSosOffering = offering; var plotDlgWidth = Math.min(700-20, dlgWidth - 20); var plotDlgHeight = Math.min(420-20, dlgHeight - 20); // create window var infoDlg = new Ext.Window({ width: plotDlgWidth, height: plotDlgHeight, closable: true, modal: true, title: 'Plot', layout: 'fit', html: '
chart
', buttons: [ { text: 'OK', minWidth: 75, handler: function() { infoDlg.close(); } } ] }); // show window infoDlg.show(); var xml = ' \n'; xml += ''+offering+' \n'; xml += '\n'; xml += '\n'; xml += 'urn:ogc:data:time:iso8601\n'; xml += '\n'; xml += ''+startdate+'\n'; xml += ''+enddate+'\n'; xml += '\n'; xml += '\n'; xml += '\n'; xml += ''+property+'\n'; xml += ' '+featureid+' \n'; xml += 'text/xml;subtype="om/1.0.0"\n'; xml += '\n'; CreateStatusDialog("SAEON - SOS", "Loading Section: GetObservations"); var conn = new Ext.data.Connection( { timeout : 120000 } ); conn.request({ url: 'tear_ns.asp?URL=' + escape(url), method: 'POST', success: sosPlotLoaded, params: xml, failure: function() { CloseStatusDialog(); alert('get features failed'); } }); } function setSosFieldValue(ret) { var q = Ext.DomQuery; var code = q.selectValue('swe_uom/@code', ret.responseXML, ''); var values = q.selectValue('swe_values', ret.responseXML, ''); if (values == '') return; var vals = values.split(','); var time = vals[0]; var feid = vals[1]; var value = vals[2]; var value = value.replace(';', ''); var fields = q.select('swe_component', ret.responseXML); for (var x=0; x\n'; xml += ' \n'; xml += ' \n'; xml += ' urn:ogc:data:time:iso8601 \n'; xml += ' \n'; xml += ' latest \n'; xml += ' \n'; xml += ' \n'; xml += ' \n'; xml += ' ' + offering.props[0] + ' \n'; xml += ' \n'; xml += ' ' + id + '\n'; xml += ' \n'; xml += ' text/xml;subtype="om/1.0.0"\n'; xml += '\n'; CreateStatusDialog("SAEON - SOS", "Loading Section: GetObservation"); var conn = new Ext.data.Connection( { timeout : 120000 } ); conn.request({ url: 'tear_ns.asp?URL=' + escape(glSosUrl), method: 'POST', success: setSosFieldValue, failure: function() { CloseStatusDialog(); alert('Failed to load observations'); }, params: xml }); } } } glSosDataStore = new Ext.data.ArrayStore({ fields: ['id', 'item', 'value', 'selected', 'prevsel'], data: data, listeners: { update: OnGridEdit } }); function OnGridEdit(store, rec) { if (rec.get('prevsel') != rec.get('selected')) { rec.set('prevsel', rec.get('selected')); rec.commit(); } } var sossm = new Ext.grid.RowSelectionModel( { singleSelect:true } ); sossm.addListener('selectionchange', onSosSelChange); function onSosSelChange() { var grid = Ext.getCmp('sosvalgrid'); var sm = grid.selModel; var rec = sm.getSelected(); if (rec && parseInt(rec.get('id')) != -1) { Ext.getCmp('plot-btn').enable(); Ext.getCmp('plot-csv').enable(); } else { Ext.getCmp('plot-btn').disable(); Ext.getCmp('plot-csv').disable(); } } function doPlotButton() { var grid = Ext.getCmp('sosvalgrid'); var sm = grid.selModel; var rec = sm.getSelected(); for (var i=0; i 5) { srs = pov[4] + ':' + pov[5]; prj = new OpenLayers.Projection(srs);//"EPSG:900913") } var pp = pos.split(' '); var lat = parseFloat(pp[0]); var lon = parseFloat(pp[1]); var lonLatMarker = new OpenLayers.LonLat(lon, lat); if (prj) lonLatMarker = lonLatMarker.transform(prj, map.getProjectionObject()); if (map.displayProjection) lonLatMarker = lonLatMarker.transform(map.displayProjection, map.projection); } else { var feature = q.select('om_featureOfInterest', root); if (feature.length > 0) { id = feature[0].attributes[0].value; var coords = q.selectValue('gml_coordinates', root); var pp = coords.split(','); var lat = parseFloat(pp[1]); var lon = parseFloat(pp[0]); var lonLatMarker = new OpenLayers.LonLat(lon, lat); if (map.displayProjection) lonLatMarker = lonLatMarker.transform(map.displayProjection, map.projection); } // get next feature var xml = '\n'; var featureID = '' + arFeaturers[++featureIndex]; xml += '' + featureID + '\n' xml += '\n'; CreateStatusDialog("SAEON - SOS", "Loading Section: GetFeatureOfInterest"); var conn = new Ext.data.Connection( { timeout : 120000 } ); conn.request({ url: 'tear_ns.asp?URL=' + escape(glSosUrl), method: 'POST', success: getFeaturesDone, params: xml, failure: function() { CloseStatusDialog(); alert('get features failed'); } }); } var html = ''; html += '' html += '' var offeringCount = 1; for (var i=0; i' offeringCount++; } } } html += '
id:' + id + '
name:' + name + '
loading data...
'; if (offeringCount > 0) { var feature = new OpenLayers.Feature(glSosLayer, lonLatMarker); feature.closeBox = true; feature.popupClass = OpenLayers.Class(OpenLayers.Popup.AnchoredBubble, {minSize: new OpenLayers.Size(400, 150) } ); feature.data.popupContentHTML = html; feature.data.overflow = "auto"; feature.id = id; feature.name = name; var size = new OpenLayers.Size(21,25); var offset = new OpenLayers.Pixel(-(size.w/2), -size.h); var icon = new OpenLayers.Icon('http://www.openlayers.org/dev/img/marker.png',size, offset); var marker = new OpenLayers.Marker(lonLatMarker, icon); marker.feature = feature; this.marker = marker; var markerClick = function(evt, a, b, c, d) { var f = this.feature; showSosInfo(f.id, f.name); OpenLayers.Event.stop(evt); }; markerClick.marker = marker; marker.events.register("mousedown", marker, markerClick); glSosLayer.addMarker(marker); } } function getFeaturesDone(ret) { var q = Ext.DomQuery; var members = q.select('gml_featureMember', ret.responseXML); var members_found = false; for (var m=0; m\n' } xml += '\n'; // get features CreateStatusDialog("SAEON - SOS", "Loading Section: GetFeatureOfInterest"); var conn = new Ext.data.Connection( { timeout : 120000 } ); conn.request({ url: 'tear_ns.asp?URL=' + escape(glSosUrl), method: 'POST', success: getFeaturesDone, params: xml, failure: function() { CloseStatusDialog(); alert('get features failed'); } }); } function addSosGetCaps(ret) { glSosOfferings = new Array(); var xml = ret.responseXML; var q = Ext.DomQuery; var list = q.select('sos_ObservationOffering', xml); for (var i=0; i