[Mapbender-commits] r8450 - in trunk/mapbender/http: classes javascripts php plugins
svn_mapbender at osgeo.org
svn_mapbender at osgeo.org
Wed Aug 8 08:19:06 PDT 2012
Author: armin11
Date: 2012-08-08 08:19:06 -0700 (Wed, 08 Aug 2012)
New Revision: 8450
Added:
trunk/mapbender/http/javascripts/mb_downloadFeedClient.js
trunk/mapbender/http/plugins/mb_downloadFeedClient.php
trunk/mapbender/http/plugins/mb_downloadFeedServer.php
Modified:
trunk/mapbender/http/classes/class_georss_geometry.php
trunk/mapbender/http/classes/class_gml2.php
trunk/mapbender/http/php/mod_inspireDownloadFeed.php
Log:
Prototype for INSPIRE Download Service client based on ATOM Feeds. Not yet ready - some further work needs to be done.
Modified: trunk/mapbender/http/classes/class_georss_geometry.php
===================================================================
--- trunk/mapbender/http/classes/class_georss_geometry.php 2012-08-06 07:45:08 UTC (rev 8449)
+++ trunk/mapbender/http/classes/class_georss_geometry.php 2012-08-08 15:19:06 UTC (rev 8450)
@@ -61,7 +61,7 @@
$rssDoc->registerXPathNamespace('xls', 'http://www.opengis.net/xls');
$rssDoc->registerXPathNamespace('gml', 'http://www.opengis.net/gml');
$rssDoc->registerXPathNamespace('georss', 'http://www.georss.org/georss');
- #for ingrid - portalu georss
+ //for ingrid - portalu georss
$rssDoc->registerXPathNamespace('ingrid', 'http://www.portalu.de/opensearch/extension/1.0');
// build feature collection
@@ -265,15 +265,19 @@
class geoRSSPolygon extends GMLPolygon{
var $targetEPSG;
- public function parsePolygon ($domNode) {
- $cnt = 0;
- $y = 0;
- foreach(explode(' ',$domNode->nodeValue) as $cord){
- if($cnt % 2)
- $this->addPoint($cord, $y);
- $y = $cord;
- $cnt++;
+ public function parsePolygon ($georssPolygon) {
+ if (gettype == 'object') {
+ //polygon is given as dom node
+ $coordArray = explode(' ',$georssPolygon->nodeValue);
+ } else {
+ //polygon is given as string
+ $coordArray = explode(' ',$georssPolygon);
}
+ $countCoordPairs = count($coordArray) / 2;
+ //in georss lat/lon is given, in geojson lon lat will be used http://www.georss.org/simple http://www.geojson.org/geojson-spec.html#coordinate-reference-system-objects
+ for ($j=0; $j<=($countCoordPairs-1); $j++) {
+ $this->addPoint($coordArray[$j*2 + 1], $coordArray[$j*2]);
+ }
}
}
Modified: trunk/mapbender/http/classes/class_gml2.php
===================================================================
--- trunk/mapbender/http/classes/class_gml2.php 2012-08-06 07:45:08 UTC (rev 8449)
+++ trunk/mapbender/http/classes/class_gml2.php 2012-08-08 15:19:06 UTC (rev 8450)
@@ -771,8 +771,10 @@
}
}
- protected function addPoint ($x, $y) {
+ public function addPoint ($x, $y) {
+ //$e = new mb_exception("add point");
array_push($this->pointArray, array("x" => $x, "y" => $y));
+ //$e = new mb_exception("add point");
}
protected function addPointToRing ($i, $x, $y) {
Added: trunk/mapbender/http/javascripts/mb_downloadFeedClient.js
===================================================================
--- trunk/mapbender/http/javascripts/mb_downloadFeedClient.js (rev 0)
+++ trunk/mapbender/http/javascripts/mb_downloadFeedClient.js 2012-08-08 15:19:06 UTC (rev 8450)
@@ -0,0 +1,317 @@
+var mapframe_dataset_list, mapframe_file_list, datasetSelect, file_list, bboxDataset, bboxFiles, formats;
+
+ function updateFormats() {
+ var in_options = {
+ 'internalProjection': mapframe_dataset_list.baseLayer.projection,
+ 'externalProjection': new OpenLayers.Projection("EPSG:4326")
+ };
+ var out_options = {
+ 'internalProjection': mapframe_dataset_list.baseLayer.projection,
+ 'externalProjection': new OpenLayers.Projection("EPSG:900913")
+ };
+ var gmlOptions = {
+ featureType: "feature",
+ featureNS: "http://example.com/feature"
+ };
+ var gmlOptionsIn = OpenLayers.Util.extend(
+ OpenLayers.Util.extend({}, gmlOptions),
+ in_options
+ );
+ var gmlOptionsOut = OpenLayers.Util.extend(
+ OpenLayers.Util.extend({}, gmlOptions),
+ out_options
+ );
+ var kmlOptionsIn = OpenLayers.Util.extend(
+ {extractStyles: true}, in_options);
+ formats = {
+ 'in': {
+ wkt: new OpenLayers.Format.WKT(in_options),
+ geojson: new OpenLayers.Format.GeoJSON(in_options),
+ georss: new OpenLayers.Format.GeoRSS(in_options),
+ gml2: new OpenLayers.Format.GML.v2(gmlOptionsIn),
+ gml3: new OpenLayers.Format.GML.v3(gmlOptionsIn),
+ kml: new OpenLayers.Format.KML(kmlOptionsIn),
+ atom: new OpenLayers.Format.Atom(in_options),
+ gpx: new OpenLayers.Format.GPX(in_options)
+ },
+ 'out': {
+ wkt: new OpenLayers.Format.WKT(out_options),
+ geojson: new OpenLayers.Format.GeoJSON(out_options),
+ georss: new OpenLayers.Format.GeoRSS(out_options),
+ gml2: new OpenLayers.Format.GML.v2(gmlOptionsOut),
+ gml3: new OpenLayers.Format.GML.v3(gmlOptionsOut),
+ kml: new OpenLayers.Format.KML(out_options),
+ atom: new OpenLayers.Format.Atom(out_options),
+ gpx: new OpenLayers.Format.GPX(out_options)
+ }
+ };
+ }
+
+function init(){
+ //generate 2 Mapframes
+ mapframe_dataset_list = new OpenLayers.Map('mapframe_dataset_list');
+
+ mapframe_file_list = new OpenLayers.Map('mapframe_file_list');
+
+ var wms1 = new OpenLayers.Layer.WMS( "OpenLayers WMS",
+ "http://www.gdi-rp-dienste2.rlp.de/cgi-bin/mapserv.fcgi?map=/data/umn/geoportal/karte_rp/rheinland-pfalz-gesamt2.map&", {layers: 'ATKIS-Praes'}, {singleTile: true});
+ var wms2 = new OpenLayers.Layer.WMS( "OpenLayers WMS",
+ "http://www.gdi-rp-dienste2.rlp.de/cgi-bin/mapserv.fcgi?map=/data/umn/geoportal/karte_rp/rheinland-pfalz-gesamt2.map&", {layers: 'ATKIS-Praes'}, {singleTile: true});
+
+
+
+ bboxDataset = new OpenLayers.Layer.Vector("Dataset bounding boxes");
+
+ bboxFiles = new OpenLayers.Layer.Vector("File bounding boxes");
+
+ mapframe_dataset_list.addLayers([wms1, bboxDataset]);
+
+ mapframe_dataset_list.addControl(new OpenLayers.Control.MousePosition());
+
+ //mapframe_dataset_list.addControl(new OpenLayers.Control.EditingToolbar(bboxDataset));
+
+ mapframe_file_list.addLayers([wms2, bboxFiles]);
+ mapframe_file_list.addControl(new OpenLayers.Control.MousePosition());
+ //mapframe_file_list.addControl(new OpenLayers.Control.EditingToolbar(bboxFiles));
+
+ var options = {
+ hover: true,
+ }
+
+ updateFormats();
+ mapframe_dataset_list.setCenter(new OpenLayers.LonLat(7, 50), 7);
+ mapframe_file_list.setCenter(new OpenLayers.LonLat(7, 50), 7);
+
+ $(document).ready(function(e) {
+ $('#download_feed_button').click(function() {
+ method = "getServiceFeedObjectFromUrl";
+ data = $("#download_feed_url").val();
+ //data = data.serialize();
+ callServer(data,method);
+ });
+ });
+ /*$(document).ready(function(e) {
+ $('#download_feed_button').click(function() {
+ method = "getDatasetFeedObjectFromUrl";
+ data = $("#download_feed_url").val();
+ //data = data.serialize();
+ callServer(data,method);
+ });
+ });*/
+
+}
+
+
+function callServer(data,method) {
+ $.ajax({
+ url: '../plugins/mb_downloadFeedServer.php',
+ type: "post",
+ async: false,
+ data: {url: data, method: method },
+ dataType: "json",
+ success: function(result) {
+ if (method == "getServiceFeedObjectFromUrl") {
+ drawMetadataPolygons(result);
+ showDatasetList(result);
+ //alert(result);
+ }
+ if (method == "getDatasetFeedObjectFromUrl") {
+ //fill dataset feed
+ //alert("got result");
+ showDatasetEntryList(result);
+ //alert(result);
+ }
+
+ }
+ });
+ return false;
+}
+
+function showDatasetEntryList(featureCollection) {
+ if (featureCollection == null) {
+ alert("No parseable content found");
+ return false;
+ }
+ //if (typeof(datasetSelect) !== 'undefined'){
+ $('#dataset_representation_select').remove();
+ //}
+ //delete old entries
+ var datasetEntrySelect = $(document.createElement('select')).appendTo('#dataset_representation_list');
+ datasetEntrySelect.attr({'id':'dataset_representation_select'});
+ var selectROptions = "";
+ for(var i=0; i<featureCollection.features.length; ++i) {
+ selectROptions = selectROptions+"<option value='"+featureCollection.features[i].properties.datasetFeedLink+"' url='"+featureCollection.features[i].properties.datasetFeedLink+"'>"+featureCollection.features[i].properties.title+"</option>";
+
+ //var datasetSelectOption = $(document.createElement('option')).appendTo(datasetSelect);
+ //datasetSelectOption.attr({'value':featureCollection.features[i].id});
+ }
+ datasetEntrySelect.append(selectROptions);
+ fillSectionList(featureCollection, 0)
+ $('#dataset_representation_select').bind('change', function() {
+ //var $this = $(this);
+ //method = "getDatasetLinkFromUrl";
+ //data = $this.val();
+ alert("list changed");
+ //callServer(data,method);
+ });
+
+}
+
+function showDatasetList(featureCollection) {
+ if (featureCollection == null) {
+ alert("No parseable content found");
+ return false;
+ }
+ //if (typeof(datasetSelect) !== 'undefined'){
+ $('#dataset_select').remove();
+ //}
+ //delete old entries
+ var datasetSelect = $(document.createElement('select')).appendTo('#dataset_list');
+ datasetSelect.attr({'id':'dataset_select'});
+ var selectOptions = "";
+ for(var i=0; i<featureCollection.features.length; ++i) {
+ //fill in first title, rights and abstract in fields
+//alert(featureCollection.features[i].properties.title);//$('#dataset_title').value = "";
+ if (i == 0) {
+ $('#dataset_title').val(featureCollection.features[i].properties.title);
+ $('#dataset_rights').val(featureCollection.features[i].properties.rights);
+ //$('#dataset_title').val() = featureCollection.features[i].properties.title;
+ }
+ selectOptions = selectOptions+"<option value='"+featureCollection.features[i].properties.datasetFeedLink+"' url='"+featureCollection.features[i].properties.datasetFeedLink+"'>"+featureCollection.features[i].properties.title+"</option>";
+
+ //var datasetSelectOption = $(document.createElement('option')).appendTo(datasetSelect);
+ //datasetSelectOption.attr({'value':featureCollection.features[i].id});
+ }
+ datasetSelect.append(selectOptions);
+
+ $('#dataset_select').bind('change', function() {
+ var $this = $(this);
+ method = "getDatasetFeedObjectFromUrl";
+ data = $this.val();
+ callServer(data,method);
+ });
+ method = "getDatasetFeedObjectFromUrl";
+ //call second feed with first entry
+ data = featureCollection.features[0].properties.datasetFeedLink;
+ //data = data.serialize();
+ callServer(data,method);
+
+}
+
+
+function fillSectionList(featureCollection, k) {
+ //fill graphic
+ //generate features from link list
+ bboxFiles.removeAllFeatures();
+ $('#section_option').remove();
+ //delete old entries
+ //datasetFileSelect = $(document.createElement('select')).appendTo('#section_select');
+ //datasetFileSelect.attr({'id':'section_file_list'});
+ //datasetFileSelect.attr({'multiple':'multiple'});
+ selectFOptions = "";
+
+
+
+ for (var i = 0; i < featureCollection.features[k].properties.entry[k].link.length; i++) {
+ ext = featureCollection.features[k].properties.entry[k].link[i]['@attributes'].bbox;
+
+ extArrayNew = new Array();
+ //extArray = new Array();
+ //alert(extArray[1]);
+ extArray = ext.split(",");
+
+ extArrayNew[0] = extArray[1];
+ extArrayNew[1] = extArray[0];
+ extArrayNew[2] = extArray[3];
+ extArrayNew[3] = extArray[2];
+
+ bound = OpenLayers.Bounds.fromArray(extArrayNew);
+ attributes = {id: i, url:featureCollection.features[k].properties.entry[k].link[i]['@attributes'].href};
+ box = new OpenLayers.Feature.Vector(bound.toGeometry(),attributes);
+ bboxFiles.addFeatures(box);
+ selectFOptions = selectFOptions+"<option value='"+i+"' url='"+featureCollection.features[k].properties.entry[k].link[i]['@attributes'].href+"' title='"+featureCollection.features[k].properties.entry[k].link[i]['@attributes'].title+"' onclick='highlightFeatureIndexById("+i+");'>"+featureCollection.features[k].properties.entry[k].link[i]['@attributes'].title+"</option>";
+
+ //var datasetSelectOption = $(document.createElement('option')).appendTo(datasetSelect);
+ //datasetSelectOption.attr({'value':featureCollection.features[i].id});
+
+ }
+ //count features of bboxFiles
+ //bboxFiles if not available show error message
+ selectFOptionsObject = $('#section_file_list').append(selectFOptions);
+ selectFOptionsObject.attr({'id':'section_option'});
+ selectFOptionsObject.attr({'width': 300});
+ bound = bboxFiles.getDataExtent();
+ mapframe_file_list.zoomToExtent(bound);
+ // map.addLayers([ol_wms, boxes]);
+ // map.addControl(new OpenLayers.Control.LayerSwitcher());
+ bboxFiles.events.on({
+ featureselected: function(event) {
+ var feature = event.feature;
+ //var area = feature.geometry.getArea();
+ var id = feature.attributes.id;
+ var url = feature.attributes.url;
+ $('#section_option option').removeAttr('selected')
+ $("#section_option option[value='"+id+"']").attr('selected',true);
+ window.open(url,'download_window');
+
+ /*if ($('#multi_select').is(':checked')) {
+ alert("checked");
+ } else {
+ alert("un-checked");
+ }
+ alert(url);*/
+ //var output = "Building: " + id + " Area: " + area.toFixed(2);
+ //document.getElementById("output-id").innerHTML = output;
+
+ }
+ });
+
+ sf = new OpenLayers.Control.SelectFeature(bboxFiles);
+ mapframe_file_list.addControl(sf);
+ sf.activate();
+
+
+
+
+}
+
+function drawMetadataPolygons(featureCollection) {
+ var type = "geojson";
+ var features = formats['in'][type].read(featureCollection);
+ var bounds;
+ if(features) {
+ if(features.constructor != Array) {
+ features = [features];
+ }
+ for(var i=0; i<features.length; ++i) {
+ if (!bounds) {
+ bounds = features[i].geometry.getBounds();
+ } else {
+ bounds.extend(features[i].geometry.getBounds());
+ }
+ }
+ //delete old features:
+ bboxDataset.removeAllFeatures();
+ bboxDataset.addFeatures(features);
+ mapframe_dataset_list.zoomToExtent(bounds);
+ }
+}
+
+function highlightFeatureIndexById(id) {
+ var features = bboxFiles.features;
+ for(var i=0; i<features.length; ++i) {
+ if(features[i].attributes.id == id) {
+ index = i;
+ break;
+ }
+ }
+ //unselect all
+ sf.unselect(bboxFiles.selectedFeatures[0]);
+ sf.select(bboxFiles.features[index]);
+ window.open(bboxFiles.features[index].attributes.url,'download_window');
+}
+
+
+
+
+
Modified: trunk/mapbender/http/php/mod_inspireDownloadFeed.php
===================================================================
--- trunk/mapbender/http/php/mod_inspireDownloadFeed.php 2012-08-06 07:45:08 UTC (rev 8449)
+++ trunk/mapbender/http/php/mod_inspireDownloadFeed.php 2012-08-08 15:19:06 UTC (rev 8450)
@@ -26,7 +26,7 @@
require_once(dirname(__FILE__) . "/../classes/class_connector.php");
require_once(dirname(__FILE__) . "/../classes/class_administration.php");
require_once(dirname(__FILE__) . "/../classes/class_Uuid.php");
-
+//http://www.weichand.de/inspire/dls/verwaltungsgrenzen.xml
$con = db_connect(DBSERVER,OWNER,PW);
db_select_db(DB,$con);
@@ -550,7 +550,7 @@
$nCols = ceil($diffXPx / floatval($maxImageSize));
$e = new mb_exception($nRows.":".$nCols);
$bboxWms = array();
- $bboxWmsWS84 = array();
+ $bboxWmsWGS84 = array();
/*echo $diffXPx.":".$diffYPx.",";
echo $nRows.":".$nCols.",";
echo $minx.":".$miny.",";
@@ -570,6 +570,7 @@
//echo "maxyWms: ". $maxyWms .",";
$bboxWms[] = $minxWms.",".$minyWms.",".$maxxWms.",".$maxyWms;
$bboxWmsWGS84[] = transformBbox($minxWms.",".$minyWms.",".$maxxWms.",".$maxyWms,intval($epsgId[1]),4326);
+
}
}
}
@@ -680,6 +681,7 @@
//transform bbox back to geographic coordinates
$lonLatBbox = transformBbox($minxWfs.",".$minyWfs.",".$maxxWfs.",".$maxyWfs,intval($epsgId[1]),4326);
$lonLatBbox = explode(',',$lonLatBbox);
+ //georss needs latitude longitude
$featureTypeBboxWGS84[] = $lonLatBbox[1].",".$lonLatBbox[0].",".$lonLatBbox[3].",".$lonLatBbox[2];
//switch bbox to lat/lon cause inspire demands ist
@@ -847,6 +849,10 @@
$furtherLinkTitle[$m] = $ressourceTitle." im CRS ".$mapbenderMetadata[$i]->metadata_ref_system." - ".$mapbenderMetadata[$i]->format." - Teil ".$currentTileIndex." von ".$numberOfTiles."";
//$furtherLinkBbox[$m] = $bboxWms[$m];
$furtherLinkBbox[$m] = $bboxWmsWGS84[$m];
+ //exchange lon lat with lat long for georss
+ $newBox = explode(',',$furtherLinkBbox[$m]);
+ //georss needs latitude longitude
+ $newBox = $newBox[1].",".$newBox[0].",".$newBox[3].",".$newBox[2];
//generate content link
$feedEntryLink = $feedDoc->createElement("link");
$feedEntryLink->setAttribute("rel", "section");
@@ -854,7 +860,7 @@
$feedEntryLink->setAttribute("type", $furtherLinkType[$m]);
$feedEntryLink->setAttribute("hreflang", "de");
$feedEntryLink->setAttribute("title", $furtherLinkTitle[$m]);
- $feedEntryLink->setAttribute("bbox", $furtherLinkBbox[$m]);
+ $feedEntryLink->setAttribute("bbox", $newBox);
$feedEntry->appendChild($feedEntryLink);
}
break;
@@ -995,12 +1001,14 @@
//$e = new mb_exception(count($arrayBbox));
//$e = new mb_exception($arrayBbox[0]);
$sql = "select asewkt(transform(GeometryFromText ( 'LINESTRING ( ".$arrayBbox[0]." ".$arrayBbox[1].",".$arrayBbox[2]." ".$arrayBbox[3]." )', $fromCRS ),".intval($toCRS)."))";
+ //$e = new mb_exception("inspireDownload sql transform: ".$sql);
//$sql = "select asewkt(transform(GeometryFromText ( 'LINESTRING ( $1 $2, $3 $4 )', $5 ),$6))";
//$v = array($arrayBbox[0],$arrayBbox[1],$arrayBbox[2],$arrayBbox[3],$fromCRS,$toCRS);
//$t = array('s','s','s','s','i','i');
$res = db_query($sql,$v,$t);
//read out result
$textBbox = db_fetch_row($res);
+ //$e = new mb_exception("inspireDownload sql result: ".$textBbox[0]);
$pattern = '~LINESTRING\((.*)\)~i';
preg_match($pattern, $textBbox[0], $subpattern);
//exchange blancs
Added: trunk/mapbender/http/plugins/mb_downloadFeedClient.php
===================================================================
--- trunk/mapbender/http/plugins/mb_downloadFeedClient.php (rev 0)
+++ trunk/mapbender/http/plugins/mb_downloadFeedClient.php 2012-08-08 15:19:06 UTC (rev 8450)
@@ -0,0 +1,138 @@
+<?php
+ //http://localhost/mapbender_trunk/plugins/mb_downloadFeedClient.php
+ require_once dirname(__FILE__) . "/../../core/globalSettings.php";
+ require_once dirname(__FILE__) . "/../classes/class_user.php";
+?>
+<html>
+<head>
+<title>INSPIRE ATOM Feed Client</title>
+<meta name="description" content="INSPIRE ATOM Feed Client" xml:lang="en" />
+<meta name="keywords" content="INSPIRE SDI GDI Download" xml:lang="en" />
+<meta http-equiv="cache-control" content="no-cache">
+<meta http-equiv="pragma" content="no-cache">
+<meta http-equiv="expires" content="0">
+<meta http-equiv="content-language" content="en" />
+<meta http-equiv="content-style-type" content="text/css" />
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
+ <link rel="stylesheet" href="../extensions/OpenLayers-2.9.1/theme/default/style.css" type="text/css">
+ <style type="text/css">
+ input, select, textarea {
+ font: 0.9em Verdana, Arial, sans-serif;
+ }
+ #leftcol {
+ position: absolute;
+ top: 0;
+ left: 1em;
+ padding: 0;
+ width: 517px;
+ }
+ #mapframe_dataset_list {
+ width: 325px;
+ height: 225px;
+ border: 1px solid #ccc;
+ }
+ #mapframe_file_list {
+ width: 325px;
+ height: 225px;
+ border: 1px solid #ccc;
+ }
+ #section_list {
+ position: relative;
+ top: 0;
+ left: 0;
+ width: 325px;
+ height: 225px;
+
+ }
+ #input {
+ width: 512px;
+ }
+ #text {
+ font-size: 0.85em;
+ margin: 1em 0 1em 0;
+ width: 100%;
+ height: 10em;
+ }
+ #info {
+ position: relative;
+ padding: 2em 0;
+ margin-left: 540px;
+ }
+ #output {
+ font-size: 0.8em;
+ width: 100%;
+ height: 512px;
+ border: 0;
+ }
+ p {
+ margin: 0;
+ padding: 0.75em 0 0.75em 0;
+ }
+ </style>
+ <!--<script src="../extensions/OpenLayers-2.9.1/OpenLayers.js"></script>-->
+ <script src="http://openlayers.org/api/OpenLayers.js"></script>
+ <script src="../extensions/jquery-ui-1.8.16.custom/js/jquery-1.6.2.min.js"></script>
+ <script src="../extensions/jquery-ui-1.8.16.custom/js/jquery-ui-1.8.16.custom.min.js"></script>
+ <script src="../javascripts/mb_downloadFeedClient.js"></script>
+</head>
+<body onload="init()">
+<fieldset>
+ <legend><?php echo _mb("INSPIRE Download Service ATOM Feed Client");?><img class="help-dialog" title="<?php echo _mb("Help");?>" help="{text:'<?php echo _mb("Client to download INSPIRE data on an easy way.");?>'}" src="../img/questionmark.png" alt="" /></legend>
+ <p>
+ <form id="service_feed_form">
+ <label for="download_feed_url"><?php echo _mb("ATOM Feed url");?></label>
+ <input name="download_feed_url" id="download_feed_url" class="required"/><input type="button" title="Get Feed" id="download_feed_button" value="Get Feed Content"/>
+ </form>
+ </p>
+ <fieldset>
+ <legend><?php echo _mb("Select dataset");?><img class="help-dialog" title="<?php echo _mb("Help");?>" help="{text:'<?php echo _mb("Select single dataset either in list or on map");?>'}" src="../img/questionmark.png" alt="" /></legend>
+ <div id="mapframe_dataset_list"></div>
+ <div id="dataset_list"></div>
+ <!--<label for="dataset_list"><?php echo _mb("List of datasets");?>:</label>
+ <select name="dataset_list" id="dataset_list" onChange="var choosenoption=this.options[this.selectedIndex];display_dataset(choosenoption.value);">
+ <option value="0">...</option>
+ </select>-->
+ </fieldset>
+
+<fieldset>
+ <legend><?php echo _mb("Dataset Feed entries");?><img class="help-dialog" title="<?php echo _mb("Help");?>" help="{text:'<?php echo _mb("The fieldset shows the content of the INSPIRE Download Service service-feed document. It contains one or more links to different datasets.");?>'}" src="../img/questionmark.png" alt="" /></legend>
+ <p>
+ <label for="dataset_title"><?php echo _mb("Dataset title");?>:</label>
+ <input readonly="readonly" name="dataset_title" id="dataset_title"/>
+ </p>
+ <p>
+ <label for="resource_identifier"><?php echo _mb("Resource identifier");?>:</label>
+ <input readonly="readonly" name="resource_identifier" id="resource_identifier"/>
+ </p>
+ <p>
+ <label for="dataset_rights"><?php echo _mb("Rights");?>:</label>
+ <input readonly="readonly" name="dataset_rights" id="dataset_rights"/>
+ </p>
+ <p>
+ <label for="representations"><?php echo _mb("Available representations");?>:</label>
+ <div id="dataset_representation_list"></div>
+
+ </p>
+</fieldset>
+<fieldset>
+ <legend><?php echo _mb("Files");?><img class="help-dialog" title="<?php echo _mb("Help");?>" help="{text:'<?php echo _mb("Files which can be downloaded");?>'}" src="../img/questionmark.png" alt="" /></legend>
+ <div>
+ <input id="multi_select" type="checkbox" disabled><?php echo _mb("Select multiple tiles");?></input><br>
+ <label for="mapframe_file_list"><?php echo _mb("Position of files (if available)");?>:</label>
+ <!--<input type="list" id="file_list"/>-->
+
+ <div id="mapframe_file_list"></div>
+ <label for="section_list"><?php echo _mb("List of files");?>:</label>
+ <div id="section_list">
+
+ <select id="section_file_list" multiple='multiple'></div>
+
+
+
+ </div>
+
+ </div>
+ <input type="button" title="Download selected files" value="Download selection"/>
+</fieldset>
+</body>
+</html>
Added: trunk/mapbender/http/plugins/mb_downloadFeedServer.php
===================================================================
--- trunk/mapbender/http/plugins/mb_downloadFeedServer.php (rev 0)
+++ trunk/mapbender/http/plugins/mb_downloadFeedServer.php 2012-08-08 15:19:06 UTC (rev 8450)
@@ -0,0 +1,209 @@
+<?php
+ //http://localhost/mapbender_trunk/plugins/mb_downloadFeedServer.php
+ require_once dirname(__FILE__) . "/../../core/globalSettings.php";
+ require_once dirname(__FILE__) . "/../classes/class_user.php";
+ require_once dirname(__FILE__) . "/../classes/class_connector.php";
+ require_once(dirname(__FILE__)."/../classes/class_json.php");
+ require_once(dirname(__FILE__)."/../classes/class_gml2.php");
+ require_once(dirname(__FILE__)."/../classes/class_georss_geometry.php");
+ require_once(dirname(__FILE__)."/../classes/class_Uuid.php");
+
+/* $ajaxResponse = new AjaxResponse($_POST);
+
+ function abort ($message) {
+ global $ajaxResponse;
+ $ajaxResponse->setSuccess(false);
+ $ajaxResponse->setMessage($message);
+ $ajaxResponse->send();
+ die;
+ }
+
+ function getServiceFeedObjectFromUrl () {
+ //define default resultObj
+ $resultObj = array(
+ "original_layer_title" => "",
+ "original_layer_abstract" => "",
+ "original_layer_keyword" => ""
+ );
+ return $resultObj;
+ }
+*/
+class geoRSSEntry extends Feature{
+ public function parse($entry, $itemsToImport) {
+ $tag = $currentSibling->nodeName;
+ if(in_array($tag, $importItems)){
+ $this->properties[$tag] = $currentSibling->nodeValue;
+ }
+ else{
+ switch ($tag) {
+ case "georss:polygon":
+ $this->geometry = new geoRSSPolygon();
+ $this->geometry->targetEPSG = $this->targetEPSG;
+ $this->geometry->parsePolygon($currentSibling);
+ break;
+ default:
+ break;
+ }
+ }
+ }
+}
+
+
+switch ($_REQUEST['method']) {
+ case "getServiceFeedObjectFromUrl" :
+ $serviceFeedUrl = $_REQUEST['url'];
+ //test url
+ //get feed from remote server
+ $feedConnector = new connector($serviceFeedUrl);
+ $feedConnector->set("timeOut", "5");
+ $feedFile = $feedConnector->file;
+ //$mbMetadata = $this->createMapbenderMetadataFromXML($xml);
+ //parse content
+ //$e = new mb_exception($feedFile);
+ libxml_use_internal_errors(true);
+ try {
+ $feedXML = simplexml_load_string($feedFile);
+ if ($feedXML === false) {
+ foreach(libxml_get_errors() as $error) {
+ $err = new mb_exception("downloadFeedServer.php:".$error->message);
+ }
+ throw new Exception("downloadFeedServer.php:".'Cannot parse Feed!');
+ return false;
+ }
+ }
+ catch (Exception $e) {
+ $err = new mb_exception("downloadFeedServer.php:".$e->getMessage());
+ return false;
+ }
+ //$e = new mb_exception($feedXML->file);
+ if ($feedXML != false) {
+ $feedXML->registerXPathNamespace("georss", "http://www.georss.org/georss");
+ $feedXML->registerXPathNamespace("inspire_dls", "http://inspire.ec.europa.eu/schemas/inspire_dls/1.0");
+ $feedXML->registerXPathNamespace("defaultns", "http://www.w3.org/2005/Atom");
+
+ $title = $feedXML->xpath('/defaultns:feed/defaultns:entry/defaultns:title');
+ $rights = $feedXML->xpath('/defaultns:feed/defaultns:entry/defaultns:rights');
+ $bbox = $feedXML->xpath('/defaultns:feed/defaultns:entry/georss:polygon');
+ $metadataLink = $feedXML->xpath('/defaultns:feed/defaultns:entry/defaultns:link[contains(@rel,\'describedby\')]/@href');
+ $datasetFeedLink = $feedXML->xpath('/defaultns:feed/defaultns:entry/defaultns:link[contains(@rel,\'alternate\')]/@href');
+ //new feature collection
+ $featureCollection = new FeatureCollection;
+ for ($i=0; $i<=(count($title)-1); $i++) {
+ $feature = new Feature;
+ $uuid = new Uuid;
+ $feature->fid = $uuid;
+ $titleArray = (array)$title[$i];
+ $rightsArray = (array)$rights[$i];
+ $bboxArray = (array)$bbox[$i];
+ $mdLinkArray = (array)$metadataLink[$i];
+ $mdLinkArray = $mdLinkArray["@attributes"];
+ $dsLinkArray = (array)$datasetFeedLink[$i];
+ $dsLinkArray = $dsLinkArray["@attributes"];
+ $feature->properties["title"] = $titleArray[0];
+ $feature->properties["rights"] = $rightsArray[0];
+ $feature->properties["metadataLink"] = $mdLinkArray["href"];
+ $feature->properties["datasetFeedLink"] = $dsLinkArray["href"];
+ $feature->geometry = new geoRSSPolygon();
+ $feature->geometry->parsePolygon($bboxArray[0]);
+ //$feature->geometry->targetEPSG = "EPSG:4326";
+ if (isset($feature->geometry) && $feature->geometry!==false) {
+ $featureCollection->addFeature($feature);
+ $e = new mb_notice("Feature added to collection!");
+ }
+ }
+ }
+ echo $featureCollection->toGeoJSON();
+ break;
+ case "getDatasetFeedObjectFromUrl" :
+ $datasetFeedUrl = $_REQUEST['url'];
+ //test url
+ //get feed from remote server
+ $feedConnector = new connector($datasetFeedUrl);
+ $feedConnector->set("timeOut", "5");
+ $feedFile = $feedConnector->file;
+ //$mbMetadata = $this->createMapbenderMetadataFromXML($xml);
+ //parse content
+ //$e = new mb_exception($feedFile);
+ libxml_use_internal_errors(true);
+ try {
+ $feedXML = simplexml_load_string($feedFile);
+ if ($feedXML === false) {
+ foreach(libxml_get_errors() as $error) {
+ $err = new mb_exception("downloadFeedServer.php:".$error->message);
+ }
+ throw new Exception("downloadFeedServer.php:".'Cannot parse Feed!');
+ return false;
+ }
+ }
+ catch (Exception $e) {
+ $err = new mb_exception("downloadFeedServer.php:".$e->getMessage());
+ return false;
+ }
+ //$e = new mb_exception($feedXML->file);
+ if ($feedXML != false) {
+ $feedXML->registerXPathNamespace("georss", "http://www.georss.org/georss");
+ $feedXML->registerXPathNamespace("inspire_dls", "http://inspire.ec.europa.eu/schemas/inspire_dls/1.0");
+ $feedXML->registerXPathNamespace("defaultns", "http://www.w3.org/2005/Atom");
+
+ $title = $feedXML->xpath('/defaultns:feed/defaultns:entry/defaultns:title');
+
+
+ $bbox = $feedXML->xpath('/defaultns:feed/defaultns:entry/georss:polygon');
+ //$link = $feedXML->xpath('/defaultns:feed/defaultns:entry/defaultns:link[contains(@rel,\'section\')]/@bbox');
+ //$datasetFeedLink = $feedXML->xpath('/defaultns:feed/defaultns:entry/defaultns:link[contains(@rel,\'alternate\')]/@href');
+ //new feature collection
+ $featureCollection = new FeatureCollection;
+ for ($i=0; $i<=(count($title)-1); $i++) {
+ $feature = new Feature;
+ $uuid = new Uuid;
+ $feature->fid = $uuid;
+
+ $entry = $feedXML->xpath('/defaultns:feed/defaultns:entry');
+
+ $titleArray = (array)$title[$i];
+ $bboxArray = (array)$bbox[$i];
+ $mdLinkArray = (array)$metadataLink[$i];
+ $mdLinkArray = $mdLinkArray["@attributes"];
+ $dsLinkArray = (array)$datasetFeedLink[$i];
+ $dsLinkArray = $dsLinkArray["@attributes"];
+ $feature->properties["title"] = $titleArray[0];
+ $feature->properties["metadataLink"] = $mdLinkArray["href"];
+ $feature->properties["datasetFeedLink"] = $dsLinkArray["href"];
+ $feature->properties["entry"] = array();
+ for ($j=0; $j<=(count($entry)-1); $j++) {
+ $feature->properties["entry"][$j] = $entry[$j];
+ }
+ $link = $feedXML->xpath('/defaultns:feed/defaultns:entry/defaultns:link[contains(@rel,\'section\')]/@bbox');
+ $feature->geometry = new geoRSSPolygon();
+ $feature->geometry->parsePolygon($bboxArray[0]);
+ //$feature->geometry->targetEPSG = "EPSG:4326";
+ if (isset($feature->geometry) && $feature->geometry!==false) {
+ $featureCollection->addFeature($feature);
+ $e = new mb_notice("Feature added to collection!");
+ }
+ /*$titleArray = (array)$title[$i];
+ $linkArray = (array)$link[$i];
+ $linkArray = $linkArray["@attributes"];
+ $bbox = $linkArray["bbox"];
+ //$e = new mb_exception($bbox);
+ $feature->properties["title"] = $titleArray[0];
+ //$feature->properties["metadataLink"] = $mdLinkArray["href"];
+ //$feature->properties["datasetFeedLink"] = $dsLinkArray["href"];
+ $feature->geometry = new geoRSSPolygon();
+ $feature->geometry->parsePolygon($bbox);
+ //$feature->geometry->targetEPSG = "EPSG:4326";
+ if (isset($feature->geometry) && $feature->geometry!==false) {
+ $featureCollection->addFeature($feature);
+ $e = new mb_notice("Feature added to collection!");
+ }*/
+ }
+ }
+
+ echo $featureCollection->toGeoJSON();
+ break;
+ default:
+ echo json_encode("Kein Treffer!");
+ break;
+}
+
+?>
More information about the Mapbender_commits
mailing list