[Mapbender-commits] r9036 - trunk/mapbender/http/php
svn_mapbender at osgeo.org
svn_mapbender at osgeo.org
Thu Aug 7 06:06:08 PDT 2014
Author: armin11
Date: 2014-08-07 06:06:08 -0700 (Thu, 07 Aug 2014)
New Revision: 9036
Modified:
trunk/mapbender/http/php/mod_inspireDownloadFeed.php
Log:
Enhancement for ATOM Feed generator: It is now possible to use a GML3 polygon to intersect the bboxes of the wms getmap and wfs getfeature requests. So no more empty tiles have to be provided ;-). It is testet with more than 8000 tiles and the performance is good.
Modified: trunk/mapbender/http/php/mod_inspireDownloadFeed.php
===================================================================
--- trunk/mapbender/http/php/mod_inspireDownloadFeed.php 2014-08-07 13:00:45 UTC (rev 9035)
+++ trunk/mapbender/http/php/mod_inspireDownloadFeed.php 2014-08-07 13:06:08 UTC (rev 9036)
@@ -568,38 +568,38 @@
switch ($generateFrom) {
case "dataurl":
$sql = <<<SQL
-select *, 'dataurl' as origin from (select * from (select * from (select * from (select mb_metadata.metadata_id, layer_relation.layer_name,layer_relation.inspire_download, layer_relation.fkey_wms_id, layer_relation.layer_id, mb_metadata.uuid as metadata_uuid, mb_metadata.format,mb_metadata.title as metadata_title, mb_metadata.abstract as metadata_abstract, box2d(mb_metadata.the_geom) as metadata_bbox, layer_relation.layer_title, layer_relation.layer_abstract, mb_metadata.ref_system as metadata_ref_system, mb_metadata.datasetid, mb_metadata.spatial_res_type, mb_metadata.spatial_res_value, mb_metadata.datasetid_codespace, mb_metadata.lastchanged as md_timestamp from (select * from layer inner join ows_relation_metadata on layer.layer_id = ows_relation_metadata.fkey_layer_id) as layer_relation inner join mb_metadata on layer_relation.fkey_metadata_id = mb_metadata.metadata_id where mb_metadata.uuid = $1) as layer_metadata inner join ows_relation_data on ows_relation_data.fkey
_layer_id = layer_metadata.layer_id) as layer_relation_data inner join datalink on layer_relation_data.fkey_datalink_id = datalink.datalink_id) as layer_data inner join wms on layer_data.fkey_wms_id = wms.wms_id) as layer_wms, layer_epsg where layer_wms.layer_id = layer_epsg.fkey_layer_id and layer_epsg.epsg = 'EPSG:4326';
+select *, 'dataurl' as origin from (select * from (select * from (select * from (select mb_metadata.metadata_id, layer_relation.layer_name,layer_relation.inspire_download, layer_relation.fkey_wms_id, layer_relation.layer_id, mb_metadata.uuid as metadata_uuid, mb_metadata.format,mb_metadata.title as metadata_title, mb_metadata.abstract as metadata_abstract, box2d(mb_metadata.the_geom) as metadata_bbox, mb_metadata.bounding_geom as polygon, layer_relation.layer_title, layer_relation.layer_abstract, mb_metadata.ref_system as metadata_ref_system, mb_metadata.datasetid, mb_metadata.spatial_res_type, mb_metadata.spatial_res_value, mb_metadata.datasetid_codespace, mb_metadata.lastchanged as md_timestamp from (select * from layer inner join ows_relation_metadata on layer.layer_id = ows_relation_metadata.fkey_layer_id) as layer_relation inner join mb_metadata on layer_relation.fkey_metadata_id = mb_metadata.metadata_id where mb_metadata.uuid = $1) as layer_metadata inner join ows_r
elation_data on ows_relation_data.fkey_layer_id = layer_metadata.layer_id) as layer_relation_data inner join datalink on layer_relation_data.fkey_datalink_id = datalink.datalink_id) as layer_data inner join wms on layer_data.fkey_wms_id = wms.wms_id) as layer_wms, layer_epsg where layer_wms.layer_id = layer_epsg.fkey_layer_id and layer_epsg.epsg = 'EPSG:4326';
SQL;
$generateFromDataurl = true;
break;
case "wmslayer":
$sql = <<<SQL
-select *, 'wmslayer' as origin from (select * from (select mb_metadata.metadata_id, layer_relation.layer_name, layer_relation.fkey_wms_id, layer_relation.layer_id,layer_relation.inspire_download, mb_metadata.uuid as metadata_uuid, mb_metadata.format,mb_metadata.title as metadata_title, mb_metadata.abstract as metadata_abstract, box2d(mb_metadata.the_geom) as metadata_bbox, layer_relation.layer_title, layer_relation.layer_abstract, mb_metadata.ref_system as metadata_ref_system, mb_metadata.datasetid, mb_metadata.spatial_res_type, mb_metadata.spatial_res_value, mb_metadata.datasetid_codespace, mb_metadata.lastchanged as md_timestamp from (select * from layer inner join ows_relation_metadata on layer.layer_id = ows_relation_metadata.fkey_layer_id) as layer_relation inner join mb_metadata on layer_relation.fkey_metadata_id = mb_metadata.metadata_id where mb_metadata.uuid = $1) layer_data inner join wms on layer_data.fkey_wms_id = wms.wms_id) as layer_wms, layer_epsg where lay
er_wms.layer_id = layer_epsg.fkey_layer_id and layer_epsg.epsg = 'EPSG:4326' and layer_wms.layer_id = $2;
+select *, 'wmslayer' as origin from (select * from (select mb_metadata.metadata_id, layer_relation.layer_name, layer_relation.fkey_wms_id, layer_relation.layer_id,layer_relation.inspire_download, mb_metadata.uuid as metadata_uuid, mb_metadata.format,mb_metadata.title as metadata_title, mb_metadata.abstract as metadata_abstract, box2d(mb_metadata.the_geom) as metadata_bbox, mb_metadata.bounding_geom as polygon, layer_relation.layer_title, layer_relation.layer_abstract, mb_metadata.ref_system as metadata_ref_system, mb_metadata.datasetid, mb_metadata.spatial_res_type, mb_metadata.spatial_res_value, mb_metadata.datasetid_codespace, mb_metadata.lastchanged as md_timestamp from (select * from layer inner join ows_relation_metadata on layer.layer_id = ows_relation_metadata.fkey_layer_id) as layer_relation inner join mb_metadata on layer_relation.fkey_metadata_id = mb_metadata.metadata_id where mb_metadata.uuid = $1) layer_data inner join wms on layer_data.fkey_wms_id = wms.wms_i
d) as layer_wms, layer_epsg where layer_wms.layer_id = layer_epsg.fkey_layer_id and layer_epsg.epsg = 'EPSG:4326' and layer_wms.layer_id = $2;
SQL;
break;
case "wfs":
$sql = <<<SQL
-select *, 'wfs' as origin from (select mb_metadata.metadata_id, featuretype_relation.featuretype_name, featuretype_relation.fkey_wfs_id, featuretype_relation.featuretype_id,featuretype_relation.inspire_download, mb_metadata.uuid as metadata_uuid, mb_metadata.format,mb_metadata.title as metadata_title, mb_metadata.abstract as metadata_abstract, box2d(mb_metadata.the_geom) as metadata_bbox, featuretype_relation.featuretype_title, featuretype_relation.featuretype_abstract, mb_metadata.ref_system as metadata_ref_system, mb_metadata.datasetid, mb_metadata.spatial_res_type, mb_metadata.spatial_res_value, mb_metadata.datasetid_codespace, featuretype_relation.featuretype_latlon_bbox as latlonbbox, featuretype_relation.featuretype_srs, mb_metadata.lastchanged as md_timestamp from (select * from wfs_featuretype inner join ows_relation_metadata on wfs_featuretype.featuretype_id = ows_relation_metadata.fkey_featuretype_id) as featuretype_relation inner join mb_metadata on featuretype_r
elation.fkey_metadata_id = mb_metadata.metadata_id where mb_metadata.uuid = $1) as featuretype_data inner join wfs on featuretype_data.fkey_wfs_id = wfs.wfs_id where wfs.wfs_id = $2;
+select *, 'wfs' as origin from (select mb_metadata.metadata_id, featuretype_relation.featuretype_name, featuretype_relation.fkey_wfs_id, featuretype_relation.featuretype_id,featuretype_relation.inspire_download, mb_metadata.uuid as metadata_uuid, mb_metadata.format,mb_metadata.title as metadata_title, mb_metadata.abstract as metadata_abstract, box2d(mb_metadata.the_geom) as metadata_bbox, mb_metadata.bounding_geom as polygon, featuretype_relation.featuretype_title, featuretype_relation.featuretype_abstract, mb_metadata.ref_system as metadata_ref_system, mb_metadata.datasetid, mb_metadata.spatial_res_type, mb_metadata.spatial_res_value, mb_metadata.datasetid_codespace, featuretype_relation.featuretype_latlon_bbox as latlonbbox, featuretype_relation.featuretype_srs, mb_metadata.lastchanged as md_timestamp from (select * from wfs_featuretype inner join ows_relation_metadata on wfs_featuretype.featuretype_id = ows_relation_metadata.fkey_featuretype_id) as featuretype_relation i
nner join mb_metadata on featuretype_relation.fkey_metadata_id = mb_metadata.metadata_id where mb_metadata.uuid = $1) as featuretype_data inner join wfs on featuretype_data.fkey_wfs_id = wfs.wfs_id where wfs.wfs_id = $2;
SQL;
break;
case "metadata":
$sql = <<<SQL
-select 'metadata' as origin,mb_metadata.metadata_id, mb_metadata.uuid as metadata_uuid, mb_metadata.format,mb_metadata.title as metadata_title, mb_metadata.abstract as metadata_abstract, box2d(mb_metadata.the_geom) as metadata_bbox, mb_metadata.ref_system as metadata_ref_system, mb_metadata.datasetid, mb_metadata.spatial_res_type, mb_metadata.spatial_res_value, mb_metadata.datasetid_codespace, mb_metadata.fkey_mb_user_id, mb_metadata.lastchanged as md_timestamp, box2d(the_geom) as bbox2d, datalinks FROM mb_metadata where uuid = $1 and inspire_download = 1;
+select 'metadata' as origin,mb_metadata.metadata_id, mb_metadata.uuid as metadata_uuid, mb_metadata.format,mb_metadata.title as metadata_title, mb_metadata.abstract as metadata_abstract, box2d(mb_metadata.the_geom) as metadata_bbox, mb_metadata.bounding_geom as polygon, mb_metadata.ref_system as metadata_ref_system, mb_metadata.datasetid, mb_metadata.spatial_res_type, mb_metadata.spatial_res_value, mb_metadata.datasetid_codespace, mb_metadata.fkey_mb_user_id, mb_metadata.lastchanged as md_timestamp, box2d(the_geom) as bbox2d, datalinks FROM mb_metadata where uuid = $1 and inspire_download = 1;
SQL;
break;
case "all":
$sql = array();
$sql[0] = <<<SQL
-select *, 'dataurl' as origin from (select * from (select * from (select * from (select mb_metadata.metadata_id, layer_relation.layer_name, layer_relation.fkey_wms_id, layer_relation.layer_id,layer_relation.inspire_download, mb_metadata.uuid as metadata_uuid, mb_metadata.format,mb_metadata.title as metadata_title, mb_metadata.abstract as metadata_abstract, box2d(mb_metadata.the_geom) as metadata_bbox, layer_relation.layer_title, layer_relation.layer_abstract, mb_metadata.ref_system as metadata_ref_system, mb_metadata.datasetid, mb_metadata.spatial_res_type, mb_metadata.spatial_res_value, mb_metadata.datasetid_codespace, mb_metadata.lastchanged as md_timestamp from (select * from layer inner join ows_relation_metadata on layer.layer_id = ows_relation_metadata.fkey_layer_id) as layer_relation inner join mb_metadata on layer_relation.fkey_metadata_id = mb_metadata.metadata_id where mb_metadata.uuid = $1) as layer_metadata inner join ows_relation_data on ows_relation_data.fkey
_layer_id = layer_metadata.layer_id) as layer_relation_data inner join datalink on layer_relation_data.fkey_datalink_id = datalink.datalink_id) as layer_data inner join wms on layer_data.fkey_wms_id = wms.wms_id) as layer_wms, layer_epsg where layer_wms.layer_id = layer_epsg.fkey_layer_id and layer_epsg.epsg = 'EPSG:4326'
+select *, 'dataurl' as origin from (select * from (select * from (select * from (select mb_metadata.metadata_id, layer_relation.layer_name, layer_relation.fkey_wms_id, layer_relation.layer_id,layer_relation.inspire_download, mb_metadata.uuid as metadata_uuid, mb_metadata.format,mb_metadata.title as metadata_title, mb_metadata.abstract as metadata_abstract, box2d(mb_metadata.the_geom) as metadata_bbox, mb_metadata.bounding_geom as polygon, layer_relation.layer_title, layer_relation.layer_abstract, mb_metadata.ref_system as metadata_ref_system, mb_metadata.datasetid, mb_metadata.spatial_res_type, mb_metadata.spatial_res_value, mb_metadata.datasetid_codespace, mb_metadata.lastchanged as md_timestamp from (select * from layer inner join ows_relation_metadata on layer.layer_id = ows_relation_metadata.fkey_layer_id) as layer_relation inner join mb_metadata on layer_relation.fkey_metadata_id = mb_metadata.metadata_id where mb_metadata.uuid = $1) as layer_metadata inner join ows_r
elation_data on ows_relation_data.fkey_layer_id = layer_metadata.layer_id) as layer_relation_data inner join datalink on layer_relation_data.fkey_datalink_id = datalink.datalink_id) as layer_data inner join wms on layer_data.fkey_wms_id = wms.wms_id) as layer_wms, layer_epsg where layer_wms.layer_id = layer_epsg.fkey_layer_id and layer_epsg.epsg = 'EPSG:4326'
SQL;
$sql[1] = <<<SQL
-select *, 'wmslayer' as origin from (select * from (select mb_metadata.metadata_id, layer_relation.layer_name,layer_relation.inspire_download, layer_relation.fkey_wms_id, layer_relation.layer_id, mb_metadata.uuid as metadata_uuid, mb_metadata.format,mb_metadata.title as metadata_title, mb_metadata.abstract as metadata_abstract, box2d(mb_metadata.the_geom) as metadata_bbox, layer_relation.layer_title, layer_relation.layer_abstract, mb_metadata.ref_system as metadata_ref_system, mb_metadata.datasetid, mb_metadata.spatial_res_type, mb_metadata.spatial_res_value, mb_metadata.datasetid_codespace, mb_metadata.lastchanged as md_timestamp from (select * from layer inner join ows_relation_metadata on layer.layer_id = ows_relation_metadata.fkey_layer_id) as layer_relation inner join mb_metadata on layer_relation.fkey_metadata_id = mb_metadata.metadata_id where mb_metadata.uuid = $1) layer_data inner join wms on layer_data.fkey_wms_id = wms.wms_id) as layer_wms, layer_epsg where lay
er_wms.layer_id = layer_epsg.fkey_layer_id and layer_epsg.epsg = 'EPSG:4326';
+select *, 'wmslayer' as origin from (select * from (select mb_metadata.metadata_id, layer_relation.layer_name,layer_relation.inspire_download, layer_relation.fkey_wms_id, layer_relation.layer_id, mb_metadata.uuid as metadata_uuid, mb_metadata.format,mb_metadata.title as metadata_title, mb_metadata.abstract as metadata_abstract, box2d(mb_metadata.the_geom) as metadata_bbox, mb_metadata.bounding_geom as polygon, layer_relation.layer_title, layer_relation.layer_abstract, mb_metadata.ref_system as metadata_ref_system, mb_metadata.datasetid, mb_metadata.spatial_res_type, mb_metadata.spatial_res_value, mb_metadata.datasetid_codespace, mb_metadata.lastchanged as md_timestamp from (select * from layer inner join ows_relation_metadata on layer.layer_id = ows_relation_metadata.fkey_layer_id) as layer_relation inner join mb_metadata on layer_relation.fkey_metadata_id = mb_metadata.metadata_id where mb_metadata.uuid = $1) layer_data inner join wms on layer_data.fkey_wms_id = wms.wms_i
d) as layer_wms, layer_epsg where layer_wms.layer_id = layer_epsg.fkey_layer_id and layer_epsg.epsg = 'EPSG:4326';
SQL;
$sql[2] = <<<SQL
-select *, 'wfs' as origin from (select mb_metadata.metadata_id, featuretype_relation.featuretype_name, featuretype_relation.fkey_wfs_id, featuretype_relation.inspire_download, featuretype_relation.featuretype_id, mb_metadata.uuid as metadata_uuid, mb_metadata.format,mb_metadata.title as metadata_title, mb_metadata.abstract as metadata_abstract, box2d(mb_metadata.the_geom) as metadata_bbox, featuretype_relation.featuretype_title, featuretype_relation.featuretype_abstract, mb_metadata.ref_system as metadata_ref_system, mb_metadata.datasetid, mb_metadata.spatial_res_type, mb_metadata.spatial_res_value, mb_metadata.datasetid_codespace, featuretype_relation.featuretype_latlon_bbox as latlonbbox, featuretype_relation.featuretype_srs, mb_metadata.lastchanged as md_timestamp from (select * from wfs_featuretype inner join ows_relation_metadata on wfs_featuretype.featuretype_id = ows_relation_metadata.fkey_featuretype_id) as featuretype_relation inner join mb_metadata on featuretype_r
elation.fkey_metadata_id = mb_metadata.metadata_id where mb_metadata.uuid = $1) as featuretype_data inner join wfs on featuretype_data.fkey_wfs_id = wfs.wfs_id;
+select *, 'wfs' as origin from (select mb_metadata.metadata_id, featuretype_relation.featuretype_name, featuretype_relation.fkey_wfs_id, featuretype_relation.inspire_download, featuretype_relation.featuretype_id, mb_metadata.uuid as metadata_uuid, mb_metadata.format,mb_metadata.title as metadata_title, mb_metadata.abstract as metadata_abstract, box2d(mb_metadata.the_geom) as metadata_bbox, mb_metadata.bounding_geom as polygon, featuretype_relation.featuretype_title, featuretype_relation.featuretype_abstract, mb_metadata.ref_system as metadata_ref_system, mb_metadata.datasetid, mb_metadata.spatial_res_type, mb_metadata.spatial_res_value, mb_metadata.datasetid_codespace, featuretype_relation.featuretype_latlon_bbox as latlonbbox, featuretype_relation.featuretype_srs, mb_metadata.lastchanged as md_timestamp from (select * from wfs_featuretype inner join ows_relation_metadata on wfs_featuretype.featuretype_id = ows_relation_metadata.fkey_featuretype_id) as featuretype_relation i
nner join mb_metadata on featuretype_relation.fkey_metadata_id = mb_metadata.metadata_id where mb_metadata.uuid = $1) as featuretype_data inner join wfs on featuretype_data.fkey_wfs_id = wfs.wfs_id;
SQL;
break;
}
@@ -1022,7 +1022,15 @@
$feedAuthor->appendChild($feedAuthorName);
$feedAuthor->appendChild($feedAuthorEmail);
$feed->appendChild($feedAuthor);
-
+ //check for given polygonal extent:
+ if (is_null($mapbenderMetadata[$m]->metadata_polygon)) {
+ $e = new mb_notice("php/mod_inspireDownloadFeed.php polygonalFilter is not set");
+ $polygonalFilter = false;
+ } else {
+ $e = new mb_notice("php/mod_inspireDownloadFeed.php polygonalFilter was found and will be applied!");
+ $polygonalFilter = true;
+ }
+ $e = new mb_notice("php/mod_inspireDownloadFeed.php metadata_uuid: ".$mapbenderMetadata[$m]->metadata_uuid);
//<!-- pre-defined dataset - a entry for each pre-defined dataset - in the case of dataURL only one entry is used! -->
//if dataurl not given and a raster wms is defined - calculate the number of entries
if ($type == 'DATASET' && $generateFrom == "wmslayer") {
@@ -1044,24 +1052,12 @@
//TODO: check if epsg, and bbox are filled correctly!
-
- $sqlMinx = "SELECT X(transform(GeometryFromText('POINT(".$mapbenderMetadata[$m]->minx." ".$mapbenderMetadata[$m]->miny.")',4326),".$epsgId.")) as minx";
- $e = new mb_exception($sqlMinx);
- $resMinx = db_query($sqlMinx);
- $minx = floatval(db_result($resMinx,0,"minx"));
-
- $sqlMiny = "SELECT Y(transform(GeometryFromText('POINT(".$mapbenderMetadata[$m]->minx." ".$mapbenderMetadata[$m]->miny.")',4326),".$epsgId.")) as miny";
- $resMiny = db_query($sqlMiny);
- $miny = floatval(db_result($resMiny,0,"miny"));
-
- $sqlMaxx = "SELECT X(transform(GeometryFromText('POINT(".$mapbenderMetadata[$m]->maxx." ".$mapbenderMetadata[$m]->maxy.")',4326),".$epsgId.")) as maxx";
- $resMaxx = db_query($sqlMaxx);
- $maxx = floatval(db_result($resMaxx,0,"maxx"));
-
- $sqlMaxy = "SELECT Y(transform(GeometryFromText('POINT(".$mapbenderMetadata[$m]->maxx." ".$mapbenderMetadata[$m]->maxy.")',4326),".$epsgId.")) as maxy";
- $resMaxy = db_query($sqlMaxy);
- $maxy = floatval(db_result($resMaxy,0,"maxy"));
-
+ $sqlExtent = "SELECT X(transform(GeometryFromText('POINT(".$mapbenderMetadata[$m]->minx." ".$mapbenderMetadata[$m]->miny.")',4326),".$epsgId.")) as minx, Y(transform(GeometryFromText('POINT(".$mapbenderMetadata[$m]->minx." ".$mapbenderMetadata[$m]->miny.")',4326),".$epsgId.")) as miny, X(transform(GeometryFromText('POINT(".$mapbenderMetadata[$m]->maxx." ".$mapbenderMetadata[$m]->maxy.")',4326),".$epsgId.")) as maxx, Y(transform(GeometryFromText('POINT(".$mapbenderMetadata[$m]->maxx." ".$mapbenderMetadata[$m]->maxy.")',4326),".$epsgId.")) as maxy";
+ $resExtent = db_query($sqlExtent);
+ $minx = floatval(db_result($resExtent,0,"minx"));
+ $miny = floatval(db_result($resExtent,0,"miny"));
+ $maxx = floatval(db_result($resExtent,0,"maxx"));
+ $maxy = floatval(db_result($resExtent,0,"maxy"));
$diffX = $maxx - $minx; //in m
$diffY = $maxy - $miny; //in m
@@ -1106,7 +1102,15 @@
$maxyWms = $miny + ($j+1) * $incY;
//echo "maxyWms: ". $maxyWms .",";
$bboxWms[] = $minxWms.",".$minyWms.",".$maxxWms.",".$maxyWms;
- $bboxWmsWGS84[] = transformBbox($minxWms.",".$minyWms.",".$maxxWms.",".$maxyWms,intval($epsgId),4326);
+ //new: use filter of polygon is given ;-)
+ $lonLatBboxWms = transformBbox($minxWms.",".$minyWms.",".$maxxWms.",".$maxyWms,intval($epsgId),4326,$mapbenderMetadata[$m]->metadata_uuid,$polygonalFilter);
+ //only add entry, if not false
+ if ($lonLatBboxWms != false) {
+ $bboxWmsWGS84[] = $lonLatBboxWms;
+ } else {
+ //delete last entry from $bboxWms, cause it is outside the polygon!
+ array_pop($bboxWms);
+ }
}
}
@@ -1133,7 +1137,7 @@
//use featuretype ref system?
$crs = $mapbenderMetadata[$i]->featuretype_srs;
//log ref system of metadata - is this a good idea?
- $e = new mb_exception("Ref system of featuretype ".$mapbenderMetadata[$i]->featuretype_name." : ".$crs);
+ $e = new mb_notice("Ref system of featuretype ".$mapbenderMetadata[$i]->featuretype_name." : ".$crs);
//
//handle other definitions of epsg ids
//urn:ogc:def:crs:EPSG::31467
@@ -1147,7 +1151,7 @@
$epsgId = end($epsgId);
//check if order have to be altered
if (strpos($crsUpper,'urn') !== false) {
- $e = new mb_exception("urn - found");
+ $e = new mb_notice("urn - found");
//check if axis order should be changed
if (check_epsg_wms_13($epsgId)) {
//alter order of axis for 4326
@@ -1228,21 +1232,12 @@
$mapbenderMetadata[$i]->maxy = $maxyI;
$mapbenderMetadata[$i]->maxx = $maxxI;
}
- $sqlMinx = "SELECT X(transform(GeometryFromText('POINT(".$mapbenderMetadata[$i]->minx." ".$mapbenderMetadata[$i]->miny.")',4326),".$epsgId.")) as minx";
- $resMinx = db_query($sqlMinx);
- $minx = floatval(db_result($resMinx,0,"minx"));
-
- $sqlMiny = "SELECT Y(transform(GeometryFromText('POINT(".$mapbenderMetadata[$i]->minx." ".$mapbenderMetadata[$i]->miny.")',4326),".$epsgId.")) as miny";
- $resMiny = db_query($sqlMiny);
- $miny = floatval(db_result($resMiny,0,"miny"));
-
- $sqlMaxx = "SELECT X(transform(GeometryFromText('POINT(".$mapbenderMetadata[$i]->maxx." ".$mapbenderMetadata[$i]->maxy.")',4326),".$epsgId.")) as maxx";
- $resMaxx = db_query($sqlMaxx);
- $maxx = floatval(db_result($resMaxx,0,"maxx"));
-
- $sqlMaxy = "SELECT Y(transform(GeometryFromText('POINT(".$mapbenderMetadata[$i]->maxx." ".$mapbenderMetadata[$i]->maxy.")',4326),".$epsgId.")) as maxy";
- $resMaxy = db_query($sqlMaxy);
- $maxy = floatval(db_result($resMaxy,0,"maxy"));
+ $sqlExtent = "SELECT X(transform(GeometryFromText('POINT(".$mapbenderMetadata[$i]->minx." ".$mapbenderMetadata[$i]->miny.")',4326),".$epsgId.")) as minx, Y(transform(GeometryFromText('POINT(".$mapbenderMetadata[$i]->minx." ".$mapbenderMetadata[$i]->miny.")',4326),".$epsgId.")) as miny, X(transform(GeometryFromText('POINT(".$mapbenderMetadata[$i]->maxx." ".$mapbenderMetadata[$i]->maxy.")',4326),".$epsgId.")) as maxx, Y(transform(GeometryFromText('POINT(".$mapbenderMetadata[$i]->maxx." ".$mapbenderMetadata[$i]->maxy.")',4326),".$epsgId.")) as maxy";
+ $resExtent = db_query($sqlExtent);
+ $minx = floatval(db_result($resExtent,0,"minx"));
+ $miny = floatval(db_result($resExtent,0,"miny"));
+ $maxx = floatval(db_result($resExtent,0,"maxx"));
+ $maxy = floatval(db_result($resExtent,0,"maxy"));
}
}
//only calculate new boxes if countTiles > 1
@@ -1266,13 +1261,16 @@
$maxyWfs = $miny + ($j+1) * $width;
//echo "maxyWms: ". $maxyWms .",";
$bboxWfs[$mapbenderMetadata[$i]->featuretype_name][$countBbox] = $minxWfs.",".$minyWfs.",".$maxxWfs.",".$maxyWfs;
- //transform bbox back to geographic coordinates
- $lonLatBbox = transformBbox($minxWfs.",".$minyWfs.",".$maxxWfs.",".$maxyWfs,intval($epsgId),4326);
- $lonLatBbox = explode(',',$lonLatBbox);
- //georss needs latitude longitude
- $featureTypeBboxWGS84[] = $lonLatBbox[1].",".$lonLatBbox[0].",".$lonLatBbox[3].",".$lonLatBbox[2];
- //switch bbox to lat/lon cause inspire demands ist
- $countBbox++;
+ //transform bbox back to geographic coordinates and filter them if a spatial_extent as polygon is given (give only those which intersects)!!
+ $lonLatBbox = transformBbox($minxWfs.",".$minyWfs.",".$maxxWfs.",".$maxyWfs,intval($epsgId),4326, $mapbenderMetadata[$i]->metadata_uuid, $mapbenderMetadata[$i]->polygonFilter);
+ //only add entry, if not false
+ if ($lonLatBbox != false) {
+ $lonLatBbox = explode(',',$lonLatBbox);
+ //georss needs latitude longitude
+ $featureTypeBboxWGS84[] = $lonLatBbox[1].",".$lonLatBbox[0].",".$lonLatBbox[3].",".$lonLatBbox[2];
+ //switch bbox to lat/lon cause inspire demands ist
+ $countBbox++;
+ }
}
}
} else {
@@ -1679,28 +1677,36 @@
return $bbox;
}
-function transformBbox($oldBbox, $fromCRS, $toCRS) {
+function transformBbox($oldBbox, $fromCRS, $toCRS, $metadataUuid = false ,$polygonFilter = false) {
//Transform the given BBOX to $toCRS
$arrayBbox = explode(',',$oldBbox);
- //$e = new mb_exception($oldBbox);
- //$e = new mb_exception(count($arrayBbox));
- //$e = new mb_exception($arrayBbox[0]);
- $sql = "select asewkt(transform(GeometryFromText ( 'LINESTRING ( ".$arrayBbox[0]." ".$arrayBbox[1].",".$arrayBbox[2]." ".$arrayBbox[3]." )', $fromCRS ),".intval($toCRS)."))";
- //$e = new mb_exception("inspireDownload sql transform: ".$sql);
- //$sql = "select asewkt(transform(GeometryFromText ( 'LINESTRING ( $1 $2, $3 $4 )', $5 ),$6))";
- //$v = array($arrayBbox[0],$arrayBbox[1],$arrayBbox[2],$arrayBbox[3],$fromCRS,$toCRS);
- //$t = array('s','s','s','s','i','i');
- $res = db_query($sql,$v,$t);
- //read out result
- $textBbox = db_fetch_row($res);
- //$e = new mb_exception("inspireDownload sql result: ".$textBbox[0]);
- $pattern = '~LINESTRING\((.*)\)~i';
- preg_match($pattern, $textBbox[0], $subpattern);
- //exchange blancs
- $newBbox = str_replace(" ", ",", $subpattern[1]);
- //set new BBOX
- //$arrayBboxNew = explode(',',$newBbox);
- return $newBbox;
+ if ($metadataUuid != false && $polygonFilter != false) {
+ $sql = "select asewkt(transform(GeometryFromText ( 'LINESTRING ( ".$arrayBbox[0]." ".$arrayBbox[1].",".$arrayBbox[2]." ".$arrayBbox[3]." )', $fromCRS ),".intval($toCRS).")) as bbox,
+CASE
+WHEN st_intersects((select bounding_geom from mb_metadata where uuid = '".$metadataUuid."'), transform(GeometryFromText ( 'LINESTRING ( ".$arrayBbox[0]." ".$arrayBbox[1].",".$arrayBbox[2]." ".$arrayBbox[3]." )', $fromCRS ),".intval($toCRS)." )) = true THEN true
+ELSE false
+END as inside;";
+ $res = db_query($sql,$v,$t);
+ $row = db_fetch_assoc($res);
+ $textBbox = $row['bbox'];
+ $inside = $row['inside'];
+ if ($inside == "f") {
+ return false;
+ } else {
+ $pattern = '~LINESTRING\((.*)\)~i';
+ preg_match($pattern, $textBbox, $subpattern);
+ $newBbox = str_replace(" ", ",", $subpattern[1]);
+ return $newBbox;
+ }
+ } else {
+ $sql = "select asewkt(transform(GeometryFromText ( 'LINESTRING ( ".$arrayBbox[0]." ".$arrayBbox[1].",".$arrayBbox[2]." ".$arrayBbox[3]." )', $fromCRS ),".intval($toCRS)."))";
+ $res = db_query($sql,$v,$t);
+ $textBbox = db_fetch_row($res);
+ $pattern = '~LINESTRING\((.*)\)~i';
+ preg_match($pattern, $textBbox[0], $subpattern);
+ $newBbox = str_replace(" ", ",", $subpattern[1]);
+ return $newBbox;
+ }
}
@@ -1775,6 +1781,7 @@
$mapbenderMetadata[$indexMapbenderMetadata]->layer_title = $row['layer_title'];
$mapbenderMetadata[$indexMapbenderMetadata]->metadata_abstract = $row['metadata_abstract'];
$mapbenderMetadata[$indexMapbenderMetadata]->metadata_bbox = $row['metadata_bbox'];
+ $mapbenderMetadata[$indexMapbenderMetadata]->metadata_polygon = $row['polygon'];
$mapbenderMetadata[$indexMapbenderMetadata]->layer_abstract = $row['layer_abstract'];
$mapbenderMetadata[$indexMapbenderMetadata]->accessconstraints = $row['accessconstraints'];
$mapbenderMetadata[$indexMapbenderMetadata]->metadata_uuid = $row['metadata_uuid'];
More information about the Mapbender_commits
mailing list