[mapserver-commits] r13226 - trunk/mapserver

svn at osgeo.org svn at osgeo.org
Fri Mar 9 11:48:43 EST 2012


Author: tbonfort
Date: 2012-03-09 08:48:43 -0800 (Fri, 09 Mar 2012)
New Revision: 13226

Modified:
   trunk/mapserver/mapdraw.c
   trunk/mapserver/maputil.c
Log:
reverting changes from #4126 as they break mapfiles with no projection set on layers


Modified: trunk/mapserver/mapdraw.c
===================================================================
--- trunk/mapserver/mapdraw.c	2012-03-09 15:51:46 UTC (rev 13225)
+++ trunk/mapserver/mapdraw.c	2012-03-09 16:48:43 UTC (rev 13226)
@@ -599,16 +599,12 @@
 
 /*
  * Test whether a layer should be drawn or not in the current map view and
- * at the current scale and in the current extent.  
+ * at the current scale.  
  * Returns TRUE if layer is visible, FALSE if not.
 */
 int msLayerIsVisible(mapObj *map, layerObj *layer)
 {
   int i;
-  int shouldFreeProjection = MS_FALSE;
-  projectionObj projection;
-  rectObj ext;
-  const char *value;
 
   if(!layer->data && !layer->tileindex && !layer->connection && !layer->features && !layer->layerinfo)
     return(MS_FALSE); /* no data associated with this layer, not an error since layer may be used as a template from MapScript */
@@ -678,59 +674,6 @@
       }
   }
 
-  /* With wms_respect_extent true, mark layer is invisible if the request bbox is
-     fully outside of the layer extent */
-  value = msOWSLookupMetadata(&(layer->metadata), "MO", "respect_extent");
-  if(value && strncasecmp(value, "true", 5) == 0) {
-
-#ifdef USE_PROJ
-    /* Use a temporary projectionObj which does not affect further layer handling */
-    if (layer->projection.numargs == 0) {
-      msInitProjection(&projection);
-      shouldFreeProjection = MS_TRUE;
-
-      /* If layer has no projection (e.g. annotation layer), read it from wms_srs metadata */
-      if ((value = (char*)msOWSGetEPSGProj(NULL, &(layer->metadata), "MO", MS_TRUE)) != NULL) {
-        msLoadProjectionStringEPSG(&projection, (char *)value);
-      }
-    }
-    /* Or use a pointer to the current layer projection, which we do not free afterwards */
-    else {
-      projection = layer->projection;
-    }
-
-    /* Check presence of projection again */
-    if ( projection.numargs == 0 ) {
-      msDebug("msLayerIsVisible(): cannot comply with respect_extent metadata, layer has no projection.\n");
-    }
-    /* Get the bounding box of this layer */
-    else if (msOWSGetLayerExtent(map, layer, "MO", &ext) != MS_SUCCESS) {
-      msDebug("msLayerIsVisible(): cannot comply with respect_extent metadata, layer has no extent.\n");
-    }
-    else
-    {
-      /* reproject layer extent to request srs */
-      if (msProjectionsDiffer(&(map->projection), &projection) == MS_TRUE)
-      {
-        msProjectRect(&projection, &(map->projection), &ext);
-      }
-#endif
-      /* compare request extent to layer extent */
-      if (MS_FALSE == msRectOverlap(&(map->extent), &ext)) {
-        if (MS_TRUE == shouldFreeProjection) {
-          msFreeProjection(&projection);
-        }
-        return MS_FALSE;
-      }
-#ifdef USE_PROJ
-    }
-
-    if (MS_TRUE == shouldFreeProjection) {
-      msFreeProjection(&projection);
-    }
-#endif
-  }
-
   return MS_TRUE;  /* All tests passed.  Layer is visible. */
 }
 /*

Modified: trunk/mapserver/maputil.c
===================================================================
--- trunk/mapserver/maputil.c	2012-03-09 15:51:46 UTC (rev 13225)
+++ trunk/mapserver/maputil.c	2012-03-09 16:48:43 UTC (rev 13226)
@@ -2160,24 +2160,10 @@
 {
     rectObj map_extent;
     rectObj layer_extent;
-    int haveOwnProjection = MS_FALSE;
-    projectionObj projection;
-    const char *value;
     
     /* No extent info? Nothing we can do, return MS_UNKNOWN. */
