[Mapbender-commits] r8192 - in trunk/mapbender/http: classes php
plugins
svn_mapbender at osgeo.org
svn_mapbender at osgeo.org
Thu Oct 27 05:30:19 EDT 2011
Author: armin11
Date: 2011-10-27 02:30:19 -0700 (Thu, 27 Oct 2011)
New Revision: 8192
Modified:
trunk/mapbender/http/classes/class_wms.php
trunk/mapbender/http/php/mod_layerISOMetadata.php
trunk/mapbender/http/php/wms.php
trunk/mapbender/http/plugins/mb_metadata_server.php
Log:
Bugfix for Metadataeditor
Modified: trunk/mapbender/http/classes/class_wms.php
===================================================================
--- trunk/mapbender/http/classes/class_wms.php 2011-10-25 13:57:33 UTC (rev 8191)
+++ trunk/mapbender/http/classes/class_wms.php 2011-10-27 09:30:19 UTC (rev 8192)
@@ -101,7 +101,7 @@
# "$1php/mod_layerMetadata.php?id=",
# LOGIN
#) . $wmsId;
- return LOGIN."/../php/mod_showMetadata.php?resource=wms&id=".$wmsId;
+ return LOGIN."/../../mapbender/php/mod_showMetadata.php?resource=wms&id=".$wmsId;
}
public static function getLayerMetadataUrl ($layerId) {
#return preg_replace(
@@ -109,7 +109,7 @@
# "$1php/mod_layerMetadata.php?id=",
# LOGIN
#) . $wmsId;
- return LOGIN."/../php/mod_showMetadata.php?resource=layer&id=".$layerId;
+ return LOGIN."/../../mapbender/php/mod_showMetadata.php?resource=layer&id=".$layerId;
}
public static function isOwsProxyUrl ($getmap) {
// $e = new mb_notice("isOwsProxyUrl? " . $getmap);
@@ -2188,6 +2188,13 @@
//load metadata from link
$metadataConnector = new connector($this->objLayer[$i]->layer_metadataurl[$j]->href);
$metaData = $metadataConnector->file;
+ //delete getRecordByIdResponse from xml if there cause we handle only iso19139 files !
+ $regex = "#<csw:GetRecordByIdResponse .*?>#";
+ $output = preg_replace($regex,"",$metaData);
+ $regex = "#</csw:GetRecordByIdResponse>#";
+ $output = preg_replace($regex,"",$output);
+ //$e = new mb_exception($output);
+ $metaData = $output;
//parse metadata
try {
//$iso19139Xml = simplexml_load_string($metaData);
Modified: trunk/mapbender/http/php/mod_layerISOMetadata.php
===================================================================
--- trunk/mapbender/http/php/mod_layerISOMetadata.php 2011-10-25 13:57:33 UTC (rev 8191)
+++ trunk/mapbender/http/php/mod_layerISOMetadata.php 2011-10-27 09:30:19 UTC (rev 8192)
@@ -508,7 +508,7 @@
//a special keyword for service type wms as INSPIRE likes it ;-)
$keyword=$iso19139->createElement("gmd:keyword");
$keyword_cs=$iso19139->createElement("gco:CharacterString");
- $keywordText = $iso19139->createTextNode("humanGeographicViewer");
+ $keywordText = $iso19139->createTextNode("infoMapAccessService");
$keyword_cs->appendChild($keywordText);
$keyword->appendChild($keyword_cs);
$MD_Keywords->appendChild($keyword);
Modified: trunk/mapbender/http/php/wms.php
===================================================================
--- trunk/mapbender/http/php/wms.php 2011-10-25 13:57:33 UTC (rev 8191)
+++ trunk/mapbender/http/php/wms.php 2011-10-27 09:30:19 UTC (rev 8192)
@@ -503,6 +503,11 @@
$onlineResource->setAttribute("xmlns:xlink", "http://www.w3.org/1999/xlink");
// $onlineResource->setAttribute("xlink:href", $wms_row['wms_getcapabilities']);
$onlRes = $_SERVER["HTTP_HOST"] . $_SERVER["SCRIPT_NAME"] . "?layer_id=" . $layerId;
+
+ if ($inspire) {
+ $onlRes = $onlRes."&INSPIRE=1";
+ }
+
if (isset($_SERVER["HTTPS"])) {
$onlRes = "https://" . $onlRes;
}
@@ -524,6 +529,11 @@
$onlineResource->setAttribute("xmlns:xlink", "http://www.w3.org/1999/xlink");
// $onlineResource->setAttribute("xlink:href", $wms_row['wms_getcapabilities']);
$onlRes = $_SERVER["HTTP_HOST"] . $_SERVER["SCRIPT_NAME"] . "?layer_id=" . $layerId;
+
+ if ($inspire) {
+ $onlRes = $onlRes."&INSPIRE=1&";
+ }
+
if (isset($_SERVER["HTTPS"])) {
$onlRes = "https://" . $onlRes;
}
@@ -664,21 +674,28 @@
$vendorSpecificCapabilities = $capability->appendChild($vendorSpecificCapabilities);
#generate inspire_vs:ExtendedCapabilities node
$inspire_vs_ExtendedCapabilities = $doc->createElement("inspire_vs:ExtendedCapabilities");
- $inspire_vs_ExtendedCapabilities->setAttribute("xmlns:inspire_common", "http://inspire.ec.europa.eu/schemas/common/1.0");
+ $inspire_vs_ExtendedCapabilities->setAttribute("xmlns:inspire_vs", "http://inspire.ec.europa.eu/schemas/inspire_vs/1.0");
$inspire_vs_ExtendedCapabilities = $vendorSpecificCapabilities->appendChild($inspire_vs_ExtendedCapabilities);
#generate inspire_vs: node
#$inspire_vs_ExtendedCapabilities = $doc->createElement("inspire_vs:ExtendedCapabilities");
#$inspire_vs_ExtendedCapabilities = $vendorSpecificCapabilities->appendChild($inspire_vs_ExtendedCapabilities);
#MetadataUrl to inspire service metadata
$inspire_common_MetadataUrl = $doc->createElement("inspire_common:MetadataUrl");
+ /*<inspire_common:MetadataUrl xmlns:inspire_common="http://inspire.ec.europa.eu/schemas/common/1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="inspire_common:resourceLocatorType">*/
+ $inspire_common_MetadataUrl->setAttribute("xmlns:inspire_common", "http://inspire.ec.europa.eu/schemas/common/1.0");
+ $inspire_common_MetadataUrl->setAttribute("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance");
+ $inspire_common_MetadataUrl->setAttribute("xsi:type", "inspire_common:resourceLocatorType");
$inspire_common_MetadataUrl = $inspire_vs_ExtendedCapabilities->appendChild($inspire_common_MetadataUrl);
#URL
$inspire_common_URL = $doc->createElement("inspire_common:URL");
+ $inspire_common_URL->setAttribute("xmlns:inspire_common", "http://inspire.ec.europa.eu/schemas/common/1.0");
+
$inspire_common_URLText = $doc->createTextNode($inspireServiceMetadataUrl.$layerId);
$inspire_common_URL->appendChild($inspire_common_URLText);
$inspire_common_URL = $inspire_common_MetadataUrl->appendChild($inspire_common_URL);
#MediaType
$inspire_common_MediaType = $doc->createElement("inspire_common:MediaType");
+ $inspire_common_MediaType->setAttribute("xmlns:inspire_common", "http://inspire.ec.europa.eu/schemas/common/1.0");
$inspire_common_MediaTypeText = $doc->createTextNode('application/vnd.iso.19139+xml');#from http://inspire.ec.europa.eu/schemas/inspire_vs/1.0/examples/WMS_Image2000GetCapabilities_InspireSchema.xml
$inspire_common_MediaType->appendChild($inspire_common_MediaTypeText);
$inspire_common_MediaType = $inspire_common_MetadataUrl->appendChild($inspire_common_MediaType);
Modified: trunk/mapbender/http/plugins/mb_metadata_server.php
===================================================================
--- trunk/mapbender/http/plugins/mb_metadata_server.php 2011-10-25 13:57:33 UTC (rev 8191)
+++ trunk/mapbender/http/plugins/mb_metadata_server.php 2011-10-27 09:30:19 UTC (rev 8192)
@@ -788,7 +788,7 @@
}
$randomid = new Uuid();
//Check if origin is external and export2csw is activated!
- if ($origin == 'external' && $export2csw == 't' ) {
+ if ($origin == 'external' ) {
//harvest link from location, parse the content for datasetid and push xml into data column
//load metadata from link TODO: function from class_wms - generate a class for metadata management and include it here and in class_wms
$metadataConnector = new connector();
@@ -798,7 +798,13 @@
if (!$metaData) {
abort(_mb("Could not load metadata from source url!"));
}
-
+ //delete getRecordByIdResponse from xml if there
+ $regex = "#<csw:GetRecordByIdResponse .*?>#";
+ $output = preg_replace($regex,"",$metaData);
+ $regex = "#</csw:GetRecordByIdResponse>#";
+ $output = preg_replace($regex,"",$output);
+ //$e = new mb_exception($output);
+ $metaData = $output;
//***
//write metadata to temporary file:
$randomFileId = new Uuid();
@@ -814,7 +820,6 @@
} else {
abort(_mb("Temporary file could not be parsed!"));
}
-
//$metaData = $metadataConnector->file;
//parse metadata
/*try {
@@ -827,6 +832,7 @@
//get elements for database from xml by using xpath
//uuid
$uuid = $iso19139Xml->xpath('/gmd:MD_Metadata/gmd:fileIdentifier/gco:CharacterString');
+ $e = new mb_exception("plugins/mb_metadata_server.php: File Identifier found: ".$uuid);
//createdate
$createdate = $iso19139Xml->xpath('/gmd:MD_Metadata/gmd:dateStamp/gco:Date');
//changedate
@@ -843,27 +849,27 @@
$datasetid = 'undefined';
$code = $iso19139Xml->xpath('/gmd:MD_Metadata/gmd:identificationInfo/gmd:MD_DataIdentification/gmd:citation/gmd:CI_Citation/gmd:identifier/gmd:MD_Identifier/gmd:code/gco:CharacterString');
if (isset($code[0]) && $code[0] != '') {
- $e = new mb_exception("class_wms.php: code given thru MD_Identifier: ".$code[0]);
+ $e = new mb_exception("plugins/mb_metadata_server.php: code given thru MD_Identifier: ".$code[0]);
//check if code is defined by codespace and code
$codeSplit = explode("#",$code);
if (isset($codeSplit[0]) && $codeSplit[0] != '' && isset($codeSplit[1]) && $codeSplit[1] != '') {
- $e = new mb_exception("class_wms.php: code was constructed via codespace#code !");
+ $e = new mb_exception("plugins/mb_metadata_server.php: code was constructed via codespace#code !");
$datasetid = $codeSplit[0]."#".$codeSplit[1];
} else {
- $e = new mb_exception("class_wms.php: code was not constructed via codespace#code !");
- $datasetid = $code;
+ $e = new mb_exception("plugins/mb_metadata_server.php: code was not constructed via codespace#code !");
+ $datasetid = $code[0];
}
} else { //try to read code from RS_Identifier
$code = $iso19139Xml->xpath('/gmd:MD_Metadata/gmd:identificationInfo/gmd:MD_DataIdentification/gmd:citation/gmd:CI_Citation/gmd:identifier/gmd:RS_Identifier/gmd:code/gco:CharacterString');
$codeSpace = $iso19139Xml->xpath('/gmd:MD_Metadata/gmd:identificationInfo/gmd:MD_DataIdentification/gmd:citation/gmd:CI_Citation/gmd:identifier/gmd:RS_Identifier/gmd:codeSpace/gco:CharacterString');
- #$e = new mb_exception("class_wms.php: code: ".$code[0]);
- #$e = new mb_exception("class_wms.php: codeSpace: ".$codeSpace[0]);
+ #$e = new mb_exception("plugins/mb_metadata_server.php: code: ".$code[0]);
+ #$e = new mb_exception("plugins/mb_metadata_server.php: codeSpace: ".$codeSpace[0]);
if (isset($codeSpace[0]) && isset($code[0]) && $codeSpace[0] != '' && $code[0] != '') {
$datasetid = $codeSpace[0]."#".$code[0];
- $e = new mb_exception("class_wms.php: datasetid: ".$datasetid);
+ $e = new mb_exception("plugins/mb_metadata_server.php: datasetid: ".$datasetid);
} else {
//neither MD_Identifier nor RS_Identifier are defined in a right way
- $e = new mb_exception("class_wms.php: the service data coupling has problems, cause the metadata doesnt have defined a datasetid");
+ $e = new mb_exception("plugins/mb_metadata_server.php: the service data coupling has problems, cause the metadata doesnt have defined a datasetid");
}
}
//abstract
@@ -905,7 +911,7 @@
abort(_mb("Problem with parsing the XML structure with SimpleXML! Record was not inserted into database! Ask your administrator."));
//give back error message - cause parsing has problems
}
- } else { //fill only links into db - do not try to load data
+ }/* else { //fill only links into db - do not try to load data
//TODO: Extract the information from the link - this should include datasetid!
$sql = <<<SQL
@@ -921,7 +927,7 @@
catch (Exception $e){
abort(_mb("Insert of link into database failed!"));
}
- }
+ }*/
//set relation into relation table
//get metadata_id of record which have been inserted before
$sql = <<<SQL
@@ -1027,16 +1033,20 @@
if (!$metaData){
abort(_mb("Reading file ".$filename." failed!"));
}
-
- try {
- $iso19139Xml = new SimpleXMLElement($metaData);
- }
- catch (Exception $e) {
- abort(_mb("Parsing ISO19139 XML failed!"));
- }
+ //delete getRecordByIdResponse from xml if there
+ $regex = "#<csw:GetRecordByIdResponse .*?>#";
+ $output = preg_replace($regex,"",$metaData);
+ $regex = "#</csw:GetRecordByIdResponse>#";
+ $output = preg_replace($regex,"",$output);
+ //$e = new mb_exception($output);
+ $metaData = $output;
//get elements for database from xml by using xpath
//uuid
$uuid = $iso19139Xml->xpath('/gmd:MD_Metadata/gmd:fileIdentifier/gco:CharacterString');
+ if (!isset($uuid) || $uuid == "") {
+ abort(_mb(" No fileIdentifier found, parsing ISO19139 XML maybe failed. Check if element /gmd:MD_Metadata/gmd:fileIdentifier/gco:CharacterString is given and not empty!"));
+ }
+ //$e = new mb_exception("plugins/mb_metadata_server.php: File Identifier found: ".$uuid);
//createdate
$createdate = $iso19139Xml->xpath('/gmd:MD_Metadata/gmd:dateStamp/gco:Date');
//changedate
@@ -1052,27 +1062,27 @@
$datasetid = 'undefined';
$code = $iso19139Xml->xpath('/gmd:MD_Metadata/gmd:identificationInfo/gmd:MD_DataIdentification/gmd:citation/gmd:CI_Citation/gmd:identifier/gmd:MD_Identifier/gmd:code/gco:CharacterString');
if (isset($code[0]) && $code[0] != '') {
- $e = new mb_exception("class_wms.php: code given thru MD_Identifier: ".$code[0]);
+ $e = new mb_exception("plugins/mb_metadata_server.php: code given thru MD_Identifier: ".$code[0]);
//check if code is defined by codespace and code
$codeSplit = explode("#",$code);
if (isset($codeSplit[0]) && $codeSplit[0] != '' && isset($codeSplit[1]) && $codeSplit[1] != '') {
- $e = new mb_exception("class_wms.php: code was constructed via codespace#code !");
+ $e = new mb_exception("plugins/mb_metadata_server.php: code was constructed via codespace#code !");
$datasetid = $codeSplit[0]."#".$codeSplit[1];
} else {
- $e = new mb_exception("class_wms.php: code was not constructed via codespace#code !");
+ $e = new mb_exception("plugins/mb_metadata_server.php: code was not constructed via codespace#code !");
$datasetid = $code;
}
} else { //try to read code from RS_Identifier
$code = $iso19139Xml->xpath('/gmd:MD_Metadata/gmd:identificationInfo/gmd:MD_DataIdentification/gmd:citation/gmd:CI_Citation/gmd:identifier/gmd:RS_Identifier/gmd:code/gco:CharacterString');
$codeSpace = $iso19139Xml->xpath('/gmd:MD_Metadata/gmd:identificationInfo/gmd:MD_DataIdentification/gmd:citation/gmd:CI_Citation/gmd:identifier/gmd:RS_Identifier/gmd:codeSpace/gco:CharacterString');
- #$e = new mb_exception("class_wms.php: code: ".$code[0]);
- #$e = new mb_exception("class_wms.php: codeSpace: ".$codeSpace[0]);
+ #$e = new mb_exception("plugins/mb_metadata_server.php: code: ".$code[0]);
+ #$e = new mb_exception("plugins/mb_metadata_server.php: codeSpace: ".$codeSpace[0]);
if (isset($codeSpace[0]) && isset($code[0]) && $codeSpace[0] != '' && $code[0] != '') {
$datasetid = $codeSpace[0]."#".$code[0];
- $e = new mb_exception("class_wms.php: datasetid: ".$datasetid);
+ $e = new mb_exception("plugins/mb_metadata_server.php: datasetid: ".$datasetid);
} else {
//neither MD_Identifier nor RS_Identifier are defined in a right way
- $e = new mb_exception("class_wms.php: the service data coupling has problems, cause the metadata doesnt have defined a datasetid");
+ $e = new mb_exception("plugins/mb_metadata_server.php: the service data coupling has problems, cause the metadata doesnt have defined a datasetid");
}
}
More information about the Mapbender_commits
mailing list