/*---------------------------------------------*/
-/**
- * @brief Throws an ereport ERROR if either geometry is a COLLECTIONTYPE. Additionally
- * displays a HINT of the first 80 characters of the WKT representation of the
- * problematic geometry so a user knows which parameter and which geometry
- * is causing the problem.
- */
-void errorIfGeometryCollection(GSERIALIZED *g1, GSERIALIZED *g2)
-{
- int t1 = gserialized_get_type(g1);
- int t2 = gserialized_get_type(g2);
-
- char *hintmsg;
- char *hintwkt;
- size_t hintsz;
- LWGEOM *lwgeom;
-
- if ( t1 == COLLECTIONTYPE)
- {
- lwgeom = lwgeom_from_gserialized(g1);
- hintwkt = lwgeom_to_wkt(lwgeom, WKT_SFSQL, DBL_DIG, &hintsz);
- lwgeom_free(lwgeom);
- hintmsg = lwmessage_truncate(hintwkt, 0, hintsz-1, 80, 1);
- ereport(ERROR,
- (errmsg("Relate Operation called with a LWGEOMCOLLECTION type. This is unsupported."),
- errhint("Change argument 1: '%s'", hintmsg))
- );
- pfree(hintwkt);
- pfree(hintmsg);
- }
- else if (t2 == COLLECTIONTYPE)
- {
- lwgeom = lwgeom_from_gserialized(g2);
- hintwkt = lwgeom_to_wkt(lwgeom, WKT_SFSQL, DBL_DIG, &hintsz);
- hintmsg = lwmessage_truncate(hintwkt, 0, hintsz-1, 80, 1);
- lwgeom_free(lwgeom);
- ereport(ERROR,
- (errmsg("Relate Operation called with a LWGEOMCOLLECTION type. This is unsupported."),
- errhint("Change argument 2: '%s'", hintmsg))
- );
- pfree(hintwkt);
- pfree(hintmsg);
- }
-}
-
PG_FUNCTION_INFO_V1(isvalid);
Datum isvalid(PG_FUNCTION_ARGS)
{
geom1 = PG_GETARG_GSERIALIZED_P(0);
geom2 = PG_GETARG_GSERIALIZED_P(1);
- errorIfGeometryCollection(geom1,geom2);
error_if_srid_mismatch(gserialized_get_srid(geom1), gserialized_get_srid(geom2));
/* A.Overlaps(Empty) == FALSE */
GBOX box1, box2;
PrepGeomCache *prep_cache;
- errorIfGeometryCollection(geom1, geom2);
error_if_srid_mismatch(gserialized_get_srid(geom1), gserialized_get_srid(geom2));
/* A.Contains(Empty) == FALSE */
geom1 = PG_GETARG_GSERIALIZED_P(0);
geom2 = PG_GETARG_GSERIALIZED_P(1);
- errorIfGeometryCollection(geom1,geom2);
error_if_srid_mismatch(gserialized_get_srid(geom1), gserialized_get_srid(geom2));
/* A.ContainsProperly(Empty) == FALSE */
if ( gserialized_is_empty(geom1) || gserialized_is_empty(geom2) )
PG_RETURN_BOOL(false);
- errorIfGeometryCollection(geom1,geom2);
error_if_srid_mismatch(gserialized_get_srid(geom1), gserialized_get_srid(geom2));
/*
geom1 = PG_GETARG_GSERIALIZED_P(0);
geom2 = PG_GETARG_GSERIALIZED_P(1);
- errorIfGeometryCollection(geom1,geom2);
error_if_srid_mismatch(gserialized_get_srid(geom1), gserialized_get_srid(geom2));
/* A.CoveredBy(Empty) == FALSE */
geom1 = PG_GETARG_GSERIALIZED_P(0);
geom2 = PG_GETARG_GSERIALIZED_P(1);
- errorIfGeometryCollection(geom1,geom2);
error_if_srid_mismatch(gserialized_get_srid(geom1), gserialized_get_srid(geom2));
/* A.Crosses(Empty) == FALSE */
geom1 = PG_GETARG_GSERIALIZED_P(0);
geom2 = PG_GETARG_GSERIALIZED_P(1);
- errorIfGeometryCollection(geom1,geom2);
error_if_srid_mismatch(gserialized_get_srid(geom1), gserialized_get_srid(geom2));
/* A.Touches(Empty) == FALSE */
geom1 = PG_GETARG_GSERIALIZED_P(0);
geom2 = PG_GETARG_GSERIALIZED_P(1);
- errorIfGeometryCollection(geom1,geom2);
error_if_srid_mismatch(gserialized_get_srid(geom1), gserialized_get_srid(geom2));
/* A.Disjoint(Empty) == TRUE */
/* TODO handle empty */
- errorIfGeometryCollection(geom1,geom2);
error_if_srid_mismatch(gserialized_get_srid(geom1), gserialized_get_srid(geom2));
initGEOS(lwpgnotice, lwgeom_geos_error);
bnr = PG_GETARG_INT32(2);
}
- errorIfGeometryCollection(geom1,geom2);
error_if_srid_mismatch(gserialized_get_srid(geom1), gserialized_get_srid(geom2));
initGEOS(lwpgnotice, lwgeom_geos_error);
geom1 = PG_GETARG_GSERIALIZED_P(0);
geom2 = PG_GETARG_GSERIALIZED_P(1);
- errorIfGeometryCollection(geom1,geom2);
error_if_srid_mismatch(gserialized_get_srid(geom1), gserialized_get_srid(geom2));
/* Empty == Empty */
ANALYZE bug_4144_table;
DROP TABLE IF EXISTS bug_4144_table;
+--4295
+-- CIP - collection within polygon
+SELECT 'contains210', ST_contains('POLYGON((0 0, 0 10, 10 10, 10 0, 0 0))'::geometry, 'GEOMETRYCOLLECTION (POINT(5 5),LINESTRING(1 1,2 2))'::geometry);
+-- CIP - collection on edge of polygon
+SELECT 'contains211', ST_contains('POLYGON((0 0, 0 10, 10 10, 10 0, 0 0))'::geometry, 'GEOMETRYCOLLECTION (POINT(10 10), LINESTRING(0 0, 0 10))'::geometry);
+-- CIP - collection outside polygon
+SELECT 'contains212', ST_contains('POLYGON((0 0, 0 10, 10 10, 10 0, 0 0))'::geometry, 'GEOMETRYCOLLECTION (POINT(-1 0),LINESTRING(11 5,12 5))'::geometry);
+-- CIP - elements of the collection fully outside and fully inside polygon
+SELECT 'contains213', ST_contains('POLYGON((0 0, 0 10, 10 10, 10 0, 0 0))'::geometry, 'GEOMETRYCOLLECTION (POINT(-1 0), LINESTRING(4 4,5 5))'::geometry);
+
+-- CIP - collection within polygon
+SELECT 'within210', ST_within('POLYGON((0 0, 0 10, 10 10, 10 0, 0 0))'::geometry, 'GEOMETRYCOLLECTION (POINT(5 5),LINESTRING(1 1,2 2))'::geometry);
+-- CIP - collection on edge of polygon
+SELECT 'within211', ST_within('POLYGON((0 0, 0 10, 10 10, 10 0, 0 0))'::geometry, 'GEOMETRYCOLLECTION (POINT(10 10), LINESTRING(0 0, 0 10))'::geometry);
+-- CIP - collection outside polygon
+SELECT 'within212', ST_within('POLYGON((0 0, 0 10, 10 10, 10 0, 0 0))'::geometry, 'GEOMETRYCOLLECTION (POINT(-1 0),LINESTRING(11 5,12 5))'::geometry);
+-- CIP - elements of the collection fully outside and fully inside polygon
+SELECT 'within213', ST_within('POLYGON((0 0, 0 10, 10 10, 10 0, 0 0))'::geometry, 'GEOMETRYCOLLECTION (POINT(-1 0), LINESTRING(4 4,5 5))'::geometry);
+
+-- CIP - collection within polygon
+SELECT 'containsproperly210', ST_containsproperly('POLYGON((0 0, 0 10, 10 10, 10 0, 0 0))'::geometry, 'GEOMETRYCOLLECTION (POINT(5 5),LINESTRING(1 1,2 2))'::geometry);
+-- CIP - collection on edge of polygon
+SELECT 'containsproperly211', ST_containsproperly('POLYGON((0 0, 0 10, 10 10, 10 0, 0 0))'::geometry, 'GEOMETRYCOLLECTION (POINT(10 10), LINESTRING(0 0, 0 10))'::geometry);
+-- CIP - collection outside polygon
+SELECT 'containsproperly212', ST_containsproperly('POLYGON((0 0, 0 10, 10 10, 10 0, 0 0))'::geometry, 'GEOMETRYCOLLECTION (POINT(-1 0),LINESTRING(11 5,12 5))'::geometry);
+-- CIP - elements of the collection fully outside and fully inside polygon
+SELECT 'containsproperly213', ST_containsproperly('POLYGON((0 0, 0 10, 10 10, 10 0, 0 0))'::geometry, 'GEOMETRYCOLLECTION (POINT(-1 0), LINESTRING(4 4,5 5))'::geometry);
+
+-- CIP - collection within polygon
+SELECT 'overlaps210', ST_overlaps('POLYGON((0 0, 0 10, 10 10, 10 0, 0 0))'::geometry, 'GEOMETRYCOLLECTION (POINT(5 5),LINESTRING(1 1,2 2))'::geometry);
+-- CIP - collection on edge of polygon
+SELECT 'overlaps211', ST_overlaps('POLYGON((0 0, 0 10, 10 10, 10 0, 0 0))'::geometry, 'GEOMETRYCOLLECTION (POINT(10 10), LINESTRING(0 0, 0 10))'::geometry);
+-- CIP - collection outside polygon
+SELECT 'overlaps212', ST_overlaps('POLYGON((0 0, 0 10, 10 10, 10 0, 0 0))'::geometry, 'GEOMETRYCOLLECTION (POINT(-1 0),LINESTRING(11 5,12 5))'::geometry);
+-- CIP - elements of the collection fully outside and fully inside polygon
+SELECT 'overlaps213', ST_overlaps('POLYGON((0 0, 0 10, 10 10, 10 0, 0 0))'::geometry, 'GEOMETRYCOLLECTION (POINT(-1 0), LINESTRING(4 4,5 5))'::geometry);
+
+-- CIP - collection within polygon
+SELECT 'covers210', ST_covers('POLYGON((0 0, 0 10, 10 10, 10 0, 0 0))'::geometry, 'GEOMETRYCOLLECTION (POINT(5 5),LINESTRING(1 1,2 2))'::geometry);
+-- CIP - collection on edge of polygon
+SELECT 'covers211', ST_covers('POLYGON((0 0, 0 10, 10 10, 10 0, 0 0))'::geometry, 'GEOMETRYCOLLECTION (POINT(10 10), LINESTRING(0 0, 0 10))'::geometry);
+-- CIP - collection outside polygon
+SELECT 'covers212', ST_covers('POLYGON((0 0, 0 10, 10 10, 10 0, 0 0))'::geometry, 'GEOMETRYCOLLECTION (POINT(-1 0),LINESTRING(11 5,12 5))'::geometry);
+-- CIP - elements of the collection fully outside and fully inside polygon
+SELECT 'covers213', ST_covers('POLYGON((0 0, 0 10, 10 10, 10 0, 0 0))'::geometry, 'GEOMETRYCOLLECTION (POINT(-1 0), LINESTRING(4 4,5 5))'::geometry);
+
+-- CIP - collection within polygon
+SELECT 'coveredby210', ST_coveredby('POLYGON((0 0, 0 10, 10 10, 10 0, 0 0))'::geometry, 'GEOMETRYCOLLECTION (POINT(5 5),LINESTRING(1 1,2 2))'::geometry);
+-- CIP - collection on edge of polygon
+SELECT 'coveredby211', ST_coveredby('POLYGON((0 0, 0 10, 10 10, 10 0, 0 0))'::geometry, 'GEOMETRYCOLLECTION (POINT(10 10), LINESTRING(0 0, 0 10))'::geometry);
+-- CIP - collection outside polygon
+SELECT 'coveredby212', ST_coveredby('POLYGON((0 0, 0 10, 10 10, 10 0, 0 0))'::geometry, 'GEOMETRYCOLLECTION (POINT(-1 0),LINESTRING(11 5,12 5))'::geometry);
+-- CIP - elements of the collection fully outside and fully inside polygon
+SELECT 'coveredby213', ST_coveredby('POLYGON((0 0, 0 10, 10 10, 10 0, 0 0))'::geometry, 'GEOMETRYCOLLECTION (POINT(-1 0), LINESTRING(4 4,5 5))'::geometry);
+
+-- CIP - collection within polygon
+SELECT 'crosses210', ST_crosses('POLYGON((0 0, 0 10, 10 10, 10 0, 0 0))'::geometry, 'GEOMETRYCOLLECTION (POINT(5 5),LINESTRING(1 1,2 2))'::geometry);
+-- CIP - collection on edge of polygon
+SELECT 'crosses211', ST_crosses('POLYGON((0 0, 0 10, 10 10, 10 0, 0 0))'::geometry, 'GEOMETRYCOLLECTION (POINT(10 10), LINESTRING(0 0, 0 10))'::geometry);
+-- CIP - collection outside polygon
+SELECT 'crosses212', ST_crosses('POLYGON((0 0, 0 10, 10 10, 10 0, 0 0))'::geometry, 'GEOMETRYCOLLECTION (POINT(-1 0),LINESTRING(11 5,12 5))'::geometry);
+-- CIP - elements of the collection fully outside and fully inside polygon
+SELECT 'crosses213', ST_crosses('POLYGON((0 0, 0 10, 10 10, 10 0, 0 0))'::geometry, 'GEOMETRYCOLLECTION (POINT(-1 0), LINESTRING(4 4,5 5))'::geometry);
+
+-- CIP - collection within polygon
+SELECT 'touches210', ST_touches('POLYGON((0 0, 0 10, 10 10, 10 0, 0 0))'::geometry, 'GEOMETRYCOLLECTION (POINT(5 5),LINESTRING(1 1,2 2))'::geometry);
+-- CIP - collection on edge of polygon
+SELECT 'touches211', ST_touches('POLYGON((0 0, 0 10, 10 10, 10 0, 0 0))'::geometry, 'GEOMETRYCOLLECTION (POINT(10 10), LINESTRING(0 0, 0 10))'::geometry);
+-- CIP - collection outside polygon
+SELECT 'touches212', ST_touches('POLYGON((0 0, 0 10, 10 10, 10 0, 0 0))'::geometry, 'GEOMETRYCOLLECTION (POINT(-1 0),LINESTRING(11 5,12 5))'::geometry);
+-- CIP - elements of the collection fully outside and fully inside polygon
+SELECT 'touches213', ST_touches('POLYGON((0 0, 0 10, 10 10, 10 0, 0 0))'::geometry, 'GEOMETRYCOLLECTION (POINT(-1 0), LINESTRING(4 4,5 5))'::geometry);
+
+-- CIP - collection within polygon
+SELECT 'disjoint210', ST_disjoint('POLYGON((0 0, 0 10, 10 10, 10 0, 0 0))'::geometry, 'GEOMETRYCOLLECTION (POINT(5 5),LINESTRING(1 1,2 2))'::geometry);
+-- CIP - collection on edge of polygon
+SELECT 'disjoint211', ST_disjoint('POLYGON((0 0, 0 10, 10 10, 10 0, 0 0))'::geometry, 'GEOMETRYCOLLECTION (POINT(10 10), LINESTRING(0 0, 0 10))'::geometry);
+-- CIP - collection outside polygon
+SELECT 'disjoint212', ST_disjoint('POLYGON((0 0, 0 10, 10 10, 10 0, 0 0))'::geometry, 'GEOMETRYCOLLECTION (POINT(-1 0),LINESTRING(11 5,12 5))'::geometry);
+-- CIP - elements of the collection fully outside and fully inside polygon
+SELECT 'disjoint213', ST_disjoint('POLYGON((0 0, 0 10, 10 10, 10 0, 0 0))'::geometry, 'GEOMETRYCOLLECTION (POINT(-1 0), LINESTRING(4 4,5 5))'::geometry);
+
+-- CIP - collection within polygon
+SELECT 'relate210', ST_relate('POLYGON((0 0, 0 10, 10 10, 10 0, 0 0))'::geometry, 'GEOMETRYCOLLECTION (POINT(5 5),LINESTRING(1 1,2 2))'::geometry);
+-- CIP - collection on edge of polygon
+SELECT 'relate211', ST_relate('POLYGON((0 0, 0 10, 10 10, 10 0, 0 0))'::geometry, 'GEOMETRYCOLLECTION (POINT(10 10), LINESTRING(0 0, 0 10))'::geometry);
+-- CIP - collection outside polygon
+SELECT 'relate212', ST_relate('POLYGON((0 0, 0 10, 10 10, 10 0, 0 0))'::geometry, 'GEOMETRYCOLLECTION (POINT(-1 0),LINESTRING(11 5,12 5))'::geometry);
+-- CIP - elements of the collection fully outside and fully inside polygon
+SELECT 'relate213', ST_relate('POLYGON((0 0, 0 10, 10 10, 10 0, 0 0))'::geometry, 'GEOMETRYCOLLECTION (POINT(-1 0), LINESTRING(4 4,5 5))'::geometry);
+
+-- CIP - collection within polygon
+SELECT 'relate_pattern210', ST_relate('POLYGON((0 0, 0 10, 10 10, 10 0, 0 0))'::geometry, 'GEOMETRYCOLLECTION (POINT(5 5),LINESTRING(1 1,2 2))'::geometry, 'FF*FF****');
+-- CIP - collection on edge of polygon
+SELECT 'relate_pattern211', ST_relate('POLYGON((0 0, 0 10, 10 10, 10 0, 0 0))'::geometry, 'GEOMETRYCOLLECTION (POINT(10 10), LINESTRING(0 0, 0 10))'::geometry, 'FF*FF****');
+-- CIP - collection outside polygon
+SELECT 'relate_pattern212', ST_relate('POLYGON((0 0, 0 10, 10 10, 10 0, 0 0))'::geometry, 'GEOMETRYCOLLECTION (POINT(-1 0),LINESTRING(11 5,12 5))'::geometry, 'FF*FF****');
+-- CIP - elements of the collection fully outside and fully inside polygon
+SELECT 'relate_pattern213', ST_relate('POLYGON((0 0, 0 10, 10 10, 10 0, 0 0))'::geometry, 'GEOMETRYCOLLECTION (POINT(-1 0), LINESTRING(4 4,5 5))'::geometry, 'FF*FF****');
+
+-- equals - element inside polygon
+SELECT 'equals210', ST_equals('POLYGON((0 0, 0 10, 10 10, 10 0, 0 0))'::geometry,
+'GEOMETRYCOLLECTION (POLYGON((0 0, 10 0, 10 10, 0 10, 0 0)),LINESTRING(0 2, 0 5))'::geometry);
+-- equals - element on border of polygon
+SELECT 'equals211', ST_equals('POLYGON((0 0, 0 10, 10 10, 10 0, 0 0))'::geometry,
+'GEOMETRYCOLLECTION (POLYGON((0 0, 10 0, 10 10, 0 10, 0 0)),MULTIPOINT(0 2, 0 5))'::geometry);
+-- equals - element on border and inside polygon
+SELECT 'equals212', ST_equals('POLYGON((0 0, 0 10, 10 10, 10 0, 0 0))'::geometry,
+'GEOMETRYCOLLECTION (POLYGON((0 0, 10 0, 10 10, 0 10, 0 0)),LINESTRING(0 2, 0 5, 5 5))'::geometry);
+SELECT 'equals213', ST_equals('POLYGON((0 0, 0 10, 10 10, 10 0, 0 0))'::geometry,
+'GEOMETRYCOLLECTION (POLYGON((0 0, 10 0, 10 10, 0 10, 0 0)),MULTIPOINT(0 2, 5 5))'::geometry);
+
-- #4299
SELECT '#4299', ST_Disjoint(ST_GeneratePoints(g, 1000), ST_GeneratePoints(g, 1000))
FROM (SELECT 'POLYGON((0 0,1 0,1 1,0 1,0 0))'::geometry AS g) AS f;