[Mapbender-commits] r9797 - trunk/mapbender/http/php
svn_mapbender at osgeo.org
svn_mapbender at osgeo.org
Thu Oct 5 06:29:28 PDT 2017
Author: armin11
Date: 2017-10-05 06:29:28 -0700 (Thu, 05 Oct 2017)
New Revision: 9797
Modified:
trunk/mapbender/http/php/mod_inspireDownloadFeed.php
Log:
Integration of new class for getting axis order from epsg registry.
Modified: trunk/mapbender/http/php/mod_inspireDownloadFeed.php
===================================================================
--- trunk/mapbender/http/php/mod_inspireDownloadFeed.php 2017-10-05 13:28:26 UTC (rev 9796)
+++ trunk/mapbender/http/php/mod_inspireDownloadFeed.php 2017-10-05 13:29:28 UTC (rev 9797)
@@ -30,6 +30,7 @@
require_once(dirname(__FILE__) . "/../../conf/mimetype.conf");
require_once(dirname(__FILE__) . "/../classes/class_cache.php");
require_once(dirname(__FILE__) . "/../classes/class_iso19139.php");
+require_once(dirname(__FILE__) . "/../classes/class_crs.php");
require_once(dirname(__FILE__) . "/../classes/class_metadata_monitor.php");
//check_epsg_wms_13($tmp_epsg)
@@ -694,10 +695,25 @@
}
//Handle CRS - maybe in 'urn:ogc:def:crs:EPSG:6.9:4326' or 'EPSG:4326' or 'epsg:4326' or 'urn:ogc:def:crs:EPSG::4326' format!
+ //*********************** New use crs class for checking if the order has to be changed in the filter!!!
+ $crsObject = new Crs($crs);
+ if ($crsObject->alterAxisOrder("wms"."_".$mapbenderMetadata[$i]->wms_version) == true) {
+ $alterAxisOrder = true;
+ } else {
+ $alterAxisOrder = false;
+ }
+ //**************************************************************************************
+ $epsgId = $crsObject->identifierCode;
+
+
//TODO test this also in sqls from mapbenders database - see wms 1.3.0 - for layer metadata
//explode strings
//alter all to uppercase
- $crsUpper = str_replace("epsg","EPSG",$crs);
+
+
+
+
+ /*$crsUpper = str_replace("epsg","EPSG",$crs);
//explode strings
$crsUpperArray = explode(":",$crsUpper);
switch (count($crsUpperArray)) {
@@ -717,7 +733,7 @@
} else {
$alterAxisOrder = false;
}
- }
+ }*/
//infos about the registrating department, check first if a special metadata point of contact is defined in the service table - function from mod_showMetadata - TODO: should be defined in admin class
if (!isset($mapbenderMetadata[$m]->fkey_mb_group_id) or is_null($mapbenderMetadata[$m]->fkey_mb_group_id) or $mapbenderMetadata[$m]->fkey_mb_group_id == 0){
$e = new mb_exception("mod_inspireDownloadFeed.php: fkey_mb_group_id not found!");
@@ -1178,11 +1194,21 @@
$maxFeatureCount = (integer)$mapbenderMetadata[$i]->wfs_max_features;
$crs = $mapbenderMetadata[$i]->metadata_ref_system;
- //use featuretype ref system?
+ //use featuretype ref system - to build the bbox filters!!!
$crs = $mapbenderMetadata[$i]->featuretype_srs;
//log ref system of metadata - is this a good idea?
$e = new mb_notice("Ref system of featuretype ".$mapbenderMetadata[$i]->featuretype_name." : ".$crs);
- //
+ //*********************** New use crs class for checking if the order has to be changed in the filter!!!
+ $crsObject = new Crs($crs);
+ if ($crsObject->alterAxisOrder("wfs"."_".$mapbenderMetadata[$i]->wfs_version) == true) {
+ $alterAxisOrder = true;
+ } else {
+ $alterAxisOrder = false;
+ }
+ //**************************************************************************************
+
+ /*
+
//handle other definitions of epsg ids
//urn:ogc:def:crs:EPSG::31467
//Handle CRS
@@ -1204,6 +1230,7 @@
$alterAxisOrder = false;
}
}
+ */
$e = new mb_notice("Epsg id of featuretype ".$mapbenderMetadata[$i]->featuretype_name." : ".$epsgId);
if (!($mapbenderMetadata[$i]->wfs_version) || $mapbenderMetadata[$i]->wfs_version == '') {
return "<error>Version of WFS : ".$mapbenderMetadata[$i]->wfs_version." is not supported to generate inspire download services for predefined datasets!</error>";
@@ -1256,7 +1283,7 @@
break;
}
$featureHits[$i] = (integer)$hits[0];
- $e = new mb_notice($featureHits[$i]." hits for featuretype ".$mapbenderMetadata[$i]->featuretype_name);
+ $e = new mb_exception($featureHits[$i]." hits for featuretype ".$mapbenderMetadata[$i]->featuretype_name);
//calculate further bboxes if the # of hits extents some value
//minimum number of single tiles:
$countTiles = ceil($featureHits[$i]/$maxFeatureCount);
@@ -1264,40 +1291,17 @@
$countTiles = 1;
}
//calculate number of rows and columns from x / y ratio
- if ($epsgId == '4326' && $alterAxisOrder) {
- //no transformation needed only change order
- $minx = $mapbenderMetadata[$i]->miny;
- $miny = $mapbenderMetadata[$i]->minx;
- $maxx = $mapbenderMetadata[$i]->maxy;
- $maxy = $mapbenderMetadata[$i]->maxx;
- } else {
- //no transformation needed normal order
- if ($epsgId == '4326') {
- $minx = $mapbenderMetadata[$i]->minx;
- $miny = $mapbenderMetadata[$i]->miny;
- $maxx = $mapbenderMetadata[$i]->maxx;
- $maxy = $mapbenderMetadata[$i]->maxy;
- } else {
- //transformation needed and axis order changed
- if ($alterAxisOrder) {
- $e = new mb_exception("axis_order_altered");
- $minxI = $mapbenderMetadata[$i]->miny;
- $minyI = $mapbenderMetadata[$i]->minx;
- $maxxI = $mapbenderMetadata[$i]->maxy;
- $maxyI = $mapbenderMetadata[$i]->maxx;
- $mapbenderMetadata[$i]->miny = $minyI;
- $mapbenderMetadata[$i]->minx = $minxI;
- $mapbenderMetadata[$i]->maxy = $maxyI;
- $mapbenderMetadata[$i]->maxx = $maxxI;
- }
- $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"));
- }
- }
+ //$e = new mb_exception("http/php/mod_inspireDownloadFeed.php: - Bbox from metadata: minx: ". $mapbenderMetadata[$i]->minx." - miny: ".$mapbenderMetadata[$i]->miny." - maxx: ".$mapbenderMetadata[$i]->maxx." - maxy: ".$mapbenderMetadata[$i]->maxy." - CRS: ".$mapbenderMetadata[$i]->featuretype_srs." - EPSG ID: ".$crsObject->identifierCode);
+ //set epsgId;
+ $epsgId = $crsObject->identifierCode;
+ //read out in variables
+ $sqlExtent = "SELECT X(transform(GeometryFromText('POINT(".$mapbenderMetadata[$i]->minx." ".$mapbenderMetadata[$i]->miny.")',4326),".$crsObject->identifierCode.")) as minx, Y(transform(GeometryFromText('POINT(".$mapbenderMetadata[$i]->minx." ".$mapbenderMetadata[$i]->miny.")',4326),".$crsObject->identifierCode.")) as miny, X(transform(GeometryFromText('POINT(".$mapbenderMetadata[$i]->maxx." ".$mapbenderMetadata[$i]->maxy.")',4326),".$crsObject->identifierCode.")) as maxx, Y(transform(GeometryFromText('POINT(".$mapbenderMetadata[$i]->maxx." ".$mapbenderMetadata[$i]->maxy.")',4326),".$crsObject->identifierCode.")) 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"));
+ $e = new mb_exception("http/php/mod_inspireDownloadFeed.php: - minx: ".$minx. " - maxx: ".$maxx);
//only calculate new boxes if countTiles > 1
if ($countTiles > 1) {
$diffX = $maxx - $minx; //in m - depends on given epsg code
@@ -1336,10 +1340,14 @@
if ($minx == "" || $miny == "" || $maxx == "" || $maxy == "") {
//set default values
//EPSG:4326
- $minx = "-90";
- $miny = "-180";
- $maxx = "90";
- $maxy = "180";
+ //use lon/lat - for postgis!!!
+ $minx = "-180";
+ $miny = "-90";
+ $maxx = "180";
+ $maxy = "90";
+ /*
+
+ */
$epsgId = "4326";
}
$bboxWfs[$mapbenderMetadata[$i]->featuretype_name][0] = $minx.",".$miny.",".$maxx.",".$maxy;
@@ -1376,6 +1384,17 @@
$geometryFieldName = 'geometry';
}
$currentBbox = explode(',',$bboxWfs[$mapbenderMetadata[$i]->featuretype_name][$l]);
+ //change axis order if crs definition and service needs it
+ if ($alterAxisOrder == true) {
+ $e = new mb_exception("mod_inspireDownloadFeed.php: axis order should be altered!");
+ $currentBboxNew = $currentBbox;
+ $currentBboxGetFeature[0] = $currentBboxNew[1];
+ $currentBboxGetFeature[1] = $currentBboxNew[0];
+ $currentBboxGetFeature[2] = $currentBboxNew[3];
+ $currentBboxGetFeature[3] = $currentBboxNew[2];
+ } else {
+ $currentBboxGetFeature = $currentBbox;
+ }
if (strpos($mapbenderMetadata[$i]->featuretype_name, ':') !== false) {
$ftNamespace = explode(':', $mapbenderMetadata[$i]->featuretype_name);
$ftNamespace = $ftNamespace[0];
@@ -1391,8 +1410,8 @@
//<gml:Envelope srsName="urn:ogc:def:crs:EPSG::1234">
$bboxFilter .= '<gml:Envelope xmlns:gml="http://www.opengis.net/gml/3.2" srsName="'.$crs.'">';
//FIX for ESRI? TODO
- $bboxFilter .= '<gml:lowerCorner>'.$currentBbox[0].' '.$currentBbox[1].'</gml:lowerCorner>';
- $bboxFilter .= '<gml:upperCorner>'.$currentBbox[2].' '.$currentBbox[3].'</gml:upperCorner>';
+ $bboxFilter .= '<gml:lowerCorner>'.$currentBboxGetFeature[0].' '.$currentBboxGetFeature[1].'</gml:lowerCorner>';
+ $bboxFilter .= '<gml:upperCorner>'.$currentBboxGetFeature[2].' '.$currentBboxGetFeature[3].'</gml:upperCorner>';
$bboxFilter .= '</gml:Envelope>';
$bboxFilter .= '</fes:BBOX>';
$bboxFilter .= '</fes:Filter>';
@@ -1404,8 +1423,8 @@
//<gml:Envelope srsName="urn:ogc:def:crs:EPSG::1234">
$bboxFilter .= '<gml:Envelope xmlns:gml="http://www.opengis.net/gml/3.2" srsName="'.$crs.'">';
//FIX for ESRI? TODO
- $bboxFilter .= '<gml:lowerCorner>'.$currentBbox[0].' '.$currentBbox[1].'</gml:lowerCorner>';
- $bboxFilter .= '<gml:upperCorner>'.$currentBbox[2].' '.$currentBbox[3].'</gml:upperCorner>';
+ $bboxFilter .= '<gml:lowerCorner>'.$currentBboxGetFeature[0].' '.$currentBboxGetFeature[1].'</gml:lowerCorner>';
+ $bboxFilter .= '<gml:upperCorner>'.$currentBboxGetFeature[2].' '.$currentBboxGetFeature[3].'</gml:upperCorner>';
$bboxFilter .= '</gml:Envelope>';
$bboxFilter .= '</fes:BBOX>';
$bboxFilter .= '</fes:Filter>';
@@ -1421,36 +1440,15 @@
//$currentBbox = explode(',',$bboxWfs[$mapbenderMetadata[$i]->featuretype_name][$l]);
$e = new mb_notice("Bounding box ".$l." : ".$l.$bboxWfs[$mapbenderMetadata[$i]->featuretype_name][$l]);
//fix for esri????? TODO check crs axes order handling
- if (strtoupper($mapbenderMetadata[$i]->geometry_field_name[0] == "SHAPE")) {
- $bboxFilter .= $currentBbox[1].','.$currentBbox[0].' '.$currentBbox[3].','.$currentBbox[2];
- } else {
- $bboxFilter .= $currentBbox[0].','.$currentBbox[1].' '.$currentBbox[2].','.$currentBbox[3];
- }
+ //if (strtoupper($mapbenderMetadata[$i]->geometry_field_name[0] == "SHAPE")) {
+ // $bboxFilter .= $currentBboxGetFeature[1].','.$currentBboxGetFeature[0].' '.$currentBboxGetFeature[3].','.$currentBboxGetFeature[2];
+ //} else {
+ $bboxFilter .= $currentBboxGetFeature[0].','.$currentBboxGetFeature[1].' '.$currentBboxGetFeature[2].','.$currentBboxGetFeature[3];
+ //}
$bboxFilter .= '</gml:coordinates></gml:Box></ogc:BBOX></ogc:Filter>';
$bboxFilter = rawurlencode(utf8_decode($bboxFilter));
break;
}
- /*
- //$bboxFilter = '<ogc:Filter><ogc:BBOX>';
- $bboxFilter = '<ogc:Filter xmlns:ogc="http://www.opengis.net/ogc"><ogc:BBOX>';
- //$bboxFilter = '<ogc:Filter xmlns:ogc="http://www.opengis.net/ogc" xmlns:gml="http://www.opengis.net/gml"><ogc:BBOX>';
- //$bboxFilter .= '<gml:Box srsName="EPSG:'.$epsgId[1].'"';
- $bboxFilter .= '<ogc:PropertyName>'.$mapbenderMetadata[$i]->geometry_field_name[0].'</ogc:PropertyName>';
- $bboxFilter .= '<gml:Box xmlns:gml="http://www.opengis.net/gml" srsName="'.$crs.'">';
- $bboxFilter .= '<gml:coordinates decimal="." cs="," ts=" ">';
- $currentBbox = explode(',',$bboxWfs[$mapbenderMetadata[$i]->featuretype_name][$l]);
-
- $e = new mb_notice("Bounding box ".$l." : ".$l.$bboxWfs[$mapbenderMetadata[$i]->featuretype_name][$l]);
- //fix for esri?????
- if (strtoupper($mapbenderMetadata[$i]->geometry_field_name[0] == "SHAPE")) {
- $bboxFilter .= $currentBbox[1].','.$currentBbox[0].' '.$currentBbox[3].','.$currentBbox[2];
- } else {
- $bboxFilter .= $currentBbox[0].','.$currentBbox[1].' '.$currentBbox[2].','.$currentBbox[3];
- }
- $bboxFilter .= '</gml:coordinates></gml:Box></ogc:BBOX></ogc:Filter>';
- $bboxFilter = rawurlencode(utf8_decode($bboxFilter));
- */
-
//check if owsproxy is activated for wfs - if so, use absolute url of wfs
//e.g.: www.geoportal.rlp.de/registry/wfs/{wfs_id}? - important - there has to be one wfsconf defined and assigned!
if ($admin->getWFSOWSstring($mapbenderMetadata[$i]->wfs_id) == false) {
@@ -1639,7 +1637,10 @@
} else {
$getMapUrl = $mapbenderMetadata[$i]->wms_getmap;
}
+ //TODO - define further link for wms 1.1.1 and wms 1.3.0 - SRS Paramter changed and maybe the axis order!!!!!!
$furtherLink[$m] = $getMapUrl."REQUEST=GetMap&VERSION=".$mapbenderMetadata[$i]->wms_version."&SERVICE=WMS&LAYERS=".$mapbenderMetadata[$i]->layer_name;
+
+
$furtherLink[$m] .= "&STYLES=&SRS=".trim($crs)."&BBOX=".$bboxWms[$m]."&WIDTH=".$maxImageSize."&HEIGHT=".$maxImageSize."&FORMAT=image/tiff&";
$furtherLink[$m] .= "BGCOLOR=0xffffff&TRANSPARENT=TRUE&EXCEPTIONS=application/vnd.ogc.se_inimage";
$furtherLinkType[$m] = "image/tiff"; //formats from layer_format - geotiff
@@ -1650,11 +1651,7 @@
//exchange lon lat with lat long for georss
$newBox = explode(',',$furtherLinkBbox[$m]);
//georss needs latitude longitude
- if ($alterAxisOrder == true) {
- $newBox = $newBox[1].",".$newBox[0].",".$newBox[3].",".$newBox[2];
- } else {
- $newBox = $newBox[0].",".$newBox[1].",".$newBox[2].",".$newBox[3];
- }
+ $newBox = $newBox[1].",".$newBox[0].",".$newBox[3].",".$newBox[2];
//generate content link
$feedEntryLink = $feedDoc->createElement("link");
if ($numberOfTiles > 1) {
@@ -1666,7 +1663,9 @@
$feedEntryLink->setAttribute("type", $furtherLinkType[$m]);
$feedEntryLink->setAttribute("hreflang", "de");
$feedEntryLink->setAttribute("title", $furtherLinkTitle[$m]);
+ //if axis order was
$feedEntryLink->setAttribute("bbox", str_replace(","," ",$newBox));
+
$feedEntry->appendChild($feedEntryLink);
}
break;
More information about the Mapbender_commits
mailing list