[Mapbender-commits] r9807 - in trunk/mapbender/http: classes php

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Wed Oct 25 07:03:50 PDT 2017


Author: armin11
Date: 2017-10-25 07:03:50 -0700 (Wed, 25 Oct 2017)
New Revision: 9807

Modified:
   trunk/mapbender/http/classes/class_crs.php
   trunk/mapbender/http/php/mod_inspireDownloadFeed.php
Log:
Fix for resolve axis order for crs and INSPIRE ATOM feed generator

Modified: trunk/mapbender/http/classes/class_crs.php
===================================================================
--- trunk/mapbender/http/classes/class_crs.php	2017-10-20 11:04:45 UTC (rev 9806)
+++ trunk/mapbender/http/classes/class_crs.php	2017-10-25 14:03:50 UTC (rev 9807)
@@ -29,6 +29,7 @@
  * https://github.com/deegree/deegree3/wiki/Axis-order-handling
  * http://docs.geotools.org/latest/userguide/library/referencing/order.html
  * http://mapserver.org/ogc/wms_server.html
+ * http://www.ogcnetwork.net/axisorder
  */
 
 class Crs {
@@ -58,16 +59,19 @@
  */
 	//handles ows identifier: wms_1.0.0, wms_1.1.1, wms_1.3.0, wfs_1.0.0, wfs_1.1.0, wfs_2.0.0, wfs_2.0.2
 	public function alterAxisOrder ($targetOws) {
-		$owsWithSpecialOrder = array("wms_1.0.0","wms_1.1.1","wfs_1.0.0");//lon/lat,east/north 
-		$owsWithOrderAsDefined = array("wms_1.3.0","wfs_1.1.0","wfs_2.0.0","wfs_2.0.2");
+		$owsWithSpecialOrder = array("wms_1.0.0","wms_1.1.1","wfs_1.0.0","gml_2.0.0","gml_2.1.0","gml_3.1.1","geojson");//lon/lat,east/north 
+
+		$owsWithOrderAsDefined = array("wms_1.3.0","wfs_1.1.0","wfs_2.0.0","wfs_2.0.2","gml_3.2.0");
+		//$owsWithOrderAsDefined = array("wms_1.3.0","wfs_2.0.0","wfs_2.0.2");
 		$order = "east,north"; //dummy postgis/oracle spatial order
-		if (in_array($targetOws, $owsWithSpecialOrder) && $this->identifierType == 'epsg' && $this->axisOrder !== $order) {
+		if (in_array($targetOws, $owsWithSpecialOrder) && $this->axisOrder !== $order) {
+		//if (in_array($targetOws, $owsWithSpecialOrder) && $this->identifierType == 'epsg' && $this->axisOrder !== $order) {
 			//return false; //cause it is hardcoded in the specs to user lon/lat as this is so in postgis
-			return true;
+			return false;
 		} else {
-			/*if (in_array($targetOws, $owsWithOrderAsDefined) && $this->axisOrder !== $order) {
+			if (in_array($targetOws, $owsWithOrderAsDefined) && $this->axisOrder !== $order) {
 				return true;
-			}*/
+			}
 			return false;
 		}
 	}

Modified: trunk/mapbender/http/php/mod_inspireDownloadFeed.php
===================================================================
--- trunk/mapbender/http/php/mod_inspireDownloadFeed.php	2017-10-20 11:04:45 UTC (rev 9806)
+++ trunk/mapbender/http/php/mod_inspireDownloadFeed.php	2017-10-25 14:03:50 UTC (rev 9807)
@@ -1012,11 +1012,12 @@
 	/*<link rel="related" href="http://xyz.org/wfs?request=GetCapabilities&service=WFS&version=2.0.0" type="application/xml" title="Service implementing Direct Access operations"/>*/
 		$feedLink = $feedDoc->createElement("link");
 		if ($admin->getWFSOWSstring($mapbenderMetadata[$m]->wfs_id) == false) {
-			$wfsGetCapabilitiesUrl = $mapbenderMetadata[$m]->wfs_getcapabilities;
+			//$wfsGetCapabilitiesUrl = $mapbenderMetadata[$m]->wfs_getcapabilities;
+			$wfsGetCapabilitiesUrl = $mapbenderPath."php/wfs.php?INSPIRE=1&FEATURETYPE_ID=".$mapbenderMetadata[$m]->featuretype_id;
 		} else {
-			$wfsGetCapabilitiesUrl = $mapbenderServerUrl."/registry/wfs/".$mapbenderMetadata[$m]->wfs_id."?";
+			$wfsGetCapabilitiesUrl = $mapbenderServerUrl."/registry/wfs/".$mapbenderMetadata[$m]->wfs_id."?INSPIRE=1";
 		}
-		$feedLink->setAttribute("href", $wfsGetCapabilitiesUrl."&request=GetCapabilities&VERSION=1.1.0&SERVICE=WFS");
+		$feedLink->setAttribute("href", $wfsGetCapabilitiesUrl."&request=GetCapabilities&VERSION=".$mapbenderMetadata[$m]->wfs_version."&SERVICE=WFS");
 		$feedLink->setAttribute("rel", "related");
 		$feedLink->setAttribute("type", "application/xml");
 		//$feedLink->setAttribute("hreflang", "en");
@@ -1197,7 +1198,7 @@
 				//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);
+				//$e = new mb_exception("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) {
@@ -1206,31 +1207,6 @@
 					$alterAxisOrder = false;
 				}
 				//**************************************************************************************
