Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix validation when creating GeometryCollections #120

Merged
merged 14 commits into from
Mar 8, 2020

Conversation

grimzy
Copy link
Owner

@grimzy grimzy commented Mar 2, 2020

Closes #95

Validation:

Class Min items Item Type
GeometryCollection 0 GeometryInterface
(abstract) PointCollection 0 (inherited) Point
LineString 2 Point (inherited)
MultiPoint 1 Point (inherited)
MultiLineString 1 LineString
Polygon 1 (inherited) LineString (inherited)
MultiPolygon 1 Polygon

Tested with:

-- Fails with message: 'Invalid GIS data provided to function st_geomfromtext.'
SET @multipt2 = ST_GeomFromText('MULTIPOINT()'); 
SET @line2a = ST_GeomFromText('LINESTRING(0 0)');
SET @line2b = ST_GeomFromText('LINESTRING()');
SET @multiline2a = ST_GeomFromText('MULTILINESTRING()');
SET @multiline2b = ST_GeomFromText('MULTILINESTRING((1 1))');
SET @poly2 = ST_GeomFromText('POLYGON()');
SET @multipoly2 = ST_GeomFromText('MULTIPOLYGON()');

-- Works:
SET @multipt1 = ST_GeomFromText('MULTIPOINT(0 0)');
SET @line1 = ST_GeomFromText('LINESTRING(0 0, 1 1)'); -- requires 2 points
SET @multiline1 = ST_GeomFromText('MULTILINESTRING((0 0, 1 1))');
SET @poly1a = ST_GeomFromText('POLYGON((0 0,10 0,10 10,0 10,0 0), (5 5,7 5,7 7,5 7, 5 5))');
SET @poly1b = ST_GeomFromText('POLYGON((0 0,10 0,10 10,0 10,0 0))');
SET @multipoly1 = ST_GeomFromText('MULTIPOLYGON(((0 0,10 0,10 10,0 10,0 0)))');
SET @geocol1a = ST_GeomFromText('GEOMETRYCOLLECTION(POINT(1 1))');
SET @geocol1b = ST_GeomFromText('GEOMETRYCOLLECTION()'); -- works while empty

@grimzy grimzy changed the title point collection min items Fix GeometryCollection validation Mar 2, 2020
@grimzy grimzy changed the title Fix GeometryCollection validation Fix validation when creation GeometryCollections Mar 2, 2020
@grimzy grimzy changed the title Fix validation when creation GeometryCollections Fix validation when creating GeometryCollections Mar 3, 2020
@grimzy grimzy merged commit e5e4c89 into master Mar 8, 2020
@grimzy grimzy deleted the issue-95-point-collection-min-items branch March 8, 2020 23:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

why PointCollection minimum of two items?
1 participant