From 9d9c19d7c14aad9e439a5bdf648b190bd97a0f27 Mon Sep 17 00:00:00 2001 From: Bborie Park Date: Fri, 24 Feb 2012 17:33:48 +0000 Subject: [PATCH] Added additional conditions for rt_raster_gdal_rasterize() determining when to expand the extent. git-svn-id: http://svn.osgeo.org/postgis/trunk@9286 b70326c6-7e19-0410-871a-916f4a2858ee --- raster/rt_core/rt_api.c | 45 ++++++++++++++++++---- raster/test/regress/rt_intersects_expected | 8 ++-- 2 files changed, 41 insertions(+), 12 deletions(-) diff --git a/raster/rt_core/rt_api.c b/raster/rt_core/rt_api.c index d1e32dad2..ef5d60bc2 100644 --- a/raster/rt_core/rt_api.c +++ b/raster/rt_core/rt_api.c @@ -8915,16 +8915,45 @@ rt_raster_gdal_rasterize(const unsigned char *wkb, #if POSTGIS_GDAL_VERSION > 18 RASTER_DEBUG(3, "Adjusting extent for GDAL > 1.8 by half the scale"); - src_env.MinX -= (_scale[0] / 2.); - src_env.MaxX += (_scale[0] / 2.); - src_env.MinY -= (_scale[1] / 2.); - src_env.MaxY += (_scale[1] / 2.); + + if ( + FLT_EQ((src_env.MaxX - src_env.MinX), 0) || + (wkbtype == wkbMultiPoint) || + (wkbtype == wkbMultiLineString) + ) { + src_env.MinX -= (_scale[0] / 2.); + src_env.MaxX += (_scale[0] / 2.); + } + + if ( + FLT_EQ((src_env.MaxY - src_env.MinY), 0) || + (wkbtype == wkbMultiPoint) || + (wkbtype == wkbMultiLineString) + ) { + src_env.MinY -= (_scale[1] / 2.); + src_env.MaxY += (_scale[1] / 2.); + } + #else RASTER_DEBUG(3, "Adjusting extent for GDAL <= 1.8 by the scale"); - src_env.MinX -= _scale[0]; - src_env.MaxX += _scale[0]; - src_env.MinY -= _scale[1]; - src_env.MaxY += _scale[1]; + + if ( + FLT_EQ((src_env.MaxX - src_env.MinX), 0) || + (wkbtype == wkbMultiPoint) || + (wkbtype == wkbMultiLineString) + ) { + src_env.MinX -= _scale[0]; + src_env.MaxX += _scale[0]; + } + + if ( + FLT_EQ((src_env.MaxY - src_env.MinY), 0) || + (wkbtype == wkbMultiPoint) || + (wkbtype == wkbMultiLineString) + ) { + src_env.MinY -= _scale[1]; + src_env.MaxY += _scale[1]; + } #endif } diff --git a/raster/test/regress/rt_intersects_expected b/raster/test/regress/rt_intersects_expected index e47990fc3..a17cebb1d 100644 --- a/raster/test/regress/rt_intersects_expected +++ b/raster/test/regress/rt_intersects_expected @@ -188,7 +188,7 @@ NOTICE: table "raster_intersects_geom" does not exist, skipping 2.5|0|25|ST_LineString|f 2.5|0|26|ST_LineString|t 2.5|0|27|ST_LineString|t -2.5|0|28|ST_LineString|t +2.5|0|28|ST_LineString|f 2.5|0|29|ST_LineString|f 2.5|0|31|ST_Polygon|t 2.5|0|32|ST_Polygon|t @@ -217,10 +217,10 @@ NOTICE: table "raster_intersects_geom" does not exist, skipping 2.6|2|15|ST_MultiPoint|t 2.6|2|21|ST_LineString|t 2.6|2|22|ST_LineString|t -2.6|2|23|ST_LineString|t -2.6|2|24|ST_LineString|t +2.6|2|23|ST_LineString|f +2.6|2|24|ST_LineString|f 2.6|2|25|ST_LineString|t -2.6|2|26|ST_LineString|t +2.6|2|26|ST_LineString|f 2.6|2|27|ST_LineString|t 2.6|2|28|ST_LineString|t 2.6|2|29|ST_LineString|t -- 2.40.0