[Mapbender-commits] r8473 - trunk/mapbender/http/php
svn_mapbender at osgeo.org
svn_mapbender at osgeo.org
Tue Aug 28 08:18:55 PDT 2012
Author: armin11
Date: 2012-08-28 08:18:54 -0700 (Tue, 28 Aug 2012)
New Revision: 8473
Modified:
trunk/mapbender/http/php/mod_inspireDownloadFeed.php
Log:
Bugfix in calculating the bbox for wfs sources
Modified: trunk/mapbender/http/php/mod_inspireDownloadFeed.php
===================================================================
--- trunk/mapbender/http/php/mod_inspireDownloadFeed.php 2012-08-28 10:41:45 UTC (rev 8472)
+++ trunk/mapbender/http/php/mod_inspireDownloadFeed.php 2012-08-28 15:18:54 UTC (rev 8473)
@@ -609,7 +609,6 @@
$gHLink = $mapbenderMetadata[$i]->wfs_getfeature."SERVICE=WFS&REQUEST=GetFeature&VERSION=";
$gHLink .= $mapbenderMetadata[$i]->wfs_version."&typeName=";
$gHLink .= $mapbenderMetadata[$i]->featuretype_name."&resultType=hits";
- //echo $gHLink;
$startRequestTime = time();
$hitConnector = new connector($gHLink);
$hitXml = $hitConnector->file;
@@ -617,7 +616,6 @@
$endRequestTime = time();
$diffTime = $endRequestTime-$startRequestTime;
$e = new mb_notice("Time for counting objects of featuretype ".$mapbenderMetadata[$i]->featuretype_name." : ".$diffTime." seconds!");
- //$e = new mb_exception($hitXml);
//parse hits
try {
$featureTypeHits = new SimpleXMLElement($hitXml);
@@ -631,18 +629,10 @@
$hits = $featureTypeHits->xpath('/wfs:FeatureCollection/@numberOfFeatures');
$featureHits[$i] = (integer)$hits[0];
$e = new mb_notice($featureHits[$i]." hits for featuretype ".$mapbenderMetadata[$i]->featuretype_name);
- //$e = new mb_exception($featureHits[$i]);
-
//calculate further bboxes if the # of hits extents some value
-
-
//minimum number of single tiles:
$countTiles = ceil($featureHits[$i]/$maxFeatureCount);
- //echo $countTiles;
- //echo $maxFeatureCount;
- //$e = new mb_exception($countTiles);
//calculate number of rows and columns from x / y ratio
-
$sqlMinx = "SELECT X(transform(GeometryFromText('POINT(".$mapbenderMetadata[$i]->minx." ".$mapbenderMetadata[$i]->miny.")',4326),".$epsgId[1].")) as minx";
$resMinx = db_query($sqlMinx);
$minx = floatval(db_result($resMinx,0,"minx"));
@@ -658,46 +648,44 @@
$sqlMaxy = "SELECT Y(transform(GeometryFromText('POINT(".$mapbenderMetadata[$i]->maxx." ".$mapbenderMetadata[$i]->maxy.")',4326),".$epsgId[1].")) as maxy";
$resMaxy = db_query($sqlMaxy);
$maxy = floatval(db_result($resMaxy,0,"maxy"));
-
- $diffX = $maxx - $minx; //in m - depends on given epsg code
- $diffY = $maxy - $miny; //in m
- $e = new mb_notice($diffX);
- $e = new mb_notice($diffY);
-
- $width = ceil(sqrt(($diffX * $diffY) / $countTiles));
- $e = new mb_notice($width);
- $nRows = ceil($diffY / $width);
- $nCols = ceil($diffX / $width);
-
- $bboxWfs = array();
- $countBbox = 0;
- /*echo $diffXPx.":".$diffYPx.",";
- echo $nRows.":".$nCols.",";
- echo $minx.":".$miny.",";
- echo $maxx.":".$maxy.",";*/
- for ($j = 0; $j < $nRows; $j++) {
- for ($k = 0; $k < $nCols; $k++) {
- //echo "j: ".$k.",k: ".$j;
- $minxWfs = $minx + $k * $width;
- //echo "minxWms: ". $minxWms .",";
- $minyWfs = $miny + $j * $width;
- //echo "minyWms: ". $minyWms .",";
- $maxxWfs = $minx + ($k+1) * $width;
- //echo "maxxWms: ". $maxxWms .",";
- $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[1]),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
-
- //$e = new mb_exception($test);
-
- $countBbox++;
+ //only calculate new boxes if countTiles > 1
+ if ($countTiles > 1) {
+ $diffX = $maxx - $minx; //in m - depends on given epsg code
+ $diffY = $maxy - $miny; //in m
+ $width = ceil(sqrt(($diffX * $diffY) / $countTiles));
+ $nRows = ceil($diffY / $width);
+ $nCols = ceil($diffX / $width);
+ $bboxWfs = array();
+ $countBbox = 0;
+ for ($j = 0; $j < $nRows; $j++) {
+ for ($k = 0; $k < $nCols; $k++) {
+ //echo "j: ".$k.",k: ".$j;
+ $minxWfs = $minx + $k * $width;
+ //echo "minxWms: ". $minxWms .",";
+ $minyWfs = $miny + $j * $width;
+ //echo "minyWms: ". $minyWms .",";
+ $maxxWfs = $minx + ($k+1) * $width;
+ //echo "maxxWms: ". $maxxWms .",";
+ $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[1]),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++;
+ }
}
+ } else {
+ //only normal extent used
+ $bboxWfs[$mapbenderMetadata[$i]->featuretype_name][0] = $minx.",".$miny.",".$maxx.",".$maxy;
+ //transform bbox back to geographic coordinates
+ $lonLatBbox = transformBbox($minx.",".$miny.",".$maxx.",".$maxy,intval($epsgId[1]),4326);
+ $lonLatBbox = explode(',',$lonLatBbox);
+ //georss needs latitude longitude
+ $featureTypeBboxWGS84[] = $lonLatBbox[1].",".$lonLatBbox[0].",".$lonLatBbox[3].",".$lonLatBbox[2];
}
//$getFeatureLink = array();
/*TODO for ($i = 0; $i < $countRessource-1; $i++) {
More information about the Mapbender_commits
mailing list