| 1 |
# |
| 2 |
# Different input paths |
| 3 |
# |
| 4 |
USE test; |
| 5 |
CREATE TABLE gis_geometrycollection(fid INTEGER NOT NULL PRIMARY KEY, g GEOMETRY); |
| 6 |
SET @ls='LINESTRING(0 0,0 1)'; |
| 7 |
INSERT INTO gis_geometrycollection VALUES (101,ST_GEOMFROMTEXT(@ls)); |
| 8 |
# 1 row. |
| 9 |
SELECT count(g IS NULL) FROM gis_geometrycollection; |
| 10 |
count(g IS NULL) |
| 11 |
1 |
| 12 |
# Test different input paths, must pass |
| 13 |
SELECT ST_ASTEXT(ST_POINTATDISTANCE(ST_GEOMFROMTEXT(@ls), 0.5)); |
| 14 |
ST_ASTEXT(ST_POINTATDISTANCE(ST_GEOMFROMTEXT(@ls), 0.5)) |
| 15 |
POINT(0 0.5) |
| 16 |
SELECT ST_ASTEXT(ST_POINTATDISTANCE(g, 0.5)) FROM gis_geometrycollection WHERE fid=101; |
| 17 |
ST_ASTEXT(ST_POINTATDISTANCE(g, 0.5)) |
| 18 |
POINT(0 0.5) |
| 19 |
SELECT ST_ASTEXT(ST_POINTATDISTANCE(ST_GEOMFROMTEXT('LINESTRING(0 0,0 1)'), 0.5)); |
| 20 |
ST_ASTEXT(ST_POINTATDISTANCE(ST_GEOMFROMTEXT('LINESTRING(0 0,0 1)'), 0.5)) |
| 21 |
POINT(0 0.5) |
| 22 |
DROP TABLE gis_geometrycollection; |
| 23 |
# |
| 24 |
# NULL values. |
| 25 |
# |
| 26 |
# At least one NULL parameter. Must return NULL. |
| 27 |
SELECT ST_POINTATDISTANCE(NULL, NULL); |
| 28 |
ST_POINTATDISTANCE(NULL, NULL) |
| 29 |
NULL |
| 30 |
SELECT ST_POINTATDISTANCE(NULL, 2); |
| 31 |
ST_POINTATDISTANCE(NULL, 2) |
| 32 |
NULL |
| 33 |
SELECT ST_POINTATDISTANCE(ST_GEOMFROMTEXT('LINESTRING(0 0, 0 1)', 4326), NULL); |
| 34 |
ST_POINTATDISTANCE(ST_GEOMFROMTEXT('LINESTRING(0 0, 0 1)', 4326), NULL) |
| 35 |
NULL |
| 36 |
# |
| 37 |
# Invalid parameters. |
| 38 |
# |
| 39 |
# Invalid geometry. Must raise error. |
| 40 |
DO ST_POINTATDISTANCE(x'000000000123456789abcdef', 1); |
| 41 |
ERROR 22023: Invalid GIS data provided to function st_pointatdistance. |
| 42 |
# Non-existing SRID. Must raise error. |
| 43 |
DO ST_POINTATDISTANCE(0xffffffff01020000000500000000000000000000000000000000000000000000000000F03F000000000000F03F000000000000F03F00000000000000400000000000000040000000000000F03F00000000000000400000000000000040,1); |
| 44 |
ERROR SR001: There's no spatial reference system with SRID 4294967295. |
| 45 |
# Latitude values must be within range [-90, 90]. |
| 46 |
DO ST_POINTATDISTANCE(0xE61000000102000000020000000000000000000000F2D24D62108056C000000000000000000000000000000000, 1); |
| 47 |
ERROR 22S03: A parameter of function st_pointatdistance contains a geometry with latitude -90.001000, which is out of range. It must be within [-90.000000, 90.000000]. |
| 48 |
DO ST_POINTATDISTANCE(0xE6100000010200000002000000000000000000000000000000000000000000000000000000F2D24D62108056C0, 1); |
| 49 |
ERROR 22S03: A parameter of function st_pointatdistance contains a geometry with latitude -90.001000, which is out of range. It must be within [-90.000000, 90.000000]. |
| 50 |
DO ST_POINTATDISTANCE(0xE61000000102000000020000000000000000000000F2D24D621080564000000000000000000000000000000000, 1); |
| 51 |
ERROR 22S03: A parameter of function st_pointatdistance contains a geometry with latitude 90.001000, which is out of range. It must be within [-90.000000, 90.000000]. |
| 52 |
DO ST_POINTATDISTANCE(0xE6100000010200000002000000000000000000000000000000000000000000000000000000F2D24D6210805640, 1); |
| 53 |
ERROR 22S03: A parameter of function st_pointatdistance contains a geometry with latitude 90.001000, which is out of range. It must be within [-90.000000, 90.000000]. |
| 54 |
# Longitude values must be within range (-180, 180]. |
| 55 |
DO ST_POINTATDISTANCE(0xE610000001020000000200000079E92631088066C0000000000000000000000000000000000000000000000000, 1); |
| 56 |
ERROR 22S02: A parameter of function st_pointatdistance contains a geometry with longitude -180.001000, which is out of range. It must be within (-180.000000, 180.000000]. |
| 57 |
DO ST_POINTATDISTANCE(0xE61000000102000000020000000000000000000000000000000000000079E92631088066C00000000000000000, 1); |
| 58 |
ERROR 22S02: A parameter of function st_pointatdistance contains a geometry with longitude -180.001000, which is out of range. It must be within (-180.000000, 180.000000]. |
| 59 |
DO ST_POINTATDISTANCE(0xE610000001020000000200000079E9263108806640000000000000000000000000000000000000000000000000, 1); |
| 60 |
ERROR 22S02: A parameter of function st_pointatdistance contains a geometry with longitude 180.001000, which is out of range. It must be within (-180.000000, 180.000000]. |
| 61 |
DO ST_POINTATDISTANCE(0xE61000000102000000020000000000000000000000000000000000000079E92631088066400000000000000000, 1); |
| 62 |
ERROR 22S02: A parameter of function st_pointatdistance contains a geometry with longitude 180.001000, which is out of range. It must be within (-180.000000, 180.000000]. |
| 63 |
# |
| 64 |
# Wrong arguments |
| 65 |
# |
| 66 |
# The geometry must be a linestring. |
| 67 |
# Cartesian SRID 0 |
| 68 |
DO ST_POINTATDISTANCE(ST_GEOMFROMTEXT('POINT(0 0)', 0), 1); |
| 69 |
ERROR 22S01: LINESTRING value is a geometry of unexpected type POINT in st_pointatdistance. |
| 70 |
DO ST_POINTATDISTANCE(ST_GEOMFROMTEXT('POLYGON((0 0, 0 1, 1 1, 0 0))', 0), 1); |
| 71 |
ERROR 22S01: LINESTRING value is a geometry of unexpected type POLYGON in st_pointatdistance. |
| 72 |
DO ST_POINTATDISTANCE(ST_GEOMFROMTEXT('MULTIPOINT((0 0), (1 1))', 0), 1); |
| 73 |
ERROR 22S01: LINESTRING value is a geometry of unexpected type MULTIPOINT in st_pointatdistance. |
| 74 |
DO ST_POINTATDISTANCE(ST_GEOMFROMTEXT('MULTILINESTRING((0 0, 1 1))', 0), 1); |
| 75 |
ERROR 22S01: LINESTRING value is a geometry of unexpected type MULTILINESTRING in st_pointatdistance. |
| 76 |
DO ST_POINTATDISTANCE(ST_GEOMFROMTEXT('MULTIPOLYGON(((0 0, 0 1, 1 1, 0 0)))', 0), 1); |
| 77 |
ERROR 22S01: LINESTRING value is a geometry of unexpected type MULTIPOLYGON in st_pointatdistance. |
| 78 |
DO ST_POINTATDISTANCE(ST_GEOMFROMTEXT('GEOMETRYCOLLECTION(POINT(0 0))', 0), 1); |
| 79 |
ERROR 22S01: LINESTRING value is a geometry of unexpected type GEOMCOLLECTION in st_pointatdistance. |
| 80 |
# Geographic |
| 81 |
DO ST_POINTATDISTANCE(ST_GEOMFROMTEXT('POINT(0 0)', 4326), 1); |
| 82 |
ERROR 22S01: LINESTRING value is a geometry of unexpected type POINT in st_pointatdistance. |
| 83 |
DO ST_POINTATDISTANCE(ST_GEOMFROMTEXT('POLYGON((0 0, 0 1, 1 1, 0 0))', 4326), 1); |
| 84 |
ERROR 22S01: LINESTRING value is a geometry of unexpected type POLYGON in st_pointatdistance. |
| 85 |
DO ST_POINTATDISTANCE(ST_GEOMFROMTEXT('MULTIPOINT((0 0), (1 1))', 4326), 1); |
| 86 |
ERROR 22S01: LINESTRING value is a geometry of unexpected type MULTIPOINT in st_pointatdistance. |
| 87 |
DO ST_POINTATDISTANCE(ST_GEOMFROMTEXT('MULTILINESTRING((0 0, 1 1))', 4326), 1); |
| 88 |
ERROR 22S01: LINESTRING value is a geometry of unexpected type MULTILINESTRING in st_pointatdistance. |
| 89 |
DO ST_POINTATDISTANCE(ST_GEOMFROMTEXT('MULTIPOLYGON(((0 0, 0 1, 1 1, 0 0)))', 4326), 1); |
| 90 |
ERROR 22S01: LINESTRING value is a geometry of unexpected type MULTIPOLYGON in st_pointatdistance. |
| 91 |
DO ST_POINTATDISTANCE(ST_GEOMFROMTEXT('GEOMETRYCOLLECTION(POINT(0 0))', 4326), 1); |
| 92 |
ERROR 22S01: LINESTRING value is a geometry of unexpected type GEOMCOLLECTION in st_pointatdistance. |
| 93 |
# The distance cannot be longer than length of linestring and must be positive |
| 94 |
DO ST_POINTATDISTANCE(ST_GEOMFROMTEXT('LINESTRING(0 0, 0 1)'), 2); |
| 95 |
ERROR 22003: Distance value is out of range in 'st_pointatdistance' |
| 96 |
DO ST_POINTATDISTANCE(ST_GEOMFROMTEXT('LINESTRING(0 0, 0 1)', 4326), 111400); |
| 97 |
ERROR 22003: Distance value is out of range in 'st_pointatdistance' |
| 98 |
# Error invoked from length function |
| 99 |
DO ST_POINTATDISTANCE(ST_GEOMFROMTEXT('LINESTRING(0 0, 0 1e308, 1e308 1e308)', 0), 1); |
| 100 |
ERROR 22003: Length value is out of range in 'st_length' |
| 101 |
# |
| 102 |
# Excercise code on supported types. |
| 103 |
# |
| 104 |
# Cartesian |
| 105 |
SELECT ST_ASTEXT(ST_POINTATDISTANCE(ST_GEOMFROMTEXT('LINESTRING(0 0, 0 1)'), 0.5)); |
| 106 |
ST_ASTEXT(ST_POINTATDISTANCE(ST_GEOMFROMTEXT('LINESTRING(0 0, 0 1)'), 0.5)) |
| 107 |
POINT(0 0.5) |
| 108 |
SELECT ST_ASTEXT(ST_LINEINTERPOLATEPOINT(ST_GEOMFROMTEXT('LINESTRING(0 0, 0 1)'), 0.5)); |
| 109 |
ST_ASTEXT(ST_LINEINTERPOLATEPOINT(ST_GEOMFROMTEXT('LINESTRING(0 0, 0 1)'), 0.5)) |
| 110 |
POINT(0 0.5) |
| 111 |
SELECT ST_ASTEXT(ST_LINEINTERPOLATEPOINTS(ST_GEOMFROMTEXT('LINESTRING(0 0, 0 1)'), 0.2)); |
| 112 |
ST_ASTEXT(ST_LINEINTERPOLATEPOINTS(ST_GEOMFROMTEXT('LINESTRING(0 0, 0 1)'), 0.2)) |
| 113 |
MULTIPOINT((0 0.2),(0 0.4),(0 0.6000000000000001),(0 0.8),(0 1)) |