[mapserver-commits] r9087 - sandbox/pramsey/mapserver-5-4-plus

svn at osgeo.org svn at osgeo.org
Fri Jun 5 20:09:05 EDT 2009


Author: pramsey
Date: 2009-06-05 20:09:05 -0400 (Fri, 05 Jun 2009)
New Revision: 9087

Modified:
   sandbox/pramsey/mapserver-5-4-plus/HISTORY.TXT
   sandbox/pramsey/mapserver-5-4-plus/mapchart.c
   sandbox/pramsey/mapserver-5-4-plus/mapdraw.c
   sandbox/pramsey/mapserver-5-4-plus/mapquery.c
   sandbox/pramsey/mapserver-5-4-plus/mapraster.c
   sandbox/pramsey/mapserver-5-4-plus/maprasterquery.c
   sandbox/pramsey/mapserver-5-4-plus/mapresample.c
   sandbox/pramsey/mapserver-5-4-plus/mapwmslayer.c
Log:
Test msProjectRect status on return (#2844)



Modified: sandbox/pramsey/mapserver-5-4-plus/HISTORY.TXT
===================================================================
--- sandbox/pramsey/mapserver-5-4-plus/HISTORY.TXT	2009-06-05 23:16:38 UTC (rev 9086)
+++ sandbox/pramsey/mapserver-5-4-plus/HISTORY.TXT	2009-06-06 00:09:05 UTC (rev 9087)
@@ -14,6 +14,8 @@
 Current Version:
 ----------------
 
+- Test msProjectRect status on return (#2844)
+
 - Do pre-emptive test for map.extent/layer.extent interaction (#3043)
 
 Version 5.4.1 (2009-06-02):

Modified: sandbox/pramsey/mapserver-5-4-plus/mapchart.c
===================================================================
--- sandbox/pramsey/mapserver-5-4-plus/mapchart.c	2009-06-05 23:16:38 UTC (rev 9086)
+++ sandbox/pramsey/mapserver-5-4-plus/mapchart.c	2009-06-06 00:09:05 UTC (rev 9087)
@@ -566,7 +566,8 @@
     
     #ifdef USE_PROJ
         if((map->projection.numargs > 0) && (layer->projection.numargs > 0))
-            msProjectRect(&map->projection, &layer->projection, &searchrect); /* project the searchrect to source coords */
+        /* if we can't project into the source srs, the source srs is not in our extent, so no-op this layer */
+		    if ( msProjectRect(&map->projection, &layer->projection, &searchrect) == MS_FAILURE ) return MS_SUCCESS; 
     #endif
         
         status = msLayerWhichShapes(layer, searchrect);

Modified: sandbox/pramsey/mapserver-5-4-plus/mapdraw.c
===================================================================
--- sandbox/pramsey/mapserver-5-4-plus/mapdraw.c	2009-06-05 23:16:38 UTC (rev 9086)
+++ sandbox/pramsey/mapserver-5-4-plus/mapdraw.c	2009-06-06 00:09:05 UTC (rev 9087)
@@ -866,7 +866,13 @@
   
 #ifdef USE_PROJ
   if((map->projection.numargs > 0) && (layer->projection.numargs > 0))
-    msProjectRect(&map->projection, &layer->projection, &searchrect); /* project the searchrect to source coords */
+  /* project into the source srs */
+  /* if we can't do it, we have no overlap, so exit */
+  if ( msProjectRect(&map->projection, &layer->projection, &searchrect) == MS_FAILURE ) 
+  {
+    msLayerClose(layer);
+    return MS_SUCCESS;
+  } 
 #endif
     
   status = msLayerWhichShapes(layer, searchrect);

Modified: sandbox/pramsey/mapserver-5-4-plus/mapquery.c
===================================================================
--- sandbox/pramsey/mapserver-5-4-plus/mapquery.c	2009-06-05 23:16:38 UTC (rev 9086)
+++ sandbox/pramsey/mapserver-5-4-plus/mapquery.c	2009-06-06 00:09:05 UTC (rev 9087)
@@ -352,7 +352,12 @@
   searchrect = map->extent;
 #ifdef USE_PROJ  
   if(lp->project && msProjectionsDiffer(&(lp->projection), &(map->projection)))  
-    msProjectRect(&(map->projection), &(lp->projection), &searchrect); /* project the searchrect to source coords */
+    status = msProjectRect(&(map->projection), &(lp->projection), &searchrect); /* project the searchrect to source coords */
+    if ( status == MS_FAILURE ) { /* can't project => no overlap */
+      msLayerClose(lp);
+      msSetError(MS_NOTFOUND, "No matching record(s) found, layer and area of interest do not overlap.", "msQueryByAttributes()");
+      return(MS_FAILURE);
+    }
   else
     lp->project = MS_FALSE;
 #endif
@@ -508,8 +513,13 @@
     /* identify target shapes */
     searchrect = rect;
 #ifdef USE_PROJ
-    if(lp->project && msProjectionsDiffer(&(lp->projection), &(map->projection)))
-      msProjectRect(&(map->projection), &(lp->projection), &searchrect); /* project the searchrect to source coords */
+    if(lp->project && msProjectionsDiffer(&(lp->projection), &(map->projection))) {
+      status = msProjectRect(&(map->projection), &(lp->projection), &searchrect); /* project the searchrect to source coords */
+      if ( status == MS_FAILURE ) { /* can't project => no overlap */
+        msLayerClose(lp);
+        continue;
+      }
+    }
     else
       lp->project = MS_FALSE;
 #endif
@@ -735,10 +745,15 @@
       searchrect = selectshape.bounds;
 
 #ifdef USE_PROJ
-      if(lp->project && msProjectionsDiffer(&(lp->projection), &(map->projection)))      
-	msProjectRect(&(map->projection), &(lp->projection), &searchrect); /* project the searchrect to source coords */
+      if(lp->project && msProjectionsDiffer(&(lp->projection), &(map->projection))) {
+	      status = msProjectRect(&(map->projection), &(lp->projection), &searchrect); /* project the searchrect to source coords */
+	      if ( status == MS_FAILURE ) { /* can't project => no overlap */
+	        msLayerClose(lp);
+	        break; /* next layer */
+        }
+      }
       else
-	lp->project = MS_FALSE;
+	      lp->project = MS_FALSE;
 #endif
 
       searchrect.minx -= tolerance; /* expand the search box to account for layer tolerances (e.g. buffered searches) */
@@ -1002,8 +1017,13 @@
     /* identify target shapes */
     searchrect = rect;
 #ifdef USE_PROJ
-    if(lp->project && msProjectionsDiffer(&(lp->projection), &(map->projection)))
-      msProjectRect(&(map->projection), &(lp->projection), &searchrect); /* project the searchrect to source coords */
+    if(lp->project && msProjectionsDiffer(&(lp->projection), &(map->projection))) {
+      status = msProjectRect(&(map->projection), &(lp->projection), &searchrect); /* project the searchrect to source coords */
+      if ( status == MS_FAILURE ) { /* can't project => no overlap */
+        msLayerClose(lp);
+        continue;
+      }
+    }
     else
       lp->project = MS_FALSE;
 #endif
@@ -1182,8 +1202,13 @@
     /* identify target shapes */
     searchrect = selectshape->bounds;
 #ifdef USE_PROJ
-    if(lp->project && msProjectionsDiffer(&(lp->projection), &(map->projection)))
-      msProjectRect(&(map->projection), &(lp->projection), &searchrect); /* project the searchrect to source coords */
+    if(lp->project && msProjectionsDiffer(&(lp->projection), &(map->projection))) {
+      status = msProjectRect(&(map->projection), &(lp->projection), &searchrect); /* project the searchrect to source coords */
+      if ( status == MS_FAILURE ) { /* can't project => no overlap */
+        msLayerClose(lp);
+        continue;
+      }
+    }
     else
       lp->project = MS_FALSE;
 #endif
@@ -1380,7 +1405,11 @@
       
 #ifdef USE_PROJ
     if(lp->project && msProjectionsDiffer(&(lp->projection), &(map->projection)))
-      msProjectRect(&(map->projection), &(lp->projection), &searchrect); /* project the searchrect to source coords */
+      status = msProjectRect(&(map->projection), &(lp->projection), &searchrect); /* project the searchrect to source coords */
+      if ( status == MS_FAILURE ) { /* can't project => no overlap */
+        msLayerClose(lp);
+        continue;
+      }
     else
       lp->project = MS_FALSE;
 #endif

Modified: sandbox/pramsey/mapserver-5-4-plus/mapraster.c
===================================================================
--- sandbox/pramsey/mapserver-5-4-plus/mapraster.c	2009-06-05 23:16:38 UTC (rev 9086)
+++ sandbox/pramsey/mapserver-5-4-plus/mapraster.c	2009-06-06 00:09:05 UTC (rev 9087)
@@ -1408,7 +1408,13 @@
     searchrect = map->extent;
 #ifdef USE_PROJ
     /* if necessary, project the searchrect to source coords */
-    if((map->projection.numargs > 0) && (layer->projection.numargs > 0)) msProjectRect(&map->projection, &layer->projection, &searchrect);
+    if((map->projection.numargs > 0) && (layer->projection.numargs > 0)) {
+      status = msProjectRect(&map->projection, &layer->projection, &searchrect);
+      if ( status == MS_FAILURE ) { /* can't project => no overlap */
+        final_status = MS_SUCCESS;
+        goto cleanup;
+      }
+    }
 #endif
     status = msLayerWhichShapes(tlp, searchrect);
     if (status != MS_SUCCESS) {

Modified: sandbox/pramsey/mapserver-5-4-plus/maprasterquery.c
===================================================================
--- sandbox/pramsey/mapserver-5-4-plus/maprasterquery.c	2009-06-05 23:16:38 UTC (rev 9086)
+++ sandbox/pramsey/mapserver-5-4-plus/maprasterquery.c	2009-06-06 00:09:05 UTC (rev 9087)
@@ -416,7 +416,7 @@
     CPLErr      eErr;
     rasterLayerInfo *rlinfo;
     rectObj     searchrect;
-    int         needReproject = MS_FALSE;
+    int         status, needReproject = MS_FALSE;
 
     rlinfo = (rasterLayerInfo *) layer->layerinfo;
 
@@ -429,7 +429,12 @@
     if(layer->project 
        && msProjectionsDiffer(&(layer->projection), &(map->projection)))
     {
-        msProjectRect(&(map->projection), &(layer->projection), &searchrect);
+        status = msProjectRect(&(map->projection), &(layer->projection), &searchrect);
+        if ( status == MS_FAILURE ) {
+          msSetError( MS_IMGERR, "Unable to project into source SRS.", 
+                    "msRasterQueryByRectLow()" );
+          return MS_FAILURE;
+        }
         needReproject = MS_TRUE;
     }
     else
@@ -732,15 +737,21 @@
 
         searchrect = queryRect;
 
+        status = MS_SUCCESS;
 #ifdef USE_PROJ
         if((map->projection.numargs > 0) && (layer->projection.numargs > 0))
-            msProjectRect(&map->projection, &layer->projection, &searchrect); /* project the searchrect to source coords */
+            status = msProjectRect(&map->projection, &layer->projection, &searchrect); /* project the searchrect to source coords */
 #endif
-        status = msShapefileWhichShapes(&tilefile, searchrect, layer->debug);
-        if(status != MS_SUCCESS) 
+        if ( status == MS_SUCCESS ) { /* rectangle projected properly */
+          status = msShapefileWhichShapes(&tilefile, searchrect, layer->debug);
+          if(status != MS_SUCCESS) 
             numtiles = 0; /* could be MS_DONE or MS_FAILURE */
-        else
+          else
             numtiles = tilefile.numshapes;
+        }
+        else { /* rectangle didn't project => no overlap */
+          numtiles = 0;
+        }
     }
 
 /* -------------------------------------------------------------------- */

Modified: sandbox/pramsey/mapserver-5-4-plus/mapresample.c
===================================================================
--- sandbox/pramsey/mapserver-5-4-plus/mapresample.c	2009-06-05 23:16:38 UTC (rev 9086)
+++ sandbox/pramsey/mapserver-5-4-plus/mapresample.c	2009-06-06 00:09:05 UTC (rev 9087)
@@ -1317,7 +1317,7 @@
 #if !defined(PJD_GRIDSHIFT) && !defined(PJ_VERSION)
     msSetError(MS_PROJERR, 
                "Projection support is not available, so msResampleGDALToMap() fails.", 
-               "msProjectRect()");
+               "msResampleGDALToMap()");
     return(MS_FAILURE);
 #else
     int		nSrcXSize, nSrcYSize, nDstXSize, nDstYSize;

Modified: sandbox/pramsey/mapserver-5-4-plus/mapwmslayer.c
===================================================================
--- sandbox/pramsey/mapserver-5-4-plus/mapwmslayer.c	2009-06-05 23:16:38 UTC (rev 9086)
+++ sandbox/pramsey/mapserver-5-4-plus/mapwmslayer.c	2009-06-06 00:09:05 UTC (rev 9087)
@@ -817,7 +817,7 @@
     char *pszURL = NULL, *pszHTTPCookieData = NULL;
     const char *pszTmp;
     rectObj bbox;
-    int nTimeout, bOkToMerge, bForceSeparateRequest;
+    int nTimeout, bOkToMerge, bForceSeparateRequest, status;
     wmsParamsObj sThisWMSParams;
     
     char    *pszProxyHost=NULL;
@@ -874,7 +874,13 @@
         /* Reproject latlonboundingbox to the selected SRS for the layer and */
         /* check if it overlaps the bbox that we calculated for the request */
 
-        msProjectRect(&(map->latlon), &(lp->projection), &ext);
+        if ( msProjectRect(&(map->latlon), &(lp->projection), &ext) == MS_FAILURE ) 
+        {
+          /* no rectangle projection => no overlap => nothing to do */
+          msFreeWmsParamsObj(&sThisWMSParams);
+          return MS_SUCCESS;  /* No overlap. */
+        }
+
         if (!msRectOverlap(&bbox, &ext))
         {
             /* No overlap... nothing to do */



More information about the mapserver-commits mailing list