[Mapbender-commits] r9692 - trunk/mapbender/http/php
svn_mapbender at osgeo.org
svn_mapbender at osgeo.org
Tue Feb 21 09:47:47 PST 2017
Author: armin11
Date: 2017-02-21 09:47:47 -0800 (Tue, 21 Feb 2017)
New Revision: 9692
Modified:
trunk/mapbender/http/php/mod_featuretypeISOMetadata.php
Log:
some fixes
Modified: trunk/mapbender/http/php/mod_featuretypeISOMetadata.php
===================================================================
--- trunk/mapbender/http/php/mod_featuretypeISOMetadata.php 2017-02-21 12:43:28 UTC (rev 9691)
+++ trunk/mapbender/http/php/mod_featuretypeISOMetadata.php 2017-02-21 17:47:47 UTC (rev 9692)
@@ -26,10 +26,18 @@
require_once(dirname(__FILE__) . "/../php/mod_validateInspire.php");
require_once(dirname(__FILE__) . "/../classes/class_iso19139.php");
require_once(dirname(__FILE__) . "/../classes/class_XmlBuilder.php");
+require_once(dirname(__FILE__)."/../classes/class_owsConstraints.php");
+require_once(dirname(__FILE__)."/../classes/class_qualityReport.php");
$con = db_connect(DBSERVER,OWNER,PW);
db_select_db(DB,$con);
+if (DEFINED("MAPBENDER_PATH") && MAPBENDER_PATH !== "") {
+ $mapbenderServiceUrl = MAPBENDER_PATH."/php/wfs.php?INSPIRE=1&&FEATURETYPE_ID=";
+} else {
+ $mapbenderServiceUrl = $_SERVER['HTTP_HOST']."/mapbender/php/wfs.php?INSPIRE=1&FEATURETYPE_ID=";
+}
+
$admin = new administration();
//define the view or table to use as input for metadata generation if this is wished. If not, the data will be directly read from the database tables
@@ -151,13 +159,13 @@
//infos about the owner of the service - he is the man who administrate the metadata - register the service
$sql = "SELECT mb_user_email ";
$sql .= "FROM mb_user WHERE mb_user_id = $1";
- $v = array((integer)$mapbenderMetadata['wfs_owner']);
+ $v = array((integer)$mbMeta['wfs_owner']);
$t = array('i');
$res = db_prep_query($sql,$v,$t);
$userMetadata = db_fetch_array($res);
- //check if resource is freely available to anonymous user - which are all users who search thru metadata catalogues:
- $hasPermission=$admin->getLayerPermission($mapbenderMetadata['wfs_id'],$mapbenderMetadata['layer_name'],PUBLIC_USER); ##################
+ //TODO: check if resource is freely available to anonymous user - which are all users who search thru metadata catalogues:
+ //$hasPermission=$admin->getLayerPermission($mbMeta['wfs_id'],$mbMeta['layer_name'],PUBLIC_USER); ##################
$iso19139 = $xmlBuilder->getDoc();
@@ -218,7 +226,7 @@
$pos = 0;
//Create date elements B5.2-5.4 - format will be only a date - no dateTime given
//Do things for B 5.2 date of publication
- if (isset($mbMeta['wfs_timestamp_create'])) {
+ /*if (isset($mbMeta['wfs_timestamp_create'])) {
$pos++;
$chunk = './gmd:identificationInfo/srv:SV_ServiceIdentification/gmd:citation/gmd:CI_Citation/gmd:date[' . $pos . ']';
$xmlBuilder->addValue($MD_Metadata, $chunk . '/gmd:CI_Date/gmd:date/gco:Date', date('Y-m-d',$mbMeta['wfs_timestamp_create']));
@@ -226,7 +234,7 @@
$xmlBuilder->addValue($MD_Metadata, $chunk . '/gmd:CI_Date/gmd:dateType/gmd:CI_DateTypeCode/@codeListValue', "publication");
$xmlBuilder->addValue($MD_Metadata, $chunk . '/gmd:CI_Date/gmd:dateType/gmd:CI_DateTypeCode/@codeList',
"http://standards.iso.org/ittf/PubliclyAvailableStandards/ISO_19139_Schemas/resources/codelist/ML_gmxCodelists.xml#CI_DateTypeCode");
- }
+ }*/
//Do things for B 5.3 date of revision
if (isset($mbMeta['wfs_timestamp'])) {
@@ -243,7 +251,7 @@
if (isset($mbMeta['wfs_timestamp_creation'])) {
$pos++;
$chunk = './gmd:identificationInfo/srv:SV_ServiceIdentification/gmd:citation/gmd:CI_Citation/gmd:date[' . $pos . ']';
- $xmlBuilder->addValue($MD_Metadata, $chunk . '/gmd:CI_Date/gmd:date/gco:Date', date('Y-m-d',$mbMeta['wfs_timestamp']));
+ $xmlBuilder->addValue($MD_Metadata, $chunk . '/gmd:CI_Date/gco:Date', date('Y-m-d',$mbMeta['wfs_timestamp']));
$xmlBuilder->addValue($MD_Metadata, $chunk . '/gmd:CI_Date/gmd:dateType/gmd:CI_DateTypeCode', "creation");
$xmlBuilder->addValue($MD_Metadata, $chunk . '/gmd:CI_Date/gmd:dateType/gmd:CI_DateTypeCode/@codeListValue', "creation");
$xmlBuilder->addValue($MD_Metadata, $chunk . '/gmd:CI_Date/gmd:dateType/gmd:CI_DateTypeCode/@codeList',
@@ -284,7 +292,7 @@
$xmlBuilder->addValue($MD_Metadata,
'./gmd:identificationInfo/srv:SV_ServiceIdentification/gmd:pointOfContact/gmd:CI_ResponsibleParty/gmd:contactInfo/gmd:CI_Contact/gmd:onlineResource/gmd:CI_OnlineResource/gmd:linkage/gmd:URL',
- "not yet defined");
+ "http://www.mapbender.org");
//generate keyword part - for services the inspire themes are not applicable!!!
//read keywords for resource out of the database:
@@ -320,8 +328,7 @@
//Part B 3 INSPIRE Category
//do this only if an INSPIRE keyword (Annex I-III) is set
//Resource Constraints B 8
-
- $xmlBuilder->addValue($MD_Metadata,
+ /* $xmlBuilder->addValue($MD_Metadata,
'./gmd:identificationInfo/srv:SV_ServiceIdentification/gmd:resourceConstraints[1]/gmd:MD_LegalConstraints/gmd:accessConstraints/gmd:MD_RestrictionCode/@codeList',
"http://standards.iso.org/ittf/PubliclyAvailableStandards/ISO_19139_Schemas/resources/codelist/ML_gmxCodelists.xml#MD_RestrictionCode");
$xmlBuilder->addValue($MD_Metadata,
@@ -337,9 +344,8 @@
$xmlBuilder->addValue($MD_Metadata,
'./gmd:identificationInfo/srv:SV_ServiceIdentification/gmd:resourceConstraints[2]/gmd:MD_LegalConstraints/gmd:otherConstraints/gco:CharacterString',
- isset($mbMeta['accessconstraints']) & strtoupper($mbMeta['accessconstraints']) != 'NONE' ? $mbMeta['accessconstraints'] : "no constraints");
+ isset($mbMeta['accessconstraints']) & strtoupper($mbMeta['accessconstraints']) != 'NONE' ? $mbMeta['accessconstraints'] : "no constraints");*/
-
$xmlBuilder->addValue($MD_Metadata,
'./gmd:identificationInfo/srv:SV_ServiceIdentification/srv:serviceType/gco:LocalName',
'download');
@@ -443,76 +449,63 @@
}
$xmlBuilder->addValue($MD_Metadata,
- './gmd:identificationInfo/gmd:distributionInfo/gmd:MD_Distribution/gmd:distributionFormat/gmd:MD_Format/gmd:name/@gco:nilReason',
+ './gmd:distributionInfo/gmd:MD_Distribution/gmd:distributionFormat/gmd:MD_Format/gmd:name/@gco:nilReason',
'missing');
$xmlBuilder->addValue($MD_Metadata,
- './gmd:identificationInfo/gmd:distributionInfo/gmd:MD_Distribution/gmd:distributionFormat/gmd:MD_Format/gmd:version/@gco:nilReason',
+ './gmd:distributionInfo/gmd:MD_Distribution/gmd:distributionFormat/gmd:MD_Format/gmd:version/@gco:nilReason',
'missing');
//Check if anonymous user has rights to access this featyretype - if not ? which resource should be advertised? TODO
$url = '';
if ($hasPermission) {
- $url = "http://".$_SERVER['HTTP_HOST']."/mapbender/php/wfs.php?inspire=1&layer_id=".$mbMeta['featuretype_id']."&REQUEST=GetCapabilities&SERVICE=WFS";
+ $url = $mapbenderServiceUrl.$mbMeta['featuretype_id']."&REQUEST=GetCapabilities&SERVICE=WFS&VERSION=".$version;
} else {
- $url = "https://".$_SERVER['HTTP_HOST']."/http_auth/".$mbMeta['featuretype_id']."?REQUEST=GetCapabilities&SERVICE=WFS";
+ $url = "https://".$_SERVER['HTTP_HOST']."/registry/wfs/".$mbMeta['featuretype_id']."?REQUEST=GetCapabilities&SERVICE=WFS&VERSION=".$version;
}
$xmlBuilder->addValue($MD_Metadata,
- './gmd:identificationInfo/gmd:distributionInfo/gmd:MD_Distribution/gmd:transferOptions/gmd:MD_DigitalTransferOptions/gmd:onLine/gmd:CI_OnlineResource/gmd:linkage/gmd:URL',
+ './gmd:distributionInfo/gmd:MD_Distribution/gmd:transferOptions/gmd:MD_DigitalTransferOptions/gmd:onLine/gmd:CI_OnlineResource/gmd:linkage/gmd:URL',
$url);
// //append things which geonetwork needs to invoke service/layer or what else? - Here the name of the layer and the protocol seems to be needed?
// //a problem will occur, if the link to get map is not the same as the link to get caps? So how can we handle this? It seems to be very silly!
$xmlBuilder->addValue($MD_Metadata,
- './gmd:identificationInfo/gmd:distributionInfo/gmd:MD_Distribution/gmd:transferOptions/gmd:MD_DigitalTransferOptions/gmd:onLine/gmd:CI_OnlineResource/gmd:protocol/gco:CharacterString',
+ './gmd:distributionInfo/gmd:MD_Distribution/gmd:transferOptions/gmd:MD_DigitalTransferOptions/gmd:onLine/gmd:CI_OnlineResource/gmd:protocol/gco:CharacterString',
"OGC:WFS-".$mbMeta['wfs_version']."-http-get-feature");
$xmlBuilder->addValue($MD_Metadata,
- './gmd:identificationInfo/gmd:distributionInfo/gmd:MD_Distribution/gmd:transferOptions/gmd:MD_DigitalTransferOptions/gmd:onLine/gmd:CI_OnlineResource/gmd:name/gco:CharacterString',
+ './gmd:distributionInfo/gmd:MD_Distribution/gmd:transferOptions/gmd:MD_DigitalTransferOptions/gmd:onLine/gmd:CI_OnlineResource/gmd:name/gco:CharacterString',
$mbMeta['featuretype_name']);
$xmlBuilder->addValue($MD_Metadata,
- './gmd:identificationInfo/gmd:distributionInfo/gmd:MD_Distribution/gmd:transferOptions/gmd:MD_DigitalTransferOptions/gmd:onLine/gmd:CI_OnlineResource/gmd:description/gco:CharacterString',
+ './gmd:distributionInfo/gmd:MD_Distribution/gmd:transferOptions/gmd:MD_DigitalTransferOptions/gmd:onLine/gmd:CI_OnlineResource/gmd:description/gco:CharacterString',
$mbMeta['featuretype_abstract']);
$xmlBuilder->addValue($MD_Metadata,
- './gmd:identificationInfo/gmd:dataQualityInfo/gmd:DQ_DataQuality/gmd:scope/gmd:DQ_Scope/gmd:level/gmd:MD_ScopeCode/@codeList',
+ './gmd:dataQualityInfo/gmd:DQ_DataQuality/gmd:scope/gmd:DQ_Scope/gmd:level/gmd:MD_ScopeCode/@codeList',
'http://standards.iso.org/ittf/PubliclyAvailableStandards/ISO_19139_Schemas/resources/codelist/ML_gmxCodelists.xml#MD_ScopeCode');
$xmlBuilder->addValue($MD_Metadata,
- './gmd:identificationInfo/gmd:dataQualityInfo/gmd:DQ_DataQuality/gmd:scope/gmd:DQ_Scope/gmd:level/gmd:MD_ScopeCode/@codeListValue',
+ './gmd:dataQualityInfo/gmd:DQ_DataQuality/gmd:scope/gmd:DQ_Scope/gmd:level/gmd:MD_ScopeCode/@codeListValue',
'service');
$xmlBuilder->addValue($MD_Metadata,
- './gmd:identificationInfo/gmd:dataQualityInfo/gmd:DQ_DataQuality/gmd:scope/gmd:DQ_Scope/gmd:level/gmd:MD_ScopeCode',
+ './gmd:dataQualityInfo/gmd:DQ_DataQuality/gmd:scope/gmd:DQ_Scope/gmd:level/gmd:MD_ScopeCode',
'service');
//TODO put in the inspire test suites from mb database!
$xmlBuilder->addValue($MD_Metadata,
- './gmd:identificationInfo/gmd:dataQualityInfo/gmd:DQ_DataQuality/gmd:report/gmd:DQ_DomainConsistency/gmd:result/gmd:DQ_ConformanceResult/gmd:specification/gmd:CI_Citation/gmd:title/gco:CharacterString',
+ './gmd:dataQualityInfo/gmd:DQ_DataQuality/gmd:report/gmd:DQ_DomainConsistency/gmd:result/gmd:DQ_ConformanceResult/gmd:specification/gmd:CI_Citation/gmd:title/gco:CharacterString',
'OpenGIS Web Feature Service 2.0 Interface Standard (OGC 09-025r1 and ISO/DIS 19142)');
//TODO put in the info from database
$xmlBuilder->addValue($MD_Metadata,
- './gmd:identificationInfo/gmd:dataQualityInfo/gmd:DQ_DataQuality/gmd:report/gmd:DQ_DomainConsistency/gmd:result/gmd:DQ_ConformanceResult/gmd:specification/gmd:CI_Citation/gmd:date/gmd:CI_Date/gmd:date/gco:Date',
+ './gmd:dataQualityInfo/gmd:DQ_DataQuality/gmd:report/gmd:DQ_DomainConsistency/gmd:result/gmd:DQ_ConformanceResult/gmd:specification/gmd:CI_Citation/gmd:date/gmd:CI_Date/gmd:date/gco:Date',
date('Y-m-d',$mbMeta['wfs_timestamp']));
-
$xmlBuilder->addValue($MD_Metadata,
- './gmd:identificationInfo/gmd:dataQualityInfo/gmd:DQ_DataQuality/gmd:report/gmd:DQ_DomainConsistency/gmd:result/gmd:DQ_ConformanceResult/gmd:specification/gmd:CI_Citation/gmd:dateType/gmd:CI_DateTypeCode/@codeList',
- "http://standards.iso.org/ittf/PubliclyAvailableStandards/ISO_19139_Schemas/resources/codelist/ML_gmxCodelists.xml#CI_DateTypeCode");
- $xmlBuilder->addValue($MD_Metadata,
- './gmd:identificationInfo/gmd:dataQualityInfo/gmd:DQ_DataQuality/gmd:report/gmd:DQ_DomainConsistency/gmd:result/gmd:DQ_ConformanceResult/gmd:specification/gmd:CI_Citation/gmd:dateType/gmd:CI_DateTypeCode/@codeListValue',
- "publication");
- $xmlBuilder->addValue($MD_Metadata,
- './gmd:identificationInfo/gmd:dataQualityInfo/gmd:DQ_DataQuality/gmd:report/gmd:DQ_DomainConsistency/gmd:result/gmd:DQ_ConformanceResult/gmd:specification/gmd:CI_Citation/gmd:dateType/gmd:CI_DateTypeCode',
- "publication");
-
- $xmlBuilder->addValue($MD_Metadata,
- './gmd:identificationInfo/gmd:dataQualityInfo/gmd:DQ_DataQuality/gmd:report/gmd:DQ_DomainConsistency/gmd:result/gmd:DQ_ConformanceResult/gmd:explanation/gco:CharacterString',
+ './gmd:dataQualityInfo/gmd:DQ_DataQuality/gmd:report/gmd:DQ_DomainConsistency/gmd:result/gmd:DQ_ConformanceResult/gmd:explanation/gco:CharacterString',
'No explanation available'); # Der Dienst ist konform zum WFS 2.0 Standard (nicht zertifiziert). ?
+
$xmlBuilder->addValue($MD_Metadata,
- './gmd:identificationInfo/gmd:dataQualityInfo/gmd:DQ_DataQuality/gmd:report/gmd:DQ_DomainConsistency/gmd:result/gmd:DQ_ConformanceResult/gmd:pass/gco:Boolean',
+ './gmd:dataQualityInfo/gmd:DQ_DataQuality/gmd:report/gmd:DQ_DomainConsistency/gmd:result/gmd:DQ_ConformanceResult/gmd:pass/gco:Boolean',
'true');
- $xmlBuilder->addValue($MD_Metadata,
- './gmd:identificationInfo/gmd:dataQualityInfo/gmd:DQ_DataQuality/gmd:lineage/gmd:LI_Lineage/gmd:statement/gco:CharacterString',
- 'WFS lineage');
return $xmlBuilder->getDoc()->saveXML();
}
@@ -520,6 +513,9 @@
//function to give away the xml data
function pushISO19139(XmlBuilder $xmlBuilder, $recordId, $outputFormat) {
$xml = fillISO19139($xmlBuilder, $recordId);
+ //exchange information
+ //exchange constraints
+ $xml = exchangeConstraintsAndConformity($xml, $recordId);
proxyFile($xml, $outputFormat);
die();
}
@@ -554,6 +550,99 @@
}
+function exchangeConstraintsAndConformity($metadataXml, $recordId) {
+ //get wfs_id from database
+ $sql = "SELECT fkey_wfs_id FROM wfs_featuretype WHERE featuretype_id = $1 LIMIT 1";
+ $v = array((integer)$recordId);
+ $t = array('i');
+ $res = db_prep_query($sql,$v,$t);
+ if ($res !== false) {
+ $row = db_fetch_array($res);
+ $serviceId = $row['fkey_wfs_id'];
+ //parse XML part
+ //echo $metadataXml;
+ //die();
+ //do parsing with dom, cause we want to alter the xml which have been parsed afterwards
+ $metadataDomObject = new DOMDocument();
+ libxml_use_internal_errors(true);
+ try {
+ $metadataDomObject->loadXML($metadataXml);
+ if ($metadataDomObject === false) {
+ foreach(libxml_get_errors() as $error) {
+ $err = new mb_exception("php/mod_featuretypeISOMetadata.php:".$error->message);
+ }
+ throw new Exception("php/mod_featuretypeISOMetadata.php:".'Cannot parse metadata with dom!');
+ }
+ }
+ catch (Exception $e) {
+ $err = new mb_exception("php/mod_featuretypeISOMetadata.php:".$e->getMessage());
+ }
+ if ($metadataDomObject !== false) {
+ //importing namespaces
+ $xpath = new DOMXPath($metadataDomObject);
+ $rootNamespace = $metadataDomObject->lookupNamespaceUri($metadataDomObject->namespaceURI);
+ $xpath->registerNamespace('defaultns', $rootNamespace);
+ //$xpath->registerNamespace('georss','http://www.georss.org/georss');
+ $xpath->registerNamespace("csw", "http://www.opengis.net/cat/csw/2.0.2");
+ $xpath->registerNamespace("gml", "http://www.opengis.net/gml");
+ $xpath->registerNamespace("gco", "http://www.isotc211.org/2005/gco");
+ $xpath->registerNamespace("gmd", "http://www.isotc211.org/2005/gmd");
+ $xpath->registerNamespace("gts", "http://www.isotc211.org/2005/gts");
+ $xpath->registerNamespace("srv", "http://www.isotc211.org/2005/srv");
+ $xpath->registerNamespace("xlink", "http://www.w3.org/1999/xlink");
+ //licenses
+ //pull licence information
+ $constraints = new OwsConstraints();
+ $constraints->languageCode = "de";
+ $constraints->asTable = false;
+ $constraints->id = $serviceId;
+ $constraints->type = "wfs";
+ $constraints->returnDirect = false;
+ $constraints->outputFormat='iso19139';
+ $tou = $constraints->getDisclaimer();
+ //constraints - after descriptive keywords
+ if (isset($tou) && $tou !== '' && $tou !== false) {
+ //count old resourceConstraints elements
+ $resourceConstraintsNodeList = $xpath->query('/gmd:MD_Metadata/gmd:identificationInfo/srv:SV_ServiceIdentification/gmd:resourceConstraints');
+ //load xml from constraint generator
+ $licenseDomObject = new DOMDocument();
+ $licenseDomObject->loadXML($tou);
+ $xpathLicense = new DOMXpath($licenseDomObject);
+ $licenseNodeList = $xpathLicense->query('/mb:constraints/gmd:resourceConstraints');
+ //insert new constraints before first old constraints node
+ for ($i = ($licenseNodeList->length)-1; $i >= 0; $i--) {
+ $resourceConstraintsNodeList->item(0)->parentNode->insertBefore($metadataDomObject->importNode($licenseNodeList->item($i), true), $resourceConstraintsNodeList->item(0));
+ }
+ //delete all resourceConstraints from original xml document
+ for ($i = 0; $i < $resourceConstraintsNodeList->length; $i++) {
+ $temp = $resourceConstraintsNodeList->item($i); //avoid calling a function twice
+ $temp->parentNode->removeChild($temp);
+ }
+ }
+ //exchange conformity declaration if service version is 2.0 and metadata should also be conform TODO filter those featuretypes - not done til now!!!
+ $qualityReport = new QualityReport();
+ //All services are conform
+ $inputXml = $qualityReport->getIso19139Representation("service", "t");
+ $reportDomObject = new DOMDocument();
+ $reportDomObject->loadXML($inputXml);
+ $xpathInput = new DOMXpath($reportDomObject);
+ $inputNodeList = $xpathInput->query('/mb:dataqualityreport/gmd:report');
+ $conformanceDeclarationNodeList = $xpath->query('/gmd:MD_Metadata/gmd:dataQualityInfo/gmd:DQ_DataQuality/gmd:report');
+ //insert new conformance declaration before first old conformance declaration
+ for ($i = ($inputNodeList->length)-1; $i >= 0; $i--) {
+ $conformanceDeclarationNodeList->item(0)->parentNode->insertBefore($metadataDomObject->importNode($inputNodeList->item($i), true), $conformanceDeclarationNodeList->item(0));
+ }
+ //delete all conformance declarations from original xml document
+ for ($i = 0; $i < $conformanceDeclarationNodeList->length; $i++) {
+ $temp = $conformanceDeclarationNodeList->item($i); //avoid calling a function twice
+ $temp->parentNode->removeChild($temp);
+ }
+ //test http://localhost/mb_trunk/php/mod_dataISOMetadata.php?outputFormat=iso19139&id=0da11651-aa61-d75a-446c-ea4ea073bc48
+ }
+ return $metadataDomObject->saveXML();
+ }
+}
+
function getEpsgByLayerId ($layer_id) { // from merge_layer.php
$epsg_list = "";
$sql = "SELECT DISTINCT epsg FROM layer_epsg WHERE fkey_layer_id = $1";
More information about the Mapbender_commits
mailing list