[postgis-commits] svn - r3658 - spike/wktraster/rt_core
postgis-commits at postgis.refractions.net
postgis-commits at postgis.refractions.net
Fri Feb 6 02:14:32 PST 2009
Author: strk
Date: 2009-02-06 02:14:32 -0800 (Fri, 06 Feb 2009)
New Revision: 3658
Modified:
spike/wktraster/rt_core/rt_api.c
spike/wktraster/rt_core/rt_api.h
spike/wktraster/rt_core/testapi.c
Log:
Fix envelope computation to take into account pixel sizes.
Modified: spike/wktraster/rt_core/rt_api.c
===================================================================
--- spike/wktraster/rt_core/rt_api.c 2009-02-06 09:24:09 UTC (rev 3657)
+++ spike/wktraster/rt_core/rt_api.c 2009-02-06 10:14:32 UTC (rev 3658)
@@ -1051,16 +1051,16 @@
void
rt_raster_cell_to_geopoint(rt_context ctx, rt_raster raster,
- unsigned int x, unsigned int y,
+ double x, double y,
double* x1, double* y1)
{
*x1 = raster->scaleX*x + raster->skewX*y + raster->ipX;
*y1 = raster->scaleY*y + raster->skewY*x + raster->ipY;
- ctx->info("rt_raster_cell_to_geopoint(%d,%d)", x, y);
+ ctx->info("rt_raster_cell_to_geopoint(%g,%g)", x, y);
ctx->info(" ipx/y:%g/%g", raster->ipX, raster->ipY);
- ctx->info("cell_to_geopoint: ipX:%g, ipY:%g, %d,%d -> %g,%g",
+ ctx->info("cell_to_geopoint: ipX:%g, ipY:%g, %g,%g -> %g,%g",
raster->ipX, raster->ipY, x, y, *x1, *y1);
}
@@ -1090,26 +1090,26 @@
/* Upper-left corner (first and last points) */
rt_raster_cell_to_geopoint(ctx, raster,
- 0, 0,
+ 0-raster->ipX, 0-raster->ipY,
&p4d.x, &p4d.y);
setPoint4d(pts, 0, &p4d);
setPoint4d(pts, 4, &p4d); /* needed for closing it? */
/* Upper-right corner (we go clockwise) */
rt_raster_cell_to_geopoint(ctx, raster,
- raster->width-1, 0,
+ raster->width-1+raster->ipX, 0-raster->ipY,
&p4d.x, &p4d.y);
setPoint4d(pts, 1, &p4d);
/* Lower-right corner */
rt_raster_cell_to_geopoint(ctx, raster,
- raster->width-1, raster->height-1,
+ raster->width-1+raster->ipX, raster->height-1+raster->ipY,
&p4d.x, &p4d.y);
setPoint4d(pts, 2, &p4d);
/* Lower-left corner */
rt_raster_cell_to_geopoint(ctx, raster,
- 0, raster->height-1,
+ 0-raster->ipX, raster->height-1+raster->ipY,
&p4d.x, &p4d.y);
setPoint4d(pts, 3, &p4d);
Modified: spike/wktraster/rt_core/rt_api.h
===================================================================
--- spike/wktraster/rt_core/rt_api.h 2009-02-06 09:24:09 UTC (rev 3657)
+++ spike/wktraster/rt_core/rt_api.h 2009-02-06 10:14:32 UTC (rev 3658)
@@ -450,7 +450,7 @@
int32_t rt_raster_get_srid(rt_context ctx, rt_raster raster);
/**
- * Convert an x,y cell on raster to an x1,y1 point on map
+ * Convert an x,y raster point to an x1,y1 point on map
*
* @param ctx : context for thread safety
* @param raster : the raster to get info from
@@ -460,7 +460,7 @@
* @param y1 : output parameter, Y ordinate of the geographical point
*/
void rt_raster_cell_to_geopoint(rt_context ctx, rt_raster raster,
- unsigned int x, unsigned int y,
+ double x, double y,
double* x1, double* y1);
/**
Modified: spike/wktraster/rt_core/testapi.c
===================================================================
--- spike/wktraster/rt_core/testapi.c 2009-02-06 09:24:09 UTC (rev 3657)
+++ spike/wktraster/rt_core/testapi.c 2009-02-06 10:14:32 UTC (rev 3658)
@@ -872,28 +872,28 @@
getPoint4d_p(ring, 0, &pt);
printf("First point on envelope ring is %g,%g\n", pt.x, pt.y);
- CHECK_EQUALS(pt.x, 0.5);
- CHECK_EQUALS(pt.y, 0.5);
+ CHECK_EQUALS(pt.x, 0.0);
+ CHECK_EQUALS(pt.y, 0.0);
getPoint4d_p(ring, 1, &pt);
printf("Second point on envelope ring is %g,%g\n", pt.x, pt.y);
- CHECK_EQUALS(pt.x, 255.5);
- CHECK_EQUALS(pt.y, 0.5);
+ CHECK_EQUALS(pt.x, 256);
+ CHECK_EQUALS(pt.y, 0.0);
getPoint4d_p(ring, 2, &pt);
printf("Third point on envelope ring is %g,%g\n", pt.x, pt.y);
- CHECK_EQUALS(pt.x, 255.5);
- CHECK_EQUALS(pt.y, 255.5);
+ CHECK_EQUALS(pt.x, 256);
+ CHECK_EQUALS(pt.y, 256);
getPoint4d_p(ring, 3, &pt);
printf("Fourth point on envelope ring is %g,%g\n", pt.x, pt.y);
- CHECK_EQUALS(pt.x, 0.5);
- CHECK_EQUALS(pt.y, 255.5);
+ CHECK_EQUALS(pt.x, 0);
+ CHECK_EQUALS(pt.y, 256);
getPoint4d_p(ring, 4, &pt);
printf("Fifth point on envelope ring is %g,%g\n", pt.x, pt.y);
- CHECK_EQUALS(pt.x, 0.5);
- CHECK_EQUALS(pt.y, 0.5);
+ CHECK_EQUALS(pt.x, 0.0);
+ CHECK_EQUALS(pt.y, 0.0);
lwpoly_free(envelope);
}
More information about the postgis-commits
mailing list