]> granicus.if.org Git - postgis/commitdiff
Move some types around, see if winnie gets happier
authorPaul Ramsey <pramsey@cleverelephant.ca>
Thu, 28 May 2015 20:21:54 +0000 (20:21 +0000)
committerPaul Ramsey <pramsey@cleverelephant.ca>
Thu, 28 May 2015 20:21:54 +0000 (20:21 +0000)
git-svn-id: http://svn.osgeo.org/postgis/trunk@13577 b70326c6-7e19-0410-871a-916f4a2858ee

liblwgeom/cunit/cu_in_twkb.c
liblwgeom/lwout_twkb.c

index b409395518e845adf47f36a16d3cdf2113857c84..0930741f9f288979cf0ee0cd724dcd980d857b99 100644 (file)
@@ -84,8 +84,8 @@ static void cu_twkb_in(char *wkt)
        twkb_b = lwgeom_to_twkb(g_b, variant, precision, precision, precision, &twkb_size_b);
 
        /* Turn TWKB into hex for comparisons */
-       if ( hex_a ) free(hex_a);
-       if ( hex_b ) free(hex_b);
+       if ( hex_a ) lwfree(hex_a);
+       if ( hex_b ) lwfree(hex_b);
        hex_a = hexbytes_from_bytes(twkb_a, twkb_size_a);
        hex_b = hexbytes_from_bytes(twkb_b, twkb_size_b);
 
@@ -208,7 +208,6 @@ static void test_twkb_in_precision(void)
        {
                cu_twkb_in("MULTILINESTRING((0 0,0 1),EMPTY,(1 1, 10 10))");
                CU_ASSERT_STRING_EQUAL(hex_a, hex_b);
-               // printf("old: %s\nnew: %s\n",hex_a, hex_b);
 
                cu_twkb_in("MULTIPOLYGON(((0 0 0,0 1 0,1 1 0,1 0 0,0 0 0)),((-1 -1 0,-1 2 0,2 2 0,2 -1 0,-1 -1 0),(0 0 0,0 1 0,1 1 0,1 0 0,0 0 0)))");
                CU_ASSERT_STRING_EQUAL(hex_a, hex_b);
@@ -217,6 +216,7 @@ static void test_twkb_in_precision(void)
                CU_ASSERT_STRING_EQUAL(hex_a, hex_b);
 
                cu_twkb_in("MULTILINESTRING((0 0 200000,0 1 10),(1 100000000 23, 10 10 45))");
+               // printf("old: %s\nnew: %s\n",hex_a, hex_b);
                CU_ASSERT_STRING_EQUAL(hex_a, hex_b);
        }
 
index b8f1b9062f42c2595a73bf4f5bc97215c00e9f1f..c0c6fe13c1664a2d1ba3cbaea4c10a82e884d27e 100644 (file)
@@ -89,14 +89,13 @@ static void write_bbox(TWKB_STATE *ts, int ndims)
 * @register_npoints, controls whether an npoints entry is added to the buffer (used to skip npoints for point types)
 * @dimension, states the dimensionality of object this array is part of (0 = point, 1 = linear, 2 = areal)
 */
-static int ptarray_to_twkb_buf(const POINTARRAY *pa, TWKB_GLOBALS *globals, TWKB_STATE *ts, int register_npoints, int dimension)
+static int ptarray_to_twkb_buf(const POINTARRAY *pa, TWKB_GLOBALS *globals, TWKB_STATE *ts, int register_npoints, int minpoints)
 {
        int ndims = FLAGS_NDIMS(pa->flags);
        int i, j;
        bytebuffer_t b;
-       int nextdelta[MAX_N_DIMS];
+       int64_t nextdelta[MAX_N_DIMS];
        int npoints = 0;
-       int minpoints = pow(2, dimension); /* 1 pt for point, 2 for line, 4 for ring */
 
        LWDEBUGF(2, "Entered %s", __func__);
 
@@ -124,9 +123,9 @@ static int ptarray_to_twkb_buf(const POINTARRAY *pa, TWKB_GLOBALS *globals, TWKB
                        /* from the last point but instead the distance from our */
                        /* last accumulated point. This is important to not build up an */
                        /* accumulated error when rounding the coordinates */
-                       nextdelta[j] = (int) lround(globals->factor[j] * dbl_ptr[j]) - ts->accum_rels[j];
+                       nextdelta[j] = (int64_t) lround(globals->factor[j] * dbl_ptr[j]) - ts->accum_rels[j];
                        LWDEBUGF(4, "deltavalue: %d, ", nextdelta[j]);
-                       diff += abs(nextdelta[j]);
+                       diff += llabs(nextdelta[j]);
                }
                
                /* Skipping the first point is not allowed */
@@ -183,7 +182,7 @@ static int lwpoint_to_twkb_buf(const LWPOINT *pt, TWKB_GLOBALS *globals, TWKB_ST
        LWDEBUGF(2, "Entered %s", __func__);
 
        /* Set the coordinates (don't write npoints) */
-       ptarray_to_twkb_buf(pt->point, globals, ts, 0, 0);
+       ptarray_to_twkb_buf(pt->point, globals, ts, 0, 1);
        return 0;
 }
 
@@ -196,7 +195,7 @@ static int lwline_to_twkb_buf(const LWLINE *line, TWKB_GLOBALS *globals, TWKB_ST
        LWDEBUGF(2, "Entered %s", __func__);
 
        /* Set the coordinates (do write npoints) */
-       ptarray_to_twkb_buf(line->points, globals, ts, 1, 1);
+       ptarray_to_twkb_buf(line->points, globals, ts, 1, 2);
        return 0;
 }
 
@@ -214,7 +213,7 @@ static int lwpoly_to_twkb_buf(const LWPOLY *poly, TWKB_GLOBALS *globals, TWKB_ST
        for ( i = 0; i < poly->nrings; i++ )
        {
                /* Set the coordinates (do write npoints) */
-               ptarray_to_twkb_buf(poly->rings[i], globals, ts, 1, 2);
+               ptarray_to_twkb_buf(poly->rings[i], globals, ts, 1, 4);
        }
 
        return 0;