[Mapbender-commits] r10099 - trunk/mapbender/http/php
svn_mapbender at osgeo.org
svn_mapbender at osgeo.org
Thu Apr 11 06:07:10 PDT 2019
Author: armin11
Date: 2019-04-11 06:07:10 -0700 (Thu, 11 Apr 2019)
New Revision: 10099
Modified:
trunk/mapbender/http/php/mod_callCswMetadata.php
Log:
Fix problem when using json_encode for strings with problematic encodings - like portugues
Modified: trunk/mapbender/http/php/mod_callCswMetadata.php
===================================================================
--- trunk/mapbender/http/php/mod_callCswMetadata.php 2019-04-11 08:41:44 UTC (rev 10098)
+++ trunk/mapbender/http/php/mod_callCswMetadata.php 2019-04-11 13:07:10 UTC (rev 10099)
@@ -805,6 +805,7 @@
for ($k = 1; $k <= count($metadataRecord) ; $k++) {
$fileIdentifier = $cswClient->operationResult->xpath('/csw:GetRecordsResponse/csw:SearchResults/gmd:MD_Metadata['.$k.']/gmd:fileIdentifier/gco:CharacterString');
$fileIdentifier = (string)$fileIdentifier[0];
+ //$e = new mb_exception("id: ".$k." - fileIdentifier: ".$fileIdentifier);
$resultObject->{$searchResource}->srv[$k-1]->id = $fileIdentifier;
$mdDateStamp = $cswClient->operationResult->xpath('/csw:GetRecordsResponse/csw:SearchResults/gmd:MD_Metadata['.$k.']/gmd:dateStamp/gco:Date');
if(empty($mdDateStamp)){
@@ -812,7 +813,7 @@
}
$mdDateStamp = (string)$mdDateStamp[0];
$resultObject->{$searchResource}->srv[$k-1]->date = $mdDateStamp;
- /* WORKAROUND
+ /* WORKAROUND TO allow wrong metadata :-(
switch ($searchResource) {
case "service":
$identifikationXPath = "srv:SV_ServiceIdentification";
@@ -823,7 +824,6 @@
}
*/
$identifikationXPath = "";
-
$datasetIdentifier = $cswClient->operationResult->xpath('/csw:GetRecordsResponse/csw:SearchResults/gmd:MD_Metadata['.$k.']/gmd:identificationInfo/'.$identifikationXPath.'/@uuid');
$datasetidentifier = (string)$datasetidentifier[0];
//preview image if available
@@ -852,7 +852,9 @@
//mdLink
//geturl for get recordbyid request
if (isset($csw->cat_op_values['getrecordbyid']['get'])) {
- $resultObject->{$searchResource}->srv[$k-1]->mdLink = $csw->cat_op_values['getrecordbyid']['get']."?request=GetRecordById&service=CSW&version=2.0.2&Id=".$fileIdentifier."&ElementSetName=full&OUTPUTSCHEMA=http://www.isotc211.org/2005/gmd";
+ $resultObject->{$searchResource}->srv[$k-1]->mdLink = $csw->cat_op_values['getrecordbyid']['get']."?request=GetRecordById&service=CSW&version=2.0.2&Id=".str_replace("{","",str_replace("}","",$fileIdentifier))."&ElementSetName=full&OUTPUTSCHEMA=http://www.isotc211.org/2005/gmd";
+ //$e = new mb_exception("url: ".$k." - getrecordbyid: ".$resultObject->{$searchResource}->srv[$k-1]->mdLink);
+ //we have problems with fileIdentifier of from {XXX} from inspire portal - those cannot be pulled via mdLink - the {} have to be removed!
}
//service type
$typeOfService = $cswClient->operationResult->xpath('/csw:GetRecordsResponse/csw:SearchResults/gmd:MD_Metadata['.$k.']/gmd:identificationInfo/srv:SV_ServiceIdentification/srv:serviceType/gco:LocalName');
@@ -876,8 +878,6 @@
$isViewService = true;
//echo "view service identified<br>";
}
-
-
if ($typeOfServiceUpper == 'DOWNLOAD' || $typeOfServiceUpper == 'ATOM' || strpos($typeOfServiceUpper,'PREDEFINED ATOM') !== false) {
$isDownloadService = true;
//echo "view service identified<br>";
@@ -938,10 +938,11 @@
}
$i++;
}
-
+//Problem portugal metadata json_encode
+//https://stackoverflow.com/questions/23652082/json-encode-issue-when-parsing-array-with-portuguese-character-in-php - use: JSON_PARTIAL_OUTPUT_ON_ERROR
//add filter object
$resultObject->searchFilter = $queryJSON->searchFilter;
-echo json_encode($resultObject);
+echo json_encode($resultObject, JSON_PARTIAL_OUTPUT_ON_ERROR);
//}
//************************************************************************************
//functions
More information about the Mapbender_commits
mailing list