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);
{
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);
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);
}
* @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__);
/* 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 */
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;
}
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;
}
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;