@@ -37,8 +37,8 @@ INSERT INTO gis_geometrycollection VALUES
37
37
(114,ST_GEOMFROMTEXT(@star_lines_near_vertical)),
38
38
(115,ST_GEOMFROMTEXT(@star_collection_elems)),
39
39
(116,ST_GEOMFROMTEXT(@star_collection_multilinestr));
40
- # Checking the integrity of the above create/insert statements
41
- # 17 rows.
40
+ # Checking the integrity of the above create/insert statements
41
+ # 17 rows.
42
42
SELECT count(ST_ASTEXT(g) != 'NULL') FROM gis_geometrycollection;
43
43
count(ST_ASTEXT(g) != 'NULL')
44
44
17
@@ -380,25 +380,31 @@ ERROR 22003: SRID value is out of range in 'st_geomfromtext'
380
380
SELECT ST_ISVALID(ST_GEOMFROMTEXT(@star_all_points,-1));
381
381
ERROR 22003: SRID value is out of range in 'st_geomfromtext'
382
382
SELECT ST_ISVALID(ST_GEOMFROMTEXT(@star_lines_near_vertical,4236));
383
- ERROR 22S00: st_isvalid(MULTILINESTRING) has not been implemented for geographic spatial reference systems.
383
+ ST_ISVALID(ST_GEOMFROMTEXT(@star_lines_near_vertical,4236))
384
+ 1
385
+ SELECT ST_ISVALID(ST_GEOMFROMTEXT(@star_elem_vertical,4294967295));
386
+ ERROR SR001: There's no spatial reference system with SRID 4294967295.
384
387
SELECT ST_ISVALID(ST_GEOMFROMTEXT(@star_of_elems,4294967297));
385
388
ERROR 22003: SRID value is out of range in 'st_geomfromtext'
386
389
SELECT ST_ISVALID(ST_GEOMFROMTEXT(@star_collection_elems,4294967295000));
387
390
ERROR 22003: SRID value is out of range in 'st_geomfromtext'
388
- SELECT ST_ISVALID(0x000000000200000000000000000000000000000000);
389
- ERROR HY000: Geometry byte string must be little endian.
390
- SELECT ST_ISVALID(0x010100000001000000010100000000000000000000);
391
- ERROR HY000: Geometry byte string must be little endian.
392
- SELECT ST_ISVALID(0x010100000002000000000000000000000000000000);
393
- ERROR HY000: Geometry byte string must be little endian.
391
+ SELECT ST_ISVALID( x'e6100000010100000000000000000000000000000000000000');
392
+ ST_ISVALID( x'e6100000010100000000000000000000000000000000000000')
393
+ 1
394
+ SELECT ST_ISVALID( x'e6100000020000000100000000000000000000000000000000');
395
+ ERROR 22023: Invalid GIS data provided to function st_isvalid.
396
+ SELECT ST_ISVALID( x'00000000000001000001010000000000000000000000000000');
397
+ ERROR 22023: Invalid GIS data provided to function st_isvalid.
398
+ SELECT ST_ISVALID( x'e6100000060100000000000000000000000000000000000000');
399
+ ERROR 22023: Invalid GIS data provided to function st_isvalid.
394
400
SELECT ST_ISVALID(0x000000000600000001000000000200000002000000);
395
- ERROR HY000: Geometry byte string must be little endian .
401
+ ERROR 22023: Invalid GIS data provided to function st_isvalid .
396
402
SELECT ST_ISVALID(0x000000000200000001000000050000000000000000);
397
- ERROR HY000: Geometry byte string must be little endian .
403
+ ERROR 22023: Invalid GIS data provided to function st_isvalid .
398
404
SELECT ST_ISVALID(0x010300000002000000010300000002000000050000);
399
- ERROR HY000: Geometry byte string must be little endian .
405
+ ERROR SR001: There's no spatial reference system with SRID 769 .
400
406
SELECT ST_ISVALID(0x010400000002000000010100000000000000000000);
401
- ERROR HY000: Geometry byte string must be little endian .
407
+ ERROR SR001: There's no spatial reference system with SRID 1025 .
402
408
# Clean up
403
409
DROP TABLE gis_geometrycollection;
404
410
########################################################################
@@ -430,19 +436,80 @@ ST_ISVALID(ST_GEOMFROMTEXT('POINT(0 0)', 0))
430
436
SELECT ST_ISVALID(ST_GEOMFROMTEXT('POINT(0 0)', 2000));
431
437
ST_ISVALID(ST_GEOMFROMTEXT('POINT(0 0)', 2000))
432
438
1
433
- # Geographic SRS (should fail )
439
+ # Geographic SRS (shall pass )
434
440
SELECT ST_ISVALID(ST_GEOMFROMTEXT('POINT(0 0)', 4326));
435
- ERROR 22S00: st_isvalid(POINT) has not been implemented for geographic spatial reference systems.
441
+ ST_ISVALID(ST_GEOMFROMTEXT('POINT(0 0)', 4326))
442
+ 1
436
443
# Unparseable SRS definition (should fail)
437
444
INSERT INTO mysql.st_spatial_reference_systems(id, catalog_id, name,
438
445
organization, organization_coordsys_id, definition, description)
439
446
VALUES (2000001, 1, 'TEST2000001', 'Foo', 2000001, 'FOOBAR', '');
440
447
SELECT ST_ISVALID(ST_GEOMFROMTEXT('POINT(0 0)', 2000001));
441
448
ERROR SR002: Can't parse the spatial reference system definition of SRID 2000001.
442
449
DELETE FROM mysql.st_spatial_reference_systems WHERE id = 2000001;
443
- #
444
- # WL#11096 Don't do Cartesian computations on geographic geometries
445
- #
446
- # Assume SRID 10 is not defined.
447
- DO ST_ISVALID(x'0A000000010100000000000000000000000000000000000000');
448
- ERROR SR001: There's no spatial reference system with SRID 10.
450
+ # Verify that ST_IsValid() returns NULL if at least one of its parameters
451
+ # is NULL
452
+ SELECT ST_ISVALID(NULL);
453
+ ST_ISVALID(NULL)
454
+ NULL
455
+ # Verify that ST_IsValid() doesn't return NULL if its arguments are not
456
+ # NULL
457
+ SELECT ST_ISVALID(ST_GEOMFROMTEXT('POINT(0 0)',4053));
458
+ ST_ISVALID(ST_GEOMFROMTEXT('POINT(0 0)',4053))
459
+ 1
460
+ # Verify that ST_IsValid() returns ER_GIS_INVALID_DATA error if geometry
461
+ # argument is not syntactically well-formed geometry
462
+ DO ST_ISVALID(X'FF');
463
+ ERROR 22023: Invalid GIS data provided to function st_isvalid.
464
+ # Verify that ST_IsValid() returns 1 with empty geometry input
465
+ SELECT ST_ISVALID( ST_GEOMFROMTEXT('GEOMETRYCOLLECTION EMPTY','4326'));
466
+ ST_ISVALID( ST_GEOMFROMTEXT('GEOMETRYCOLLECTION EMPTY','4326'))
467
+ 1
468
+ # Verify that ST_IsValid() returns 1 if the input is geometrically valid
469
+ SELECT ST_ISVALID( ST_GEOMFROMTEXT('POINT(1 1)',4053));
470
+ ST_ISVALID( ST_GEOMFROMTEXT('POINT(1 1)',4053))
471
+ 1
472
+ SELECT ST_ISVALID( ST_GEOMFROMTEXT('POINT(1 1)'));
473
+ ST_ISVALID( ST_GEOMFROMTEXT('POINT(1 1)'))
474
+ 1
475
+ SELECT ST_ISVALID( ST_GEOMFROMTEXT('POINT(1 1)',4326));
476
+ ST_ISVALID( ST_GEOMFROMTEXT('POINT(1 1)',4326))
477
+ 1
478
+ SELECT ST_ISVALID( ST_GEOMFROMTEXT('POLYGON((0 0,0 1,1 1,1 0,0 0),(0.25 0.25,0.75 0.25, 0.25 0.75, 0.25 0.25))',4053));
479
+ ST_ISVALID( ST_GEOMFROMTEXT('POLYGON((0 0,0 1,1 1,1 0,0 0),(0.25 0.25,0.75 0.25, 0.25 0.75, 0.25 0.25))',4053))
480
+ 1
481
+ SELECT ST_ISVALID( ST_GEOMFROMTEXT('POLYGON((0 0,0 1,1 1,1 0,0 0),(0.25 0.25,0.75 0.25, 0.25 0.75, 0.25 0.25))',4326));
482
+ ST_ISVALID( ST_GEOMFROMTEXT('POLYGON((0 0,0 1,1 1,1 0,0 0),(0.25 0.25,0.75 0.25, 0.25 0.75, 0.25 0.25))',4326))
483
+ 1
484
+ # Verify that ST_IsValid() returns 0 if input is geometrically invalid
485
+ SELECT ST_ISVALID( ST_GEOMFROMTEXT('POLYGON((0 0,0 1,1 1,1 0,0 0),(0.25 0.25,1.75 0.25, 0.25 0.75, 0.25 0.25))',4053));
486
+ ST_ISVALID( ST_GEOMFROMTEXT('POLYGON((0 0,0 1,1 1,1 0,0 0),(0.25 0.25,1.75 0.25, 0.25 0.75, 0.25 0.25))',4053))
487
+ 0
488
+ SELECT ST_ISVALID( ST_GEOMFROMTEXT('POLYGON((0 0,0 1,1 1,1 0,0 0),(0.25 0.25,1.75 0.25, 0.25 0.75, 0.25 0.25))',4326));
489
+ ST_ISVALID( ST_GEOMFROMTEXT('POLYGON((0 0,0 1,1 1,1 0,0 0),(0.25 0.25,1.75 0.25, 0.25 0.75, 0.25 0.25))',4326))
490
+ 0
491
+ # Verify that ST_IsValid() returns ER_LONGITUDE_OUT_OF_RANGE error with a
492
+ # geometry in a geographic SRS and a longitude value is not in the range
493
+ # (-180,180]
494
+ DO ST_ISVALID(X'D50F0000010100000000000000000070400000000000000000');
495
+ ERROR 22S02: Longitude 256.000000 is out of range in function st_isvalid. It must be within (-180.000000, 180.000000].
496
+ # Verify that ST_IsValid() returns ER_LATITUDE_OUT_OF_RANGE error with a
497
+ # geometry in geographic SRS and a latitude value is not in the range
498
+ # [-90,90]
499
+ DO ST_ISVALID(X'D50F0000010100000000000000000000000000000000008040');
500
+ ERROR 22S03: Latitude 512.000000 is out of range in function st_isvalid. It must be within [-90.000000, 90.000000].
501
+ # If a multipoint is made up of valid points it should be valid.
502
+ SELECT ST_ISVALID(ST_GEOMFROMTEXT('multipoint((0 0),(1 1))',4053 )) AS RESULT;
503
+ RESULT
504
+ 1
505
+ SELECT ST_IsValid(ST_GeomFromText('MULTIPOLYGON(((9 11,14 84,43 54,9 11)),((-144
506
+ -58,-142 -6,-4 -70,-144 -58)))', '4326', 'axis-order=long-lat')) AS RESULT;
507
+ RESULT
508
+ 1
509
+ SELECT ST_ISVALID(ST_GEOMFROMTEXT('GEOMETRYCOLLECTION(POLYGON((0 0,0 1,1 1,1 0,0 0),(0.25 0.25,0.75 0.25, 0.25 0.75, 0.25 0.25)),POINT(1 1))',4053)) as result;
510
+ result
511
+ 1
512
+ SELECT ST_IsValid(ST_GeomFromText('GEOMETRYCOLLECTION(MULTIPOLYGON(((9 11,14 84,43 54,9 11)),((-144
513
+ -58,-142 -6,-4 -70,-144 -58))), point( 1 1))', '4326', 'axis-order=long-lat')) AS RESULT;
514
+ RESULT
515
+ 1
0 commit comments