# Disabled on Windows ASAN due to https://bugs.llvm.org/show_bug.cgi?id=35365 --source include/not_asan_windows.inc ################################################################################## # # # This test is aimed to focus on Spatial Analysis Functions. # # # # ST_Distance functions take 2 geometries as inpout parameters and # # returns minimum distance between them. # # # # Creation Date: 2014-06-09 # # Author : Pavan Naik # # # ################################################################################## ############################################################################################ # Creating the spatial objects # ############################################################################################ --echo # Creating the spatial Geometry object USE test; CREATE TABLE gis_geometrycollection (fid INTEGER NOT NULL PRIMARY KEY, g GEOMETRY); ############################################################################################ # Inserting the values specific to the spatial objects # ############################################################################################ # Geometric elements constructing a star and some of its elememts as base SET @star_elem_vertical= 'POLYGON((5 0,15 25,25 0,15 5,5 0))'; SET @star_elem_horizontal= 'POLYGON((25 0,0 15,30 15,22 10,25 0))'; SET @star_center= 'POINT(15 10)'; SET @star_top= 'POINT(15 25)'; SET @star_bottom_left= 'POINT(5 0)'; SET @star_bottom_right= 'POINT(25 0)'; SET @star_bottom_points= 'MULTIPOINT(5 0,25 0)'; SET @star_all_points= 'MULTIPOINT(5 0,25 0,15 10,15 25)'; SET @star_line_horizontal= 'LINESTRING(10 15,20 15)'; SET @star_line_vertical= 'LINESTRING(15 5,15 25)'; SET @star_top_to_center= 'LINESTRING(15 25,15 10)'; SET @star_lines_near_horizontal= 'MULTILINESTRING((25 0,0 15,15 30,0 5))'; SET @star_lines_near_vertical= 'MULTILINESTRING((0 5,15 25,0 25))'; SET @star= 'POLYGON((5 0,7 10,0 15,10 15,15 25,20 15,30 15,22 10,25 0,15 5,5 0))'; SET @star_elem_vertical_val= '((5 0,15 25,25 0,15 5,5 0))'; SET @star_elem_horizontal_val= '((25 0,0 15,30 15,22 10,25 0))'; SET @star_of_elems='MULTIPOLYGON(((5 0,15 25,25 0,15 5,5 0)),((25 0,0 15,30 15,22 10,25 0)))'; SET @star_collection_elems='GEOMETRYCOLLECTION(MULTIPOLYGON(((5 0,15 25,25 0,15 5,5 0)),((25 0,0 15,30 15,22 10,25 0))),POLYGON((5 0,7 10,0 15,10 15,15 25,20 15,30 15,22 10,25 0,15 5,5 0)),LINESTRING(15 25,15 10),MULTIPOINT(5 0,25 0),POINT(15 25))'; SET @star_collection_multilinestr='GEOMETRYCOLLECTION(MULTIPOLYGON(((5 0,15 25,25 0,15 5,5 0)),((25 0,0 15,30 15,22 10,25 0))),POLYGON((5 0,7 10,0 15,10 15,15 25,20 15,30 15,22 10,25 0,15 5,5 0)),MULTILINESTRING((25 0,0 15,15 30,0 5)),LINESTRING(15 25,15 10),MULTIPOINT(5 0,25 0),POINT(15 25))'; # Star identical to the base star SET @star_elem_vertical_1= 'POLYGON((5 0,15 25,25 0,15 5,5 0))'; SET @star_elem_horizontal_1= 'POLYGON((25 0,0 15,30 15,22 10,25 0))'; SET @star_center_1= 'POINT(15 10)'; SET @star_top_1= 'POINT(15 25)'; SET @star_bottom_left_1= 'POINT(5 0)'; SET @star_bottom_right_1= 'POINT(25 0)'; SET @star_bottom_points_1= 'MULTIPOINT(5 0,25 0)'; SET @star_all_points_1= 'MULTIPOINT(5 0,25 0,15 10,15 25)'; SET @star_line_horizontal_1= 'LINESTRING(10 15,20 15)'; SET @star_line_vertical_1= 'LINESTRING(15 5,15 25)'; SET @star_top_to_center_1= 'LINESTRING(15 25,15 10)'; SET @star_lines_near_horizontal_1= 'MULTILINESTRING((25 0,0 15,15 30,0 5))'; SET @star_lines_near_vertical_1= 'MULTILINESTRING((0 5,15 25,0 25))'; SET @star_1= 'POLYGON((5 0,7 10,0 15,10 15,15 25,20 15,30 15,22 10,25 0,15 5,5 0))'; SET @star_elem_vertical_val_1= '((5 0,15 25,25 0,15 5,5 0))'; SET @star_elem_horizontal_val_1= '((25 0,0 15,30 15,22 10,25 0))'; SET @star_of_elems_1='MULTIPOLYGON(((5 0,15 25,25 0,15 5,5 0)),((25 0,0 15,30 15,22 10,25 0)))'; SET @star_collection_elems_1='GEOMETRYCOLLECTION(MULTIPOLYGON(((5 0,15 25,25 0,15 5,5 0)),((25 0,0 15,30 15,22 10,25 0))),POLYGON((5 0,7 10,0 15,10 15,15 25,20 15,30 15,22 10,25 0,15 5,5 0)),LINESTRING(15 25,15 10),MULTIPOINT(5 0,25 0),POINT(15 25))'; # Star like the base star, but shifted to right by 10 on X to overlap base star SET @star_elem_vertical_2= 'POLYGON((15 0,25 25,35 0,25 5,15 0))'; SET @star_elem_horizontal_2= 'POLYGON((35 0,10 15,40 15,32 10,35 0))'; SET @star_center_2= 'POINT(25 10)'; SET @star_top_2= 'POINT(25 25)'; SET @star_bottom_left_2= 'POINT(15 0)'; SET @star_bottom_right_2= 'POINT(35 0)'; SET @star_bottom_points_2= 'MULTIPOINT(15 0,35 0)'; SET @star_all_points_2= 'MULTIPOINT(15 0,35 0,35 10,25 25)'; SET @star_line_horizontal_2= 'LINESTRING(20 15,30 15)'; SET @star_line_vertical_2= 'LINESTRING(25 5,25 25)'; SET @star_top_to_center_2= 'LINESTRING(25 25,25 10)'; SET @star_lines_near_horizontal_2= 'MULTILINESTRING((35 0,10 15,25 30,10 5))'; SET @star_lines_near_vertical_2= 'MULTILINESTRING((10 5,25 25,10 25))'; SET @star_2= 'POLYGON((15 0,17 10,10 15,20 15,25 25,30 15,40 15,32 10,35 0,25 5,15 0))'; SET @star_elem_vertical_val_2= '((15 0,25 25,35 0,25 5,15 0))'; SET @star_elem_horizontal_val_2= '((35 0,10 15,40 15,32 10,35 0))'; SET @star_of_elems_2='MULTIPOLYGON(((15 0,25 25,35 0,25 5,15 0)),((35 0,10 15,40 15,32 10,35 0)))'; SET @star_collection_elems_2='GEOMETRYCOLLECTION(MULTIPOLYGON(((15 0,25 25,35 0,25 5,15 0)),((35 0,10 15,40 15,32 10,35 0))),POLYGON((15 0,17 10,10 15,20 15,25 25,30 15,40 15,32 10,35 0,25 5,15 0)),LINESTRING(25 25,25 10),MULTIPOINT(15 0,35 0),POINT(25 25))'; # Star like the base star, but shifted to right by 60 on X to be completly separate SET @star_elem_vertical_3= 'POLYGON((65 0,75 25,85 0,75 5,65 0))'; SET @star_elem_horizontal_3= 'POLYGON((85 0,60 15,90 15,82 10,85 0))'; SET @star_center_3= 'POINT(75 10)'; SET @star_top_3= 'POINT(75 25)'; SET @star_bottom_left_3= 'POINT(65 0)'; SET @star_bottom_right_3= 'POINT(85 0)'; SET @star_bottom_points_3= 'MULTIPOINT(65 0,85 0)'; SET @star_all_points_3= 'MULTIPOINT(65 0,85 0,75 10,75 25)'; SET @star_line_horizontal_3= 'LINESTRING(70 15,80 15)'; SET @star_line_vertical_3= 'LINESTRING(75 5,75 25)'; SET @star_top_to_center_3= 'LINESTRING(75 25,75 10)'; SET @star_lines_near_horizontal_3= 'MULTILINESTRING((85 0,60 15,85 30,60 5))'; SET @star_lines_near_vertical_3= 'MULTILINESTRING((60 5,75 25,60 25))'; SET @star_3= 'POLYGON((65 0,67 10,60 15,70 15,75 25,80 15,90 15,82 10,85 0,75 5,65 0))'; SET @star_elem_vertical_val_3= '((65 0,75 25,85 0,75 5,65 0))'; SET @star_elem_horizontal_val_3= '((85 0,60 15,90 15,82 10,85 0))'; SET @star_of_elems_3='MULTIPOLYGON(((65 0,75 25,85 0,75 5,65 0)),((85 0,60 15,90 15,82 10,85 0)))'; SET @star_collection_elems_3='GEOMETRYCOLLECTION(MULTIPOLYGON(((65 0,75 25,85 0,75 5,65 0)),((85 0,60 15,90 15,82 10,85 0))),POLYGON((65 0,67 10,60 15,70 15,75 25,80 15,90 15,82 10,85 0,75 5,65 0)),LINESTRING(75 25,75 10),MULTIPOINT(65 0,85 0),POINT(75 25))'; --echo # INSERT base star --disable_warnings INSERT INTO gis_geometrycollection VALUES (100,ST_GEOMFROMTEXT(@star)), (101,ST_GEOMFROMTEXT(@star_elem_vertical)), (102,ST_GEOMFROMTEXT(@star_elem_horizontal)), (103,ST_GEOMFROMTEXT(@star_of_elems)), (104,ST_GEOMFROMTEXT(@star_top)), (105,ST_GEOMFROMTEXT(@star_center)), (106,ST_GEOMFROMTEXT(@star_bottom_left)), (107,ST_GEOMFROMTEXT(@star_bottom_right)), (108,ST_GEOMFROMTEXT(@star_bottom_points)), (109,ST_GEOMFROMTEXT(@star_all_points)), (110,ST_GEOMFROMTEXT(@star_line_horizontal)), (111,ST_GEOMFROMTEXT(@star_line_vertical)), (112,ST_GEOMFROMTEXT(@star_top_to_center)), (113,ST_GEOMFROMTEXT(@star_lines_near_horizontal)), (114,ST_GEOMFROMTEXT(@star_lines_near_vertical)), (115,ST_GEOMFROMTEXT(@star_collection_elems)); --enable_warnings --echo # INSERT identical (to base) star --disable_warnings INSERT INTO gis_geometrycollection VALUES (200,ST_GEOMFROMTEXT(@star_1)), (201,ST_GEOMFROMTEXT(@star_elem_vertical_1)), (202,ST_GEOMFROMTEXT(@star_elem_horizontal_1)), (203,ST_GEOMFROMTEXT(@star_of_elems_1)), (204,ST_GEOMFROMTEXT(@star_top_1)), (205,ST_GEOMFROMTEXT(@star_center_1)), (206,ST_GEOMFROMTEXT(@star_bottom_left_1)), (207,ST_GEOMFROMTEXT(@star_bottom_right_1)), (208,ST_GEOMFROMTEXT(@star_bottom_points_1)), (209,ST_GEOMFROMTEXT(@star_all_points_1)), (210,ST_GEOMFROMTEXT(@star_line_horizontal_1)), (211,ST_GEOMFROMTEXT(@star_line_vertical_1)), (212,ST_GEOMFROMTEXT(@star_top_to_center_1)), (213,ST_GEOMFROMTEXT(@star_lines_near_horizontal_1)), (214,ST_GEOMFROMTEXT(@star_lines_near_vertical_1)), (215,ST_GEOMFROMTEXT(@star_collection_elems_1)); --enable_warnings --echo # INSERT overlapping star --disable_warnings INSERT INTO gis_geometrycollection VALUES (300,ST_GEOMFROMTEXT(@star_2)), (301,ST_GEOMFROMTEXT(@star_elem_vertical_2)), (302,ST_GEOMFROMTEXT(@star_elem_horizontal_2)), (303,ST_GEOMFROMTEXT(@star_of_elems_2)), (304,ST_GEOMFROMTEXT(@star_top_2)), (305,ST_GEOMFROMTEXT(@star_center_2)), (306,ST_GEOMFROMTEXT(@star_bottom_left_2)), (307,ST_GEOMFROMTEXT(@star_bottom_right_2)), (308,ST_GEOMFROMTEXT(@star_bottom_points_2)), (309,ST_GEOMFROMTEXT(@star_all_points_2)), (310,ST_GEOMFROMTEXT(@star_line_horizontal_2)), (311,ST_GEOMFROMTEXT(@star_line_vertical_2)), (312,ST_GEOMFROMTEXT(@star_top_to_center_2)), (313,ST_GEOMFROMTEXT(@star_lines_near_horizontal_2)), (314,ST_GEOMFROMTEXT(@star_lines_near_vertical_2)), (315,ST_GEOMFROMTEXT(@star_collection_elems_2)); --enable_warnings --echo # INSERT seperate star --disable_warnings INSERT INTO gis_geometrycollection VALUES (400,ST_GEOMFROMTEXT(@star_3)), (401,ST_GEOMFROMTEXT(@star_elem_vertical_3)), (402,ST_GEOMFROMTEXT(@star_elem_horizontal_3)), (403,ST_GEOMFROMTEXT(@star_of_elems_3)), (404,ST_GEOMFROMTEXT(@star_top_3)), (405,ST_GEOMFROMTEXT(@star_center_3)), (406,ST_GEOMFROMTEXT(@star_bottom_left_3)), (407,ST_GEOMFROMTEXT(@star_bottom_right_3)), (408,ST_GEOMFROMTEXT(@star_bottom_points_3)), (409,ST_GEOMFROMTEXT(@star_all_points_3)), (410,ST_GEOMFROMTEXT(@star_line_horizontal_3)), (411,ST_GEOMFROMTEXT(@star_line_vertical_3)), (412,ST_GEOMFROMTEXT(@star_top_to_center_3)), (413,ST_GEOMFROMTEXT(@star_lines_near_horizontal_3)), (414,ST_GEOMFROMTEXT(@star_lines_near_vertical_3)), (415,ST_GEOMFROMTEXT(@star_collection_elems_3)); --enable_warnings CREATE TABLE gis_geometrycollection_2 SELECT fid as fid2,g as g2 FROM gis_geometrycollection; --echo # Checking the integrity of the above create/insert statements --echo # 64 rows. SELECT count(ST_AsText(g) != 'NULL') FROM gis_geometrycollection; --echo # 64 rows. SELECT count(ST_AsText(g2) != 'NULL') FROM gis_geometrycollection_2; --echo ##################################################################################### --echo # ST_DISTANCE(g1,g2) --echo ##################################################################################### --echo #==================================================================================== --echo # point,point --echo #==================================================================================== SELECT ST_DISTANCE(ST_GEOMFROMTEXT(@star_center),ST_GEOMFROMTEXT(@star_center)); SELECT ST_DISTANCE(ST_GEOMFROMTEXT(@star_top),ST_GEOMFROMTEXT(@star_center)); SELECT ST_DISTANCE(ST_GEOMFROMTEXT('POINT(0 0)'),ST_GEOMFROMTEXT('POINT(-0 0.00)')); SELECT ST_DISTANCE(ST_GEOMFROMTEXT('POINT(0 0)'),ST_GEOMFROMTEXT('POINT(1e154 0)')); SELECT ST_DISTANCE(ST_GEOMFROMTEXT('POINT(0 0)'),ST_GEOMFROMTEXT('POINT(-1e154 0)')); SELECT ST_DISTANCE(g,ST_GEOMFROMTEXT(@star_center)) FROM gis_geometrycollection WHERE fid=105; --echo #==================================================================================== --echo # point,multipoint --echo #==================================================================================== SELECT ST_DISTANCE(ST_GEOMFROMTEXT(@star_bottom_left),ST_GEOMFROMTEXT(@star_bottom_points)); SELECT ST_DISTANCE(ST_GEOMFROMTEXT('POINT(0 0)'),ST_GEOMFROMTEXT('MULTIPOINT(10 10)')); SELECT ST_DISTANCE(ST_GEOMFROMTEXT('POINT(1e154 0)'),ST_GEOMFROMTEXT('MULTIPOINT(1e154 10)')); SELECT ST_DISTANCE(ST_GEOMFROMTEXT('POINT(0 0)'),ST_GEOMFROMTEXT('MULTIPOINT(-0 0.000,-0.000 0)')); SELECT ST_DISTANCE(g,ST_GEOMFROMTEXT(@star_bottom_points)) FROM gis_geometrycollection WHERE fid=106; --echo #==================================================================================== --echo # point,linestring --echo #==================================================================================== SELECT ST_DISTANCE(ST_GEOMFROMTEXT(@star_top),ST_GEOMFROMTEXT(@star_top_to_center)); SELECT ST_DISTANCE(ST_GEOMFROMTEXT('POINT(0 0)'),ST_GEOMFROMTEXT('LINESTRING(10 10,10 0)')); SELECT ST_DISTANCE(ST_GEOMFROMTEXT('POINT(0 0)'),ST_GEOMFROMTEXT('LINESTRING(10 10,10 0,0.0000 -0.0000)')); SELECT ST_DISTANCE(g,ST_GEOMFROMTEXT(@star_top_to_center)) FROM gis_geometrycollection WHERE fid=104; --echo #==================================================================================== --echo # point,multilinestring --echo #==================================================================================== SELECT ST_DISTANCE(ST_GEOMFROMTEXT(@star_top),ST_GEOMFROMTEXT(@star_lines_near_vertical)); SELECT ST_DISTANCE(ST_GEOMFROMTEXT('POINT(0 0)'),ST_GEOMFROMTEXT('MULTILINESTRING((10 10,1 0))')); --error ER_GIS_INVALID_DATA SELECT ST_DISTANCE(ST_GEOMFROMTEXT('POINT(0 0)'),ST_GEOMFROMTEXT('MULTILINESTRING((10 10,10 0),(0.0000 -0.0000))')); SELECT ST_DISTANCE(ST_GEOMFROMTEXT('POINT(1e77 0)'),ST_GEOMFROMTEXT('MULTILINESTRING((0 0,0 1e154),(0 1e154,1e154 0))')); SELECT ST_DISTANCE(g,ST_GEOMFROMTEXT(@star_lines_near_vertical)) FROM gis_geometrycollection WHERE fid=104; --echo #==================================================================================== --echo # point,polygon --echo #==================================================================================== SELECT ST_DISTANCE(ST_GEOMFROMTEXT(@star_top),ST_GEOMFROMTEXT(@star)); SELECT ST_DISTANCE(ST_GEOMFROMTEXT('POINT(5 5)'),ST_GEOMFROMTEXT('POLYGON((0 0,0 10,10 10,10 0,0 0))')); SELECT ST_DISTANCE(ST_GEOMFROMTEXT('POINT(5 5)'),ST_GEOMFROMTEXT('POLYGON((0 0,0 10,10 10,10 0, 0 0),(4 4,4 6,6 6,6 4,4 4))')); SELECT ST_DISTANCE(ST_GEOMFROMTEXT('POINT(20 20)'),ST_GEOMFROMTEXT('POLYGON((0 0,0 10,10 10,10 0,0 0))')); SELECT ST_DISTANCE(g,ST_GEOMFROMTEXT(@star)) FROM gis_geometrycollection WHERE fid=104; --echo #==================================================================================== --echo # point,multipolygon --echo #==================================================================================== SELECT ST_DISTANCE(ST_GEOMFROMTEXT(@star_top),ST_GEOMFROMTEXT(@star_of_elems)); SELECT ST_DISTANCE(ST_GEOMFROMTEXT('POINT(1 1)'),ST_GEOMFROMTEXT('MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0)))')); SELECT ST_DISTANCE(ST_GEOMFROMTEXT('POINT(15 15)'),ST_GEOMFROMTEXT('MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0)))')); SELECT ST_DISTANCE(ST_GEOMFROMTEXT('POINT(4 4)'),ST_GEOMFROMTEXT('MULTIPOLYGON(((0 0,0 10,10 10,10 0, 0 0),(4 4,4 6,6 6,6 4,4 4)))')); SELECT ST_DISTANCE(ST_GEOMFROMTEXT('POINT(5 5)'),ST_GEOMFROMTEXT('MULTIPOLYGON(((0 0,0 10,10 10,10 0, 0 0)),' '((3 3,3 7,7 7,7 3, 3 3),(4 4,4 6,6 6,6 4,4 4)))')); SELECT ST_DISTANCE(ST_GEOMFROMTEXT('POINT(5 5)'),ST_GEOMFROMTEXT('MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0),(4 4,4 6,6 6,6 4,4 4)),' '((3 3,3 7,7 7,7 3,3 3),(4 4,4 6,6 6,6 4,4 4)))')); SELECT ST_DISTANCE(g,ST_GEOMFROMTEXT(@star_of_elems)) FROM gis_geometrycollection WHERE fid=104; --echo #==================================================================================== --echo # point,geometrycollection --echo #==================================================================================== SELECT ST_DISTANCE(ST_GEOMFROMTEXT(@star_top),ST_GEOMFROMTEXT(@star_collection_elems)); SELECT ST_DISTANCE(ST_GEOMFROMTEXT('POINT(5 5)'),ST_GEOMFROMTEXT('GEOMETRYCOLLECTION(GEOMETRYCOLLECTION(POINT(5 5)))')); SELECT ST_DISTANCE(ST_GEOMFROMTEXT('POINT(5 5)'),ST_GEOMFROMTEXT('GEOMETRYCOLLECTION(' 'LINESTRING(1 1,2 2,3 3,4 4,5 5),' 'POLYGON((0 0,0 10,10 10,10 0,0 0),(4 4,4 6,6 6,6 4,4 4)))')); SELECT ST_DISTANCE(ST_GEOMFROMTEXT('POINT(5 5)'),ST_GEOMFROMTEXT('GEOMETRYCOLLECTION(' 'POLYGON((0 0,0 10,10 10,10 0,0 0),(4 4,4 6,6 6,6 4,4 4)),' 'POLYGON((3 3,3 7,7 7,7 3,3 3),(4 4,4 6,6 6,6 4,4 4)))')); SELECT ST_DISTANCE(g,ST_GEOMFROMTEXT(@star_collection_elems)) FROM gis_geometrycollection WHERE fid=104; --echo #==================================================================================== --echo # multipoint,point --echo #==================================================================================== SELECT ST_DISTANCE(ST_GEOMFROMTEXT(@star_all_points),ST_GEOMFROMTEXT(@star_top)); SELECT ST_DISTANCE(ST_GEOMFROMTEXT(@star_bottom_points),ST_GEOMFROMTEXT(@star_center)); SELECT ST_DISTANCE(ST_GEOMFROMTEXT('MULTIPOINT(0 0,10 0)'),ST_GEOMFROMTEXT('POINT(5 0)')); SELECT ST_DISTANCE(ST_GEOMFROMTEXT('MULTIPOINT(0 0,10 0)'),ST_GEOMFROMTEXT('POINT(5 5)')); SELECT ST_DISTANCE(ST_GEOMFROMTEXT('MULTIPOINT(0 0,10 0)'),ST_GEOMFROMTEXT('POINT(10 5)')); SELECT ST_DISTANCE(ST_GEOMFROMTEXT('MULTIPOINT(1e154 0)'),ST_GEOMFROMTEXT('POINT(1e154 0)')); SELECT ST_DISTANCE(g,ST_GEOMFROMTEXT(@star_bottom_left)) FROM gis_geometrycollection WHERE fid=108; --echo #==================================================================================== --echo # multipoint,multipoint --echo #==================================================================================== SELECT ST_DISTANCE(ST_GEOMFROMTEXT(@star_all_points),ST_GEOMFROMTEXT(@star_bottom_points)); SELECT ST_DISTANCE(ST_GEOMFROMTEXT(@star_bottom_points),ST_GEOMFROMTEXT(@star_all_points)); SELECT ST_DISTANCE(ST_GEOMFROMTEXT('MULTIPOINT(0 0,5 0,10 0)'),ST_GEOMFROMTEXT('MULTIPOINT(10 0.0001)')); SELECT ST_DISTANCE(ST_GEOMFROMTEXT('MULTIPOINT(0 0,5 0,10 0)'),ST_GEOMFROMTEXT('MULTIPOINT(2.5 0.0001)')); SELECT ST_DISTANCE(ST_GEOMFROMTEXT('MULTIPOINT(0 0,5 0,10 0)'),ST_GEOMFROMTEXT('MULTIPOINT(0 -1e154)')); SELECT ST_DISTANCE(g,ST_GEOMFROMTEXT(@star_all_points)) FROM gis_geometrycollection WHERE fid=108; --echo #==================================================================================== --echo # multipoint,linestring --echo #==================================================================================== SELECT ST_DISTANCE(ST_GEOMFROMTEXT(@star_all_points),ST_GEOMFROMTEXT(@star_top_to_center)); SELECT ST_DISTANCE(ST_GEOMFROMTEXT('MULTIPOINT(0 0,5 0)'),ST_GEOMFROMTEXT('LINESTRING(2 2,5 0,8 2)')); SELECT ST_DISTANCE(ST_GEOMFROMTEXT('MULTIPOINT(0 0,5 0,10 0)'),ST_GEOMFROMTEXT('LINESTRING(2 2,8 2)')); SELECT ST_DISTANCE(ST_GEOMFROMTEXT('MULTIPOINT(1 1,1 4,4 4,4 0.00009)'),ST_GEOMFROMTEXT('LINESTRING(0 0,0 5,5 5,5 0,0 0)')); SELECT ST_DISTANCE(g,ST_GEOMFROMTEXT(@star_top_to_center)) FROM gis_geometrycollection WHERE fid=109; --echo #==================================================================================== --echo # multipoint,multilinestring --echo #==================================================================================== SELECT ST_DISTANCE(ST_GEOMFROMTEXT(@star_all_points),ST_GEOMFROMTEXT(@star_lines_near_vertical)); SELECT ST_DISTANCE(ST_GEOMFROMTEXT(@star_all_points),ST_GEOMFROMTEXT(@star_lines_near_horizontal)); SELECT ST_DISTANCE(ST_GEOMFROMTEXT('MULTIPOINT(0 0,5 0)'),ST_GEOMFROMTEXT('MULTILINESTRING((2 2,5 0),(1 1,10 10))')); SELECT ST_DISTANCE(ST_GEOMFROMTEXT('MULTIPOINT(0 0,5 0)'),ST_GEOMFROMTEXT('MULTILINESTRING((2 2,2 10,10 10),(10 10,10 2,2 2))')); SELECT ST_DISTANCE(ST_GEOMFROMTEXT('MULTIPOINT(4 4,6 6)'),ST_GEOMFROMTEXT('MULTILINESTRING((0 0,0 10,10 10,10 0,0 0))')); SELECT ST_DISTANCE(g,ST_GEOMFROMTEXT(@star_lines_near_horizontal)) FROM gis_geometrycollection WHERE fid=109; --echo #==================================================================================== --echo # multipoint,polygon --echo #==================================================================================== SELECT ST_DISTANCE(ST_GEOMFROMTEXT(@star_all_points),ST_GEOMFROMTEXT(@star_elem_vertical)); SELECT ST_DISTANCE(ST_GEOMFROMTEXT(@star_all_points),ST_GEOMFROMTEXT(@star_elem_horizontal)); SELECT ST_DISTANCE(ST_GEOMFROMTEXT('MULTIPOINT(4 4,11 11)'),ST_GEOMFROMTEXT('POLYGON((0 0,0 10,10 10,10 0,0 0))')); SELECT ST_DISTANCE(ST_GEOMFROMTEXT('MULTIPOINT(0 -2,11 11)'),ST_GEOMFROMTEXT('POLYGON((0 0,0 10,10 10,10 0,0 0))')); SELECT ST_DISTANCE(ST_GEOMFROMTEXT('MULTIPOINT(5.5 5.5)'),ST_GEOMFROMTEXT('POLYGON((0 0,0 10,10 10,10 0, 0 0),(4 4,4 6,6 6,6 4,4 4))')); SELECT ST_DISTANCE(ST_GEOMFROMTEXT('MULTIPOINT(4 4,6 6)'),ST_GEOMFROMTEXT('POLYGON((0 0,0 10,10 10,10 0, 0 0),(4 4,4 6,6 6,6 4,4 4))')); SELECT ST_DISTANCE(g,ST_GEOMFROMTEXT(@star_elem_horizontal)) FROM gis_geometrycollection WHERE fid=109; --echo #==================================================================================== --echo # multipoint,multipolygon --echo #==================================================================================== SELECT ST_DISTANCE(ST_GEOMFROMTEXT(@star_all_points),ST_GEOMFROMTEXT(@star_of_elems)); SELECT ST_DISTANCE(ST_GEOMFROMTEXT('MULTIPOINT(0 0,0 30,30 25)'),ST_GEOMFROMTEXT(@star_of_elems)); SELECT ST_DISTANCE(ST_GEOMFROMTEXT('MULTIPOINT(0 0,0 5)'),ST_GEOMFROMTEXT('MULTIPOLYGON(((0 0,0 4,4 4,0 0)),((0 5,0 10,10 5,0 5)))')); SELECT ST_DISTANCE(ST_GEOMFROMTEXT('MULTIPOINT(4.5 4.5,5.5 5.5)'),ST_GEOMFROMTEXT('MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0),(4 4,4 6,6 6,6 4,4 4)),' '((4 4,4 6,6 6,6 4,4 4)))')); SELECT ST_DISTANCE(ST_GEOMFROMTEXT('MULTIPOINT(5 5,15 15.1)'),ST_GEOMFROMTEXT('MULTIPOLYGON(((0 0,0 10,10 10,10 0, 0 0),(4 4,4 6,6 6,6 4,4 4)),' '((10 10,10 20,20 20,20 10,10 10),(14 14,14 16,16 16,16 14,14 14)))')); SELECT ST_DISTANCE(g,ST_GEOMFROMTEXT(@star_of_elems)) FROM gis_geometrycollection WHERE fid=109; --echo #==================================================================================== --echo # multipoint,geometrycollection --echo #==================================================================================== SELECT ST_DISTANCE(ST_GEOMFROMTEXT(@star_all_points),ST_GEOMFROMTEXT(@star_collection_elems)); SELECT ST_DISTANCE(ST_GEOMFROMTEXT(@star_all_points),ST_GEOMFROMTEXT(@star_collection_multilinestr)); SELECT ST_DISTANCE(ST_GEOMFROMTEXT('MULTIPOINT(0 0,0 30,30 25)'),ST_GEOMFROMTEXT(@star_collection_elems)); SELECT ST_DISTANCE(ST_GEOMFROMTEXT('MULTIPOINT(5 5,10 10)'),ST_GEOMFROMTEXT('GEOMETRYCOLLECTION(GEOMETRYCOLLECTION(POINT(5 5)))')); SELECT ST_DISTANCE(ST_GEOMFROMTEXT('MULTIPOINT(5 5,20 20)'),ST_GEOMFROMTEXT('GEOMETRYCOLLECTION(' 'LINESTRING(1 1,2 2,3 3,4 4,5 5),' 'POLYGON((0 0,0 10,10 10,10 0,0 0),(4 4,4 6,6 6,6 4,4 4)))')); SELECT ST_DISTANCE(ST_GEOMFROMTEXT('MULTIPOINT(5 5,20 20)'),ST_GEOMFROMTEXT('GEOMETRYCOLLECTION(' 'POLYGON((0 0,0 10,10 10,10 0,0 0),(4 4,4 6,6 6,6 4,4 4)),' 'POLYGON((3 3,3 7,7 7,7 3,3 3),(4 4,4 6,6 6,6 4,4 4)))')); SELECT ST_DISTANCE(g,ST_GEOMFROMTEXT(@star_collection_elems)) FROM gis_geometrycollection WHERE fid=109; --echo #==================================================================================== --echo # linestring,point --echo #==================================================================================== SELECT ST_DISTANCE(ST_GEOMFROMTEXT(@star_top_to_center),ST_GEOMFROMTEXT(@star_center)); SELECT ST_DISTANCE(ST_GEOMFROMTEXT(@star_top_to_center),ST_GEOMFROMTEXT(@star_bottom_left)); SELECT ST_DISTANCE(ST_GEOMFROMTEXT('LINESTRING(0 0,10 0)'),ST_GEOMFROMTEXT('POINT(5 0)')); SELECT ST_DISTANCE(ST_GEOMFROMTEXT('LINESTRING(0 0,10 0)'),ST_GEOMFROMTEXT('POINT(10 0.00000001)')); SELECT ST_DISTANCE(ST_GEOMFROMTEXT('LINESTRING(0 0,10 0)'),ST_GEOMFROMTEXT('POINT(5 1000000)')); SELECT ST_DISTANCE(g,g2) FROM gis_geometrycollection,gis_geometrycollection_2 WHERE fid=110 and fid2=105; --echo #==================================================================================== --echo # linestring,multipoint --echo #==================================================================================== SELECT ST_DISTANCE(ST_GEOMFROMTEXT(@star_line_vertical),ST_GEOMFROMTEXT(@star_all_points)); SELECT ST_DISTANCE(ST_GEOMFROMTEXT(@star_line_vertical),ST_GEOMFROMTEXT('MULTIPOINT(15 10,15 25)')); SELECT ST_DISTANCE(ST_GEOMFROMTEXT('LINESTRING(0 0,10 0,10 10,0 10)'),ST_GEOMFROMTEXT('MULTIPOINT(5 0,10 5,5 10)')); SELECT ST_DISTANCE(ST_GEOMFROMTEXT('LINESTRING(0 0,10 0,10 10,0 10)'),ST_GEOMFROMTEXT('MULTIPOINT(10.2 0,10 10.4)')); SELECT ST_DISTANCE(ST_GEOMFROMTEXT('LINESTRING(0 0,10 0,10 10,0 10)'),ST_GEOMFROMTEXT('MULTIPOINT(4 4,5 5,7 7)')); SELECT ST_DISTANCE(g,ST_GEOMFROMTEXT('MULTIPOINT(15 10,15 25)')) FROM gis_geometrycollection WHERE fid=111; --echo #==================================================================================== --echo # linestring,linestring --echo #==================================================================================== SELECT ST_DISTANCE(ST_GEOMFROMTEXT(@star_line_vertical),ST_GEOMFROMTEXT(@star_top_to_center)); SELECT ST_DISTANCE(ST_GEOMFROMTEXT(@star_top_to_center),ST_GEOMFROMTEXT(@star_line_vertical)); SELECT ST_DISTANCE(ST_GEOMFROMTEXT('LINESTRING(0 0,10 10)'),ST_GEOMFROMTEXT('LINESTRING(0 10,10 0)')); SELECT ST_DISTANCE(ST_GEOMFROMTEXT('LINESTRING(0 0,10 10)'),ST_GEOMFROMTEXT('LINESTRING(0 10,10 19)')); SELECT ST_DISTANCE(g,ST_GEOMFROMTEXT(@star_top_to_center)) FROM gis_geometrycollection WHERE fid=111; --echo #==================================================================================== --echo # linestring,multilinestring --echo #==================================================================================== SELECT ST_DISTANCE(ST_GEOMFROMTEXT(@star_line_horizontal),ST_GEOMFROMTEXT(@star_lines_near_horizontal)); SELECT ST_DISTANCE(ST_GEOMFROMTEXT(@star_line_horizontal),ST_GEOMFROMTEXT(@star_lines_near_vertical)); SELECT ST_DISTANCE(ST_GEOMFROMTEXT('LINESTRING(0 0,10 10)'),ST_GEOMFROMTEXT('MULTILINESTRING((0 10,5 5.5),(5 4.6,10 0))')); SELECT ST_DISTANCE(ST_GEOMFROMTEXT('LINESTRING(0 0,10 10)'),ST_GEOMFROMTEXT('MULTILINESTRING((0 10,10 19),(10 0,10 10))')); SELECT ST_DISTANCE(g,ST_GEOMFROMTEXT(@star_lines_near_horizontal)) FROM gis_geometrycollection WHERE fid=110; --echo #==================================================================================== --echo # linestring,polygon --echo #==================================================================================== SELECT ST_DISTANCE(ST_GEOMFROMTEXT(@star_line_horizontal),ST_GEOMFROMTEXT(@star_elem_horizontal)); SELECT ST_DISTANCE(ST_GEOMFROMTEXT(@star_line_horizontal),ST_GEOMFROMTEXT('POLYGON((11 15,19 15,19 10, 11 15))')); SELECT ST_DISTANCE(ST_GEOMFROMTEXT('LINESTRING(4 4,6 6)'),ST_GEOMFROMTEXT('POLYGON((0 0,0 10,10 10,10 0,0 0))')); SELECT ST_DISTANCE(ST_GEOMFROMTEXT('LINESTRING(4 4,6 6)'),ST_GEOMFROMTEXT('POLYGON((0 0,0 10,10 10,10 0, 0 0),(4 4,4 6,6 6,6 4,4 4))')); SELECT ST_DISTANCE(ST_GEOMFROMTEXT('LINESTRING(-11 -11,-11 11)'),ST_GEOMFROMTEXT('POLYGON((0 0,0 10,10 10,10 0,0 0))')); SELECT ST_DISTANCE(ST_GEOMFROMTEXT('LINESTRING(4.5 4.5,5.5 5.4)'),ST_GEOMFROMTEXT('POLYGON((0 0,0 10,10 10,10 0, 0 0),(4 4,4 6,6 6,6 4,4 4))')); --echo #==================================================================================== --echo # linestring,multipolygon --echo #==================================================================================== SELECT ST_DISTANCE(ST_GEOMFROMTEXT(@star_line_horizontal),ST_GEOMFROMTEXT(@star_of_elems)); SELECT ST_DISTANCE(ST_GEOMFROMTEXT(@star_line_horizontal),ST_GEOMFROMTEXT('MULTIPOLYGON(((11 15,19 15,19 10,11 15)),((25 0,0 15,25 10,25 0)))')); SELECT ST_DISTANCE(ST_GEOMFROMTEXT('LINESTRING(0 0,20 20,30 30)'),ST_GEOMFROMTEXT('MULTIPOLYGON(((0 0,0 4,4 4,0 0)),((0 5,0 10,10 5,0 5)))')); --error ER_GIS_INVALID_DATA SELECT ST_DISTANCE(ST_GEOMFROMTEXT('LINESTRING(-1 5)'),ST_GEOMFROMTEXT('MULTIPOLYGON(((0 0,0 4,4 4,0 0)),((0 5,0 10,10 5,0 5)))')); SELECT ST_DISTANCE(ST_GEOMFROMTEXT('LINESTRING(4.5 4.5,5.5 5.5)'),ST_GEOMFROMTEXT('MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0),(4 4,4 6,6 6,6 4,4 4)),' '((4 4,4 6,6 6,6 4,4 4)))')); SELECT ST_DISTANCE(ST_GEOMFROMTEXT('LINESTRING(5 5,15 15)'),ST_GEOMFROMTEXT('MULTIPOLYGON(((0 0,0 10,10 10,10 0, 0 0),(4 4,4 6,6 6,6 4,4 4)),' '((10 10,10 20,20 20,20 10,10 10),(14 14,14 16,16 16,16 14,14 14)))')); --echo #==================================================================================== --echo # linestring,geometrycollection --echo #==================================================================================== SELECT ST_DISTANCE(ST_GEOMFROMTEXT(@star_line_horizontal),ST_GEOMFROMTEXT(@star_collection_elems_3)); SELECT ST_DISTANCE(ST_GEOMFROMTEXT(@star_line_horizontal),ST_GEOMFROMTEXT(@star_collection_elems)); SELECT ST_DISTANCE(ST_GEOMFROMTEXT(@star_line_horizontal),ST_GEOMFROMTEXT(@star_collection_multilinestr)); SELECT ST_DISTANCE(ST_GEOMFROMTEXT('LINESTRING(0 0,10 10)'),ST_GEOMFROMTEXT('GEOMETRYCOLLECTION(GEOMETRYCOLLECTION(POINT(0 5)))')); SELECT ST_DISTANCE(ST_GEOMFROMTEXT('LINESTRING(4.5 4.5,5.5 5.5)'),ST_GEOMFROMTEXT('GEOMETRYCOLLECTION(' 'LINESTRING(1 1,2 2,3 3,4 4),' 'POLYGON((0 0,0 10,10 10,10 0,0 0),(4 4,4 6,6 6,6 4,4 4)))')); SELECT ST_DISTANCE(ST_GEOMFROMTEXT('LINESTRING(5 5,15 15,25 24)'),ST_GEOMFROMTEXT('GEOMETRYCOLLECTION(' 'POLYGON((0 0,0 10,10 10,10 0,0 0),(4 4,4 6,6 6,6 4,4 4)),' 'POLYGON((3 3,3 7,7 7,7 3,3 3),(4 4,4 6,6 6,6 4,4 4)))')); SELECT ST_DISTANCE(g,ST_GEOMFROMTEXT(@star_collection_elems_3)) FROM gis_geometrycollection WHERE fid=110; --echo #==================================================================================== --echo # multilinestring,point --echo #==================================================================================== SELECT ST_DISTANCE(ST_GEOMFROMTEXT(@star_lines_near_vertical),ST_GEOMFROMTEXT(@star_top)); SELECT ST_DISTANCE(ST_GEOMFROMTEXT(@star_lines_near_vertical),ST_GEOMFROMTEXT(@star_center)); SELECT ST_DISTANCE(ST_GEOMFROMTEXT('MULTILINESTRING((0 0,10 0),(0 10,10 10))'),ST_GEOMFROMTEXT('POINT(5 0)')); SELECT ST_DISTANCE(ST_GEOMFROMTEXT('MULTILINESTRING((0 0,10 0),(0 10,10 10))'),ST_GEOMFROMTEXT('POINT(5 5)')); SELECT ST_DISTANCE(ST_GEOMFROMTEXT('MULTILINESTRING((0 0,10 0),(0 10,10 10))'),ST_GEOMFROMTEXT('POINT(5 1000000)')); SELECT ST_DISTANCE(g,ST_GEOMFROMTEXT(@star_top)) FROM gis_geometrycollection WHERE fid=114; --echo #==================================================================================== --echo # multilinestring,multipoint --echo #==================================================================================== SELECT ST_DISTANCE(ST_GEOMFROMTEXT(@star_lines_near_vertical),ST_GEOMFROMTEXT(@star_bottom_points)); SELECT ST_DISTANCE(ST_GEOMFROMTEXT(@star_lines_near_vertical),ST_GEOMFROMTEXT(@star_all_points)); SELECT ST_DISTANCE(ST_GEOMFROMTEXT('MULTILINESTRING((0 0,10 0),(10 10,0 10))'),ST_GEOMFROMTEXT('MULTIPOINT(5 0,10 5,5 10)')); SELECT ST_DISTANCE(ST_GEOMFROMTEXT('MULTILINESTRING((0 0,10 0),(10 10,0 10))'),ST_GEOMFROMTEXT('MULTIPOINT(10.41 0,10 10.4)')); SELECT ST_DISTANCE(ST_GEOMFROMTEXT('MULTILINESTRING((0 0,10 0),(10 10,0 10))'),ST_GEOMFROMTEXT('MULTIPOINT(4 4,5 5,6.5 6.5)')); SELECT ST_DISTANCE(g,ST_GEOMFROMTEXT(@star_bottom_points)) FROM gis_geometrycollection WHERE fid=114; SELECT ST_DISTANCE(g,g2) FROM gis_geometrycollection,gis_geometrycollection_2 WHERE fid=114 and fid2=108; --echo #==================================================================================== --echo # multilinestring,linestring --echo #==================================================================================== SELECT ST_DISTANCE(ST_GEOMFROMTEXT(@star_lines_near_vertical),ST_GEOMFROMTEXT(@star_line_vertical)); SELECT ST_DISTANCE(ST_GEOMFROMTEXT(@star_lines_near_vertical),ST_GEOMFROMTEXT(@star_line_horizontal)); SELECT ST_DISTANCE(ST_GEOMFROMTEXT('MULTILINESTRING((0 0,10 0),(10 10,0 10))'),ST_GEOMFROMTEXT('LINESTRING(0 5,10 5)')); SELECT ST_DISTANCE(ST_GEOMFROMTEXT('MULTILINESTRING((0 0,10 0),(10 10,0 10))'),ST_GEOMFROMTEXT('LINESTRING(0 10,10 19)')); SELECT ST_DISTANCE(g,ST_GEOMFROMTEXT(@star_line_vertical)) FROM gis_geometrycollection WHERE fid=114; --echo #==================================================================================== --echo # multilinestring,multilinestring --echo #==================================================================================== SELECT ST_DISTANCE(ST_GEOMFROMTEXT(@star_lines_near_vertical),ST_GEOMFROMTEXT(@star_lines_near_horizontal)); SELECT ST_DISTANCE(ST_GEOMFROMTEXT(@star_lines_near_vertical),ST_GEOMFROMTEXT('MULTILINESTRING((0 5,15 25,0 15))')); SELECT ST_DISTANCE(ST_GEOMFROMTEXT('MULTILINESTRING((0 0,10 0),(0 10,10 10))'),ST_GEOMFROMTEXT('MULTILINESTRING((0 5,14.5 5,14 15,0 15))')); SELECT ST_DISTANCE(ST_GEOMFROMTEXT('MULTILINESTRING((0 0,10 0),(0 10,10 10))'),ST_GEOMFROMTEXT('MULTILINESTRING((0 0,0 10,10 0,10 10))')); SELECT ST_DISTANCE(g,ST_GEOMFROMTEXT('MULTILINESTRING((0 5,15 25,0 15))')) FROM gis_geometrycollection WHERE fid=114; SELECT ST_DISTANCE(g,ST_GEOMFROMTEXT(@star_line_vertical)) FROM gis_geometrycollection WHERE fid=114; --echo #==================================================================================== --echo # multilinestring,polygon --echo #==================================================================================== SELECT ST_DISTANCE(ST_GEOMFROMTEXT(@star_lines_near_vertical),ST_GEOMFROMTEXT(@star_elem_vertical)); SELECT ST_DISTANCE(ST_GEOMFROMTEXT(@star_lines_near_vertical),ST_GEOMFROMTEXT(@star_elem_horizontal)); SELECT ST_DISTANCE(ST_GEOMFROMTEXT('MULTILINESTRING((4 4,6 6))'),ST_GEOMFROMTEXT('POLYGON((0 0,0 10,10 10,10 0,0 0))')); SELECT ST_DISTANCE(ST_GEOMFROMTEXT('MULTILINESTRING((4 4,6 6))'),ST_GEOMFROMTEXT('POLYGON((0 0,0 10,10 10,10 0, 0 0),(4 4,4 6,6 6,6 4,4 4))')); SELECT ST_DISTANCE(ST_GEOMFROMTEXT('MULTILINESTRING((-11 -11,-11 11))'),ST_GEOMFROMTEXT('POLYGON((0 0,0 10,10 10,10 0,0 0))')); SELECT ST_DISTANCE(ST_GEOMFROMTEXT('MULTILINESTRING((4.5 4.5,5.5 5.4))'),ST_GEOMFROMTEXT('POLYGON((0 0,0 10,10 10,10 0, 0 0),(4 4,4 6,6 6,6 4,4 4))')); SELECT ST_DISTANCE(ST_GEOMFROMTEXT('MULTILINESTRING((14 14,14 16),(10 15,10 20,20 20))'),ST_GEOMFROMTEXT('POLYGON((0 0,0 10,10 10,10 0,0 0),' '(14 14,14 16,16 16,16 14,14 14))')); SELECT ST_DISTANCE(g,ST_GEOMFROMTEXT(@star_elem_vertical)) FROM gis_geometrycollection WHERE fid=114; --echo #==================================================================================== --echo # multilinestring,multipolygon --echo #==================================================================================== SELECT ST_DISTANCE(ST_GEOMFROMTEXT(@star_lines_near_vertical),ST_GEOMFROMTEXT(@star_of_elems)); SELECT ST_DISTANCE(ST_GEOMFROMTEXT('MULTILINESTRING((0 25,25 0,25 30))'),ST_GEOMFROMTEXT(@star_elem_vertical)); SELECT ST_DISTANCE(ST_GEOMFROMTEXT('MULTILINESTRING((0 0,20 20,30 30))'),ST_GEOMFROMTEXT('MULTIPOLYGON(((0 0,0 4,4 4,0 0)),((0 5,0 10,10 5,0 5)))')); --error ER_GIS_INVALID_DATA SELECT ST_DISTANCE(ST_GEOMFROMTEXT('MULTILINESTRING((10 10,20 20),(30 30))'),ST_GEOMFROMTEXT('MULTIPOLYGON(((0 0,0 4,4 4,0 0)),((0 5,0 10,10 5,0 5)))')); SELECT ST_DISTANCE(ST_GEOMFROMTEXT('MULTILINESTRING((4.5 4.5,5.5 5.5))'), ST_GEOMFROMTEXT('MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0),(4 4,4 6,6 6,6 4,4 4)),((4 4,4 6,6 6,6 4,4 4)))')); SELECT ST_DISTANCE(ST_GEOMFROMTEXT('MULTILINESTRING((4.5 4.5,5.5 5.5),(14.5 14.5,15.4 15.6))'), ST_GEOMFROMTEXT('MULTIPOLYGON(((0 0,0 10,10 10,10 0, 0 0),(4 4,4 6,6 6,6 4,4 4)),((10 10,10 20,20 20,20 10,10 10),(14 14,14 16,16 16,16 14,14 14)))')); SELECT ST_DISTANCE(g,ST_GEOMFROMTEXT(@star_of_elems)) FROM gis_geometrycollection WHERE fid=114; --echo #==================================================================================== --echo # multilinestring,geometrycollection --echo #==================================================================================== SELECT ST_DISTANCE(ST_GEOMFROMTEXT(@star_lines_near_vertical),ST_GEOMFROMTEXT(@star_collection_elems)); SELECT ST_DISTANCE(ST_GEOMFROMTEXT(@star_lines_near_vertical),ST_GEOMFROMTEXT(@star_collection_multilinestr)); SELECT ST_DISTANCE(ST_GEOMFROMTEXT('MULTILINESTRING((0 25,25 0,25 30))'),ST_GEOMFROMTEXT(@star_collection_elems)); SELECT ST_DISTANCE(ST_GEOMFROMTEXT('MULTILINESTRING((0 0,10 10))'),ST_GEOMFROMTEXT('GEOMETRYCOLLECTION(GEOMETRYCOLLECTION(POINT(0 5)))')); SELECT ST_DISTANCE(ST_GEOMFROMTEXT('MULTILINESTRING((4.5 4.5,5.5 5.5))'),ST_GEOMFROMTEXT('GEOMETRYCOLLECTION(' 'LINESTRING(1 1,2 2,3 3,4 4),' 'POLYGON((0 0,0 10,10 10,10 0,0 0),(4 4,4 6,6 6,6 4,4 4)))')); SELECT ST_DISTANCE(ST_GEOMFROMTEXT('MULTILINESTRING((5 5,15 15,25 25))'),ST_GEOMFROMTEXT('GEOMETRYCOLLECTION(' 'POLYGON((0 0,0 10,10 10,10 0,0 0),(4 4,4 6,6 6,6 4,4 4)),' 'POLYGON((3 3,3 7,7 7,7 3,3 3),(4 4,4 6,6 6,6 4,4 4)))')); SELECT ST_DISTANCE(g,ST_GEOMFROMTEXT(@star_collection_elems)) FROM gis_geometrycollection WHERE fid=114; --echo #==================================================================================== --echo # polygon,point --echo #==================================================================================== SELECT ST_DISTANCE(ST_GEOMFROMTEXT(@star),ST_GEOMFROMTEXT(@star_center)); SELECT ST_DISTANCE(ST_GEOMFROMTEXT(@star_elem_vertical),ST_GEOMFROMTEXT('POINT(0 0)')); SELECT ST_DISTANCE(ST_GEOMFROMTEXT('POLYGON((0 0,0 10,10 10,10 0,0 0))'),ST_GEOMFROMTEXT('POINT(5 0)')); SELECT ST_DISTANCE(ST_GEOMFROMTEXT('POLYGON((0 0,0 10,10 10,10 0,0 0))'),ST_GEOMFROMTEXT('POINT(20 20)')); SELECT ST_DISTANCE(ST_GEOMFROMTEXT('POLYGON((0 0,0 10,10 10,10 0, 0 0),(4 4,4 6,6 6,6 4,4 4))'),ST_GEOMFROMTEXT('POINT(5 5)')); SELECT ST_DISTANCE(ST_GEOMFROMTEXT('POLYGON((0 0,0 10,10 10,10 0, 0 0),(4 4,4 6,6 6,6 4,4 4))'),ST_GEOMFROMTEXT('POINT(6 6)')); SELECT ST_DISTANCE(ST_GEOMFROMTEXT('POLYGON((0 0,0 10,10 10,10 0,0 0),(14 14,14 16,16 16,16 14,14 14))'),ST_GEOMFROMTEXT('POINT(15 15)')); SELECT ST_DISTANCE(g,ST_GEOMFROMTEXT(@star_center)) FROM gis_geometrycollection WHERE fid=100; --echo #==================================================================================== --echo # polygon,multipoint --echo #==================================================================================== SELECT ST_DISTANCE(ST_GEOMFROMTEXT(@star),ST_GEOMFROMTEXT(@star_all_points)); SELECT ST_DISTANCE(ST_GEOMFROMTEXT(@star_elem_vertical),ST_GEOMFROMTEXT('MULTIPOINT(0 0,30 25)')); SELECT ST_DISTANCE(ST_GEOMFROMTEXT('POLYGON((0 0,0 10,10 10,10 0,0 0))'),ST_GEOMFROMTEXT('MULTIPOINT(5 0,20 20)')); SELECT ST_DISTANCE(ST_GEOMFROMTEXT('POLYGON((0 0,0 10,10 10,10 0,0 0))'),ST_GEOMFROMTEXT('MULTIPOINT(20 20,-9 -9)')); SELECT ST_DISTANCE(ST_GEOMFROMTEXT('POLYGON((0 0,0 10,10 10,10 0, 0 0),(4 4,4 6,6 6,6 4,4 4))'),ST_GEOMFROMTEXT('MULTIPOINT(4.5 4.5,5.5 5.5)')); SELECT ST_DISTANCE(ST_GEOMFROMTEXT('POLYGON((0 0,0 10,10 10,10 0, 0 0),(4 4,4 6,6 6,6 4,4 4))'),ST_GEOMFROMTEXT('MULTIPOINT(4 4,6 6,8 8,15 15)')); SELECT ST_DISTANCE(ST_GEOMFROMTEXT('POLYGON((0 0,0 10,10 10,10 0,0 0),(14 14,14 16,16 16,16 14,14 14))'),ST_GEOMFROMTEXT('MULTIPOINT(15 15)')); SELECT ST_DISTANCE(g,ST_GEOMFROMTEXT(@star_all_points)) FROM gis_geometrycollection WHERE fid=100; --echo #==================================================================================== --echo # polygon,linestring --echo #==================================================================================== SELECT ST_DISTANCE(ST_GEOMFROMTEXT(@star),ST_GEOMFROMTEXT(@star_line_vertical)); SELECT ST_DISTANCE(ST_GEOMFROMTEXT(@star_elem_vertical),ST_GEOMFROMTEXT(@star_line_horizontal)); SELECT ST_DISTANCE(ST_GEOMFROMTEXT('POLYGON((0 0,0 10,10 10,10 0,0 0))'),ST_GEOMFROMTEXT('LINESTRING(5 0,20 20,100 100)')); SELECT ST_DISTANCE(ST_GEOMFROMTEXT('POLYGON((0 0,0 10,10 10,10 0,0 0))'),ST_GEOMFROMTEXT('LINESTRING(110 110,-100 50)')); SELECT ST_DISTANCE(ST_GEOMFROMTEXT('POLYGON((0 0,0 10,10 10,10 0, 0 0),(4 4,4 6,6 6,6 4,4 4))'),ST_GEOMFROMTEXT('LINESTRING(4.3 4.3,5.5 5.5)')); SELECT ST_DISTANCE(ST_GEOMFROMTEXT('POLYGON((0 0,0 10,10 10,10 0, 0 0),(4 4,4 6,6 6,6 4,4 4))'),ST_GEOMFROMTEXT('LINESTRING(4 4,6 6,8 8,15 15)')); SELECT ST_DISTANCE(ST_GEOMFROMTEXT('POLYGON((0 0,0 10,10 10,10 0,0 0),(14 14,14 16,16 16,16 14,14 14))'), ST_GEOMFROMTEXT('LINESTRING(11 11,14 14,15 15,16 16,20 20)')); SELECT ST_DISTANCE(g,ST_GEOMFROMTEXT(@star_line_vertical)) FROM gis_geometrycollection WHERE fid=100; SELECT ST_DISTANCE(g,g2) FROM gis_geometrycollection,gis_geometrycollection_2 WHERE fid=100 and fid2=111; --echo #==================================================================================== --echo # polygon,multilinestring --echo #==================================================================================== SELECT ST_DISTANCE(ST_GEOMFROMTEXT(@star),ST_GEOMFROMTEXT(@star_lines_near_vertical)); SELECT ST_DISTANCE(ST_GEOMFROMTEXT(@star_elem_vertical),ST_GEOMFROMTEXT(@star_lines_near_horizontal)); --error ER_GIS_INVALID_DATA SELECT ST_DISTANCE(ST_GEOMFROMTEXT('POLYGON((0 0,0 10,10 10,10 0,0 0))'),ST_GEOMFROMTEXT('MULTILINESTRING((5 0,20 20),(100 100))')); --error ER_GIS_INVALID_DATA SELECT ST_DISTANCE(ST_GEOMFROMTEXT('POLYGON((0 0,0 10,10 10,10 0,0 0))'),ST_GEOMFROMTEXT('MULTILINESTRING((110 110,-100 100),(-50 50))')); SELECT ST_DISTANCE(ST_GEOMFROMTEXT('POLYGON((0 0,0 10,10 10,10 0, 0 0),(4 4,4 6,6 6,6 4,4 4))'),ST_GEOMFROMTEXT('MULTILINESTRING((4.3 4.3,5.5 5.5))')); SELECT ST_DISTANCE(ST_GEOMFROMTEXT('POLYGON((0 0,0 10,10 10,10 0, 0 0),(4 4,4 6,6 6,6 4,4 4))'), ST_GEOMFROMTEXT('MULTILINESTRING((0 0,2 2,4 4,6 6),(8 8,10 10,15 15))')); SELECT ST_DISTANCE(ST_GEOMFROMTEXT('POLYGON((0 0,0 10,10 10,10 0,0 0),(14 14,14 16,16 16,16 14,14 14))'), ST_GEOMFROMTEXT('MULTILINESTRING((11 11,14 14),(15 15,16 16,20 20))')); SELECT ST_DISTANCE(g,ST_GEOMFROMTEXT(@star_lines_near_vertical)) FROM gis_geometrycollection WHERE fid=100; --echo #==================================================================================== --echo # polygon,polygon --echo #==================================================================================== SELECT ST_DISTANCE(ST_GEOMFROMTEXT(@star),ST_GEOMFROMTEXT(@star_elem_vertical)); SELECT ST_DISTANCE(ST_GEOMFROMTEXT(@star_elem_vertical),ST_GEOMFROMTEXT(@star)); SELECT ST_DISTANCE(ST_GEOMFROMTEXT('POLYGON((0 0,0 10,10 10,10 0,0 0))'),ST_GEOMFROMTEXT('POLYGON((5 0,20 20,100 100,5 0))')); SELECT ST_DISTANCE(ST_GEOMFROMTEXT('POLYGON((0 0,0 10,10 10,10 0,0 0))'),ST_GEOMFROMTEXT('POLYGON((110 110,-100 100,-50 50,110 110))')); SELECT ST_DISTANCE(ST_GEOMFROMTEXT('POLYGON((0 0,0 10,10 10,10 0, 0 0),(4 4,4 6,6 6,6 4,4 4))'),ST_GEOMFROMTEXT('POLYGON((4.3 4.3,4.5 4.8,5 5.5,4.3 4.3))')); SELECT ST_DISTANCE(ST_GEOMFROMTEXT('POLYGON((0 0,0 10,10 10,10 0, 0 0),(4 4,4 6,6 6,6 4,4 4))'),ST_GEOMFROMTEXT('POLYGON((4 4,6 6,8 8,10 15,4 4))')); SELECT ST_DISTANCE(g,ST_GEOMFROMTEXT(@star_elem_vertical)) FROM gis_geometrycollection WHERE fid=100; --echo #==================================================================================== --echo # polygon,multipolygon --echo #==================================================================================== SELECT ST_DISTANCE(ST_GEOMFROMTEXT(@star),ST_GEOMFROMTEXT(@star_of_elems)); SELECT ST_DISTANCE(ST_GEOMFROMTEXT(@star_elem_vertical),ST_GEOMFROMTEXT(@star_of_elems)); SELECT ST_DISTANCE(ST_GEOMFROMTEXT('POLYGON((0 0,0 10,10 10,10 0,0 0))'),ST_GEOMFROMTEXT('MULTIPOLYGON(((110 110,-100 100,-50 50,110 110)))')); SELECT ST_DISTANCE(ST_GEOMFROMTEXT('POLYGON((0 0,0 10,10 10,10 0,0 0))'),ST_GEOMFROMTEXT('MULTIPOLYGON(((5 0,20 20,100 100,5 0)),((0 0,-10 -10,10 100,0 0)))')); SELECT ST_DISTANCE(ST_GEOMFROMTEXT('POLYGON((0 0,0 10,10 10,10 0, 0 0),(4 4,4 6,6 6,6 4,4 4))'),ST_GEOMFROMTEXT('MULTIPOLYGON(((4.3 4.3,4.7 5,5 5.6,4.3 4.3)))')); SELECT ST_DISTANCE(ST_GEOMFROMTEXT('POLYGON((0 0,0 10,10 10,10 0, 0 0),(4 4,4 6,6 6,6 4,4 4))'),ST_GEOMFROMTEXT('MULTIPOLYGON(((4 4,6 6,8 8,10 15,4 4)))')); SELECT ST_DISTANCE(g,ST_GEOMFROMTEXT(@star_of_elems)) FROM gis_geometrycollection WHERE fid=100; --echo #==================================================================================== --echo # polygon,geometrycollection --echo #==================================================================================== SELECT ST_DISTANCE(ST_GEOMFROMTEXT(@star),ST_GEOMFROMTEXT(@star_collection_elems)); SELECT ST_DISTANCE(ST_GEOMFROMTEXT(@star_elem_vertical),ST_GEOMFROMTEXT(@star_collection_elems)); SELECT ST_DISTANCE(ST_GEOMFROMTEXT(@star),ST_GEOMFROMTEXT(@star_collection_multilinestr)); SELECT ST_DISTANCE(ST_GEOMFROMTEXT('POLYGON((0 0,0 10,10 10,10 0,0 0))'),ST_GEOMFROMTEXT('GEOMETRYCOLLECTION(GEOMETRYCOLLECTION(POINT(10 15)))')); SELECT ST_DISTANCE(ST_GEOMFROMTEXT('POLYGON((0 0,0 10,10 10,10 0,0 0))'), ST_GEOMFROMTEXT('GEOMETRYCOLLECTION(POLYGON((20 20,20 30,30 30,30 20,20 20),(0 0,0 10,10 10,10 0,0 0)))')); SELECT ST_DISTANCE(ST_GEOMFROMTEXT('POLYGON((0 0,0 10,10 10,10 0, 0 0),(4 4,4 6,6 6,6 4,4 4))'), ST_GEOMFROMTEXT('GEOMETRYCOLLECTION(LINESTRING(1 1,2 2,3 3,4 4),POLYGON((0 0,0 10,10 10,10 0,0 0),(4 4,4 6,6 6,6 4,4 4)))')); SELECT ST_DISTANCE(ST_GEOMFROMTEXT('POLYGON((0 0,0 10,10 10,10 0,0 0),(14 14,14 16,16 16,16 14,14 14))'), ST_GEOMFROMTEXT('GEOMETRYCOLLECTION(POLYGON((0 0,0 10,10 10,10 0,0 0),(4 4,4 6,6 6,6 4,4 4)),' 'POLYGON((3 3,3 7,7 7,7 3,3 3),(4 4,4 6,6 6,6 4,4 4)))')); SELECT ST_DISTANCE(g,ST_GEOMFROMTEXT(@star_collection_elems)) FROM gis_geometrycollection WHERE fid=100; --echo #==================================================================================== --echo # multipolygon,point --echo #==================================================================================== SELECT ST_DISTANCE(ST_GEOMFROMTEXT(@star_of_elems),ST_GEOMFROMTEXT(@star_top)); SELECT ST_DISTANCE(ST_GEOMFROMTEXT(@star_of_elems),ST_GEOMFROMTEXT('POINT(30 30)')); SELECT ST_DISTANCE(ST_GEOMFROMTEXT('MULTIPOLYGON(((0 0,0 4,4 4,0 0)),((0 5,0 10,10 5,0 5)))'),ST_GEOMFROMTEXT('POINT(0 8)')); SELECT ST_DISTANCE(ST_GEOMFROMTEXT('MULTIPOLYGON(((0 0,0 4,4 4,0 0)),((0 5,0 10,10 5,0 5)))'),ST_GEOMFROMTEXT('POINT(20 20)')); SELECT ST_DISTANCE(ST_GEOMFROMTEXT('MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0),(4 4,4 6,6 6,6 4,4 4)),((4 4,4 6,6 6,6 4,4 4)))'), ST_GEOMFROMTEXT('POINT(5 5)')); SELECT ST_DISTANCE(ST_GEOMFROMTEXT('MULTIPOLYGON(((0 0,0 10,10 10,10 0, 0 0),(4 4,4 6,6 6,6 4,4 4)),((10 10,10 20,20 20,20 10,10 10),(14 14,14 16,16 16,16 14,14 14)))'), ST_GEOMFROMTEXT('POINT(15 15)')); SELECT ST_DISTANCE(ST_GEOMFROMTEXT('MULTIPOLYGON(((0 0,0 10,10 10,10 0, 0 0),(4 4,4 6,6 6,6 4,4 4)),((10 10,10 20,20 20,20 10,10 10),(14 14,14 16,16 16,16 14,14 14)))'), ST_GEOMFROMTEXT('POINT(16.1 16.1)')); SELECT ST_DISTANCE(g,ST_GEOMFROMTEXT(@star_top)) FROM gis_geometrycollection WHERE fid=103; --echo #==================================================================================== --echo # multipolygon,multipoint --echo #==================================================================================== SELECT ST_DISTANCE(ST_GEOMFROMTEXT(@star_of_elems),ST_GEOMFROMTEXT(@star_bottom_points)); SELECT ST_DISTANCE(ST_GEOMFROMTEXT(@star_of_elems),ST_GEOMFROMTEXT('MULTIPOINT(30 30,0 35)')); SELECT ST_DISTANCE(ST_GEOMFROMTEXT('MULTIPOLYGON(((0 0,0 4,4 4,0 0)),((0 5,0 10,10 5,0 5)))'),ST_GEOMFROMTEXT('MULTIPOINT(0 8,100 100)')); SELECT ST_DISTANCE(ST_GEOMFROMTEXT('MULTIPOLYGON(((0 0,0 4,4 4,0 0)),((0 5,0 10,10 5,0 5)))'),ST_GEOMFROMTEXT('MULTIPOINT(50 50,-30 50)')); SELECT ST_DISTANCE(ST_GEOMFROMTEXT('MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0),(4 4,4 6,6 6,6 4,4 4)),((4 4,4 6,6 6,6 4,4 4)))'), ST_GEOMFROMTEXT('MULTIPOINT(4.5 4.5,5.5 5.5)')); SELECT ST_DISTANCE(ST_GEOMFROMTEXT('MULTIPOLYGON(((0 0,0 10,10 10,10 0, 0 0),(4 4,4 6,6 6,6 4,4 4)),((10 10,10 20,20 20,20 10,10 10),(14 14,14 16,16 16,16 14,14 14)))'), ST_GEOMFROMTEXT('MULTIPOINT(15.9 15.9)')); SELECT ST_DISTANCE(ST_GEOMFROMTEXT('MULTIPOLYGON(((0 0,0 10,10 10,10 0, 0 0),(4 4,4 6,6 6,6 4,4 4)),((10 10,10 20,20 20,20 10,10 10),(14 14,14 16,16 16,16 14,14 14)))'), ST_GEOMFROMTEXT('MULTIPOINT(19 19,100 100)')); SELECT ST_DISTANCE(g,ST_GEOMFROMTEXT(@star_bottom_points)) FROM gis_geometrycollection WHERE fid=103; --echo #==================================================================================== --echo # multipolygon,linestring --echo #==================================================================================== SELECT ST_DISTANCE(ST_GEOMFROMTEXT(@star_of_elems),ST_GEOMFROMTEXT(@star_top_to_center)); SELECT ST_DISTANCE(ST_GEOMFROMTEXT(@star_of_elems),ST_GEOMFROMTEXT('LINESTRING(30 30,0 35)')); SELECT ST_DISTANCE(ST_GEOMFROMTEXT('MULTIPOLYGON(((0 0,0 4,4 4,0 0)),((0 5,0 10,10 5,0 5)))'),ST_GEOMFROMTEXT('LINESTRING(0 8,100 100)')); SELECT ST_DISTANCE(ST_GEOMFROMTEXT('MULTIPOLYGON(((0 0,0 4,4 4,0 0)),((0 5,0 10,10 5,0 5)))'),ST_GEOMFROMTEXT('LINESTRING(50 50,-30 50)')); SELECT ST_DISTANCE(ST_GEOMFROMTEXT('MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0),(4 4,4 6,6 6,6 4,4 4)),((4 4,4 6,6 6,6 4,4 4)))'), ST_GEOMFROMTEXT('LINESTRING(4.5 4.5,5.5 5.5)')); SELECT ST_DISTANCE(ST_GEOMFROMTEXT('MULTIPOLYGON(((0 0,0 10,10 10,10 0, 0 0),(4 4,4 6,6 6,6 4,4 4)),((10 10,10 20,20 20,20 10,10 10),(14 14,14 16,16 16,16 14,14 14)))'), ST_GEOMFROMTEXT('LINESTRING(14.5 14.5,15.5 15.5)')); SELECT ST_DISTANCE(ST_GEOMFROMTEXT('MULTIPOLYGON(((0 0,0 10,10 10,10 0, 0 0),(4 4,4 6,6 6,6 4,4 4)),((10 10,10 20,20 20,20 10,10 10),(14 14,14 16,16 16,16 14,14 14)))'), ST_GEOMFROMTEXT('LINESTRING(19 19,100 100)')); SELECT ST_DISTANCE(g,ST_GEOMFROMTEXT(@star_top_to_center)) FROM gis_geometrycollection WHERE fid=103; --echo #==================================================================================== --echo # multipolygon,multilinestring --echo #==================================================================================== SELECT ST_DISTANCE(ST_GEOMFROMTEXT(@star_of_elems),ST_GEOMFROMTEXT(@star_lines_near_vertical)); SELECT ST_DISTANCE(ST_GEOMFROMTEXT(@star_of_elems),ST_GEOMFROMTEXT('MULTILINESTRING((0 30,30 30,0 35))')); SELECT ST_DISTANCE(ST_GEOMFROMTEXT('MULTIPOLYGON(((0 0,0 4,4 4,0 0)),((0 5,0 10,10 5,0 5)))'), ST_GEOMFROMTEXT('MULTILINESTRING((0 8,10 10,20 20),(50 50,75 75,100 100))')); SELECT ST_DISTANCE(ST_GEOMFROMTEXT('MULTIPOLYGON(((0 0,0 4,4 4,0 0)),((0 5,0 10,10 5,0 5)))'), ST_GEOMFROMTEXT('MULTILINESTRING((50 50,100 50),(-50 50,-40 50))')); SELECT ST_DISTANCE(ST_GEOMFROMTEXT('MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0),(4 4,4 6,6 6,6 4,4 4)),((4 4,4 6,6 6,6 4,4 4)))'), ST_GEOMFROMTEXT('MULTILINESTRING((4.5 4.5,5.5 5.5))')); SELECT ST_DISTANCE(ST_GEOMFROMTEXT('MULTIPOLYGON(((0 0,0 10,10 10,10 0, 0 0),(4 4,4 6,6 6,6 4,4 4)),((10 10,10 20,20 20,20 10,10 10),(14 14,14 16,16 16,16 14,14 14)))'), ST_GEOMFROMTEXT('MULTILINESTRING((14.5 14.5,15.5 15.5))')); SELECT ST_DISTANCE(ST_GEOMFROMTEXT('MULTIPOLYGON(((0 0,0 10,10 10,10 0, 0 0),(4 4,4 6,6 6,6 4,4 4)),((10 10,10 20,20 20,20 10,10 10),(14 14,14 16,16 16,16 14,14 14)))'), ST_GEOMFROMTEXT('MULTILINESTRING((-10 -10,50 50,100 100))')); SELECT ST_DISTANCE(g,ST_GEOMFROMTEXT(@star_lines_near_vertical)) FROM gis_geometrycollection WHERE fid=103; --echo #==================================================================================== --echo # multipolygon,polygon --echo #==================================================================================== SELECT ST_DISTANCE(ST_GEOMFROMTEXT(@star_of_elems),ST_GEOMFROMTEXT(@star_elem_vertical)); SELECT ST_DISTANCE(ST_GEOMFROMTEXT(@star_of_elems),ST_GEOMFROMTEXT(@star)); SELECT ST_DISTANCE(ST_GEOMFROMTEXT(@star_of_elems),ST_GEOMFROMTEXT('POLYGON((0 0,15 25,35 0,0 0))')); SELECT ST_DISTANCE(ST_GEOMFROMTEXT('MULTIPOLYGON(((0 0,0 4,4 4,0 0)),((0 5,0 10,10 5,0 5)))'),ST_GEOMFROMTEXT('POLYGON((10 10,10 -10,-10 -10,-10 10,10 10))')); SELECT ST_DISTANCE(ST_GEOMFROMTEXT('MULTIPOLYGON(((0 0,0 4,4 4,0 0)),((0 5,0 10,10 5,0 5)))'),ST_GEOMFROMTEXT('POLYGON((20 20,20 30,30 30,30 20,20 20))')); SELECT ST_DISTANCE(ST_GEOMFROMTEXT('MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0),(4 4,4 6,6 6,6 4,4 4)),((4 4,4 6,6 6,6 4,4 4)))'), ST_GEOMFROMTEXT('POLYGON((4 4,4 6,6 6,6 4,4 4))')); SELECT ST_DISTANCE(ST_GEOMFROMTEXT('MULTIPOLYGON(((0 0,0 10,10 10,10 0, 0 0),(4 4,4 6,6 6,6 4,4 4)),((10 10,10 20,20 20,20 10,10 10),(14 14,14 16,16 16,16 14,14 14)))'), ST_GEOMFROMTEXT('POLYGON((14.5 14.5,14.5 15.5,15.5 15.5,14.5 14.5))')); SELECT ST_DISTANCE(g,ST_GEOMFROMTEXT(@star_elem_vertical)) FROM gis_geometrycollection WHERE fid=103; --echo #==================================================================================== --echo # multipolygon,multipolygon --echo #==================================================================================== SELECT ST_DISTANCE(ST_GEOMFROMTEXT(@star_of_elems),ST_GEOMFROMTEXT(@star_of_elems)); SELECT ST_DISTANCE(ST_GEOMFROMTEXT(@star_of_elems),ST_GEOMFROMTEXT('MULTIPOLYGON(((0 0,15 25,35 0,0 0),(5 0,15 25,25 0,15 5,5 0)))')); SELECT ST_DISTANCE(ST_GEOMFROMTEXT('MULTIPOLYGON(((0 0,0 4,4 4,0 0)),((0 5,0 10,10 5,0 5)))'), ST_GEOMFROMTEXT('MULTIPOLYGON(((10 10,10 -10,-10 -10,-10 10,10 10)))')); SELECT ST_DISTANCE(ST_GEOMFROMTEXT('MULTIPOLYGON(((0 0,0 4,4 4,0 0)),((0 5,0 10,10 5,0 5)))'), ST_GEOMFROMTEXT('MULTIPOLYGON(((20 20,20 30,30 30,30 20,20 20)))')); SELECT ST_DISTANCE(ST_GEOMFROMTEXT('MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0),(4 4,4 6,6 6,6 4,4 4)),((4 4,4 6,6 6,6 4,4 4)))'), ST_GEOMFROMTEXT('MULTIPOLYGON(((4 4,4 6,6 6,6 4,4 4)))')); SELECT ST_DISTANCE(ST_GEOMFROMTEXT('MULTIPOLYGON(((0 0,0 10,10 10,10 0, 0 0),(4 4,4 6,6 6,6 4,4 4)),((10 10,10 20,20 20,20 10,10 10),(14 14,14 16,16 16,16 14,14 14)))'), ST_GEOMFROMTEXT('MULTIPOLYGON(((14.5 14.5,14.5 15.5,15.5 15.5,14.5 14.5)))')); SELECT ST_DISTANCE(g,ST_GEOMFROMTEXT(@star_of_elems)) FROM gis_geometrycollection WHERE fid=103; SELECT ST_DISTANCE(g,g2) FROM gis_geometrycollection,gis_geometrycollection_2 WHERE fid=103 and fid2=103; SELECT ST_DISTANCE(g,g2) FROM gis_geometrycollection,gis_geometrycollection_2 WHERE fid=103 and fid2=103; --echo #==================================================================================== --echo # multipolygon,geometrycollection --echo #==================================================================================== SELECT ST_DISTANCE(ST_GEOMFROMTEXT(@star_of_elems),ST_GEOMFROMTEXT(@star_collection_elems)); SELECT ST_DISTANCE(ST_GEOMFROMTEXT(@star_of_elems),ST_GEOMFROMTEXT(@star_collection_elems_3)); SELECT ST_DISTANCE(ST_GEOMFROMTEXT(@star_of_elems),ST_GEOMFROMTEXT(@star_collection_multilinestr)); SELECT ST_DISTANCE(ST_GEOMFROMTEXT('MULTIPOLYGON(((0 0,0 4,4 4,0 0)),((0 5,0 10,10 5,0 5)))'), ST_GEOMFROMTEXT('GEOMETRYCOLLECTION(GEOMETRYCOLLECTION(POINT(50 55)))')); SELECT ST_DISTANCE(ST_GEOMFROMTEXT('MULTIPOLYGON(((0 0,0 4,4 4,0 0)),((0 5,0 10,10 5,0 5)))'), ST_GEOMFROMTEXT('GEOMETRYCOLLECTION(POLYGON((20 20,20 30,30 30,30 20,20 20),(0 0,0 10,10 10,10 0,0 0)))')); SELECT ST_DISTANCE(ST_GEOMFROMTEXT('MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0),(4 4,4 6,6 6,6 4,4 4)),((4 4,4 6,6 6,6 4,4 4)))'), ST_GEOMFROMTEXT('GEOMETRYCOLLECTION(LINESTRING(1 1,2 2,3 3,4 4),POLYGON((0 0,0 10,10 10,10 0,0 0),(4 4,4 6,6 6,6 4,4 4)))')); SELECT ST_DISTANCE(ST_GEOMFROMTEXT('MULTIPOLYGON(((0 0,0 10,10 10,10 0, 0 0),(4 4,4 6,6 6,6 4,4 4)),((10 10,10 20,20 20,20 10,10 10),(14 14,14 16,16 16,16 14,14 14)))'), ST_GEOMFROMTEXT('GEOMETRYCOLLECTION(POLYGON((0 0,0 10,10 10,10 0,0 0),(4 4,4 6,6 6,6 4,4 4)),' 'POLYGON((3 3,3 7,7 7,7 3,3 3),(4 4,4 6,6 6,6 4,4 4)))')); SELECT ST_DISTANCE(g,ST_GEOMFROMTEXT(@star_collection_elems)) FROM gis_geometrycollection WHERE fid=103; SELECT ST_DISTANCE(g,g2) FROM gis_geometrycollection,gis_geometrycollection_2 WHERE fid=103 and fid2=215; --echo #==================================================================================== --echo # geometrycollection,point --echo #==================================================================================== SELECT ST_DISTANCE(ST_GEOMFROMTEXT(@star_collection_elems),ST_GEOMFROMTEXT(@star_top)); SELECT ST_DISTANCE(ST_GEOMFROMTEXT(@star_collection_elems),ST_GEOMFROMTEXT('POINT(30 30)')); SELECT ST_DISTANCE(ST_GEOMFROMTEXT(@star_collection_multilinestr),ST_GEOMFROMTEXT('POINT(30 30)')); SELECT ST_DISTANCE(ST_GEOMFROMTEXT('GEOMETRYCOLLECTION(GEOMETRYCOLLECTION(POINT(50 50)))'),ST_GEOMFROMTEXT('POINT(0 0)')); Select ST_DISTANCE(ST_GEOMFROMTEXT('GEOMETRYCOLLECTION(POLYGON((0 0,0 10,10 10,10 0,0 0)))'),ST_GEOMFROMTEXT('POINT(100 100)')); Select ST_DISTANCE(ST_GEOMFROMTEXT('GEOMETRYCOLLECTION(GEOMETRYCOLLECTION(),POLYGON((0 0,0 10,10 10,10 0,0 0)))'),ST_GEOMFROMTEXT('POINT(100 100)')); Select ST_DISTANCE(ST_GEOMFROMTEXT('GEOMETRYCOLLECTION(POLYGON((0 0,0 10,10 10,10 0,0 0)),GEOMETRYCOLLECTION())'),ST_GEOMFROMTEXT('POINT(100 100)')); SELECT ST_DISTANCE(ST_GEOMFROMTEXT('GEOMETRYCOLLECTION(POLYGON((20 20,20 30,30 30,30 20,20 20),(0 0,0 10,10 10,10 0,0 0)))'), ST_GEOMFROMTEXT('POINT(20 20)')); SELECT ST_DISTANCE(ST_GEOMFROMTEXT('GEOMETRYCOLLECTION(GEOMETRYCOLLECTION(GEOMETRYCOLLECTION(LINESTRING(1 1,2 2,3 3,4 4))),' 'POLYGON((0 0,0 10,10 10,10 0,0 0),(4 4,4 6,6 6,6 4,4 4)))'), ST_GEOMFROMTEXT('POINT(5 5)')); SELECT ST_DISTANCE(ST_GEOMFROMTEXT('GEOMETRYCOLLECTION(GEOMETRYCOLLECTION(POLYGON((0 0,0 10,10 10,10 0,0 0),(4 4,4 6,6 6,6 4,4 4))),' 'GEOMETRYCOLLECTION(MULTIPOLYGON(((3 3,3 7,7 7,7 3,3 3),(4 4,4 6,6 6,6 4,4 4)))))'), ST_GEOMFROMTEXT('POINT(15 15)')); SELECT ST_DISTANCE(g,ST_GEOMFROMTEXT(@star_top)) FROM gis_geometrycollection WHERE fid=115; --echo #==================================================================================== --echo # geometrycollection,multipoint --echo #==================================================================================== SELECT ST_DISTANCE(ST_GEOMFROMTEXT(@star_collection_elems),ST_GEOMFROMTEXT(@star_bottom_points)); SELECT ST_DISTANCE(ST_GEOMFROMTEXT(@star_collection_elems),ST_GEOMFROMTEXT('MULTIPOINT(30 30,0 35)')); SELECT ST_DISTANCE(ST_GEOMFROMTEXT(@star_collection_multilinestr),ST_GEOMFROMTEXT('MULTIPOINT(30 30,0 35)')); SELECT ST_DISTANCE(ST_GEOMFROMTEXT('GEOMETRYCOLLECTION(GEOMETRYCOLLECTION(POINT(50 50)))'),ST_GEOMFROMTEXT('MULTIPOINT(0 0,100 100)')); SELECT ST_DISTANCE(ST_GEOMFROMTEXT('GEOMETRYCOLLECTION(LINESTRING(0 0,10 10,20 20),GEOMETRYCOLLECTION())'),ST_GEOMFROMTEXT('MULTIPOINT(5 0,10 0)')); SELECT ST_DISTANCE(ST_GEOMFROMTEXT('GEOMETRYCOLLECTION(POLYGON((20 20,20 30,30 30,30 20,20 20),(0 0,0 10,10 10,10 0,0 0)))'), ST_GEOMFROMTEXT('MULTIPOINT(20 20,40 40,60 60)')); SELECT ST_DISTANCE(ST_GEOMFROMTEXT('GEOMETRYCOLLECTION(GEOMETRYCOLLECTION(GEOMETRYCOLLECTION(LINESTRING(1 1,2 2,3 3,4 4))),' 'POLYGON((0 0,0 10,10 10,10 0,0 0),(4 4,4 6,6 6,6 4,4 4)))'), ST_GEOMFROMTEXT('MULTIPOINT(4.5 4.5,5.5 5.5)')); SELECT ST_DISTANCE(ST_GEOMFROMTEXT('GEOMETRYCOLLECTION(GEOMETRYCOLLECTION(POLYGON((0 0,0 10,10 10,10 0,0 0),(4 4,4 6,6 6,6 4,4 4))),' 'GEOMETRYCOLLECTION(MULTIPOLYGON(((3 3,3 7,7 7,7 3,3 3),(4 4,4 6,6 6,6 4,4 4)))))'), ST_GEOMFROMTEXT('MULTIPOINT(4 4,6 6,8 8)')); SELECT ST_DISTANCE(g,ST_GEOMFROMTEXT(@star_bottom_points)) FROM gis_geometrycollection WHERE fid=115; --echo #==================================================================================== --echo # geometrycollection,linestring --echo #==================================================================================== SELECT ST_DISTANCE(ST_GEOMFROMTEXT(@star_collection_elems),ST_GEOMFROMTEXT(@star_top_to_center)); SELECT ST_DISTANCE(ST_GEOMFROMTEXT(@star_collection_elems),ST_GEOMFROMTEXT('LINESTRING(30 30,0 35)')); SELECT ST_DISTANCE(ST_GEOMFROMTEXT(@star_collection_multilinestr),ST_GEOMFROMTEXT('LINESTRING(30 30,0 35)')); SELECT ST_DISTANCE(ST_GEOMFROMTEXT('GEOMETRYCOLLECTION(GEOMETRYCOLLECTION(POINT(50 50)))'),ST_GEOMFROMTEXT('LINESTRING(0 0,100 100)')); Select ST_DISTANCE(ST_GEOMFROMTEXT('GEOMETRYCOLLECTION(POLYGON((0 0,0 10,10 10,10 0,0 0)))'),ST_GEOMFROMTEXT('LINESTRING(0 0,10 10)')); Select ST_DISTANCE(ST_GEOMFROMTEXT('GEOMETRYCOLLECTION(GEOMETRYCOLLECTION(),POLYGON((0 0,0 10,10 10,10 0,0 0)))'),ST_GEOMFROMTEXT('LINESTRING(0 0,10 10)')); Select ST_DISTANCE(ST_GEOMFROMTEXT('GEOMETRYCOLLECTION(POLYGON((0 0,0 10,10 10,10 0,0 0)),GEOMETRYCOLLECTION())'),ST_GEOMFROMTEXT('LINESTRING(0 0,10 10)')); SELECT ST_DISTANCE(ST_GEOMFROMTEXT('GEOMETRYCOLLECTION(POLYGON((20 20,20 30,30 30,30 20,20 20),(0 0,0 10,10 10,10 0,0 0)))'), ST_GEOMFROMTEXT('LINESTRING(20 20,40 40,60 60)')); SELECT ST_DISTANCE(ST_GEOMFROMTEXT('GEOMETRYCOLLECTION(LINESTRING(0 0,10 10,20 20))'),ST_GEOMFROMTEXT('LINESTRING(5 0,10 0)')); SELECT ST_DISTANCE(ST_GEOMFROMTEXT('GEOMETRYCOLLECTION(LINESTRING(0 0,10 10,20 20),GEOMETRYCOLLECTION())'),ST_GEOMFROMTEXT('LINESTRING(5 0,10 0)')); SELECT ST_DISTANCE(ST_GEOMFROMTEXT('GEOMETRYCOLLECTION(GEOMETRYCOLLECTION(GEOMETRYCOLLECTION(LINESTRING(1 1,2 2,3 3,4 4))),' 'POLYGON((0 0,0 10,10 10,10 0,0 0),(4 4,4 6,6 6,6 4,4 4)))'), ST_GEOMFROMTEXT('LINESTRING(4.5 4.5,5.5 5.5)')); SELECT ST_DISTANCE(ST_GEOMFROMTEXT('GEOMETRYCOLLECTION(GEOMETRYCOLLECTION(POLYGON((0 0,0 10,10 10,10 0,0 0),(4 4,4 6,6 6,6 4,4 4))),' 'GEOMETRYCOLLECTION(MULTIPOLYGON(((3 3,3 7,7 7,7 3,3 3),(4 4,4 6,6 6,6 4,4 4)))))'), ST_GEOMFROMTEXT('LINESTRING(4 4,6 6,8 8)')); SELECT ST_DISTANCE(g,ST_GEOMFROMTEXT(@star_top_to_center)) FROM gis_geometrycollection WHERE fid=115; --echo #==================================================================================== --echo # geometrycollection,multilinestring --echo #==================================================================================== SELECT ST_DISTANCE(ST_GEOMFROMTEXT(@star_collection_elems),ST_GEOMFROMTEXT(@star_lines_near_vertical)); SELECT ST_DISTANCE(ST_GEOMFROMTEXT(@star_collection_elems),ST_GEOMFROMTEXT('MULTILINESTRING((0 30,30 30,0 35))')); SELECT ST_DISTANCE(ST_GEOMFROMTEXT(@star_collection_multilinestr),ST_GEOMFROMTEXT('MULTILINESTRING((0 30,30 30,0 35))')); SELECT ST_DISTANCE(ST_GEOMFROMTEXT('GEOMETRYCOLLECTION(GEOMETRYCOLLECTION(POINT(50 50)))'),ST_GEOMFROMTEXT('MULTILINESTRING((0 0,100 100))')); --error ER_GIS_INVALID_DATA SELECT ST_DISTANCE(ST_GEOMFROMTEXT('GEOMETRYCOLLECTION(POLYGON((20 20,20 30,30 30,30 20,20 20),(0 0,0 10,10 10,10 0,0 0)))'), ST_GEOMFROMTEXT('MULTILINESTRING((20 20,40 40),(60 60))')); SELECT ST_DISTANCE(ST_GEOMFROMTEXT('GEOMETRYCOLLECTION(GEOMETRYCOLLECTION(GEOMETRYCOLLECTION(LINESTRING(1 1,2 2,3 3,4 4))),' 'POLYGON((0 0,0 10,10 10,10 0,0 0),(4 4,4 6,6 6,6 4,4 4)))'), ST_GEOMFROMTEXT('MULTILINESTRING((4.5 4.5,5.5 5.5))')); SELECT ST_DISTANCE(ST_GEOMFROMTEXT('GEOMETRYCOLLECTION(GEOMETRYCOLLECTION(POLYGON((0 0,0 10,10 10,10 0,0 0),(4 4,4 6,6 6,6 4,4 4))),' 'GEOMETRYCOLLECTION(MULTIPOLYGON(((3 3,3 7,7 7,7 3,3 3),(4 4,4 6,6 6,6 4,4 4)))))'), ST_GEOMFROMTEXT('MULTILINESTRING((4 4,6 6),(8 8,10 10))')); SELECT ST_DISTANCE(g,ST_GEOMFROMTEXT(@star_lines_near_vertical)) FROM gis_geometrycollection WHERE fid=115; --echo #==================================================================================== --echo # geometrycollection,polygon --echo #==================================================================================== SELECT ST_DISTANCE(ST_GEOMFROMTEXT(@star_collection_elems),ST_GEOMFROMTEXT(@star_elem_vertical)); SELECT ST_DISTANCE(ST_GEOMFROMTEXT(@star_collection_elems),ST_GEOMFROMTEXT(@star)); SELECT ST_DISTANCE(ST_GEOMFROMTEXT(@star_collection_elems),ST_GEOMFROMTEXT('POLYGON((0 0,15 25,35 0,0 0))')); SELECT ST_DISTANCE(ST_GEOMFROMTEXT(@star_collection_multilinestr),ST_GEOMFROMTEXT('POLYGON((0 0,15 25,35 0,0 0))')); SELECT ST_DISTANCE(ST_GEOMFROMTEXT('GEOMETRYCOLLECTION(GEOMETRYCOLLECTION(POINT(50 50)))'),ST_GEOMFROMTEXT('POLYGON((0 0,30 40,90 100, 0 0))')); SELECT ST_DISTANCE(ST_GEOMFROMTEXT('GEOMETRYCOLLECTION(POLYGON((20 20,20 30,30 30,30 20,20 20),(0 0,0 10,10 10,10 0,0 0)))'), ST_GEOMFROMTEXT('POLYGON((20 20,40 40,50 60,20 20))')); SELECT ST_DISTANCE(ST_GEOMFROMTEXT('GEOMETRYCOLLECTION(GEOMETRYCOLLECTION(GEOMETRYCOLLECTION(LINESTRING(1 1,2 2,3 3,4 4))),' 'POLYGON((0 0,0 10,10 10,10 0,0 0),(4 4,4 6,6 6,6 4,4 4)))'), ST_GEOMFROMTEXT('POLYGON((4.2 4.2,5 5,5.7 5.8,4.2 4.2))')); SELECT ST_DISTANCE(ST_GEOMFROMTEXT('GEOMETRYCOLLECTION(GEOMETRYCOLLECTION(POLYGON((0 0,0 10,10 10,10 0,0 0),(4 4,4 6,6 6,6 4,4 4))),' 'GEOMETRYCOLLECTION(MULTIPOLYGON(((3 3,3 7,7 7,7 3,3 3),(4 4,4 6,6 6,6 4,4 4)))))'), ST_GEOMFROMTEXT('POLYGON((4 4,6 6,8 8,10 20,4 4))')); SELECT ST_DISTANCE(g,ST_GEOMFROMTEXT(@star_elem_vertical)) FROM gis_geometrycollection WHERE fid=115; --echo #==================================================================================== --echo # geometrycollection,multipolygon --echo #==================================================================================== SELECT ST_DISTANCE(ST_GEOMFROMTEXT(@star_collection_elems),ST_GEOMFROMTEXT(@star_of_elems)); SELECT ST_DISTANCE(ST_GEOMFROMTEXT(@star_collection_elems),ST_GEOMFROMTEXT('MULTIPOLYGON(((0 0,15 25,35 0,0 0),(5 0,15 25,25 0,15 5,5 0)))')); SELECT ST_DISTANCE(ST_GEOMFROMTEXT(@star_collection_multilinestr),ST_GEOMFROMTEXT('MULTIPOLYGON(((0 0,15 25,35 0,0 0),(5 0,15 25,25 0,15 5,5 0)))')); SELECT ST_DISTANCE(ST_GEOMFROMTEXT('GEOMETRYCOLLECTION(GEOMETRYCOLLECTION(POINT(50 50)))'),ST_GEOMFROMTEXT('MULTIPOLYGON(((0 0,30 40,90 100,0 0)))')); SELECT ST_DISTANCE(ST_GEOMFROMTEXT('GEOMETRYCOLLECTION(POLYGON((20 20,20 30,30 30,30 20,20 20),(0 0,0 10,10 10,10 0,0 0)))'), ST_GEOMFROMTEXT('MULTIPOLYGON(((20 20,40 40,50 60,20 20)))')); SELECT ST_DISTANCE(ST_GEOMFROMTEXT('GEOMETRYCOLLECTION(GEOMETRYCOLLECTION(GEOMETRYCOLLECTION(LINESTRING(1 1,2 2,3 3,4 4))),' 'POLYGON((0 0,0 10,10 10,10 0,0 0),(4 4,4 6,6 6,6 4,4 4)))'), ST_GEOMFROMTEXT('MULTIPOLYGON(((4.2 4.2,5 5,5.7 5.8,4.2 4.2)))')); SELECT ST_DISTANCE(ST_GEOMFROMTEXT('GEOMETRYCOLLECTION(GEOMETRYCOLLECTION(POLYGON((0 0,0 10,10 10,10 0,0 0),(4 4,4 6,6 6,6 4,4 4))),' 'GEOMETRYCOLLECTION(MULTIPOLYGON(((3 3,3 7,7 7,7 3,3 3),(4 4,4 6,6 6,6 4,4 4)))))'), ST_GEOMFROMTEXT('MULTIPOLYGON(((4 4,6 6,8 8,10 20,4 4)))')); SELECT ST_DISTANCE(g,ST_GEOMFROMTEXT(@star_collection_elems)) FROM gis_geometrycollection WHERE fid=115; SELECT ST_DISTANCE(g,g2) FROM gis_geometrycollection,gis_geometrycollection_2 WHERE fid=115 and fid2=103; --echo #==================================================================================== --echo # geometrycollection,geometrycollection --echo #==================================================================================== SELECT ST_DISTANCE(ST_GEOMFROMTEXT(@star_collection_elems),ST_GEOMFROMTEXT(@star_collection_elems)); SELECT ST_DISTANCE(ST_GEOMFROMTEXT(@star_collection_elems),ST_GEOMFROMTEXT(@star_collection_elems_3)); SELECT ST_DISTANCE(ST_GEOMFROMTEXT(@star_collection_multilinestr),ST_GEOMFROMTEXT(@star_collection_elems_3)); SELECT ST_DISTANCE(ST_GEOMFROMTEXT('GEOMETRYCOLLECTION(GEOMETRYCOLLECTION(POINT(50 50)))'), ST_GEOMFROMTEXT('GEOMETRYCOLLECTION(POINT(0 0),LINESTRING(0 0,50 0,100 0))')); SELECT ST_DISTANCE(ST_GEOMFROMTEXT('GEOMETRYCOLLECTION(POLYGON((20 20,20 30,30 30,30 20,20 20),(0 0,0 10,10 10,10 0,0 0)))'), ST_GEOMFROMTEXT('GEOMETRYCOLLECTION(POLYGON((0 0,0 10,10 10,10 0,0 0)))')); SELECT ST_DISTANCE(ST_GEOMFROMTEXT('GEOMETRYCOLLECTION(GEOMETRYCOLLECTION(GEOMETRYCOLLECTION(LINESTRING(1 1,2 2,3 3,4 4))),' 'POLYGON((0 0,0 10,10 10,10 0,0 0),(4 4,4 6,6 6,6 4,4 4)))'), ST_GEOMFROMTEXT('GEOMETRYCOLLECTION(MULTIPOINT(4.5 4.5,5.5 5.5))')); --error ER_GIS_INVALID_DATA SELECT ST_DISTANCE(ST_GEOMFROMTEXT('GEOMETRYCOLLECTION(GEOMETRYCOLLECTION(POLYGON((0 0,0 10,10 10,10 0,0 0),(4 4,4 6,6 6,6 4,4 4))),' 'GEOMETRYCOLLECTION(MULTIPOLYGON(((3 3,3 7,7 7,7 3,3 3),(4 4,4 6,6 6,6 4,4 4)))))'), ST_GEOMFROMTEXT('GEOMETRYCOLLECTION(MULTILINESTRING((40 40,50 50),(5 5)))')); SELECT ST_DISTANCE(g,ST_GEOMFROMTEXT(@star_collection_elems)) FROM gis_geometrycollection WHERE fid=115; SELECT ST_DISTANCE(g,g2) FROM gis_geometrycollection,gis_geometrycollection_2 WHERE fid=115 and fid2=215; --echo ##################################################################################### --echo # ST_DISTANCE() with 2 geometries of same SRID --echo ##################################################################################### SELECT ST_DISTANCE(ST_GEOMFROMTEXT(@star_top,0),ST_GEOMFROMTEXT(@star_center,0)); --error ER_SRS_NOT_FOUND SELECT ST_DISTANCE(ST_GEOMFROMTEXT(@star_top,100),ST_GEOMFROMTEXT(@star_center,100)); --error ER_SRS_NOT_FOUND SELECT ST_DISTANCE(ST_GEOMFROMTEXT(@star_top,20000),ST_GEOMFROMTEXT(@star_center,20000)); --error ER_SRS_NOT_FOUND SELECT ST_DISTANCE(ST_GEOMFROMTEXT(@star_top,123456),ST_GEOMFROMTEXT(@star_center,123456)); --error ER_SRS_NOT_FOUND SELECT ST_DISTANCE(ST_GEOMFROMTEXT(@star_top,1048575),ST_GEOMFROMTEXT(@star_center,1048575)); --error ER_SRS_NOT_FOUND SELECT ST_DISTANCE(ST_GEOMFROMTEXT(@star_top,4294967295),ST_GEOMFROMTEXT(@star_center,4294967295)); --error ER_DATA_OUT_OF_RANGE SELECT ST_DISTANCE(ST_GEOMFROMTEXT(@star_top,-1),ST_GEOMFROMTEXT(@star_center,-1)); --error ER_DATA_OUT_OF_RANGE SELECT ST_DISTANCE(ST_GEOMFROMTEXT(@star_top,-1024),ST_GEOMFROMTEXT(@star_center,-1024)); --error ER_DATA_OUT_OF_RANGE SELECT ST_DISTANCE(ST_GEOMFROMTEXT(@star_top,4294967295000),ST_GEOMFROMTEXT(@star_center,4294967295000)); --echo ##################################################################################### --echo # Invalid function calls --echo ##################################################################################### --error ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT SELECT ST_DISTANCE(); --error ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT SELECT ST_DISTANCE(ST_GEOMFROMTEXT('POINT(10 10)')); SELECT ST_DISTANCE(ST_GEOMFROMTEXT('POINT(10 10)'),NULL); SELECT ST_DISTANCE(NULL,ST_GEOMFROMTEXT('POINT(10 10)')); --error ER_GIS_DIFFERENT_SRIDS SELECT ST_DISTANCE(ST_GEOMFROMTEXT(@star_top),ST_GEOMFROMTEXT(@star_center,4326)); --error ER_SRS_NOT_FOUND SELECT ST_DISTANCE(ST_GEOMFROMTEXT(@star_top,1048576),ST_GEOMFROMTEXT(@star_center,4326)); SELECT ST_DISTANCE(NULL,ST_GEOMFROMTEXT(@star_top)); SELECT ST_DISTANCE(ST_GEOMFROMTEXT(@star_of_elems),NULL); SELECT ST_DISTANCE(NULL,NULL); SELECT ST_DISTANCE(g,NULL) FROM gis_geometrycollection,gis_geometrycollection_2 WHERE fid=103 and fid2=103; SELECT ST_DISTANCE(fid,NULL) FROM gis_geometrycollection,gis_geometrycollection_2 WHERE fid=103 and fid2=103; --error ER_GIS_INVALID_DATA SELECT ST_DISTANCE(fid,ST_GEOMFROMTEXT(@star_top)) FROM gis_geometrycollection,gis_geometrycollection_2 WHERE fid=103 and fid2=103; --error ER_GIS_INVALID_DATA SELECT ST_DISTANCE(ST_GEOMFROMTEXT(@star_of_elems),fid) FROM gis_geometrycollection,gis_geometrycollection_2 WHERE fid=103 and fid2=103; --error ER_GIS_INVALID_DATA SELECT ST_DISTANCE(ST_GEOMFROMTEXT('POINT(a 0)'),ST_GEOMFROMTEXT('LINESTRING(0 0,10 10)')); --error ER_GIS_INVALID_DATA SELECT ST_DISTANCE(ST_GEOMFROMTEXT('POINT(! 0)'),ST_GEOMFROMTEXT('LINESTRING(0 0,10 10)')); --error ER_PARSE_ERROR SELECT ST_DISTANCE(ST_GEOMFROMTEXT('POINT('!' 0)'),ST_GEOMFROMTEXT('LINESTRING(0 0,10 10)')); --error ER_GIS_INVALID_DATA SELECT ST_DISTANCE(ST_GEOMFROMTEXT('POINT(12,34 0)'),ST_GEOMFROMTEXT('LINESTRING(0 0,10 10)')); --error ER_GIS_INVALID_DATA SELECT ST_DISTANCE(ST_GEOMFROMTEXT('LINESTRING(a 0,10 10)'),ST_GEOMFROMTEXT('LINESTRING(0 0,10 10)')); --error ER_GIS_INVALID_DATA SELECT ST_DISTANCE(ST_GEOMFROMTEXT('LINESTRING(0 0,! 10)'),ST_GEOMFROMTEXT('LINESTRING(0 0,10 10)')); --error ER_PARSE_ERROR SELECT ST_DISTANCE(ST_GEOMFROMTEXT('LINESTRING('!' 0,10 10)'),ST_GEOMFROMTEXT('LINESTRING(0 0,10 10)')); --error ER_GIS_INVALID_DATA SELECT ST_DISTANCE(ST_GEOMFROMTEXT('LINESTRING(12,34 0,10 10)'),ST_GEOMFROMTEXT('LINESTRING(0 0,10 10)')); --error ER_GIS_INVALID_DATA SELECT ST_DISTANCE(ST_GEOMFROMTEXT('POLYGON((a 0,10 10,10 0,0 0))'),ST_GEOMFROMTEXT('LINESTRING(0 0,10 10)')); --error ER_GIS_INVALID_DATA SELECT ST_DISTANCE(ST_GEOMFROMTEXT('POLYGON((0 0,! 10,10 0,0 0))'),ST_GEOMFROMTEXT('LINESTRING(0 0,10 10)')); --error ER_PARSE_ERROR SELECT ST_DISTANCE(ST_GEOMFROMTEXT('POLYGON(('!' 0,10 10,10 0,0 0))'),ST_GEOMFROMTEXT('LINESTRING(0 0,10 10)')); --error ER_GIS_INVALID_DATA SELECT ST_DISTANCE(ST_GEOMFROMTEXT('POLYGON((12,34 0,10 10,10 0,0 0))'),ST_GEOMFROMTEXT('LINESTRING(0 0,10 10)')); --error ER_GIS_INVALID_DATA SELECT ST_DISTANCE(ST_GEOMFROMTEXT('POLYGON((12,34 0,10 10,10 0,0 0)'),ST_GEOMFROMTEXT('LINESTRING(0 0,10 10)')); --error ER_GIS_INVALID_DATA SELECT ST_DISTANCE(g,ST_GEOMFROMTEXT('POLYGON((11 15,19 15,11 15))')) FROM gis_geometrycollection WHERE fid=110; --error ER_GIS_INVALID_DATA SELECT ST_DISTANCE(g,ST_GEOMFROMTEXT('MULTIPOLYGON(((11 15,19 15,11 15)),((25 0,0 15,25 0)))')) FROM gis_geometrycollection WHERE fid=110; --echo # Invalid polygon. SELECT ST_DISTANCE(ST_GEOMFROMTEXT('POLYGON((0 0,0 10,10 10,10 0,0 0),(14 14,14 16,16 16,16 14,14 14))'), ST_GEOMFROMTEXT('POLYGON((11 11,14 14,15 15,16 16,20 20,11 11))')); --echo # Invalid polygon. SELECT ST_DISTANCE(ST_GEOMFROMTEXT('POLYGON((0 0,0 10,10 10,10 0,0 0),(14 14,14 16,16 16,16 14,14 14))'), ST_GEOMFROMTEXT('MULTIPOLYGON(((11 11,14 14,15 15,11 11)),((16 16,20 20,30 30,16 16)))')); SELECT ST_DISTANCE(ST_GEOMFROMTEXT('GEOMETRYCOLLECTION()'),ST_GEOMFROMTEXT('GEOMETRYCOLLECTION(GEOMETRYCOLLECTION())')); SELECT ST_DISTANCE(ST_GEOMFROMTEXT('POINT(10 10)'),ST_GEOMFROMTEXT('GEOMETRYCOLLECTION(GEOMETRYCOLLECTION())')); SELECT ST_DISTANCE(ST_GEOMFROMTEXT('GEOMETRYCOLLECTION()'),ST_GEOMFROMTEXT('POINT(10 10)')); --error ER_PARSE_ERROR SELECT ST_DISTANCE(,); --error ER_PARSE_ERROR SELECT ST_DISTANCE(ST_GEOMFROMTEXT(@star_of_elems),); --error ER_PARSE_ERROR SELECT ST_DISTANCE(,ST_GEOMFROMTEXT(@star_top)); --error ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT SELECT ST_DISTANCE(ST_GEOMFROMTEXT('POINT(1 1)')); --error ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT SELECT ST_DISTANCE(ST_GEOMFROMTEXT('POINT(1 1)'), ST_GEOMFROMTEXT('POINT(0 0)'), 200, 300); --echo # Clean up DROP TABLE gis_geometrycollection; DROP TABLE gis_geometrycollection_2; --echo # --echo # WL#8579 Spatial Reference Systems --echo # --echo # SRID 0 (should pass) SELECT ST_DISTANCE( ST_GEOMFROMTEXT('POINT(0 0)', 0), ST_GEOMFROMTEXT('POINT(0 0)', 0) ); --echo # Projected SRS (should pass) SELECT ST_DISTANCE( ST_GEOMFROMTEXT('POINT(0 0)', 2000), ST_GEOMFROMTEXT('POINT(0 0)', 2000) ); --echo # Geographic SRS (should pass) SELECT ST_DISTANCE( ST_GEOMFROMTEXT('POINT(0 0)', 4326), ST_GEOMFROMTEXT('POINT(0 0)', 4326) ); --echo # Undefined SRS (should fail) # Assume SRID 13000000 is undefined --error ER_SRS_NOT_FOUND SELECT ST_DISTANCE( ST_GEOMFROMTEXT('POINT(0 0)', 13000000), ST_GEOMFROMTEXT('POINT(0 0)', 13000000) ); --echo # --echo # WL#9347 Ellipsoidal ST_Distance for point and multipoint --echo # --echo # All parameter types (Cartesian) DO ST_DISTANCE( ST_GEOMFROMTEXT('POINT(0 0)'), ST_GEOMFROMTEXT('POINT(1 0)')); DO ST_DISTANCE( ST_GEOMFROMTEXT('POINT(0 0)'), ST_GEOMFROMTEXT('LINESTRING(1 0, 1 1)')); DO ST_DISTANCE( ST_GEOMFROMTEXT('POINT(0 0)'), ST_GEOMFROMTEXT('POLYGON((1 0, 2 0, 2 1, 1 1, 1 0))')); DO ST_DISTANCE( ST_GEOMFROMTEXT('POINT(0 0)'), ST_GEOMFROMTEXT('MULTIPOINT((1 0))')); DO ST_DISTANCE( ST_GEOMFROMTEXT('POINT(0 0)'), ST_GEOMFROMTEXT('MULTILINESTRING((1 0, 1 1))')); DO ST_DISTANCE( ST_GEOMFROMTEXT('POINT(0 0)'), ST_GEOMFROMTEXT('MULTIPOLYGON(((1 0, 2 0, 2 1, 1 1, 1 0)))')); DO ST_DISTANCE( ST_GEOMFROMTEXT('POINT(0 0)'), ST_GEOMFROMTEXT( 'GEOMETRYCOLLECTION(MULTIPOLYGON(((1 0, 2 0, 2 1, 1 1, 1 0))))')); DO ST_DISTANCE( ST_GEOMFROMTEXT('LINESTRING(1 0, 1 1)'), ST_GEOMFROMTEXT('POINT(1 0)')); DO ST_DISTANCE( ST_GEOMFROMTEXT('LINESTRING(1 0, 1 1)'), ST_GEOMFROMTEXT('LINESTRING(1 0, 1 1)')); DO ST_DISTANCE( ST_GEOMFROMTEXT('LINESTRING(1 0, 1 1)'), ST_GEOMFROMTEXT('POLYGON((1 0, 2 0, 2 1, 1 1, 1 0))')); DO ST_DISTANCE( ST_GEOMFROMTEXT('LINESTRING(1 0, 1 1)'), ST_GEOMFROMTEXT('MULTIPOINT((1 0))')); DO ST_DISTANCE( ST_GEOMFROMTEXT('LINESTRING(1 0, 1 1)'), ST_GEOMFROMTEXT('MULTILINESTRING((1 0, 1 1))')); DO ST_DISTANCE( ST_GEOMFROMTEXT('LINESTRING(1 0, 1 1)'), ST_GEOMFROMTEXT('MULTIPOLYGON(((1 0, 2 0, 2 1, 1 1, 1 0)))')); DO ST_DISTANCE( ST_GEOMFROMTEXT('LINESTRING(1 0, 1 1)'), ST_GEOMFROMTEXT( 'GEOMETRYCOLLECTION(MULTIPOLYGON(((1 0, 2 0, 2 1, 1 1, 1 0))))')); DO ST_DISTANCE( ST_GEOMFROMTEXT('POLYGON((1 0, 2 0, 2 1, 1 1, 1 0))'), ST_GEOMFROMTEXT('POINT(1 0)')); DO ST_DISTANCE( ST_GEOMFROMTEXT('POLYGON((1 0, 2 0, 2 1, 1 1, 1 0))'), ST_GEOMFROMTEXT('LINESTRING(1 0, 1 1)')); DO ST_DISTANCE( ST_GEOMFROMTEXT('POLYGON((1 0, 2 0, 2 1, 1 1, 1 0))'), ST_GEOMFROMTEXT('POLYGON((1 0, 2 0, 2 1, 1 1, 1 0))')); DO ST_DISTANCE( ST_GEOMFROMTEXT('POLYGON((1 0, 2 0, 2 1, 1 1, 1 0))'), ST_GEOMFROMTEXT('MULTIPOINT((1 0))')); DO ST_DISTANCE( ST_GEOMFROMTEXT('POLYGON((1 0, 2 0, 2 1, 1 1, 1 0))'), ST_GEOMFROMTEXT('MULTILINESTRING((1 0, 1 1))')); DO ST_DISTANCE( ST_GEOMFROMTEXT('POLYGON((1 0, 2 0, 2 1, 1 1, 1 0))'), ST_GEOMFROMTEXT('MULTIPOLYGON(((1 0, 2 0, 2 1, 1 1, 1 0)))')); DO ST_DISTANCE( ST_GEOMFROMTEXT('POLYGON((1 0, 2 0, 2 1, 1 1, 1 0))'), ST_GEOMFROMTEXT( 'GEOMETRYCOLLECTION(MULTIPOLYGON(((1 0, 2 0, 2 1, 1 1, 1 0))))')); DO ST_DISTANCE( ST_GEOMFROMTEXT('MULTIPOINT((0 0))'), ST_GEOMFROMTEXT('POINT(1 0)')); DO ST_DISTANCE( ST_GEOMFROMTEXT('MULTIPOINT((0 0))'), ST_GEOMFROMTEXT('LINESTRING(1 0, 1 1)')); DO ST_DISTANCE( ST_GEOMFROMTEXT('MULTIPOINT((0 0))'), ST_GEOMFROMTEXT('POLYGON((1 0, 2 0, 2 1, 1 1, 1 0))')); DO ST_DISTANCE( ST_GEOMFROMTEXT('MULTIPOINT((0 0))'), ST_GEOMFROMTEXT('MULTIPOINT((1 0))')); DO ST_DISTANCE( ST_GEOMFROMTEXT('MULTIPOINT((0 0))'), ST_GEOMFROMTEXT('MULTILINESTRING((1 0, 1 1))')); DO ST_DISTANCE( ST_GEOMFROMTEXT('MULTIPOINT((0 0))'), ST_GEOMFROMTEXT('MULTIPOLYGON(((1 0, 2 0, 2 1, 1 1, 1 0)))')); DO ST_DISTANCE( ST_GEOMFROMTEXT('MULTIPOINT((0 0))'), ST_GEOMFROMTEXT( 'GEOMETRYCOLLECTION(MULTIPOLYGON(((1 0, 2 0, 2 1, 1 1, 1 0))))')); DO ST_DISTANCE( ST_GEOMFROMTEXT('MULTILINESTRING((1 0, 1 1))'), ST_GEOMFROMTEXT('POINT(1 0)')); DO ST_DISTANCE( ST_GEOMFROMTEXT('MULTILINESTRING((1 0, 1 1))'), ST_GEOMFROMTEXT('LINESTRING(1 0, 1 1)')); DO ST_DISTANCE( ST_GEOMFROMTEXT('MULTILINESTRING((1 0, 1 1))'), ST_GEOMFROMTEXT('POLYGON((1 0, 2 0, 2 1, 1 1, 1 0))')); DO ST_DISTANCE( ST_GEOMFROMTEXT('MULTILINESTRING((1 0, 1 1))'), ST_GEOMFROMTEXT('MULTIPOINT((1 0))')); DO ST_DISTANCE( ST_GEOMFROMTEXT('MULTILINESTRING((1 0, 1 1))'), ST_GEOMFROMTEXT('MULTILINESTRING((1 0, 1 1))')); DO ST_DISTANCE( ST_GEOMFROMTEXT('MULTILINESTRING((1 0, 1 1))'), ST_GEOMFROMTEXT('MULTIPOLYGON(((1 0, 2 0, 2 1, 1 1, 1 0)))')); DO ST_DISTANCE( ST_GEOMFROMTEXT('MULTILINESTRING((1 0, 1 1))'), ST_GEOMFROMTEXT( 'GEOMETRYCOLLECTION(MULTIPOLYGON(((1 0, 2 0, 2 1, 1 1, 1 0))))')); DO ST_DISTANCE( ST_GEOMFROMTEXT('MULTIPOLYGON(((1 0, 2 0, 2 1, 1 1, 1 0)))'), ST_GEOMFROMTEXT('POINT(1 0)')); DO ST_DISTANCE( ST_GEOMFROMTEXT('MULTIPOLYGON(((1 0, 2 0, 2 1, 1 1, 1 0)))'), ST_GEOMFROMTEXT('LINESTRING(1 0, 1 1)')); DO ST_DISTANCE( ST_GEOMFROMTEXT('MULTIPOLYGON(((1 0, 2 0, 2 1, 1 1, 1 0)))'), ST_GEOMFROMTEXT('POLYGON((1 0, 2 0, 2 1, 1 1, 1 0))')); DO ST_DISTANCE( ST_GEOMFROMTEXT('MULTIPOLYGON(((1 0, 2 0, 2 1, 1 1, 1 0)))'), ST_GEOMFROMTEXT('MULTIPOINT((1 0))')); DO ST_DISTANCE( ST_GEOMFROMTEXT('MULTIPOLYGON(((1 0, 2 0, 2 1, 1 1, 1 0)))'), ST_GEOMFROMTEXT('MULTILINESTRING((1 0, 1 1))')); DO ST_DISTANCE( ST_GEOMFROMTEXT('MULTIPOLYGON(((1 0, 2 0, 2 1, 1 1, 1 0)))'), ST_GEOMFROMTEXT('MULTIPOLYGON(((1 0, 2 0, 2 1, 1 1, 1 0)))')); DO ST_DISTANCE( ST_GEOMFROMTEXT('MULTIPOLYGON(((1 0, 2 0, 2 1, 1 1, 1 0)))'), ST_GEOMFROMTEXT( 'GEOMETRYCOLLECTION(MULTIPOLYGON(((1 0, 2 0, 2 1, 1 1, 1 0))))')); DO ST_DISTANCE( ST_GEOMFROMTEXT('GEOMETRYCOLLECTION(POINT(0 0), LINESTRING(-1 -1, -2 -2))'), ST_GEOMFROMTEXT('POINT(1 0)')); DO ST_DISTANCE( ST_GEOMFROMTEXT('GEOMETRYCOLLECTION(POINT(0 0), LINESTRING(-1 -1, -2 -2))'), ST_GEOMFROMTEXT('LINESTRING(1 0, 1 1)')); DO ST_DISTANCE( ST_GEOMFROMTEXT('GEOMETRYCOLLECTION(POINT(0 0), LINESTRING(-1 -1, -2 -2))'), ST_GEOMFROMTEXT('POLYGON((1 0, 2 0, 2 1, 1 1, 1 0))')); DO ST_DISTANCE( ST_GEOMFROMTEXT('GEOMETRYCOLLECTION(POINT(0 0), LINESTRING(-1 -1, -2 -2))'), ST_GEOMFROMTEXT('MULTIPOINT((1 0))')); DO ST_DISTANCE( ST_GEOMFROMTEXT('GEOMETRYCOLLECTION(POINT(0 0), LINESTRING(-1 -1, -2 -2))'), ST_GEOMFROMTEXT('MULTILINESTRING((1 0, 1 1))')); DO ST_DISTANCE( ST_GEOMFROMTEXT('GEOMETRYCOLLECTION(POINT(0 0), LINESTRING(-1 -1, -2 -2))'), ST_GEOMFROMTEXT('MULTIPOLYGON(((1 0, 2 0, 2 1, 1 1, 1 0)))')); DO ST_DISTANCE( ST_GEOMFROMTEXT('GEOMETRYCOLLECTION(POINT(0 0), LINESTRING(-1 -1, -2 -2))'), ST_GEOMFROMTEXT( 'GEOMETRYCOLLECTION(MULTIPOLYGON(((1 0, 2 0, 2 1, 1 1, 1 0))))')); --echo # All parameter types (Geographic) DO ST_DISTANCE( ST_GEOMFROMTEXT('POINT(0 0)', 4326), ST_GEOMFROMTEXT('POINT(1 0)', 4326)); DO ST_DISTANCE( ST_GEOMFROMTEXT('POINT(0 0)', 4326), ST_GEOMFROMTEXT('LINESTRING(1 0, 1 1)', 4326)); DO ST_DISTANCE( ST_GEOMFROMTEXT('POINT(0 0)', 4326), ST_GEOMFROMTEXT('POLYGON((1 0, 2 0, 2 1, 1 1, 1 0))', 4326)); DO ST_DISTANCE( ST_GEOMFROMTEXT('POINT(0 0)', 4326), ST_GEOMFROMTEXT('MULTIPOINT((1 0))', 4326)); DO ST_DISTANCE( ST_GEOMFROMTEXT('POINT(0 0)', 4326), ST_GEOMFROMTEXT('MULTILINESTRING((1 0, 1 1))', 4326)); DO ST_DISTANCE( ST_GEOMFROMTEXT('POINT(0 0)', 4326), ST_GEOMFROMTEXT('MULTIPOLYGON(((1 0, 2 0, 2 1, 1 1, 1 0)))', 4326)); DO ST_DISTANCE( ST_GEOMFROMTEXT('POINT(0 0)', 4326), ST_GEOMFROMTEXT( 'GEOMETRYCOLLECTION(MULTIPOLYGON(((1 0, 2 0, 2 1, 1 1, 1 0))))', 4326) ); DO ST_DISTANCE( ST_GEOMFROMTEXT('LINESTRING(1 0, 1 1)', 4326), ST_GEOMFROMTEXT('POINT(1 0)', 4326)); DO ST_DISTANCE( ST_GEOMFROMTEXT('LINESTRING(1 0, 1 1)', 4326), ST_GEOMFROMTEXT('LINESTRING(1 0, 1 1)', 4326)); DO ST_DISTANCE( ST_GEOMFROMTEXT('LINESTRING(1 0, 1 1)', 4326), ST_GEOMFROMTEXT('POLYGON((1 0, 2 0, 2 1, 1 1, 1 0))', 4326)); DO ST_DISTANCE( ST_GEOMFROMTEXT('LINESTRING(1 0, 1 1)', 4326), ST_GEOMFROMTEXT('MULTIPOINT((1 0))', 4326)); DO ST_DISTANCE( ST_GEOMFROMTEXT('LINESTRING(1 0, 1 1)', 4326), ST_GEOMFROMTEXT('MULTILINESTRING((1 0, 1 1))', 4326)); DO ST_DISTANCE( ST_GEOMFROMTEXT('LINESTRING(1 0, 1 1)', 4326), ST_GEOMFROMTEXT('MULTIPOLYGON(((1 0, 2 0, 2 1, 1 1, 1 0)))', 4326)); DO ST_DISTANCE( ST_GEOMFROMTEXT('LINESTRING(1 0, 1 1)', 4326), ST_GEOMFROMTEXT( 'GEOMETRYCOLLECTION(MULTIPOLYGON(((1 0, 2 0, 2 1, 1 1, 1 0))))', 4326) ); DO ST_DISTANCE( ST_GEOMFROMTEXT('POLYGON((1 0, 2 0, 2 1, 1 1, 1 0))', 4326), ST_GEOMFROMTEXT('POINT(1 0)', 4326)); DO ST_DISTANCE( ST_GEOMFROMTEXT('POLYGON((1 0, 2 0, 2 1, 1 1, 1 0))', 4326), ST_GEOMFROMTEXT('LINESTRING(1 0, 1 1)', 4326)); DO ST_DISTANCE( ST_GEOMFROMTEXT('POLYGON((1 0, 2 0, 2 1, 1 1, 1 0))', 4326), ST_GEOMFROMTEXT('POLYGON((1 0, 2 0, 2 1, 1 1, 1 0))', 4326)); DO ST_DISTANCE( ST_GEOMFROMTEXT('POLYGON((1 0, 2 0, 2 1, 1 1, 1 0))', 4326), ST_GEOMFROMTEXT('MULTIPOINT((1 0))', 4326)); DO ST_DISTANCE( ST_GEOMFROMTEXT('POLYGON((1 0, 2 0, 2 1, 1 1, 1 0))', 4326), ST_GEOMFROMTEXT('MULTILINESTRING((1 0, 1 1))', 4326)); DO ST_DISTANCE( ST_GEOMFROMTEXT('POLYGON((1 0, 2 0, 2 1, 1 1, 1 0))', 4326), ST_GEOMFROMTEXT('MULTIPOLYGON(((1 0, 2 0, 2 1, 1 1, 1 0)))', 4326)); DO ST_DISTANCE( ST_GEOMFROMTEXT('POLYGON((1 0, 2 0, 2 1, 1 1, 1 0))', 4326), ST_GEOMFROMTEXT( 'GEOMETRYCOLLECTION(MULTIPOLYGON(((1 0, 2 0, 2 1, 1 1, 1 0))))', 4326) ); DO ST_DISTANCE( ST_GEOMFROMTEXT('MULTIPOINT((0 0))', 4326), ST_GEOMFROMTEXT('POINT(1 0)', 4326)); DO ST_DISTANCE( ST_GEOMFROMTEXT('MULTIPOINT((0 0))', 4326), ST_GEOMFROMTEXT('LINESTRING(1 0, 1 1)', 4326)); DO ST_DISTANCE( ST_GEOMFROMTEXT('MULTIPOINT((0 0))', 4326), ST_GEOMFROMTEXT('POLYGON((1 0, 2 0, 2 1, 1 1, 1 0))', 4326)); DO ST_DISTANCE( ST_GEOMFROMTEXT('MULTIPOINT((0 0))', 4326), ST_GEOMFROMTEXT('MULTIPOINT((1 0))', 4326)); DO ST_DISTANCE( ST_GEOMFROMTEXT('MULTIPOINT((0 0))', 4326), ST_GEOMFROMTEXT('MULTILINESTRING((1 0, 1 1))', 4326)); DO ST_DISTANCE( ST_GEOMFROMTEXT('MULTIPOINT((0 0))', 4326), ST_GEOMFROMTEXT('MULTIPOLYGON(((1 0, 2 0, 2 1, 1 1, 1 0)))', 4326)); DO ST_DISTANCE( ST_GEOMFROMTEXT('MULTIPOINT((0 0))', 4326), ST_GEOMFROMTEXT( 'GEOMETRYCOLLECTION(MULTIPOLYGON(((1 0, 2 0, 2 1, 1 1, 1 0))))', 4326) ); DO ST_DISTANCE( ST_GEOMFROMTEXT('MULTILINESTRING((1 0, 1 1))', 4326), ST_GEOMFROMTEXT('POINT(1 0)', 4326)); DO ST_DISTANCE( ST_GEOMFROMTEXT('MULTILINESTRING((1 0, 1 1))', 4326), ST_GEOMFROMTEXT('LINESTRING(1 0, 1 1)', 4326)); DO ST_DISTANCE( ST_GEOMFROMTEXT('MULTILINESTRING((1 0, 1 1))', 4326), ST_GEOMFROMTEXT('POLYGON((1 0, 2 0, 2 1, 1 1, 1 0))', 4326)); DO ST_DISTANCE( ST_GEOMFROMTEXT('MULTILINESTRING((1 0, 1 1))', 4326), ST_GEOMFROMTEXT('MULTIPOINT((1 0))', 4326)); DO ST_DISTANCE( ST_GEOMFROMTEXT('MULTILINESTRING((1 0, 1 1))', 4326), ST_GEOMFROMTEXT('MULTILINESTRING((1 0, 1 1))', 4326)); DO ST_DISTANCE( ST_GEOMFROMTEXT('MULTILINESTRING((1 0, 1 1))', 4326), ST_GEOMFROMTEXT('MULTIPOLYGON(((1 0, 2 0, 2 1, 1 1, 1 0)))', 4326)); DO ST_DISTANCE( ST_GEOMFROMTEXT('MULTILINESTRING((1 0, 1 1))', 4326), ST_GEOMFROMTEXT( 'GEOMETRYCOLLECTION(MULTIPOLYGON(((1 0, 2 0, 2 1, 1 1, 1 0))))', 4326) ); DO ST_DISTANCE( ST_GEOMFROMTEXT('MULTIPOLYGON(((1 0, 2 0, 2 1, 1 1, 1 0)))', 4326), ST_GEOMFROMTEXT('POINT(1 0)', 4326)); DO ST_DISTANCE( ST_GEOMFROMTEXT('MULTIPOLYGON(((1 0, 2 0, 2 1, 1 1, 1 0)))', 4326), ST_GEOMFROMTEXT('LINESTRING(1 0, 1 1)', 4326)); DO ST_DISTANCE( ST_GEOMFROMTEXT('MULTIPOLYGON(((1 0, 2 0, 2 1, 1 1, 1 0)))', 4326), ST_GEOMFROMTEXT('POLYGON((1 0, 2 0, 2 1, 1 1, 1 0))', 4326)); DO ST_DISTANCE( ST_GEOMFROMTEXT('MULTIPOLYGON(((1 0, 2 0, 2 1, 1 1, 1 0)))', 4326), ST_GEOMFROMTEXT('MULTIPOINT((1 0))', 4326)); DO ST_DISTANCE( ST_GEOMFROMTEXT('MULTIPOLYGON(((1 0, 2 0, 2 1, 1 1, 1 0)))', 4326), ST_GEOMFROMTEXT('MULTILINESTRING((1 0, 1 1))', 4326)); DO ST_DISTANCE( ST_GEOMFROMTEXT('MULTIPOLYGON(((1 0, 2 0, 2 1, 1 1, 1 0)))', 4326), ST_GEOMFROMTEXT('MULTIPOLYGON(((1 0, 2 0, 2 1, 1 1, 1 0)))', 4326)); DO ST_DISTANCE( ST_GEOMFROMTEXT('MULTIPOLYGON(((1 0, 2 0, 2 1, 1 1, 1 0)))', 4326), ST_GEOMFROMTEXT( 'GEOMETRYCOLLECTION(MULTIPOLYGON(((1 0, 2 0, 2 1, 1 1, 1 0))))', 4326) ); DO ST_DISTANCE( ST_GEOMFROMTEXT('GEOMETRYCOLLECTION(POINT(0 0), LINESTRING(-1 -1, -2 -2))', 4326), ST_GEOMFROMTEXT('POINT(1 0)', 4326)); DO ST_DISTANCE( ST_GEOMFROMTEXT('GEOMETRYCOLLECTION(POINT(0 0), LINESTRING(-1 -1, -2 -2))', 4326), ST_GEOMFROMTEXT('LINESTRING(1 0, 1 1)', 4326)); DO ST_DISTANCE( ST_GEOMFROMTEXT('GEOMETRYCOLLECTION(POINT(0 0), LINESTRING(-1 -1, -2 -2))', 4326), ST_GEOMFROMTEXT('POLYGON((1 0, 2 0, 2 1, 1 1, 1 0))', 4326)); DO ST_DISTANCE( ST_GEOMFROMTEXT('GEOMETRYCOLLECTION(POINT(0 0), LINESTRING(-1 -1, -2 -2))', 4326), ST_GEOMFROMTEXT('MULTIPOINT((1 0))', 4326)); DO ST_DISTANCE( ST_GEOMFROMTEXT('GEOMETRYCOLLECTION(POINT(0 0), LINESTRING(-1 -1, -2 -2))', 4326), ST_GEOMFROMTEXT('MULTILINESTRING((1 0, 1 1))', 4326)); DO ST_DISTANCE( ST_GEOMFROMTEXT('GEOMETRYCOLLECTION(POINT(0 0), LINESTRING(-1 -1, -2 -2))', 4326), ST_GEOMFROMTEXT('MULTIPOLYGON(((1 0, 2 0, 2 1, 1 1, 1 0)))', 4326)); DO ST_DISTANCE( ST_GEOMFROMTEXT('GEOMETRYCOLLECTION(POINT(0 0), LINESTRING(-1 -1, -2 -2))', 4326), ST_GEOMFROMTEXT( 'GEOMETRYCOLLECTION(MULTIPOLYGON(((1 0, 2 0, 2 1, 1 1, 1 0))))', 4326)); --echo # All types in a geometrycollection SET @pt = ST_GEOMFROMTEXT('POINT(0 0)'); SET @ls = ST_GEOMFROMTEXT('LINESTRING(0 0, 10 0, 10 10, 0 10, 0 0)'); SET @py = ST_GEOMFROMTEXT( 'POLYGON((0 0, 10 0, 10 10, 0 10, 0 0),(2 2, 8 2, 8 8, 2 8, 2 2))'); SET @mpt = ST_GEOMFROMTEXT('MULTIPOINT((0 0),(1 1))'); SET @mls = ST_GEOMFROMTEXT('MULTILINESTRING((0 0, 1 1),(2 2, 3 3))'); SET @mpy = ST_GEOMFROMTEXT( 'MULTIPOLYGON(((0 0, 10 0, 10 10, 0 10, 0 0),(2 2, 8 2, 8 8, 2 8, 2 2)))'); SET @gc = ST_GEOMFROMTEXT('GEOMETRYCOLLECTION( POINT(0 0), LINESTRING(0 0, 10 0, 10 10, 0 10, 0 0), POLYGON((0 0, 10 0, 10 10, 0 10, 0 0),(2 2, 8 2, 8 8, 2 8, 2 2)), MULTIPOINT((0 0),(1 1)), MULTILINESTRING((0 0, 1 1),(2 2, 3 3)), MULTIPOLYGON(((0 0, 10 0, 10 10, 0 10, 0 0),(2 2, 8 2, 8 8, 2 8, 2 2))), GEOMETRYCOLLECTION(GEOMETRYCOLLECTION(POINT(0 0))), GEOMETRYCOLLECTION())' ); DO ST_DISTANCE(ST_SRID(@pt, 0), ST_SRID(@gc, 0)); DO ST_DISTANCE(ST_SRID(@pt, 4326), ST_SRID(@gc, 4326)); --echo # Polygon ring directions # CCW exterior DO ST_DISTANCE(POINT(0, 0), ST_GEOMFROMTEXT( 'POLYGON((0 0, 10 0, 10 10, 0 10, 0 0))' )); # CW exterior DO ST_DISTANCE(POINT(0, 0), ST_GEOMFROMTEXT( 'POLYGON((0 0, 0 10, 10 10, 10 0, 0 0))' )); # CCW interior DO ST_DISTANCE(POINT(0, 0), ST_GEOMFROMTEXT( 'POLYGON((0 0, 10 0, 10 10, 0 10, 0 0),(2 2, 8 2, 8 8, 2 2))' )); # CW interior DO ST_DISTANCE(POINT(0, 0), ST_GEOMFROMTEXT( 'POLYGON((0 0, 10 0, 10 10, 0 10, 0 0),(2 2, 8 8, 8 2, 2 2))' )); # Exterior with only one point --echo # Invalid polygon. DO ST_DISTANCE(POINT(0, 0), ST_GEOMFROMTEXT( 'POLYGON((0 0, 0 0, 0 0, 0 0, 0 0))' )); # Interior with only one point --echo # Invalid polygon. DO ST_DISTANCE(POINT(0, 0), ST_GEOMFROMTEXT( 'POLYGON((0 0, 10 0, 10 10, 0 10, 0 0),(2 2, 2 2, 2 2, 2 2, 2 2))' )); # Assume SRID 13001000-13001999 are undefined # WGS 84 with long-lat axis ordering CREATE SPATIAL REFERENCE SYSTEM 13001000 NAME 'TEST13001000 Long-Lat WGS 84' DEFINITION 'GEOGCS["Long-Lat WGS 84",DATUM["World Geodetic System 1984",SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.017453292519943278,AUTHORITY["EPSG","9122"]],AXIS["Lon",EAST],AXIS["Lat",NORTH],AUTHORITY["EPSG","4326"]]'; # WGS 84 with gradians CREATE SPATIAL REFERENCE SYSTEM 13001001 NAME 'TEST13001001 Gradian WGS 84' DEFINITION 'GEOGCS["Gradian WGS 84",DATUM["World Geodetic System 1984",SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["grad",0.01570796326794895,AUTHORITY["EPSG","9105"]],AXIS["Lat",NORTH],AXIS["Lon",EAST],AUTHORITY["EPSG","4326"]]'; # WGS 84 with lat-long (South-West) axes in gradians, meridian 10 grads East of # Greenwich. CREATE SPATIAL REFERENCE SYSTEM 13001002 NAME 'TEST13001002 Tweaked WGS 84' DEFINITION 'GEOGCS["Tweaked",DATUM["World Geodetic System 1984",SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],AUTHORITY["EPSG","6326"]],PRIMEM["10 E",10,AUTHORITY["EPSG","8901"]],UNIT["grad",0.01570796326794895,AUTHORITY["EPSG","9105"]],AXIS["Lat",SOUTH],AXIS["Lon",WEST],AUTHORITY["EPSG","4326"]]'; # WGS 84 with radians CREATE SPATIAL REFERENCE SYSTEM 13001003 NAME 'TEST13001003 Radian WGS 84' DEFINITION 'GEOGCS["Radian WGS 84",DATUM["World Geodetic System 1984",SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["radian",1.0,AUTHORITY["EPSG","9101"]],AXIS["Lat",NORTH],AXIS["Lon",EAST],AUTHORITY["EPSG","4326"]]'; --echo # From the Equator to the North Pole along the Greenwich meridian # Degrees (lat-long) SELECT ROUND(ST_DISTANCE(ST_GEOMFROMTEXT('POINT(0 0)', 4326), ST_GEOMFROMTEXT('POINT(90 0)', 4326)), 3) AS d; SELECT ROUND(ST_DISTANCE(ST_GEOMFROMTEXT('POINT(0 0)', 4326), ST_GEOMFROMTEXT('MULTIPOINT((90 0))', 4326)), 3) AS d; SELECT ROUND(ST_DISTANCE(ST_GEOMFROMTEXT('MULTIPOINT((0 0))', 4326), ST_GEOMFROMTEXT('POINT(90 0)', 4326)), 3) AS d; # Degrees (long-lat) SELECT ROUND(ST_DISTANCE(ST_GEOMFROMTEXT('POINT(0 0)', 13001000), ST_GEOMFROMTEXT('POINT(0 90)', 13001000)), 3) AS d; SELECT ROUND(ST_DISTANCE(ST_GEOMFROMTEXT('POINT(0 0)', 13001000), ST_GEOMFROMTEXT('MULTIPOINT((0 90))', 13001000)), 3) AS d; SELECT ROUND(ST_DISTANCE(ST_GEOMFROMTEXT('MULTIPOINT((0 0))', 13001000), ST_GEOMFROMTEXT('POINT(0 90)', 13001000)), 3) AS d; # Gradians (lat-long) SELECT ROUND(ST_DISTANCE(ST_GEOMFROMTEXT('POINT(0 0)', 13001001), ST_GEOMFROMTEXT('POINT(100 0)', 13001001)), 3) AS d; SELECT ROUND(ST_DISTANCE(ST_GEOMFROMTEXT('POINT(0 0)', 13001001), ST_GEOMFROMTEXT('MULTIPOINT((100 0))', 13001001)), 3) AS d; SELECT ROUND(ST_DISTANCE(ST_GEOMFROMTEXT('MULTIPOINT((0 0))', 13001001), ST_GEOMFROMTEXT('POINT(100 0)', 13001001)), 3) AS d; # Gradians (lat-long), meridian at 10 grad East SELECT ROUND(ST_DISTANCE(ST_GEOMFROMTEXT('POINT(0 10)', 13001002), ST_GEOMFROMTEXT('POINT(-100 10)', 13001002)), 3) AS d; SELECT ROUND(ST_DISTANCE(ST_GEOMFROMTEXT('POINT(0 10)', 13001002), ST_GEOMFROMTEXT('MULTIPOINT((-100 10))', 13001002)), 3) AS d; SELECT ROUND(ST_DISTANCE(ST_GEOMFROMTEXT('MULTIPOINT((0 10))', 13001002), ST_GEOMFROMTEXT('POINT(-100 10)', 13001002)), 3) AS d; --echo # 45 degrees East along the Equator from the Greenwich meridian # Degrees (lat-long) SELECT ROUND(ST_DISTANCE(ST_GEOMFROMTEXT('POINT(0 0)', 4326), ST_GEOMFROMTEXT('POINT(0 45)', 4326)), 3) AS d; SELECT ROUND(ST_DISTANCE(ST_GEOMFROMTEXT('POINT(0 0)', 4326), ST_GEOMFROMTEXT('MULTIPOINT((0 45))', 4326)), 3) AS d; SELECT ROUND(ST_DISTANCE(ST_GEOMFROMTEXT('MULTIPOINT((0 0))', 4326), ST_GEOMFROMTEXT('POINT(0 45)', 4326)), 3) AS d; # Degreees (long-lat) SELECT ROUND(ST_DISTANCE(ST_GEOMFROMTEXT('POINT(0 0)', 13001000), ST_GEOMFROMTEXT('POINT(45 0)', 13001000)), 3) AS d; SELECT ROUND(ST_DISTANCE(ST_GEOMFROMTEXT('POINT(0 0)', 13001000), ST_GEOMFROMTEXT('MULTIPOINT((45 0))', 13001000)), 3) AS d; SELECT ROUND(ST_DISTANCE(ST_GEOMFROMTEXT('MULTIPOINT((0 0))', 13001000), ST_GEOMFROMTEXT('POINT(45 0)', 13001000)), 3) AS d; # Gradians (lat-long) SELECT ROUND(ST_DISTANCE(ST_GEOMFROMTEXT('POINT(0 0)', 13001001), ST_GEOMFROMTEXT('POINT(0 50)', 13001001)), 3) AS d; SELECT ROUND(ST_DISTANCE(ST_GEOMFROMTEXT('POINT(0 0)', 13001001), ST_GEOMFROMTEXT('MULTIPOINT((0 50))', 13001001)), 3) AS d; SELECT ROUND(ST_DISTANCE(ST_GEOMFROMTEXT('MULTIPOINT((0 0))', 13001001), ST_GEOMFROMTEXT('POINT(0 50)', 13001001)), 3) AS d; # Gradians (lat-long), meridian at 10 grad East SELECT ROUND(ST_DISTANCE(ST_GEOMFROMTEXT('POINT(0 10)', 13001002), ST_GEOMFROMTEXT('POINT(0 -40)', 13001002)), 3) AS d; SELECT ROUND(ST_DISTANCE(ST_GEOMFROMTEXT('POINT(0 10)', 13001002), ST_GEOMFROMTEXT('MULTIPOINT((0 -40))', 13001002)), 3) AS d; SELECT ROUND(ST_DISTANCE(ST_GEOMFROMTEXT('MULTIPOINT((0 10))', 13001002), ST_GEOMFROMTEXT('POINT(0 -40)', 13001002)), 3) AS d; --echo # Trondheim (63.430492N, 10.395046E) - Bangalore (12.976679N, 77.593916E) # Degrees (lat-long) SELECT ROUND(ST_DISTANCE( ST_GEOMFROMTEXT('POINT(63.430492 10.395046)', 4326), ST_GEOMFROMTEXT('POINT(12.976679 77.593916)', 4326) ), 3) AS d; SELECT ROUND(ST_DISTANCE( ST_GEOMFROMTEXT('POINT(63.430492 10.395046)', 4326), ST_GEOMFROMTEXT('MULTIPOINT((12.976679 77.593916))', 4326) ), 3) AS d; SELECT ROUND(ST_DISTANCE( ST_GEOMFROMTEXT('MULTIPOINT((63.430492 10.395046))', 4326), ST_GEOMFROMTEXT('POINT(12.976679 77.593916)', 4326) ), 3) AS d; # Degreees (long-lat) SELECT ROUND(ST_DISTANCE( ST_GEOMFROMTEXT('POINT(10.395046 63.430492)', 13001000), ST_GEOMFROMTEXT('POINT(77.593916 12.976679)', 13001000) ), 3) AS d; SELECT ROUND(ST_DISTANCE( ST_GEOMFROMTEXT('POINT(10.395046 63.430492)', 13001000), ST_GEOMFROMTEXT('MULTIPOINT((77.593916 12.976679))', 13001000) ), 3) AS d; SELECT ROUND(ST_DISTANCE( ST_GEOMFROMTEXT('MULTIPOINT((10.395046 63.430492))', 13001000), ST_GEOMFROMTEXT('POINT(77.593916 12.976679)', 13001000) ), 3) AS d; # Gradians (lat-long) SELECT ROUND(ST_DISTANCE( ST_GEOMFROMTEXT('POINT(70.47832444444444 11.550051111111111)', 13001001), ST_GEOMFROMTEXT('POINT(14.418532222222222 86.21546222222221)', 13001001) ), 3) AS d; SELECT ROUND(ST_DISTANCE( ST_GEOMFROMTEXT('POINT(70.47832444444444 11.550051111111111)', 13001001), ST_GEOMFROMTEXT('MULTIPOINT((14.418532222222222 86.21546222222221))', 13001001) ), 3) AS d; SELECT ROUND(ST_DISTANCE( ST_GEOMFROMTEXT('MULTIPOINT((70.47832444444444 11.550051111111111))', 13001001), ST_GEOMFROMTEXT('POINT(14.418532222222222 86.21546222222221)', 13001001) ), 3) AS d; # Gradians (lat-long), meridian at 10 grad East SELECT ROUND(ST_DISTANCE( ST_GEOMFROMTEXT('POINT(70.47832444444444 -1.550051111111111)', 13001002), ST_GEOMFROMTEXT('POINT(14.418532222222222 -76.21546222222221)', 13001002) ), 3) AS d; SELECT ROUND(ST_DISTANCE( ST_GEOMFROMTEXT('POINT(70.47832444444444 -1.550051111111111)', 13001002), ST_GEOMFROMTEXT('MULTIPOINT((14.418532222222222 -76.21546222222221))', 13001002) ), 3) AS d; SELECT ROUND(ST_DISTANCE( ST_GEOMFROMTEXT('MULTIPOINT((70.47832444444444 -1.550051111111111))', 13001002), ST_GEOMFROMTEXT('POINT(14.418532222222222 -76.21546222222221)', 13001002) ), 3) AS d; --echo # Longitude out of range # Degrees (lat-long) # Due to floating point math, the limit is around +/- 180.00000000000017. # SRID=4326, long=180.000000000001, lat=0. SET @pt_long_above = x'E6100000010100000023000000008066400000000000000000'; --error ER_GEOMETRY_PARAM_LONGITUDE_OUT_OF_RANGE DO ST_DISTANCE( @pt_long_above, ST_SRID(ST_SWAPXY(ST_GEOMFROMTEXT('MULTIPOINT((0 0))')), 4326) ) AS d; # Just within range DO ST_DISTANCE( ST_SRID(ST_SWAPXY(ST_GEOMFROMTEXT('POINT(0 180)')), 4326), ST_SRID(ST_SWAPXY(ST_GEOMFROMTEXT('MULTIPOINT((0 0))')), 4326) ) AS d; # SRID=4326, long=-180.000000000001, lat=0. SET @pt_long_below = x'E6100000010100000023000000008066C00000000000000000'; --error ER_GEOMETRY_PARAM_LONGITUDE_OUT_OF_RANGE DO ST_DISTANCE( @pt_long_below, ST_SRID(ST_SWAPXY(ST_GEOMFROMTEXT('MULTIPOINT((0 0))')), 4326) ) AS d; # Just within range DO ST_DISTANCE( ST_SRID(ST_SWAPXY(ST_GEOMFROMTEXT('POINT(0 -179.999999999999)')), 4326), ST_SRID(ST_SWAPXY(ST_GEOMFROMTEXT('MULTIPOINT((0 0))')), 4326) ) AS d; # Degreees (long-lat) # Due to floating point math, the limit is around +/- 180.00000000000017. # SRID=13001000, long=180.000000000001, lat=0. SET @pt_long_above = x'2861C600010100000023000000008066400000000000000000'; --error ER_GEOMETRY_PARAM_LONGITUDE_OUT_OF_RANGE DO ST_DISTANCE( @pt_long_above, ST_SRID(ST_GEOMFROMTEXT('MULTIPOINT((0 0))'), 13001000) ) AS d; # Just within range DO ST_DISTANCE( ST_SRID(ST_GEOMFROMTEXT('POINT(180 0)'), 13001000), ST_SRID(ST_GEOMFROMTEXT('MULTIPOINT((0 0))'), 13001000) ) AS d; # SRID=13001000, long=-180.000000000001, lat=0. SET @pt_long_below = x'2861C600010100000023000000008066C00000000000000000'; --error ER_GEOMETRY_PARAM_LONGITUDE_OUT_OF_RANGE DO ST_DISTANCE( @pt_long_below, ST_SRID(ST_GEOMFROMTEXT('MULTIPOINT((0 0))'), 13001000) ) AS d; # Just within range DO ST_DISTANCE( ST_SRID(ST_GEOMFROMTEXT('POINT(-179.999999999999 0)'), 13001000), ST_SRID(ST_GEOMFROMTEXT('MULTIPOINT((0 0))'), 13001000) ) AS d; # Gradians (lat-long) # Due to floating point math, the limit is around +/- 200.0000000000002. # SRID=13001001, long=200.000000000001, lat=0. SET @pt_long_above = x'2961C600010100000023000000000069400000000000000000'; --error ER_GEOMETRY_PARAM_LONGITUDE_OUT_OF_RANGE DO ST_DISTANCE( @pt_long_above, ST_SRID(ST_SWAPXY(ST_GEOMFROMTEXT('MULTIPOINT((0 0))')), 13001001) ) AS d; # Just within range DO ST_DISTANCE( ST_SRID(ST_SWAPXY(ST_GEOMFROMTEXT('POINT(0 200)')), 13001001), ST_SRID(ST_SWAPXY(ST_GEOMFROMTEXT('MULTIPOINT((0 0))')), 13001001) ) AS d; # SRID=13001001, long=-200.000000000001, lat=0. SET @pt_long_below = x'2961C600010100000023000000000069C00000000000000000'; --error ER_GEOMETRY_PARAM_LONGITUDE_OUT_OF_RANGE DO ST_DISTANCE( @pt_long_below, ST_SRID(ST_SWAPXY(ST_GEOMFROMTEXT('MULTIPOINT((0 0))')), 13001001) ) AS d; # Just within range DO ST_DISTANCE( ST_SRID(ST_SWAPXY(ST_GEOMFROMTEXT('POINT(0 -199.999999999999)')), 13001001), ST_SRID(ST_SWAPXY(ST_GEOMFROMTEXT('MULTIPOINT((0 0))')), 13001001) ) AS d; # Gradians (lat-long), meridian at 10 grad East # Due to floating point math, the limit is around +/- 200.0000000000002. # SRID=13001002, long=200.000000000001, lat=0. SET @pt_long_above = x'2A61C600010100000023000000000069400000000000000000'; --error ER_GEOMETRY_PARAM_LONGITUDE_OUT_OF_RANGE DO ST_DISTANCE( @pt_long_above, ST_SRID(ST_SWAPXY(ST_GEOMFROMTEXT('MULTIPOINT((0 0))')), 13001002) ) AS d; # Just within range DO ST_DISTANCE( ST_SRID(ST_SWAPXY(ST_GEOMFROMTEXT('POINT(0 200)')), 13001002), ST_SRID(ST_SWAPXY(ST_GEOMFROMTEXT('MULTIPOINT((0 0))')), 13001002) ) AS d; # SRID=13001002, long=-200.000000000001, lat=0. SET @pt_long_below = x'2A61C600010100000023000000000069C00000000000000000'; --error ER_GEOMETRY_PARAM_LONGITUDE_OUT_OF_RANGE DO ST_DISTANCE( @pt_long_below, ST_SRID(ST_SWAPXY(ST_GEOMFROMTEXT('MULTIPOINT((0 0))')), 13001002) ) AS d; # Just within range DO ST_DISTANCE( ST_SRID(ST_SWAPXY(ST_GEOMFROMTEXT('POINT(0 -199.999999999999)')), 13001002), ST_SRID(ST_SWAPXY(ST_GEOMFROMTEXT('MULTIPOINT((0 0))')), 13001002) ) AS d; # Radians (lat-long) # The limit is around +/- 3.141592653589793. # SRID=13001003, long=3.141592653589794, lat=0. SET @pt_long_above = x'2B61C60001010000001A2D4454FB2109400000000000000000'; --error ER_GEOMETRY_PARAM_LONGITUDE_OUT_OF_RANGE DO ST_DISTANCE( @pt_long_above, ST_SRID(ST_SWAPXY(ST_GEOMFROMTEXT('MULTIPOINT((0 0))')), 13001003) ) AS d; # Just within range DO ST_DISTANCE( ST_SRID(ST_SWAPXY(ST_GEOMFROMTEXT('POINT(0 3.141592653589793)')), 13001003), ST_SRID(ST_SWAPXY(ST_GEOMFROMTEXT('MULTIPOINT((0 0))')), 13001003) ) AS d; # SRID=13001003, long=-3.141592653589793, lat=0. SET @pt_long_below = x'2B61C6000101000000182D4454FB2109C00000000000000000'; --error ER_GEOMETRY_PARAM_LONGITUDE_OUT_OF_RANGE DO ST_DISTANCE( @pt_long_below, ST_SRID(ST_SWAPXY(ST_GEOMFROMTEXT('MULTIPOINT((0 0))')), 13001003) ) AS d; # Just within range DO ST_DISTANCE( ST_SRID(ST_SWAPXY(ST_GEOMFROMTEXT('POINT(0 -3.141592653589792)')), 13001003), ST_SRID(ST_SWAPXY(ST_GEOMFROMTEXT('MULTIPOINT((0 0))')), 13001003) ) AS d; --echo # Latitude out of range # Degrees (lat-long) # Due to floating point math, the limit is around +/- 90.00000000000009. # SRID=4326, long=0, lat=90.0000000000001. SET @pt_lat_above = x'E6100000010100000000000000000000000700000000805640'; --error ER_GEOMETRY_PARAM_LATITUDE_OUT_OF_RANGE DO ST_DISTANCE( @pt_lat_above, ST_SRID(ST_SWAPXY(ST_GEOMFROMTEXT('MULTIPOINT((0 0))')), 4326) ) AS d; # Just within range DO ST_DISTANCE( ST_SRID(ST_SWAPXY(ST_GEOMFROMTEXT('POINT(90 0)')), 4326), ST_SRID(ST_SWAPXY(ST_GEOMFROMTEXT('MULTIPOINT((0 0))')), 4326) ) AS d; # SRID=4326, long=0, lat=-90.0000000000001. SET @pt_lat_below = x'E61000000101000000000000000000000007000000008056C0'; --error ER_GEOMETRY_PARAM_LATITUDE_OUT_OF_RANGE DO ST_DISTANCE( @pt_lat_below, ST_SRID(ST_SWAPXY(ST_GEOMFROMTEXT('MULTIPOINT((0 0))')), 4326) ) AS d; # Just within range DO ST_DISTANCE( ST_SRID(ST_SWAPXY(ST_GEOMFROMTEXT('POINT(-90 0)')), 4326), ST_SRID(ST_SWAPXY(ST_GEOMFROMTEXT('MULTIPOINT((0 0))')), 4326) ) AS d; # Degreees (long-lat) # Due to floating point math, the limit is around +/- 90.00000000000009. # SRID=13001000, long=0, lat=90.0000000000001. SET @pt_lat_above = x'2861C600010100000000000000000000000700000000805640'; --error ER_GEOMETRY_PARAM_LATITUDE_OUT_OF_RANGE DO ST_DISTANCE( @pt_lat_above, ST_SRID(ST_GEOMFROMTEXT('MULTIPOINT((0 0))'), 13001000) ) AS d; # Just within range DO ST_DISTANCE( ST_SRID(ST_GEOMFROMTEXT('POINT(0 90)'), 13001000), ST_SRID(ST_GEOMFROMTEXT('MULTIPOINT((0 0))'), 13001000) ) AS d; # SRID=13001000, long=0, lat=-90.0000000000001. SET @pt_lat_below = x'2861C6000101000000000000000000000007000000008056C0'; --error ER_GEOMETRY_PARAM_LATITUDE_OUT_OF_RANGE DO ST_DISTANCE( @pt_lat_below, ST_SRID(ST_GEOMFROMTEXT('MULTIPOINT((0 0))'), 13001000) ) AS d; # Just within range DO ST_DISTANCE( ST_SRID(ST_GEOMFROMTEXT('POINT(0 -90)'), 13001000), ST_SRID(ST_GEOMFROMTEXT('MULTIPOINT((0 0))'), 13001000) ) AS d; # Gradians (lat-long) # Due to floating point math, the limit is around +/- 100.0000000000001. # SRID=13001001, long=0, lat=100.000000000001. SET @pt_lat_above = x'2961C600010100000000000000000000004600000000005940'; --error ER_GEOMETRY_PARAM_LATITUDE_OUT_OF_RANGE DO ST_DISTANCE( @pt_lat_above, ST_SRID(ST_SWAPXY(ST_GEOMFROMTEXT('MULTIPOINT((0 0))')), 13001001) ) AS d; # Just within range DO ST_DISTANCE( ST_SRID(ST_SWAPXY(ST_GEOMFROMTEXT('POINT(100 0)')), 13001001), ST_SRID(ST_SWAPXY(ST_GEOMFROMTEXT('MULTIPOINT((0 0))')), 13001001) ) AS d; # SRID=13001001, long=0, lat=-100.000000000001. SET @pt_lat_below = x'2961C6000101000000000000000000000046000000000059C0'; --error ER_GEOMETRY_PARAM_LATITUDE_OUT_OF_RANGE DO ST_DISTANCE( @pt_lat_below, ST_SRID(ST_SWAPXY(ST_GEOMFROMTEXT('MULTIPOINT((0 0))')), 13001001) ) AS d; # Just within range DO ST_DISTANCE( ST_SRID(ST_SWAPXY(ST_GEOMFROMTEXT('POINT(-100 0)')), 13001001), ST_SRID(ST_SWAPXY(ST_GEOMFROMTEXT('MULTIPOINT((0 0))')), 13001001) ) AS d; # Gradians (lat-long), meridian at 10 grad East # Due to floating point math, the limit is around +/- 100.0000000000001. # SRID=13001002, long=0, lat=100.000000000001. SET @pt_lat_above = x'2A61C600010100000000000000000000004600000000005940'; --error ER_GEOMETRY_PARAM_LATITUDE_OUT_OF_RANGE DO ST_DISTANCE( @pt_lat_above, ST_SRID(ST_SWAPXY(ST_GEOMFROMTEXT('MULTIPOINT((0 0))')), 13001002) ) AS d; # Just within range DO ST_DISTANCE( ST_SRID(ST_SWAPXY(ST_GEOMFROMTEXT('POINT(100 0)')), 13001002), ST_SRID(ST_SWAPXY(ST_GEOMFROMTEXT('MULTIPOINT((0 0))')), 13001002) ) AS d; # SRID=13001002, long=0, lat=-100.000000000001. SET @pt_lat_below = x'2A61C6000101000000000000000000000046000000000059C0'; --error ER_GEOMETRY_PARAM_LATITUDE_OUT_OF_RANGE DO ST_DISTANCE( @pt_lat_below, ST_SRID(ST_SWAPXY(ST_GEOMFROMTEXT('MULTIPOINT((0 0))')), 13001002) ) AS d; # Just within range DO ST_DISTANCE( ST_SRID(ST_SWAPXY(ST_GEOMFROMTEXT('POINT(-100 0)')), 13001002), ST_SRID(ST_SWAPXY(ST_GEOMFROMTEXT('MULTIPOINT((0 0))')), 13001002) ) AS d; # Radians (lat-long) # The limit is around +/- 1.5707963267948966. # SRID=13001003, long=0, lat=1.5707963267948967. SET @pt_lat_above = x'2B61C60001010000000000000000000000192D4454FB21F93F'; --error ER_GEOMETRY_PARAM_LATITUDE_OUT_OF_RANGE DO ST_DISTANCE( @pt_lat_above, ST_SRID(ST_SWAPXY(ST_GEOMFROMTEXT('MULTIPOINT((0 0))')), 13001003) ) AS d; # Just within range DO ST_DISTANCE( ST_SRID(ST_SWAPXY(ST_GEOMFROMTEXT('POINT(1.5707963267948966 0)')), 13001003), ST_SRID(ST_SWAPXY(ST_GEOMFROMTEXT('MULTIPOINT((0 0))')), 13001003) ) AS d; # SRID=13001003, long=0, lat=-1.5707963267948967. SET @pt_lat_below = x'2B61C60001010000000000000000000000192D4454FB21F9BF'; --error ER_GEOMETRY_PARAM_LATITUDE_OUT_OF_RANGE DO ST_DISTANCE( @pt_lat_below, ST_SRID(ST_SWAPXY(ST_GEOMFROMTEXT('MULTIPOINT((0 0))')), 13001003) ) AS d; # Just within range DO ST_DISTANCE( ST_SRID(ST_SWAPXY(ST_GEOMFROMTEXT('POINT(-1.5707963267948965 0)')), 13001003), ST_SRID(ST_SWAPXY(ST_GEOMFROMTEXT('MULTIPOINT((0 0))')), 13001003) ) AS d; # Longitude out of range in a point in a multipoint. # SRID=4326, MULTIPOINT((0 0), (0 200)). SET @mpt_long_above = x'E6100000010400000002000000010100000000000000000000000000000000000000010100000000000000000069400000000000000000'; --error ER_GEOMETRY_PARAM_LONGITUDE_OUT_OF_RANGE DO ST_DISTANCE( @mpt_long_above, ST_SRID(ST_SWAPXY(ST_GEOMFROMTEXT('POINT(1 1)')), 4326) ) AS d; # Latitude out of range in a point in a multipoint. # SRID=4326, MULTIPOINT((0 0), (100 0)). SET @mpt_lat_above = x'E6100000010400000002000000010100000000000000000000000000000000000000010100000000000000000000000000000000005940'; --error ER_GEOMETRY_PARAM_LATITUDE_OUT_OF_RANGE DO ST_DISTANCE( @mpt_lat_above, ST_SRID(ST_SWAPXY(ST_GEOMFROMTEXT('POINT(1 1)')), 4326) ) AS d; DROP SPATIAL REFERENCE SYSTEM 13001000; DROP SPATIAL REFERENCE SYSTEM 13001001; DROP SPATIAL REFERENCE SYSTEM 13001002; DROP SPATIAL REFERENCE SYSTEM 13001003; --echo # Spherical SRS SELECT ROUND(ST_DISTANCE( ST_GEOMFROMTEXT('POINT(0 0)', 4053), ST_GEOMFROMTEXT('POINT(90 0)', 4053)), 3 ) AS d; SELECT ROUND(ST_DISTANCE( ST_GEOMFROMTEXT('POINT(0 0)', 4053), ST_GEOMFROMTEXT('POINT(0 45)', 4053)), 3 ) AS d; SELECT ROUND(ST_DISTANCE( ST_GEOMFROMTEXT('POINT(63.430492 10.395046)', 4053), ST_GEOMFROMTEXT('POINT(12.976679 77.593916)', 4053)), 3 ) AS d; --echo # Input parsing # NaN # POINT(0 NaN) and MULTIPOINT((0 0)) --error ER_GIS_INVALID_DATA DO ST_DISTANCE( x'E610000001010000000000000000000000FFFFFFFFFFFFFFFF', x'E6100000010400000001000000010100000000000000000000000000000000000000' ); # MULTIPOINT((NaN 0)) and POINT(0 0) --error ER_GIS_INVALID_DATA DO ST_DISTANCE( x'000000000104000000010000000101000000FFFFFFFFFFFFFFFF0000000000000000', x'00000000010100000000000000000000000000000000000000' ); # Inf --error ER_GIS_INVALID_DATA DO ST_DISTANCE(POINT(1.7e+308, 1.7e308), POINT(-1.7e308, -1.7e308)); --disable_result_log SELECT UNIT_NAME, CONVERSION_FACTOR, UNIT_TYPE, DESCRIPTION FROM INFORMATION_SCHEMA.ST_UNITS_OF_MEASURE; --enable_result_log SELECT ROUND(ST_DISTANCE( ST_GEOMFROMTEXT('POINT(63.430492 10.395046)', 4053), ST_GEOMFROMTEXT('POINT(12.976679 77.593916)', 4053),'metre'), 5) AS d; SELECT ST_DISTANCE( ST_GEOMFROMTEXT('POINT(63.430492 10.395046)', 2001), ST_GEOMFROMTEXT('POINT(12.976679 77.593916)', 2001),'metre') AS d; --error ER_UNIT_NOT_FOUND SELECT ST_DISTANCE( ST_GEOMFROMTEXT('POINT(63.430492 10.395046)', 4053), ST_GEOMFROMTEXT('POINT(12.976679 77.593916)', 4053),'meter') AS d; --error ER_GEOMETRY_IN_UNKNOWN_LENGTH_UNIT SELECT ST_DISTANCE( ST_GEOMFROMTEXT('POINT(63.430492 10.395046)'), ST_GEOMFROMTEXT('POINT(12.976679 77.593916)'),'metre') AS d; SET @A = 'POINT(0 0)'; SET @B = 'POINT(0.1 0.1)'; SET @A_SRID0 = ST_GEOMFROMTEXT(@A); SET @B_SRID0 = ST_GEOMFROMTEXT(@B); SET @A_WGS84 = ST_GEOMFROMTEXT(@A,4326); SET @B_WGS84 = ST_GEOMFROMTEXT(@B,4326); SET @A_EPSG4053 = ST_GEOMFROMTEXT(@A,4053); SET @B_EPSG4053 = ST_GEOMFROMTEXT(@B,4053); SELECT ROUND(ST_DISTANCE(@A_WGS84,@B_WGS84), 5); # this and the next should be the same SELECT ROUND(ST_DISTANCE(@A_WGS84,@B_WGS84, "metre"), 5); --error ER_UNIT_NOT_FOUND SELECT ST_DISTANCE(@A_WGS84,@B_WGS84, "meter"); SELECT ROUND(ST_DISTANCE(@A_EPSG4053, @B_EPSG4053), 5); # this and the next should be the same SELECT ROUND(ST_DISTANCE(@A_EPSG4053, @B_EPSG4053, "metre"), 5); SELECT ROUND(ST_DISTANCE(@A_EPSG4053, @B_EPSG4053, "Clarke's link"), 5); # check that apostrophes are handled SELECT ST_DISTANCE(@A_EPSG4053, @B_EPSG4053, NULL); # check that null values are handled, SELECT ST_DISTANCE(@A_EPSG4053, NULL, "Clarke's link"); # Result is NULL when any geometry argument is NULL SELECT ST_DISTANCE(NULL, @B_EPSG4053, "Clarke's link"); SELECT ST_DISTANCE(@A_EPSG4053, NULL, NULL); SELECT ST_DISTANCE(NULL, @B_EPSG4053, NULL); SELECT ST_DISTANCE(NULL,NULL, "Clarke's link"); SELECT ST_DISTANCE(NULL, NULL, NULL); SELECT ROUND(ST_DISTANCE(@A_WGS84, @B_WGS84, "British link (Sears 1922)"), 5); SELECT ROUND(ST_DISTANCE(@A_EPSG4053, @B_EPSG4053, "Clarke's link") , 5); --error ER_GEOMETRY_IN_UNKNOWN_LENGTH_UNIT SELECT ST_DISTANCE(@A_SRID0, @B_SRID0, "metre"); SET @EMPTY_COLLECTION_A = 'GEOMETRYCOLLECTION EMPTY'; SET @EMPTY_COLLECTION_SRID0_A = ST_GEOMFROMTEXT(@EMPTY_COLLECTION_A); SET @EMPTY_COLLECTION_SRID4326_A = ST_GEOMFROMTEXT(@EMPTY_COLLECTION_A,4326); SELECT ST_DISTANCE( @EMPTY_COLLECTION_SRID0_A, @A_SRID0); SELECT ST_DISTANCE( @A_SRID0, @EMPTY_COLLECTION_SRID0_A); SELECT ST_DISTANCE( @EMPTY_COLLECTION_SRID4326_A, @A_WGS84); SELECT ST_DISTANCE( @A_WGS84, @EMPTY_COLLECTION_SRID4326_A);