-
-				/*
-
-				//handle other definitions of epsg ids
-				//urn:ogc:def:crs:EPSG::31467
-				//Handle CRS
-				//alter all to uppercase 
-				$crsUpper = str_replace("epsg","EPSG",$crs);
-				//Exchange :: with :
-				$crsUpper = str_replace("::",":",$crsUpper);
-				$crsUpper = str_replace(":6.9:",":",$crsUpper);
-				$epsgId = explode('EPSG:',$crsUpper);
-				$epsgId = end($epsgId);
-				//check if order have to be altered
-				if (strpos($crsUpper,'urn') !== false) {
-					$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
-						$alterAxisOrder = true;
-					} else {
-						$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>";
@@ -1283,7 +1259,7 @@
 							break;
 					}
 					$featureHits[$i] = (integer)$hits[0];
-					$e = new mb_exception($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);
@@ -1301,7 +1277,7 @@
 				$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);	
+				//$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
@@ -1382,11 +1358,15 @@
 					*/
 					if (!isset($mapbenderMetadata[$i]->geometry_field_name[0]) || $mapbenderMetadata[$i]->geometry_field_name[0] == '') {
 						$geometryFieldName = 'geometry';
+					} else {
+						$geometryFieldName = $mapbenderMetadata[$i]->geometry_field_name[0];
 					}
+					//$e = new mb_exception("mod_inspireDownloadFeed.php: geometryFieldName: ".$geometryFieldName);
+					//get bbox from wfs metadata
 					$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!");
+						//$e = new mb_exception("mod_inspireDownloadFeed.php: axis order should be altered!");
 						$currentBboxNew = $currentBbox;
 						$currentBboxGetFeature[0] = $currentBboxNew[1];
 						$currentBboxGetFeature[1] = $currentBboxNew[0];
@@ -1395,6 +1375,8 @@
 					} else {
 						$currentBboxGetFeature = $currentBbox;
 					}
+					/*$e = new mb_exception("ftname: ".$mapbenderMetadata[$i]->featuretype_name);
+					$e = new mb_exception("gfname: ".$geometryFieldName);*/
 					if (strpos($mapbenderMetadata[$i]->featuretype_name, ':') !== false) {
 						$ftNamespace = explode(':', $mapbenderMetadata[$i]->featuretype_name);
 						$ftNamespace = $ftNamespace[0];
@@ -1459,6 +1441,8 @@
 					$gFLink = $wfsGetFeatureUrl."SERVICE=WFS&REQUEST=GetFeature&VERSION=";
 					$gFLink .= $mapbenderMetadata[$i]->wfs_version."&typeName=".$mapbenderMetadata[$i]->featuretype_name;
 					$gFLink .= "&srsName=".$mapbenderMetadata[$i]->featuretype_srs;
+					//TODO check if other epsg string should be used!
+					//$crsObject->identifier;
 					if (count($mapbenderMetadata[$i]->output_formats) >= 1 && strtoupper($mapbenderMetadata[$i]->geometry_field_name[0] !== "SHAPE")) {
 						//use first output format which have been found - TODO - check if it should be pulled from featuretype instead from wfs 
 						$gFLink .= "&outputFormat=".rawurlencode($mapbenderMetadata[$i]->output_formats[0]);
@@ -1703,11 +1687,12 @@
 						$furtherLinkBbox[$m] = $featureTypeBboxWGS84[$m];
 
 						$newBox = explode(',',$furtherLinkBbox[$m]);
-						if ($alterAxisOrder == true) {
+						/*if ($alterAxisOrder == true) {
 							$newBox = $newBox[1].",".$newBox[0].",".$newBox[3].",".$newBox[2];
-						} else {
+						} else {*/
+						
 							$newBox = $newBox[0].",".$newBox[1].",".$newBox[2].",".$newBox[3];
-						}
+						/*}*/
 						//generate content links
 						$feedEntryLink = $feedDoc->createElement("link");
 						if (count($getFeatureLink) > 1) {
@@ -2067,11 +2052,12 @@
 					$t = array('i');
 					$res = db_prep_query($sql,$v,$t);
 					//pull first element with type is string like "PropertyType"
+					$geometryElements = array("GeometryPropertyType","MultiSurfacePropertyType","GeometryPropertyType","CurvePropertyType","PolygonPropertyType","LineStringPropertyType","PointPropertyType","MultiPolygonPropertyType","MultiLineStringPropertyType","MultiPointPropertyType","SurfacePropertyType");
 					while ($row = db_fetch_array($res)) {
-						//$e = new mb_notice("php/mod_inspireDownloadFeed.php: test element_type: ".$row['element_type']);
-						if (strpos($row['element_type'], "PropertyType") !== false) {
+						//$e = new mb_exception("php/mod_inspireDownloadFeed.php: test element_type: ".$row['element_type']);
+						if (in_array($row['element_type'], $geometryElements)) {
 							$mapbenderMetadata[$indexMapbenderMetadata]->geometry_field_name[] = $row['element_name'];
-							$e = new mb_notice("php/mod_inspireDownloadFeed.php: element_name of geometry field (type name like PropertyName) found: ".$row['element_name']);
+							//$e = new mb_exception("php/mod_inspireDownloadFeed.php: element_name of geometry field (type name like PropertyName) found: ".$row['element_name']);
 							break;
 						}
 					}



More information about the Mapbender_commits mailing list