return 0;
}
+static void cu_wkb_malformed_in(char *hex)
+{
+ LWGEOM_PARSER_RESULT p;
+ int rv = 0;
+
+ rv = lwgeom_parse_wkt(&p, hex, 0);
+ CU_ASSERT( LW_FAILURE == rv );
+ CU_ASSERT( p.errcode );
+ lwgeom_parser_result_free(&p);
+}
+
static void cu_wkb_in(char *wkt)
{
LWGEOM_PARSER_RESULT pr;
static void test_wkb_in_multisurface(void) {}
+static void test_wkb_in_malformed(void)
+{
+ /* See http://trac.osgeo.org/postgis/ticket/1445 */
+ cu_wkb_malformed_in("01060000400200000001040000400100000001010000400000000000000000000000000000000000000000000000000101000040000000000000F03F000000000000F03F000000000000F03F");
+ cu_wkb_malformed_in("01050000400200000001040000400100000001010000400000000000000000000000000000000000000000000000000101000040000000000000F03F000000000000F03F000000000000F03F");
+ cu_wkb_malformed_in("01040000400200000001040000400100000001010000400000000000000000000000000000000000000000000000000101000040000000000000F03F000000000000F03F000000000000F03F");
+ cu_wkb_malformed_in("01030000400200000001040000400100000001010000400000000000000000000000000000000000000000000000000101000040000000000000F03F000000000000F03F000000000000F03F");
+}
+
/*
** Used by test harness to register the tests in this file.
PG_TEST(test_wkb_in_curvpolygon),
PG_TEST(test_wkb_in_multicurve),
PG_TEST(test_wkb_in_multisurface),
+ PG_TEST(test_wkb_in_malformed),
CU_TEST_INFO_NULL
};
CU_SuiteInfo wkb_in_suite = {"WKB In Suite", init_wkb_in_suite, clean_wkb_in_suite, wkb_in_tests};
if ( col == NULL || geom == NULL ) return NULL;
- if ( col->geoms == NULL && (col->ngeoms || col->maxgeoms) )
+ if ( col->geoms == NULL && (col->ngeoms || col->maxgeoms) ) {
lwerror("Collection is in inconsistent state. Null memory but non-zero collection counts.");
+ return NULL;
+ }
+
+ /* Check type compatibility */
+ if ( col->type < 7 ) {
+ if ( geom->type != col->type-3 ) {
+ lwerror("%s cannot contain %s element", lwtype_name(col->type), lwtype_name(geom->type));
+ return NULL;
+ }
+ }
+ else if ( col->type == COMPOUNDTYPE ) {
+ /* Allow: linestring, circularstring */
+ if ( geom->type != LINETYPE && geom->type != CIRCSTRINGTYPE ) {
+ lwerror("%s cannot contain %s element", lwtype_name(col->type), lwtype_name(geom->type));
+ return NULL;
+ }
+ }
+ else if ( col->type == MULTICURVETYPE ) {
+ /* Allow: linestring, circularstring, compoundcurve */
+ if ( geom->type != LINETYPE && geom->type != CIRCSTRINGTYPE && geom->type != COMPOUNDTYPE ) {
+ lwerror("%s cannot contain %s element", lwtype_name(col->type), lwtype_name(geom->type));
+ return NULL;
+ }
+ }
+ /* TODO: I'm probably missing something else here... would be nice to have the +3 invariant always */
/* In case this is a truly empty, make some initial space */
if ( col->geoms == NULL )
for ( i = 0; i < ngeoms; i++ )
{
geom = lwgeom_from_wkb_state(s);
- if ( lwcollection_add_lwgeom(col, geom) == LW_FALSE )
+ if ( lwcollection_add_lwgeom(col, geom) == NULL )
+ {
lwerror("Unable to add geometry (%p) to collection (%p)", geom, col);
+ return NULL;
+ }
}
return col;
SELECT '#1305.2',abs(ST_Distance(e, ST_Project(s, ST_Distance(s, e), ST_Azimuth(s, e)))) < 0.001 FROM pts;
SELECT '#1305.3',ST_Azimuth('POINT(0 45)'::geography, 'POINT(0 45)'::geography) IS NULL;
+-- #1445
+SELECT '01060000400200000001040000400100000001010000400000000000000000000000000000000000000000000000000101000040000000000000F03F000000000000F03F000000000000F03F'::geometry;
+SELECT '01050000400200000001040000400100000001010000400000000000000000000000000000000000000000000000000101000040000000000000F03F000000000000F03F000000000000F03F'::geometry;
+SELECT '01040000400200000001040000400100000001010000400000000000000000000000000000000000000000000000000101000040000000000000F03F000000000000F03F000000000000F03F'::geometry;
+SELECT '01090000400200000001040000400100000001010000400000000000000000000000000000000000000000000000000101000040000000000000F03F000000000000F03F000000000000F03F'::geometry;
+SELECT '010B0000400200000001040000400100000001010000400000000000000000000000000000000000000000000000000101000040000000000000F03F000000000000F03F000000000000F03F'::geometry;
+SELECT '010C0000400200000001040000400100000001010000400000000000000000000000000000000000000000000000000101000040000000000000F03F000000000000F03F000000000000F03F'::geometry;
+
-- Clean up
DELETE FROM spatial_ref_sys;
#1305.1|POINT(10 10)
#1305.2|t
#1305.3|t
+ERROR: MultiPolygon cannot contain MultiPoint element
+ERROR: MultiLineString cannot contain MultiPoint element
+ERROR: MultiPoint cannot contain MultiPoint element
+ERROR: CompoundCurve cannot contain MultiPoint element
+ERROR: MultiCurve cannot contain MultiPoint element
+ERROR: Invalid subtype (MultiPoint) for collection type (MultiSurface)