[Mapbender-commits] r8698 - in trunk/mapbender: http/classes http/plugins resources/db/pgsql/UTF-8/update
svn_mapbender at osgeo.org
svn_mapbender at osgeo.org
Thu Aug 29 07:57:08 PDT 2013
Author: armin11
Date: 2013-08-29 07:57:08 -0700 (Thu, 29 Aug 2013)
New Revision: 8698
Modified:
trunk/mapbender/http/classes/class_iso19139.php
trunk/mapbender/http/plugins/mb_metadata_addon.php
trunk/mapbender/http/plugins/mb_metadata_server.php
trunk/mapbender/http/plugins/mb_metadata_wfs_server.php
trunk/mapbender/resources/db/pgsql/UTF-8/update/update_2.7.3_to_2.7.4_pgsql_UTF-8.sql
Log:
Enhancement to store url handle url for download at metadata level. The urls are stored as json in mb_metadata.datalinks column.
Modified: trunk/mapbender/http/classes/class_iso19139.php
===================================================================
--- trunk/mapbender/http/classes/class_iso19139.php 2013-08-28 20:04:37 UTC (rev 8697)
+++ trunk/mapbender/http/classes/class_iso19139.php 2013-08-29 14:57:08 UTC (rev 8698)
@@ -35,7 +35,7 @@
var $isoCategories = array();
var $inspireCategories = array();
var $customCategories = array();
-
+ var $downloadLinks = array(); //store in db as json object!!!!
var $hierachyLevel;
var $tmpExtentBegin;
var $tmpExtentEnd;
@@ -79,6 +79,7 @@
$this->isoCategories = array();
$this->inspireCategories = array();
$this->customCategories = array();
+ $this->downloadLinks = array();
//
$this->hierachyLevel = "dataset";
$this->tmpExtentBegin = "1900-01-01";
@@ -233,7 +234,10 @@
foreach ($this->customCategories as $category) {
$e = new mb_exception("class_iso19139.php: customcat: ".$category);
}
+ $this->downloadLinks = $iso19139Xml->xpath('/gmd:MD_Metadata/gmd:distributionInfo/gmd:MD_Distribution/gmd:transferOptions/gmd:MD_DigitalTransferOptions/gmd:onLine/gmd:CI_OnlineResource[gmd:function/gmd:CI_OnLineFunctionCode/@codeListValue="download"]/gmd:linkage/gmd:URL');
/*<gmd:extent><gmd:EX_Extent><gmd:geographicElement><gmd:EX_GeographicBoundingBox><gmd:westBoundLongitude><gco:Decimal>5</gco:Decimal></gmd:westBoundLongitude><gmd:eastBoundLongitude><gco:Decimal>10</gco:Decimal></gmd:eastBoundLongitude><gmd:southBoundLatitude><gco:Decimal>48</gco:Decimal></gmd:southBoundLatitude><gmd:northBoundLatitude><gco:Decimal>52</gco:Decimal></gmd:northBoundLatitude></gmd:EX_GeographicBoundingBox></gmd:geographicElement></gmd:EX_Extent></gmd:extent>*/
+ //esri
+ /*<gmd:extent><gmd:EX_Extent><gmd:geographicElement><gmd:EX_GeographicBoundingBox><gmd:westBoundLongitude><gco:Decimal>11.1414</gco:Decimal></gmd:westBoundLongitude><gmd:eastBoundLongitude><gco:Decimal>11.7284</gco:Decimal></gmd:eastBoundLongitude><gmd:southBoundLatitude><gco:Decimal>58.8838</gco:Decimal></gmd:southBoundLatitude><gmd:northBoundLatitude><gco:Decimal>59.2562</gco:Decimal></gmd:northBoundLatitude></gmd:EX_GeographicBoundingBox></gmd:geographicElement><gmd:temporalElement><gmd:EX_TemporalExtent><gmd:extent><gml:TimePeriod gml:id="idNummer1"><gml:beginPosition>1999-05-05</gml:beginPosition><gml:endPosition>2012-04-04</gml:endPosition></gml:TimePeriod></gmd:extent></gmd:EX_TemporalExtent></gmd:temporalElement></gmd:EX_Extent></gmd:extent>*/
//get bbox from xml:
$minx = $iso19139Xml->xpath('/gmd:MD_Metadata/gmd:identificationInfo/gmd:MD_DataIdentification/gmd:extent/gmd:EX_Extent/gmd:geographicElement/gmd:EX_GeographicBoundingBox/gmd:westBoundLongitude/gco:Decimal');
$minx = $minx[0];
@@ -691,7 +695,7 @@
$this->datasetIdCodeSpace = $row['datasetid_codespace'];
if (isset($row['bbox2d']) && $row['bbox2d'] != '') {
$bbox = str_replace(' ',',',str_replace(')','',str_replace('BOX(','',$row['bbox2d'])));
- $e = new mb_exception("class_iso19139.php: got bbox for metadata: ".$bbox);
+ //$e = new mb_exception("class_iso19139.php: got bbox for metadata: ".$bbox);
$this->wgs84Bbox = explode(',',$bbox);
}
//fill keywords and categories later cause they are stored in relations!
@@ -724,7 +728,10 @@
$this->updateFrequency = $row['update_frequency'];//"";
$this->dataFormat = $row['format'];//"";
$this->inspireCharset = $row['inspire_charset'];//"";
- //
+ //$test = print_r($row['datalinks'],true);
+ //$e = new mb_exception((string)$test);
+ $this->downloadLinks = $this->jsonDecodeDownloadLinks($row['datalinks']);
+ //$e = new mb_exception($this->downloadLinks[0]);
//$this->linkAlreadyInDB = false;
//$this->fileIdentifierAlreadyInDB = false;
//get relations from other tables:
@@ -868,7 +875,7 @@
}
//bequeath categories from coupled resources
$this->bequeathCategoriesToCoupledResource($metadataId,$resourceType,$resourceId);
- $e = new mb_exception("iso19139.php: bequeathed categories to ".$resourceType." : ".$resourceId);
+ //$e = new mb_exception("iso19139.php: bequeathed categories to ".$resourceType." : ".$resourceId);
$returnObject['success'] = true;
$returnObject['message'] = _mb("Internal metadata linkage inserted!");
return $returnObject;
@@ -1016,9 +1023,11 @@
$postGisBbox = "";
//"SRID=4326;POLYGON((-140 -80,-140 80,170 80,170 -80,-140 -80))"
$postGisBbox = "SRID=4326;POLYGON((".$bboxArray[0]." ".$bboxArray[1].",".$bboxArray[0]." ".$bboxArray[3].",".$bboxArray[2]." ".$bboxArray[3].",".$bboxArray[2]." ".$bboxArray[1].",".$bboxArray[0]." ".$bboxArray[1]."))";
+ //$e = new mb_exception("class_iso19139.php: bbox: ".$postGisBbox);
return $postGisBbox;
}
+
public function insertKeywordsAndCategoriesIntoDB($metadataId,$resourceType,$resourceId){
//first delete old classifications - after that create new ones
$this->deleteKeywordsAndCategoriesFromDB($metadataId,$resourceType,$resourceId);
@@ -1304,7 +1313,7 @@
public function insertMetadataIntoDB() {
//insert an instance for iso19139 into mapbenders database
$sql = <<<SQL
-INSERT INTO mb_metadata (lastchanged, link, origin, md_format, data, linktype, uuid, title, createdate, changedate, abstract, searchtext, type, tmp_reference_1, tmp_reference_2, export2csw, datasetid, datasetid_codespace, randomid, fkey_mb_user_id, harvestresult, harvestexception, lineage, inspire_top_consistence, spatial_res_type, spatial_res_value, update_frequency, format, inspire_charset, ref_system, the_geom) VALUES(now(), $1, $18, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $19, $20, $21, $22, $23, $24, $25, $26, $27, $28, $29, $30)
+INSERT INTO mb_metadata (lastchanged, link, origin, md_format, data, linktype, uuid, title, createdate, changedate, abstract, searchtext, type, tmp_reference_1, tmp_reference_2, export2csw, datasetid, datasetid_codespace, randomid, fkey_mb_user_id, harvestresult, harvestexception, lineage, inspire_top_consistence, spatial_res_type, spatial_res_value, update_frequency, format, inspire_charset, ref_system, the_geom, datalinks) VALUES(now(), $1, $18, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $19, $20, $21, $22, $23, $24, $25, $26, $27, $28, $29, $30, $31)
SQL;
$v = array(
$this->href,
@@ -1336,13 +1345,24 @@
$this->dataFormat,
$this->inspireCharset,
$this->refSystem,
- $this->createWktBboxFromArray($this->wgs84Bbox)
+ $this->createWktBboxFromArray($this->wgs84Bbox),
+ $this->jsonEncodeDownloadLinks($this->downloadLinks)
);
- $t = array('s','s','s','s','s','s','s','s','s','s','s','s','s','b','s','s','s','s','i','i','s','s','b','s','s','s','s','s','s','POLYGON');
+ $t = array('s','s','s','s','s','s','s','s','s','s','s','s','s','b','s','s','s','s','i','i','s','s','b','s','s','s','s','s','s','POLYGON','s');
$res = db_prep_query($sql,$v,$t);
return $res;
}
+ private function jsonEncodeDownloadLinks($dlArray) {
+ $dummy->downloadLinks = $dlArray;
+ return json_encode($dummy);
+ }
+ //TODO - maybe we will encode more things than only the url ;-)
+ private function jsonDecodeDownloadLinks($dlJson) {
+ $dummy = json_decode($dlJson);
+ $dummy = $dummy->downloadLinks;
+ return $dummy;
+ }
public function updateMetadataById($metadataId) {
//check if the timestamp of an existing metadata element is not newer than the timestamp of the current metadata object!!!!
@@ -1352,7 +1372,7 @@
$sql .= "linktype = $4, uuid = $5, title = $6, createdate = $7, changedate = $8, lastchanged = now(), ";
$sql .= "abstract = $9, searchtext = $10, type = $11, tmp_reference_1 = $12, tmp_reference_2 = $13, export2csw = $14, datasetid = $15, ";
$sql .= "datasetid_codespace = $16, randomid = $17, harvestresult = $20, harvestexception = $21, lineage = $22, inspire_top_consistence = $23, ";
- $sql .= "spatial_res_type = $24, spatial_res_value = $25, update_frequency = $26, format = $27, inspire_charset = $28, ref_system = $29, the_geom = $30 WHERE metadata_id = $19";
+ $sql .= "spatial_res_type = $24, spatial_res_value = $25, update_frequency = $26, format = $27, inspire_charset = $28, ref_system = $29, the_geom = $30, datalinks = $31 WHERE metadata_id = $19";
$v = array(
$this->href,
@@ -1385,9 +1405,10 @@
$this->dataFormat,
$this->inspireCharset,
$this->refSystem,
- $this->createWktBboxFromArray($this->wgs84Bbox)
+ $this->createWktBboxFromArray($this->wgs84Bbox),
+ $this->jsonEncodeDownloadLinks($this->downloadLinks)
);
- $t = array('s','s','s','s','s','s','s','s','s','s','s','s','s','b','s','s','s','s','i','i','s','s','b','s','s','s','s','s','s','POLYGON');
+ $t = array('s','s','s','s','s','s','s','s','s','s','s','s','s','b','s','s','s','s','i','i','s','s','b','s','s','s','s','s','s','POLYGON','s');
$res = db_prep_query($sql,$v,$t);
return $res;
}
Modified: trunk/mapbender/http/plugins/mb_metadata_addon.php
===================================================================
--- trunk/mapbender/http/plugins/mb_metadata_addon.php 2013-08-28 20:04:37 UTC (rev 8697)
+++ trunk/mapbender/http/plugins/mb_metadata_addon.php 2013-08-29 14:57:08 UTC (rev 8698)
@@ -221,22 +221,18 @@
<label for="west">
<?php echo _mb("West [decimal degrees]");?>
<input class="required" name="west" id="west"/>
-
- </label><br>
+ </label><br />
+ <label for="south">
+ <?php echo _mb("South [decimal degrees]");?>
+ <input class="required" name="south" id="south"/>
+ </label><br />
+ <label for="east">
+ <?php echo _mb("East [decimal degrees]");?>
+ <input class="required" name="east" id="east"/>
+ </label><br />
<label for="north">
<?php echo _mb("North [decimal degrees]");?>
<input class="required" name="north" id="north"/>
-
- </label><br>
- <label for="east">
- <?php echo _mb("East [decimal degrees]");?>
- <input class="required" name="east" id="east"/>
-
- </label><br>
- <label for="south">
- <?php echo _mb("South [decimal degrees]");?>
- <input class="required" name="south" id="south"/>
-
</label>
</fieldset>
<fieldset>
@@ -245,6 +241,12 @@
</fieldset>
</div>
<div id="tabs-6">
+ <fieldset>
+ <label for="downloadlink">
+ <?php echo _mb("Download link to dataset");?>
+ <input class="" name="downloadlink" id="downloadlink"/>
+ </label>
+ </fieldset>
</div>
<div id="tabs-7">
</div>
Modified: trunk/mapbender/http/plugins/mb_metadata_server.php
===================================================================
--- trunk/mapbender/http/plugins/mb_metadata_server.php 2013-08-28 20:04:37 UTC (rev 8697)
+++ trunk/mapbender/http/plugins/mb_metadata_server.php 2013-08-29 14:57:08 UTC (rev 8698)
@@ -668,6 +668,7 @@
$resultObj["south"] = $mbMetadata->wgs84Bbox[1];
$resultObj["east"] = $mbMetadata->wgs84Bbox[2];
$resultObj["north"] = $mbMetadata->wgs84Bbox[3];
+ $resultObj["downloadlink"] = $mbMetadata->downloadLinks[0]; //only the first link!
$export2csw = $mbMetadata->export2Csw; //boolean
$resultObj["update_frequency"] = $mbMetadata->updateFrequency; //text
switch ($export2csw) {
@@ -768,7 +769,7 @@
$mbMetadata->spatialResValue = $data->spatial_res_value;
$mbMetadata->inspireCharset = $data->inspire_charset;
$mbMetadata->updateFrequency = $data->update_frequency;
-
+ $mbMetadata->downloadLinks = array($data->downloadlink);
//categories ...
//new for keywords and classifications:
if (isset($data->keywords) && $data->keywords != "") {
@@ -942,6 +943,9 @@
if (isset($data->update_frequency)) {
$mbMetadata->updateFrequency = $data->update_frequency;
}
+ if (isset($data->update_frequency)) {
+ $mbMetadata->downloadLinks = array($data->downloadlink);
+ }
//new for keywords and classifications:
if (isset($data->keywords) && $data->keywords != "") {
$mbMetadata->keywords = array_map('trim',explode(',',$data->keywords));
Modified: trunk/mapbender/http/plugins/mb_metadata_wfs_server.php
===================================================================
--- trunk/mapbender/http/plugins/mb_metadata_wfs_server.php 2013-08-28 20:04:37 UTC (rev 8697)
+++ trunk/mapbender/http/plugins/mb_metadata_wfs_server.php 2013-08-29 14:57:08 UTC (rev 8698)
@@ -326,8 +326,8 @@
$metadataId = $ajaxResponse->getParameter("metadataId");
//TODO: check like operator and ambigious wfs_featuretype_epsg - are they not deleted on update? Get rid of the limit 1
$sql = <<<SQL
-SELECT featuretype_title, featuretype_abstract, minx as west, miny as south, maxx as east, maxy as north
-FROM wfs_featuretype INNER JOIN wfs_featuretype_epsg ON wfs_featuretype.featuretype_id = wfs_featuretype_epsg.fkey_featuretype_id WHERE featuretype_id = $1 AND epsg like '%:4326' LIMIT 1
+SELECT featuretype_title, featuretype_abstract, featuretype_latlon_bbox
+FROM wfs_featuretype WHERE featuretype_id = $1
SQL;
$v = array($featuretypeId);
$t = array('i');
@@ -336,11 +336,16 @@
if ($res) {
$row = db_fetch_assoc($res);
$resultObj["title"]= $row['featuretype_title']; //serial
- $resultObj["abstract"] = $row["featuretype_abstract"]; //char
- $resultObj["west"]= $row['west']; //double
- $resultObj["south"] = $row["south"]; //double
- $resultObj["east"]= $row['east']; //double
- $resultObj["north"] = $row["north"]; //double
+ $resultObj["abstract"] = $row["featuretype_abstract"]; //char
+ if (isset($resultObj["featuretype_latlon_bbox"]) && $resultObj["featuretype_latlon_bbox"] != '') {
+ $bbox = explode(',',$resultObj["featuretype_latlon_bbox"]);
+ } else {
+ $bbox = array(-180,-90,180,90);
+ }
+ $resultObj["west"] = $bbox[0]; //double
+ $resultObj["south"] = $bbox[1]; //double
+ $resultObj["east"]= $bbox[2]; //double
+ $resultObj["north"] = $bbox[3]; //double
}
$ajaxResponse->setResult($resultObj);
$ajaxResponse->setSuccess(true);
Modified: trunk/mapbender/resources/db/pgsql/UTF-8/update/update_2.7.3_to_2.7.4_pgsql_UTF-8.sql
===================================================================
--- trunk/mapbender/resources/db/pgsql/UTF-8/update/update_2.7.3_to_2.7.4_pgsql_UTF-8.sql 2013-08-28 20:04:37 UTC (rev 8697)
+++ trunk/mapbender/resources/db/pgsql/UTF-8/update/update_2.7.3_to_2.7.4_pgsql_UTF-8.sql 2013-08-29 14:57:08 UTC (rev 8698)
@@ -606,5 +606,9 @@
ALTER TABLE mb_metadata
ADD CONSTRAINT enforce_geotype_the_geom CHECK (geometrytype(the_geom) = 'MULTIPOLYGON'::text OR the_geom IS NULL OR geometrytype(the_geom) = 'POLYGON'::text);
+-- Column: datalinks - for storing download links to datasets as json object
+-- ALTER TABLE mb_metadata DROP COLUMN datalinks;
+ALTER TABLE mb_metadata ADD COLUMN datalinks text;
+
More information about the Mapbender_commits
mailing list