- #2567, ST_Count(tablename, rastercolumn, ...) uses ST_CountAgg()
- By default, PostGIS raster disables all GDAL drivers affecting
out-db rasters, ST_FromGDALRaster() and ST_AsGDALRaster() variants
+ - #3181, POINT EMPTY is now stored as POINT(NaN NaN) in WKB, instead of as MULTIPOINT EMPTY
* Deprecated signatures *
CU_ASSERT_STRING_EQUAL(hex_a, hex_b);
cu_wkb_in("SRID=4;POINTM(1 1 1)");
-// printf("old: %s\nnew: %s\n",hex_a, hex_b);
CU_ASSERT_STRING_EQUAL(hex_a, hex_b);
+
+ cu_wkb_in("POINT EMPTY");
+ CU_ASSERT_STRING_EQUAL(hex_a, hex_b);
+
+ cu_wkb_in("SRID=4326;POINT EMPTY");
+ CU_ASSERT_STRING_EQUAL(hex_a, hex_b);
+
+ cu_wkb_in("POINT Z EMPTY");
+ CU_ASSERT_STRING_EQUAL(hex_a, hex_b);
+
+ cu_wkb_in("POINT M EMPTY");
+ CU_ASSERT_STRING_EQUAL(hex_a, hex_b);
+
+ cu_wkb_in("POINT ZM EMPTY");
+ CU_ASSERT_STRING_EQUAL(hex_a, hex_b);
+
}
static void test_wkb_in_linestring(void)
-
static void test_lwgeom_from_gserialized(void)
{
LWGEOM *geom;
cu_wkb("SRID=4;POINTM(1 1 1)");
CU_ASSERT_STRING_EQUAL(s,"0060000001000000043FF00000000000003FF00000000000003FF0000000000000");
+
+ cu_wkb("POINT EMPTY");
+ CU_ASSERT_STRING_EQUAL(s,"00000000017FF80000000000007FF8000000000000");
+
+ cu_wkb("SRID=4326;POINT EMPTY");
+ CU_ASSERT_STRING_EQUAL(s,"0020000001000010E67FF80000000000007FF8000000000000");
+
+ cu_wkb("POINT Z EMPTY");
+ CU_ASSERT_STRING_EQUAL(s,"00800000017FF80000000000007FF80000000000007FF8000000000000");
+
+ cu_wkb("POINT M EMPTY");
+ CU_ASSERT_STRING_EQUAL(s,"00400000017FF80000000000007FF80000000000007FF8000000000000");
+
+ cu_wkb("POINT ZM EMPTY");
+ CU_ASSERT_STRING_EQUAL(s,"00C00000017FF80000000000007FF80000000000007FF80000000000007FF8000000000000");
}
static void test_wkb_out_linestring(void)
#include "liblwgeom_internal.h"
#include "lwgeom_log.h"
+#include <math.h>
/**
* Used for passing the parse state between the parsing functions.
POINTARRAY *pa = NULL;
size_t pa_size;
uint32_t ndims = 2;
+ const POINT2D *pt;
/* Count the dimensions. */
if( s->has_z ) ndims++;
}
}
- return lwpoint_construct(s->srid, NULL, pa);
+ /* Check for POINT(NaN NaN) ==> POINT EMPTY */
+ pt = getPoint2d_cp(pa, 0);
+ if ( isnan(pt->x) && isnan(pt->y) )
+ {
+ return lwpoint_construct_empty(s->srid, s->has_z, s->has_m);
+ }
+ else
+ {
+ return lwpoint_construct(s->srid, NULL, pa);
+ }
}
/**
*
**********************************************************************/
+#include <math.h>
+
#include "liblwgeom_internal.h"
#include "lwgeom_log.h"
*/
static size_t empty_to_wkb_size(const LWGEOM *geom, uint8_t variant)
{
- size_t size = WKB_BYTE_SIZE + WKB_INT_SIZE + WKB_INT_SIZE;
+ /* endian byte + type integer */
+ size_t size = WKB_BYTE_SIZE + WKB_INT_SIZE;
+ /* optional srid integer */
if ( lwgeom_wkb_needs_srid(geom, variant) )
size += WKB_INT_SIZE;
+ /* Represent POINT EMPTY as POINT(NaN NaN) */
+ if ( geom->type == POINTTYPE )
+ {
+ const LWPOINT *pt = (LWPOINT*)geom;
+ size += WKB_DOUBLE_SIZE * FLAGS_NDIMS(pt->point->flags);
+ }
+ /* num-elements */
+ else
+ {
+ size += WKB_INT_SIZE;
+ }
+
return size;
}
{
uint32_t wkb_type = lwgeom_wkb_type(geom, variant);
- if ( geom->type == POINTTYPE )
- {
- /* Change POINT to MULTIPOINT */
- wkb_type &= ~WKB_POINT_TYPE; /* clear POINT flag */
- wkb_type |= WKB_MULTIPOINT_TYPE; /* set MULTIPOINT flag */
- }
-
/* Set the endian flag */
buf = endian_to_wkb_buf(buf, variant);
if ( lwgeom_wkb_needs_srid(geom, variant) )
buf = integer_to_wkb_buf(geom->srid, buf, variant);
- /* Set nrings/npoints/ngeoms to zero */
- buf = integer_to_wkb_buf(0, buf, variant);
+ /* Represent POINT EMPTY as POINT(NaN NaN) */
+ if ( geom->type == POINTTYPE )
+ {
+ const LWPOINT *pt = (LWPOINT*)geom;
+ static double nn = NAN;
+ int i;
+ for ( i = 0; i < FLAGS_NDIMS(pt->point->flags); i++ )
+ {
+ buf = double_to_wkb_buf(nn, buf, variant);
+ }
+ }
+ /* Everything else is flagged as empty using num-elements == 0 */
+ else
+ {
+ /* Set nrings/npoints/ngeoms to zero */
+ buf = integer_to_wkb_buf(0, buf, variant);
+ }
+
return buf;
}