[Mapbender-commits] r8173 - in trunk/mapbender/http: classes php
plugins
svn_mapbender at osgeo.org
svn_mapbender at osgeo.org
Mon Oct 3 05:45:51 EDT 2011
Author: armin11
Date: 2011-10-03 02:45:50 -0700 (Mon, 03 Oct 2011)
New Revision: 8173
Modified:
trunk/mapbender/http/classes/class_wms.php
trunk/mapbender/http/php/mod_dataISOMetadata.php
trunk/mapbender/http/php/mod_layerISOMetadata.php
trunk/mapbender/http/php/wms.php
trunk/mapbender/http/plugins/mb_metadata_server.php
Log:
Extension for INSPIRE conformant layer metadata editor. It now parses either MD_Identifier or RS_Identifier if coupled datasets are given. The simple editor now gets a new constant METADATA_DEFAULT_CODESPACE which is defined in the mapbender.conf. Some further things have to be done, but this is conformant with the way the GDI-DE will handle the service-dataset metadata coupling.
Modified: trunk/mapbender/http/classes/class_wms.php
===================================================================
--- trunk/mapbender/http/classes/class_wms.php 2011-09-28 13:47:25 UTC (rev 8172)
+++ trunk/mapbender/http/classes/class_wms.php 2011-10-03 09:45:50 UTC (rev 8173)
@@ -2010,7 +2010,7 @@
// GET SRS_ARRAY of mapbender.conf
if(SRS_ARRAY != "") {
- $confSrsArray = split(",",SRS_ARRAY);
+ $confSrsArray = explode(",",SRS_ARRAY);
foreach($confSrsArray as &$srs) {
$srs = trim($srs);
}
@@ -2212,18 +2212,35 @@
$title = $iso19139Xml->xpath('/gmd:MD_Metadata/gmd:identificationInfo/gmd:MD_DataIdentification/gmd:citation/gmd:CI_Citation/gmd:title/gco:CharacterString');
//dataset identifier - howto model into md_metadata?
//check where datasetid is defined - maybe as RS_Identifier or as MD_Identifier see http://inspire.jrc.ec.europa.eu/documents/Metadata/INSPIRE_MD_IR_and_ISO_v1_2_20100616.pdf page 18
- $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]);
- if (isset($codeSpace[0]) && isset($code[0]) && $codeSpace[0] != '' && $code[0] != '') {
+ //First check if MD_Identifier is set, then check if RS_Identifier is used!
+ //Initialize datasetid
+ $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]);
+ //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 !");
+ $datasetid = $codeSplit[0]."#".$codeSplit[1];
- $datasetid = $codeSpace[0]."#".$code[0];
- $e = new mb_exception("class_wms.php: datasetid: ".$datasetid);
- } else {
-
- $datasetid = 'undefined';# in sense of INSPIRE TODO control MD_Identifier too!
- $e = new mb_exception("class_wms.php: datasetid: ".$datasetid);
+
+ } else {
+ $e = new mb_exception("class_wms.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]);
+ 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);
+ } 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");
+ }
}
//abstract
$abstract = $iso19139Xml->xpath('/gmd:MD_Metadata/gmd:identificationInfo/gmd:MD_DataIdentification/gmd:abstract/gco:CharacterString');
Modified: trunk/mapbender/http/php/mod_dataISOMetadata.php
===================================================================
--- trunk/mapbender/http/php/mod_dataISOMetadata.php 2011-09-28 13:47:25 UTC (rev 8172)
+++ trunk/mapbender/http/php/mod_dataISOMetadata.php 2011-10-03 09:45:50 UTC (rev 8173)
@@ -532,12 +532,17 @@
$CI_Citation->appendChild($date1);
}
*/
- #Do things for B 1.5 Resource unique identifier NOTE: not applicable for services
+
+
+#Do things for B 1.5 Resource unique identifier NOTE: not applicable for services
//example from INSPIRE Guidance Metadata
//The main problem will be, that this entry is the identifier for the service data coupling
//to make it easy, we will use the same identifier as for fileidentifier! In case of external datasets, the right data identifier must be harvested!
//
+//*******exchanged with some new german specific way - use MD_Identifier
+
/*<gmd:identifier><gmd:RS_Identifier><gmd:code><gco:CharacterString>gdi-rp</gco:CharacterString></gmd:code><gmd:codeSpace><gco:CharacterString>gdi-rp</gco:CharacterString></gmd:codeSpace></gmd:RS_Identifier></gmd:identifier>*/
+/*
$identifier=$iso19139->createElement("gmd:identifier");
$rs_identifier=$iso19139->createElement("gmd:RS_Identifier");
@@ -556,12 +561,32 @@
$codeSpace_cs->appendChild($codeSpaceText);
$codeSpace->appendChild($codeSpace_cs);
$rs_identifier->appendChild($codeSpace);
+*/
+//****** exchanged with some kind of MD_Identifier - cause this has to bee defined for german datasets
+/*<gmd:identifier><gmd:MD_Identifier><gmd:code><gco:CharacterString>gdi-rp</gco:CharacterString></gmd:code></gmd:MD_Identifier></gmd:identifier>*/
+ $identifier=$iso19139->createElement("gmd:identifier");
+ $md_identifier=$iso19139->createElement("gmd:MD_Identifier");
+ $code=$iso19139->createElement("gmd:code");
+ $code_cs=$iso19139->createElement("gco:CharacterString");
+ if (defined('METADATA_DEFAULT_CODESPACE')) {
+ $codeText=$iso19139->createTextNode(METADATA_DEFAULT_CODESPACE."#".$mb_metadata['uuid']); //in case of the mapbender addon!
+ } else {
+ $codeText=$iso19139->createTextNode("http://www.mapender.org"."#".$mb_metadata['uuid']); //in case of the mapbender addon!
+ }
- $identifier->appendChild($rs_identifier);
+ $code_cs->appendChild($codeText);
+ $code->appendChild($code_cs);
+ $md_identifier->appendChild($code);
+
+ $identifier->appendChild($md_identifier);
$CI_Citation->appendChild($identifier);
+
+
+
+
$citation->appendChild($CI_Citation);
$MD_DataIdentification->appendChild($citation);
Modified: trunk/mapbender/http/php/mod_layerISOMetadata.php
===================================================================
--- trunk/mapbender/http/php/mod_layerISOMetadata.php 2011-09-28 13:47:25 UTC (rev 8172)
+++ trunk/mapbender/http/php/mod_layerISOMetadata.php 2011-10-03 09:45:50 UTC (rev 8173)
@@ -734,7 +734,12 @@
break;
case 'metador':
$operatesOn=$iso19139->createElement("srv:operatesOn");
- $operatesOn->setAttribute("xlink:href", "http://www.geoportal.rlp.de#".$row_metadata['uuid']);
+ if (defined('METADATA_DEFAULT_CODESPACE')) {
+ $operatesOn->setAttribute("xlink:href", METADATA_DEFAULT_CODESPACE."#".$row_metadata['uuid']);
+ } else {
+ $operatesOn->setAttribute("xlink:href", "http://www.mapbender.org#".$row_metadata['uuid']);
+ }
+
$SV_ServiceIdentification->appendChild($operatesOn);
break;
case 'external':
Modified: trunk/mapbender/http/php/wms.php
===================================================================
--- trunk/mapbender/http/php/wms.php 2011-09-28 13:47:25 UTC (rev 8172)
+++ trunk/mapbender/http/php/wms.php 2011-10-03 09:45:50 UTC (rev 8173)
@@ -1096,7 +1096,8 @@
while ($row_metadata = db_fetch_array($res_metadata)) {
//check id datasetid is set, if not use metadataid
if ($row_metadata["datasetid"] == '' || !isset($row_metadata["datasetid"])) {
- $datasetId = $row_metadata["uuid"];
+ //this column is empty, if metador was used and the identifier for dataset id is equal to the identifier of the metadata fileidentifier. In this case we expand a standard codespace http://www.geoportal.rlp.de TODO: use a define in mapbender.conf to pull the standard codespace from!
+ $datasetId = "http://www.geoportal.rlp.de"."#".$row_metadata["uuid"];
} else {
$datasetId = $row_metadata["datasetid"]; //really datasetid or only second part?
}
Modified: trunk/mapbender/http/plugins/mb_metadata_server.php
===================================================================
--- trunk/mapbender/http/plugins/mb_metadata_server.php 2011-09-28 13:47:25 UTC (rev 8172)
+++ trunk/mapbender/http/plugins/mb_metadata_server.php 2011-10-03 09:45:50 UTC (rev 8173)
@@ -786,20 +786,37 @@
//TODO: check if this is set, maybe DateTime must be searched instead?
//title
$title = $iso19139Xml->xpath('/gmd:MD_Metadata/gmd:identificationInfo/gmd:MD_DataIdentification/gmd:citation/gmd:CI_Citation/gmd:title/gco:CharacterString');
+ //datasetid
+ //next came from class_wms - TODO maybe put it into a special function
//dataset identifier - howto model into md_metadata?
//check where datasetid is defined - maybe as RS_Identifier or as MD_Identifier see http://inspire.jrc.ec.europa.eu/documents/Metadata/INSPIRE_MD_IR_and_ISO_v1_2_20100616.pdf page 18
- $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_notice("class_wms.php: code: ".$code[0]);
- $e = new mb_notice("class_wms.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);
- } else {
-
- $datasetid = 'undefined';# in sense of INSPIRE TODO control MD_Identifier too!
- $e = new mb_exception("class_wms.php: datasetid: ".$datasetid);
+ //First check if MD_Identifier is set, then check if RS_Identifier is used!
+ //Initialize datasetid
+ $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]);
+ //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 !");
+ $datasetid = $codeSplit[0]."#".$codeSplit[1];
+ } else {
+ $e = new mb_exception("class_wms.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]);
+ 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);
+ } 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");
+ }
}
//abstract
$abstract = $iso19139Xml->xpath('/gmd:MD_Metadata/gmd:identificationInfo/gmd:MD_DataIdentification/gmd:abstract/gco:CharacterString');
@@ -841,6 +858,7 @@
//give back error message - cause parsing has problems
}
} 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
INSERT INTO mb_metadata (link, uuid, origin, title, abstract, format, ref_system, export2csw, inspire_top_consistence, tmp_reference_1, tmp_reference_2, lineage, spatial_res_type, spatial_res_value, inspire_charset, createdate, randomid, update_frequency) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, now(), $16, $17)
@@ -978,19 +996,39 @@
//TODO: check if this is set, maybe DateTime must be searched instead?
//title
$title = $iso19139Xml->xpath('/gmd:MD_Metadata/gmd:identificationInfo/gmd:MD_DataIdentification/gmd:citation/gmd:CI_Citation/gmd:title/gco:CharacterString');
+ //next came from class_wms - TODO maybe put it into a special function
//dataset identifier - howto model into md_metadata?
//check where datasetid is defined - maybe as RS_Identifier or as MD_Identifier see http://inspire.jrc.ec.europa.eu/documents/Metadata/INSPIRE_MD_IR_and_ISO_v1_2_20100616.pdf page 18
- $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_notice("plugins/mb_metadata_server.php: code: ".$code[0]);
- $e = new mb_notice("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_notice("class_wms.php: datasetid: ".$datasetid);
- } else {
- $datasetid = 'undefined';# in sense of INSPIRE TODO control MD_Identifier too!
- $e = new mb_notice("class_wms.php: datasetid: ".$datasetid);
+ //First check if MD_Identifier is set, then check if RS_Identifier is used!
+ //Initialize datasetid
+ $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]);
+ //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 !");
+ $datasetid = $codeSplit[0]."#".$codeSplit[1];
+ } else {
+ $e = new mb_exception("class_wms.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]);
+ 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);
+ } 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");
+ }
}
+
+
//abstract
$abstract = $iso19139Xml->xpath('/gmd:MD_Metadata/gmd:identificationInfo/gmd:MD_DataIdentification/gmd:abstract/gco:CharacterString');
//searchtext -- use keywords!
More information about the Mapbender_commits
mailing list