-    /* Otherwise copy extents and leave the originals intact, */
-    /* beacuse we will need to transform our rectangles for comparison. */
     if( (map->extent.minx == -1) && (map->extent.miny == -1) && (map->extent.maxx == -1 ) && (map->extent.maxy == -1) ) return MS_UNKNOWN;
-    else MS_COPYRECT(&map_extent, &(map->extent) );
-
-    /* For the layer extent, do a second try to read the extent */
-    /* from wms_extent or layer data */
-    if( (layer->extent.minx == -1) && (layer->extent.miny == -1) && (layer->extent.maxx == -1 ) && (layer->extent.maxy == -1) ) {
-      if (msOWSGetLayerExtent(map, layer, "MO", &layer_extent) != MS_SUCCESS) {
-        return MS_UNKNOWN;
-      }
-    }
-    else MS_COPYRECT(&layer_extent, &(layer->extent) );
+    if( (layer->extent.minx == -1) && (layer->extent.miny == -1) && (layer->extent.maxx == -1 ) && (layer->extent.maxy == -1) ) return MS_UNKNOWN;
         
 #ifdef USE_PROJ
 
@@ -2185,47 +2171,24 @@
     if( ! (map->projection.numargs > 0) ) 
         return MS_UNKNOWN;
 
-    /* No layer projection? Try to get it from wms_srs. */
-    if( ! (layer->projection.numargs > 0) ) {
-      value = (char*)msOWSGetEPSGProj(NULL, &(layer->metadata), "MO", MS_TRUE);
-      if (value != NULL) {
-        msInitProjection(&projection);
-        haveOwnProjection = MS_TRUE;
-        msLoadProjectionStringEPSG(&projection, (char *)value);
-      }
-    }
-
-    /* Agaian no layer projection? Return MS_UNKNOWN. We can not perform */
-    /* naive comparison, because in WMS mode, map->extent is expressed in */
-    /* the request SRS. */
-    if( ! (layer->projection.numargs > 0) && ! (projection.numargs > 0) ) {
-        if ( MS_TRUE == haveOwnProjection ) msFreeProjection(&projection);
-        return MS_UNKNOWN;
-    }
+    /* No layer projection? Perform naive comparison, because they are 
+    ** in the same projection. */
+    if( ! (layer->projection.numargs > 0) ) 
+        return msRectOverlap( &(map->extent), &(layer->extent) );
     
+    /* We need to transform our rectangles for comparison, 
+    ** so we will work with copies and leave the originals intact. */
+    MS_COPYRECT(&map_extent, &(map->extent) );
+    MS_COPYRECT(&layer_extent, &(layer->extent) );
+
     /* Transform map extents into geographics for comparison. */
-    if( msProjectRect(&(map->projection), &(map->latlon), &map_extent) ) {
-        if ( MS_TRUE == haveOwnProjection ) msFreeProjection(&projection);
+    if( msProjectRect(&(map->projection), &(map->latlon), &map_extent) )
         return MS_UNKNOWN;
-    }
         
     /* Transform layer extents into geographics for comparison. */
-    /* First case: using layer projection */
-    /* Second case: using temporarily read projection from wms_srs */
-    if( MS_FALSE == haveOwnProjection ) {
-      if( msProjectRect(&(layer->projection), &(map->latlon), &layer_extent) ) 
-          return MS_UNKNOWN;
-    }
-    else {
-      if( msProjectRect(&(projection), &(map->latlon), &layer_extent) ) {
-          if ( MS_TRUE == haveOwnProjection ) msFreeProjection(&projection);
-          return MS_UNKNOWN;
-      }
-    }
+    if( msProjectRect(&(layer->projection), &(map->latlon), &layer_extent) )
+        return MS_UNKNOWN;
 
-    /* Finally free the possibly created projectionObj agaian */
-    if ( MS_TRUE == haveOwnProjection ) msFreeProjection(&projection);
-
     /* Simple case? Return simple answer. */
     if ( map_extent.minx < map_extent.maxx && layer_extent.minx < layer_extent.maxx )
         return msRectOverlap( &(map_extent), &(layer_extent) );
@@ -2236,7 +2199,7 @@
    
 #else
     /* No proj? Naive comparison. */
-    if( msRectOverlap( &(map_extent), &(layer_extent) ) ) return MS_TRUE;
+    if( msRectOverlap( &(map->extent), &(layer->extent) ) ) return MS_TRUE;
     return MS_FALSE;
 #endif
 



More information about the mapserver-commits mailing list