0

I am running MySQL // Percona 5.7 and I added a Polygon to my table:

DROP TABLE IF EXISTS `test_table`;
CREATE TABLE `test_table` (`uid` int(11) unsigned NOT NULL AUTO_INCREMENT,`geom` geometry NOT NULL, PRIMARY KEY (`uid`), SPATIAL KEY `i_geomidx` (`geom`) );
INSERT INTO `test_table` (`uid`, `geom`) VALUES ('1',ST_GeomFromGeoJSON('{"type": "FeatureCollection","features": [{"type": "Feature","properties": {},"geometry": {"type": "Polygon","coordinates": [[[-91.2,45.4],[-79.8,49.8],[-69.0,43.4],[-88.2,32.6],[-91.2,45.4]]]}}]}',1,4326));
SELECT uid FROM test_table  WHERE ( St_intersects(geom,St_geomfromGeoJSON('{"type": "Point", "coordinates": [-80.8,43.7], "crs":{"type":"name","properties":{"name":"EPSG:4326"}}}',1,4326)));
SELECT St_IsValid(geom) FROM test_table;

The first test with the intersect works like a charm but the ST_IsValid function returns the error:

ERROR 1210 (HY000): Incorrect arguments to st_isvalid

But the MySQL help states:

SET @ls1 = ST_GeomFromText('LINESTRING(0 0)');
SELECT ST_IsValid(@ls1);

Any ideas someone?

  • What does PostGIS have to do with this? It is tagged PostGIS. – Nicklas Avén Aug 1 '16 at 13:38
  • What does it return if you actually check using a valid linestring -- which a single point is not? I believe MySQL is objecting to the function ST_GeomFromText not the ST_IsValid. Postgis behaves the same. I believe the behavoir of MySQL is correct, but the docs are not. – John Powell Aug 1 '16 at 14:16
  • Postgis, for what it is worth, returns ERROR: geometry requires more points HINT: "LINESTRING(0 0)" <-- parse error at position 16 within geometry to select ST_GeomFromText('LINESTRING(0 0)'); I don't have a MySQL install to check against any more, but this suggests that MySQL has correctly implemented the standard. – John Powell Aug 1 '16 at 14:17
  • @JohnBarça, you're about right that LINESTRING(0 0) is not a valid geometry. Yet I used this example to demonstrate the the argument to ST_isvalid might not be wrong at all. – Riccardo Aug 2 '16 at 5:19
  • What does select ST_GeomFromText('LINESTRING(0 0)'); return. And what about select ST_GeomFromText('LINESTRING(0 0, 1 1)')? That is your answer. – John Powell Aug 2 '16 at 12:29
1

MySQL version 5.7 says:

ST_IsValid() works only for the Cartesian coordinate system and requires a geometry argument with an SRID of 0.

The geometries you created use an SRID of 4326.

The behaviour changed for MySQL 8.0.

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.