MCPcopy Index your code
hub / github.com/MapServer/MapServer / msExtentsOverlap

Function msExtentsOverlap

maputil.c:2083–2130  ·  view source on GitHub ↗

** Issue #3043: Layer extent comparison short circuit. ** ** msExtentsOverlap() ** ** Returns MS_TRUE if map extent and layer extent overlap, ** MS_FALSE if they are disjoint, and MS_UNKNOWN if there is ** not enough info to calculate a deterministic answer. ** */

Source from the content-addressed store, hash-verified

2081**
2082*/
2083int msExtentsOverlap(mapObj *map, layerObj *layer)
2084{
2085 rectObj map_extent;
2086 rectObj layer_extent;
2087
2088 /* No extent info? Nothing we can do, return MS_UNKNOWN. */
2089 if( (map->extent.minx == -1) && (map->extent.miny == -1) && (map->extent.maxx == -1 ) && (map->extent.maxy == -1) ) return MS_UNKNOWN;
2090 if( (layer->extent.minx == -1) && (layer->extent.miny == -1) && (layer->extent.maxx == -1 ) && (layer->extent.maxy == -1) ) return MS_UNKNOWN;
2091
2092#ifdef USE_PROJ
2093
2094 /* No map projection? Let someone else sort this out. */
2095 if( ! (map->projection.numargs > 0) )
2096 return MS_UNKNOWN;
2097
2098 /* No layer projection? Perform naive comparison, because they are
2099 ** in the same projection. */
2100 if( ! (layer->projection.numargs > 0) )
2101 return msRectOverlap( &(map->extent), &(layer->extent) );
2102
2103 /* We need to transform our rectangles for comparison,
2104 ** so we will work with copies and leave the originals intact. */
2105 MS_COPYRECT(&map_extent, &(map->extent) );
2106 MS_COPYRECT(&layer_extent, &(layer->extent) );
2107
2108 /* Transform map extents into geographics for comparison. */
2109 if( msProjectRect(&(map->projection), &(map->latlon), &map_extent) )
2110 return MS_UNKNOWN;
2111
2112 /* Transform layer extents into geographics for comparison. */
2113 if( msProjectRect(&(layer->projection), &(map->latlon), &layer_extent) )
2114 return MS_UNKNOWN;
2115
2116 /* Simple case? Return simple answer. */
2117 if ( map_extent.minx < map_extent.maxx && layer_extent.minx < layer_extent.maxx )
2118 return msRectOverlap( &(map_extent), &(layer_extent) );
2119
2120 /* Uh oh, one of the rects crosses the dateline!
2121 ** Let someone else handle it. */
2122 return MS_UNKNOWN;
2123
2124#else
2125 /* No proj? Naive comparison. */
2126 if( msRectOverlap( &(map->extent), &(layer->extent) ) ) return MS_TRUE;
2127 return MS_FALSE;
2128#endif
2129
2130}
2131
2132/************************************************************************/
2133/* msSmallMalloc() */

Callers 1

msLayerIsVisibleFunction · 0.85

Calls 2

msRectOverlapFunction · 0.85
msProjectRectFunction · 0.85

Tested by

no test coverage detected