Skip to content

Commit 9695eca

Browse files
Martin Kofahltbonfort
Martin Kofahl
authored andcommitted
MapServer#3443 reports a huge performance issue because of falling back to world bounds when reprojection of a map request rectangle into layer projection fails. This patch will abort drawing such a layer.
1 parent 9bcec4f commit 9695eca

File tree

2 files changed

+13
-14
lines changed

2 files changed

+13
-14
lines changed

mapproject.c

+5-13
Original file line numberDiff line numberDiff line change
@@ -641,20 +641,12 @@ int msProjectRectGrid(projectionObj *in, projectionObj *out, rectObj *rect)
641641
}
642642

643643
if( !rect_initialized ) {
644-
if( out == NULL || out->proj == NULL
645-
|| pj_is_latlong(in->proj) ) {
646-
prj_rect.minx = -180;
647-
prj_rect.maxx = 180;
648-
prj_rect.miny = -90;
649-
prj_rect.maxy = 90;
650-
} else {
651-
prj_rect.minx = -22000000;
652-
prj_rect.maxx = 22000000;
653-
prj_rect.miny = -11000000;
654-
prj_rect.maxy = 11000000;
655-
}
644+
prj_rect.minx = 0;
645+
prj_rect.maxx = 0;
646+
prj_rect.miny = 0;
647+
prj_rect.maxy = 0;
656648

657-
msDebug( "msProjectRect(): all points failed to reproject, trying to fall back to using world bounds ... hope this helps.\n" );
649+
msSetError(MS_PROJERR, "All points failed to reproject.", "msProjectRect()");
658650
} else {
659651
msDebug( "msProjectRect(): some points failed to reproject, doing internal sampling.\n" );
660652
}

mapraster.c

+8-1
Original file line numberDiff line numberDiff line change
@@ -474,7 +474,14 @@ int msDrawRasterLayerLow(mapObj *map, layerObj *layer, imageObj *image,
474474
searchrect = map->extent;
475475
#ifdef USE_PROJ
476476
/* if necessary, project the searchrect to source coords */
477-
if((map->projection.numargs > 0) && (layer->projection.numargs > 0)) msProjectRect(&map->projection, &layer->projection, &searchrect);
477+
if((map->projection.numargs > 0) && (layer->projection.numargs > 0)) {
478+
if( msProjectRect(&map->projection, &layer->projection, &searchrect)
479+
!= MS_SUCCESS ) {
480+
msDebug( "msDrawRasterLayerLow(%s): unable to reproject map request rectangle into layer projection, canceling.\n", layer->name );
481+
final_status = MS_FAILURE;
482+
goto cleanup;
483+
}
484+
}
478485
#endif
479486
status = msLayerWhichShapes(tlp, searchrect, MS_FALSE);
480487
if (status != MS_SUCCESS) {

0 commit comments

Comments
 (0)