[GIS] How does MYSQL accept the WKT representation of a polygon with holes

MySQLqgiswell-known-text

I have a set of coordinates that creates a polygon with holes in it. I'm using qgis with mmqgis to extract. How does MYSQL accept the WKT representation of a polygon with holes? By holes I mean areas within the perimeter of the polygon that belong to that of another polygon, they're voids in the shape.

Is it with something like GeomFromText('MULTIPOLYGON((0,0 3,3 0,3 0,0), (1,1 1,2 2,2 2,1))')?

The first set of coordinates is the main polygon, the second set is the inner?

Best Answer

MySQL should be following the WKT specification that was detailed by the Open Geospatial Consortium's Simple Feature Access - Part 1: Common Architecture.

The text you have is not valid WKT, and no GIS software will accept it (generally it will raise a parse error). Commas are used to separate coordinates and spaces between components of each coordinate. Furthermore with polygons, each linear ring needs to be closed, such that the first and last coordinate are repeated. Lastly, with Multi- shapes, you need an additional nesting of parentheses to consider 1 or more polygons.

In all, the valid WKT approximation of your attempt is:

MULTIPOLYGON (((0 0, 3 3, 0 3, 0 0), (1 1, 1 2, 2 2, 2 1, 1 1)))

Which is technically an invalid geometry, as it has a self-intersection at point (1 1). A valid polygon would have this interior ring completely contained within the outer ring, and not overlapping any other interior rings (if present).

JTS

If you want to get more familiar with WKT structures, I find JTS TestBuilder a really good program to visually interact with geometries.