Current Path : /home/usr.opt/mysql57/mysql-test/suite/gis/t/ |
FreeBSD hs32.drive.ne.jp 9.1-RELEASE FreeBSD 9.1-RELEASE #1: Wed Jan 14 12:18:08 JST 2015 root@hs32.drive.ne.jp:/sys/amd64/compile/hs32 amd64 |
Current File : //home/usr.opt/mysql57/mysql-test/suite/gis/t/spatial_utility_function_distance_sphere.test |
############################################################################### # # # ST_Distance_Sphere returns the minimum distance on the earth in meters # # between two lon/lat geometries. Uses a spherical earth and a configurable # # radius, which is 6370986 meters by default. # # # # Creation Date: 2014-12-02 # # Author : Pavan Naik # # # ############################################################################### --source include/have_geometry.inc ############################################################################################ # 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_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))'; --echo #INSERT base star 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)), (116,ST_GEOMFROMTEXT(@star_collection_multilinestr)); --echo # Checking the integrity of the above create/insert statements --echo # 17 rows. SELECT count(ST_ASTEXT(g) != 'NULL') FROM gis_geometrycollection; --echo ##################################################################################### --echo # ST_DISTANCE_SPHERE(point, point) --echo ##################################################################################### SELECT ST_DISTANCE_SPHERE(ST_GEOMFROMTEXT('POINT(0 0)'), ST_GEOMFROMTEXT('POINT(0 0)')); SELECT ST_DISTANCE_SPHERE(ST_GEOMFROMTEXT('POINT(0 0)'), ST_GEOMFROMTEXT('POINT(180 0)')); --replace_numeric_round 5 SELECT ST_DISTANCE_SPHERE(ST_GEOMFROMTEXT('POINT(0 0)'), ST_GEOMFROMTEXT('POINT(0 90)')); --replace_numeric_round 5 SELECT ST_DISTANCE_SPHERE(ST_GEOMFROMTEXT('POINT(0 0)'), ST_GEOMFROMTEXT('POINT(-179 0)')); --replace_numeric_round 5 SELECT ST_DISTANCE_SPHERE(ST_GEOMFROMTEXT('POINT(0 0)'), ST_GEOMFROMTEXT('POINT(0 -90)')); --replace_numeric_round 5 SELECT ST_DISTANCE_SPHERE(ST_GEOMFROMTEXT('POINT(0 0)'), ST_GEOMFROMTEXT('POINT(180 90)')); --replace_numeric_round 5 SELECT ST_DISTANCE_SPHERE(ST_GEOMFROMTEXT('POINT(0 0)'), ST_GEOMFROMTEXT('POINT(180 -90)')); --replace_numeric_round 5 SELECT ST_DISTANCE_SPHERE(ST_GEOMFROMTEXT('POINT(0 0)'), ST_GEOMFROMTEXT('POINT(-179 90)')); --replace_numeric_round 5 SELECT ST_DISTANCE_SPHERE(ST_GEOMFROMTEXT('POINT(0 0)'), ST_GEOMFROMTEXT('POINT(-179 -90)')); SELECT ST_DISTANCE_SPHERE(ST_GEOMFROMTEXT('POINT(0 0)'), ST_GEOMFROMTEXT('POINT(1 1)')); SELECT ST_DISTANCE_SPHERE(ST_GEOMFROMTEXT('POINT(0 0)'), ST_GEOMFROMTEXT('POINT(0.0000 -0.000)')); SELECT ST_DISTANCE_SPHERE(ST_GEOMFROMTEXT('POINT(0 0)'), ST_GEOMFROMTEXT('POINT(1 1)')); SELECT ST_DISTANCE_SPHERE(ST_GEOMFROMTEXT('POINT(0 0)'), ST_GEOMFROMTEXT('POINT(1 -1)')); SELECT ST_DISTANCE_SPHERE(ST_GEOMFROMTEXT('POINT(0 0)'), ST_GEOMFROMTEXT('POINT(-1 1)')); SELECT ST_DISTANCE_SPHERE(ST_GEOMFROMTEXT('POINT(0 0)'), ST_GEOMFROMTEXT('POINT(-1 -1)')); SELECT ST_DISTANCE_SPHERE(ST_GEOMFROMTEXT('POINT(0 0)'), ST_GEOMFROMTEXT('POINT(90 45)')); SELECT ST_DISTANCE_SPHERE(ST_GEOMFROMTEXT('POINT(0 0)'), ST_GEOMFROMTEXT('POINT(90 -45)')); SELECT ST_DISTANCE_SPHERE(ST_GEOMFROMTEXT('POINT(0 0)'), ST_GEOMFROMTEXT('POINT(-90 45)')); SELECT ST_DISTANCE_SPHERE(ST_GEOMFROMTEXT('POINT(0 0)'), ST_GEOMFROMTEXT('POINT(-90 -45)')); SELECT ST_DISTANCE_SPHERE(ST_GEOMFROMTEXT('POINT(180 90)'), ST_GEOMFROMTEXT('POINT(180 90)')); SELECT ST_DISTANCE_SPHERE(ST_GEOMFROMTEXT('POINT(180 -90)'), ST_GEOMFROMTEXT('POINT(180 -90)')); SELECT ST_DISTANCE_SPHERE(ST_GEOMFROMTEXT('POINT(-179.999 -90)'), ST_GEOMFROMTEXT('POINT(-179.999 -90)')); SELECT ST_DISTANCE_SPHERE(ST_GEOMFROMTEXT('POINT(-179.999 -89.999)'), ST_GEOMFROMTEXT('POINT(-179.999 -89.999)')); --replace_numeric_round 15 SELECT ST_DISTANCE_SPHERE(ST_GEOMFROMTEXT('POINT(-179.9 90)'), ST_GEOMFROMTEXT('POINT(-179.99 90)')); --replace_numeric_round 15 SELECT ST_DISTANCE_SPHERE(ST_GEOMFROMTEXT('POINT(-179.9 -90)'), ST_GEOMFROMTEXT('POINT(-179.9999 -90)')); --echo ##################################################################################### --echo # ST_DISTANCE_SPHERE(point, multipoint) --echo ##################################################################################### SELECT ST_DISTANCE_SPHERE(ST_GEOMFROMTEXT('POINT(0 0)'), ST_GEOMFROMTEXT('MULTIPOINT(0 0)')); SELECT ST_DISTANCE_SPHERE(ST_GEOMFROMTEXT('POINT(0 0)'), ST_GEOMFROMTEXT('MULTIPOINT(180 0)')); --replace_numeric_round 5 SELECT ST_DISTANCE_SPHERE(ST_GEOMFROMTEXT('POINT(0 0)'), ST_GEOMFROMTEXT('MULTIPOINT(0 90)')); --replace_numeric_round 5 SELECT ST_DISTANCE_SPHERE(ST_GEOMFROMTEXT('POINT(0 0)'), ST_GEOMFROMTEXT('MULTIPOINT(-179 0)')); SELECT ST_DISTANCE_SPHERE(ST_GEOMFROMTEXT('POINT(0 0)'), ST_GEOMFROMTEXT('MULTIPOINT(0 0,1 1,2 2)')); SELECT ST_DISTANCE_SPHERE(ST_GEOMFROMTEXT('POINT(0 0)'), ST_GEOMFROMTEXT('MULTIPOINT(0 0,180 90)')); SELECT ST_DISTANCE_SPHERE(ST_GEOMFROMTEXT('POINT(0 0)'), ST_GEOMFROMTEXT('MULTIPOINT(180 90,0 0,-179 -90)')); SELECT ST_DISTANCE_SPHERE(ST_GEOMFROMTEXT('POINT(0 0)'), ST_GEOMFROMTEXT('MULTIPOINT(0 1)')); SELECT ST_DISTANCE_SPHERE(ST_GEOMFROMTEXT('POINT(0 0)'), ST_GEOMFROMTEXT('MULTIPOINT(0 1,1 0,1 1)')); --replace_numeric_round 14 SELECT ST_DISTANCE_SPHERE(ST_GEOMFROMTEXT('POINT(180 90)'), ST_GEOMFROMTEXT('MULTIPOINT(180 -90,-179 90,-179 -90)')); SELECT ST_DISTANCE_SPHERE(ST_GEOMFROMTEXT('POINT(37 -42)'), ST_GEOMFROMTEXT('MULTIPOINT(57 32)')); SELECT ST_DISTANCE_SPHERE(ST_GEOMFROMTEXT('POINT(-85 48)'), ST_GEOMFROMTEXT('MULTIPOINT(159 -49)')); SELECT ST_DISTANCE_SPHERE(ST_GEOMFROMTEXT('POINT(168 -21)'), ST_GEOMFROMTEXT('MULTIPOINT(-22 -32)')); --replace_numeric_round 5 SELECT ST_DISTANCE_SPHERE(ST_GEOMFROMTEXT('POINT(-64 67)'), ST_GEOMFROMTEXT('MULTIPOINT(-103 45,155 57,-166 85)')); SELECT ST_DISTANCE_SPHERE(ST_GEOMFROMTEXT('POINT(-36 -41)'), ST_GEOMFROMTEXT('MULTIPOINT(-37 45,-49 23,97 -19)')); SELECT ST_DISTANCE_SPHERE(ST_GEOMFROMTEXT('POINT(138 86)'), ST_GEOMFROMTEXT('MULTIPOINT(15 -79,-110 -76,49 31)')); --replace_numeric_round 5 SELECT ST_DISTANCE_SPHERE(ST_GEOMFROMTEXT('POINT(164 -41)'), ST_GEOMFROMTEXT('MULTIPOINT(-11 2,-81 3,161 62,-119 31)')); --replace_numeric_round 5 SELECT ST_DISTANCE_SPHERE(ST_GEOMFROMTEXT('POINT(-106 -23)'), ST_GEOMFROMTEXT('MULTIPOINT(-152 72,89 -3,-23 -42,126 59)')); --replace_numeric_round 5 SELECT ST_DISTANCE_SPHERE(ST_GEOMFROMTEXT('POINT(168 -15)'), ST_GEOMFROMTEXT('MULTIPOINT(68 73,157 -55,-178 -29,46 78,-133 59,180 59)')); --replace_numeric_round 5 SELECT ST_DISTANCE_SPHERE(ST_GEOMFROMTEXT('POINT(106 76)'), ST_GEOMFROMTEXT('MULTIPOINT(53 20,148 -40,-61 -90,170 -37,-64 -82,-167 85)')); SELECT ST_DISTANCE_SPHERE(ST_GEOMFROMTEXT('POINT(-50 36)'), ST_GEOMFROMTEXT('MULTIPOINT(-32 -64,-116 -35,148 89,-75 16,-99 87,-51 -2,-113 24,93 46,168 53)')); --replace_numeric_round 5 SELECT ST_DISTANCE_SPHERE(ST_GEOMFROMTEXT('POINT(-139 54)'), ST_GEOMFROMTEXT('MULTIPOINT(151 -57,-74 61,10 28,170 -47,97 -45,-5 -82,121 -21,-96 -44,81 -68)')); --echo ##################################################################################### --echo # ST_DISTANCE_SPHERE(multipoint, point) --echo ##################################################################################### SELECT ST_DISTANCE_SPHERE(ST_GEOMFROMTEXT('MULTIPOINT(0 0)'), ST_GEOMFROMTEXT('POINT(0 0)')); SELECT ST_DISTANCE_SPHERE(ST_GEOMFROMTEXT('MULTIPOINT(0 0)'), ST_GEOMFROMTEXT('POINT(180 0)')); --replace_numeric_round 5 SELECT ST_DISTANCE_SPHERE(ST_GEOMFROMTEXT('MULTIPOINT(0 0)'), ST_GEOMFROMTEXT('POINT(0 90)')); --replace_numeric_round 5 SELECT ST_DISTANCE_SPHERE(ST_GEOMFROMTEXT('MULTIPOINT(0 0)'), ST_GEOMFROMTEXT('POINT(-179 0)')); SELECT ST_DISTANCE_SPHERE(ST_GEOMFROMTEXT('MULTIPOINT(0 0,1 1,2 2)'), ST_GEOMFROMTEXT('POINT(0 0)')); SELECT ST_DISTANCE_SPHERE(ST_GEOMFROMTEXT('MULTIPOINT(180 90,0 0,180 -90)'), ST_GEOMFROMTEXT('POINT(-0 0)')); --replace_numeric_round 5 SELECT ST_DISTANCE_SPHERE(ST_GEOMFROMTEXT('MULTIPOINT(-179 90,0 0,-179 -90)'), ST_GEOMFROMTEXT('POINT(-179 0)')); SELECT ST_DISTANCE_SPHERE(ST_GEOMFROMTEXT('MULTIPOINT(-179 90,0 0,-179 -90)'), ST_GEOMFROMTEXT('POINT(-179 -90)')); SELECT ST_DISTANCE_SPHERE(ST_GEOMFROMTEXT('MULTIPOINT(-172 -70)'), ST_GEOMFROMTEXT('POINT(45 90)')); SELECT ST_DISTANCE_SPHERE(ST_GEOMFROMTEXT('MULTIPOINT(-157 -67)'), ST_GEOMFROMTEXT('POINT(-92 -88)')); SELECT ST_DISTANCE_SPHERE(ST_GEOMFROMTEXT('MULTIPOINT(156 -64,-96 57,-15 -18)'), ST_GEOMFROMTEXT('POINT(-73 -1)')); SELECT ST_DISTANCE_SPHERE(ST_GEOMFROMTEXT('MULTIPOINT(-110 43,-79 -82,-32 24)'), ST_GEOMFROMTEXT('POINT(61 27)')); --replace_numeric_round 5 SELECT ST_DISTANCE_SPHERE(ST_GEOMFROMTEXT('MULTIPOINT(-85 87,-155 48,-163 -84)'), ST_GEOMFROMTEXT('POINT(-95 84)')); SELECT ST_DISTANCE_SPHERE(ST_GEOMFROMTEXT('MULTIPOINT(33 -49,174 -25,-4 -56)'), ST_GEOMFROMTEXT('POINT(48 46)')); SELECT ST_DISTANCE_SPHERE(ST_GEOMFROMTEXT('MULTIPOINT(-36 -87,-75 20,-157 78)'), ST_GEOMFROMTEXT('POINT(-165 18)')); SELECT ST_DISTANCE_SPHERE(ST_GEOMFROMTEXT('MULTIPOINT(151 17,-150 -43,-165 76,87 53)'), ST_GEOMFROMTEXT('POINT(152 27)')); SELECT ST_DISTANCE_SPHERE(ST_GEOMFROMTEXT('MULTIPOINT(-159 -88,-177 -82,17 76,79 1)'), ST_GEOMFROMTEXT('POINT(35 -74)')); SELECT ST_DISTANCE_SPHERE(ST_GEOMFROMTEXT('MULTIPOINT(-130 -20,-118 -63,-57 0)'), ST_GEOMFROMTEXT('POINT(-156 89)')); --replace_numeric_round 5 SELECT ST_DISTANCE_SPHERE(ST_GEOMFROMTEXT('MULTIPOINT(-84 25,-52 53,125 -50,-171 51,55 -13,-4 -69)'), ST_GEOMFROMTEXT('POINT(-127 52)')); --replace_numeric_round 5 SELECT ST_DISTANCE_SPHERE(ST_GEOMFROMTEXT('MULTIPOINT(56 -45,158 84,112 2,85 21,88 89,-151 33,-158 40)'), ST_GEOMFROMTEXT('POINT(-172 87)')); SELECT ST_DISTANCE_SPHERE(ST_GEOMFROMTEXT('MULTIPOINT(-6 -56,-73 54,20 -74,-160 72,-4 42,-120 -62,-54 -8,-85 48,159 -49,100 -75)'), ST_GEOMFROMTEXT('POINT(167 -17)')); --echo ##################################################################################### --echo # ST_DISTANCE_SPHERE(multipoint, multipoint) --echo ##################################################################################### SELECT ST_DISTANCE_SPHERE(ST_GEOMFROMTEXT('MULTIPOINT(0 0)'), ST_GEOMFROMTEXT('MULTIPOINT(0 0)')); SELECT ST_DISTANCE_SPHERE(ST_GEOMFROMTEXT('MULTIPOINT(0 0)'), ST_GEOMFROMTEXT('MULTIPOINT(180 0)')); --replace_numeric_round 5 SELECT ST_DISTANCE_SPHERE(ST_GEOMFROMTEXT('MULTIPOINT(0 0)'), ST_GEOMFROMTEXT('MULTIPOINT(0 90)')); --replace_numeric_round 5 SELECT ST_DISTANCE_SPHERE(ST_GEOMFROMTEXT('MULTIPOINT(0 0)'), ST_GEOMFROMTEXT('MULTIPOINT(-179 0)')); SELECT ST_DISTANCE_SPHERE(ST_GEOMFROMTEXT('MULTIPOINT(0 0,1 1,2 2)'), ST_GEOMFROMTEXT('MULTIPOINT(1 1,0 0,2 2)')); SELECT ST_DISTANCE_SPHERE(ST_GEOMFROMTEXT('MULTIPOINT(180 90,0 0)'), ST_GEOMFROMTEXT('MULTIPOINT(180 90)')); SELECT ST_DISTANCE_SPHERE(ST_GEOMFROMTEXT('MULTIPOINT(180 0,0 0)'), ST_GEOMFROMTEXT('MULTIPOINT(180 0,0 90)')); --replace_numeric_round 5 SELECT ST_DISTANCE_SPHERE(ST_GEOMFROMTEXT('MULTIPOINT(-179 90,0 0)'), ST_GEOMFROMTEXT('MULTIPOINT(-179 0,0 -90)')); SELECT ST_DISTANCE_SPHERE(ST_GEOMFROMTEXT('MULTIPOINT(111 11,11 1)'), ST_GEOMFROMTEXT('MULTIPOINT(1 11,11 11)')); SELECT ST_DISTANCE_SPHERE(ST_GEOMFROMTEXT('MULTIPOINT(10 10,20 20,30 30)'), ST_GEOMFROMTEXT('MULTIPOINT(15 15,20 20,25 25)')); SELECT ST_DISTANCE_SPHERE(ST_GEOMFROMTEXT('MULTIPOINT(-10 -10,-20 -20,-30 -30)'), ST_GEOMFROMTEXT('MULTIPOINT(180 0,-30 -30,180 -90)')); SELECT ST_DISTANCE_SPHERE(ST_GEOMFROMTEXT('MULTIPOINT(-150 -79)'), ST_GEOMFROMTEXT('MULTIPOINT(145 -2)')); --replace_numeric_round 5 SELECT ST_DISTANCE_SPHERE(ST_GEOMFROMTEXT('MULTIPOINT(164 -37)'), ST_GEOMFROMTEXT('MULTIPOINT(67 59)')); SELECT ST_DISTANCE_SPHERE(ST_GEOMFROMTEXT('MULTIPOINT(135 62)'), ST_GEOMFROMTEXT('MULTIPOINT(-116 -22)')); --replace_numeric_round 5 SELECT ST_DISTANCE_SPHERE(ST_GEOMFROMTEXT('MULTIPOINT(-123 85)'), ST_GEOMFROMTEXT('MULTIPOINT(-54 -40)')); SELECT ST_DISTANCE_SPHERE(ST_GEOMFROMTEXT('MULTIPOINT(152 43)'), ST_GEOMFROMTEXT('MULTIPOINT(106 76,53 20,148 -40)')); SELECT ST_DISTANCE_SPHERE(ST_GEOMFROMTEXT('MULTIPOINT(-177 -88,-165 9,153 40,2 17)'), ST_GEOMFROMTEXT('MULTIPOINT(-150 -4)')); SELECT ST_DISTANCE_SPHERE(ST_GEOMFROMTEXT('MULTIPOINT(154 84,-124 37,17 50)'), ST_GEOMFROMTEXT('MULTIPOINT(42 34)')); --replace_numeric_round 5 SELECT ST_DISTANCE_SPHERE(ST_GEOMFROMTEXT('MULTIPOINT(88 -65,49 85,68 77)'), ST_GEOMFROMTEXT('MULTIPOINT(125 82,-83 -5,3 -40)')); --replace_numeric_round 5 SELECT ST_DISTANCE_SPHERE(ST_GEOMFROMTEXT('MULTIPOINT(174 59,91 24,26 28)'), ST_GEOMFROMTEXT('MULTIPOINT(-35 -33,-171 -37,-30 -43)')); --replace_numeric_round 5 SELECT ST_DISTANCE_SPHERE(ST_GEOMFROMTEXT('MULTIPOINT(-140 -63,103 -42,160 -53)'), ST_GEOMFROMTEXT('MULTIPOINT(-78 -80,-133 -24,73 -15)')); SELECT ST_DISTANCE_SPHERE(ST_GEOMFROMTEXT('MULTIPOINT(137 -65,-63 13,38 9)'), ST_GEOMFROMTEXT('MULTIPOINT(-166 -35,107 -18,-83 -18,91 -24)')); SELECT ST_DISTANCE_SPHERE(ST_GEOMFROMTEXT('MULTIPOINT(-128 90,90 -17,-176 -37,40 -78,156 -82,37 -42)'), ST_GEOMFROMTEXT('MULTIPOINT(57 32,-3 22,24 -88)')); SELECT ST_DISTANCE_SPHERE(ST_GEOMFROMTEXT('MULTIPOINT(87 -12,-25 31,-47 23,134 83,120 69,39 -41)'), ST_GEOMFROMTEXT('MULTIPOINT(-9 -4,-171 -82,140 -26)')); --replace_numeric_round 5 SELECT ST_DISTANCE_SPHERE(ST_GEOMFROMTEXT('MULTIPOINT(-119 50,28 22,-122 -74)'), ST_GEOMFROMTEXT('MULTIPOINT(134 14,-32 -84,96 74,44 59,-88 73,-136 12)')); SELECT ST_DISTANCE_SPHERE(ST_GEOMFROMTEXT('MULTIPOINT(-144 73,81 61,-78 4,50 -28)'), ST_GEOMFROMTEXT('MULTIPOINT(-176 48,-154 -39,-140 -60,135 72,-97 28,-35 69)')); --replace_numeric_round 5 SELECT ST_DISTANCE_SPHERE(ST_GEOMFROMTEXT('MULTIPOINT(-14 49)'), ST_GEOMFROMTEXT('MULTIPOINT(-160 -51,-141 72,50 -30,96 -64,-41 -59,-128 -28,0 -77,179 -78,-84 -67)')); SELECT ST_DISTANCE_SPHERE(ST_GEOMFROMTEXT('MULTIPOINT(-165 61,-43 -47,-89 40,-137 -64,11 26,-8 -31,28 -77,37 -44,124 51)'), ST_GEOMFROMTEXT('MULTIPOINT(63 39,98 14,-123 79,-30 -27)')); SELECT ST_DISTANCE_SPHERE(ST_GEOMFROMTEXT('MULTIPOINT(11 -38,-17 54,-104 73)'), ST_GEOMFROMTEXT('MULTIPOINT(167 -50,103 -21,-122 24,-122 80,-41 37,-175 -25,-155 48,-23 -34,-105 48)')); --echo ##################################################################################### --echo # ST_DISTANCE_SPHERE with different earth radius value --echo ##################################################################################### SELECT ST_DISTANCE_SPHERE(ST_GEOMFROMTEXT('POINT(1 1)'), ST_GEOMFROMTEXT('POINT(0 0)'), 1); SELECT ST_DISTANCE_SPHERE(ST_GEOMFROMTEXT('POINT(1 1)'), ST_GEOMFROMTEXT('POINT(0 0)'), 10); SELECT ST_DISTANCE_SPHERE(ST_GEOMFROMTEXT('POINT(1 1)'), ST_GEOMFROMTEXT('POINT(0 0)'), 100); SELECT ST_DISTANCE_SPHERE(ST_GEOMFROMTEXT('POINT(1 1)'), ST_GEOMFROMTEXT('POINT(0 0)'), 2000); SELECT ST_DISTANCE_SPHERE(ST_GEOMFROMTEXT('POINT(1 1)'), ST_GEOMFROMTEXT('POINT(0 0)'), 1234567); SELECT ST_DISTANCE_SPHERE(ST_GEOMFROMTEXT('POINT(1 1)'), ST_GEOMFROMTEXT('POINT(0 0)'), 6370986); SELECT ST_DISTANCE_SPHERE(ST_GEOMFROMTEXT('POINT(1 1)'), ST_GEOMFROMTEXT('POINT(0 0)'), 6370987); SELECT ST_DISTANCE_SPHERE(ST_GEOMFROMTEXT('POINT(1 1)'), ST_GEOMFROMTEXT('POINT(0 0)'), 1234567890); --echo ##################################################################################### --echo # Invalid function calls --echo ##################################################################################### --error ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT SELECT ST_DISTANCE_SPHERE(); --error ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT SELECT ST_DISTANCE_SPHERE(ST_GEOMFROMTEXT('POINT(10 10)')); SELECT ST_DISTANCE_SPHERE(ST_GEOMFROMTEXT('POINT(10 10)'),NULL); SELECT ST_DISTANCE_SPHERE(NULL,ST_GEOMFROMTEXT('POINT(10 10)')); SELECT ST_DISTANCE_SPHERE(NULL,ST_GEOMFROMTEXT(@star_top)); SELECT ST_DISTANCE_SPHERE(ST_GEOMFROMTEXT(@star_of_elems),NULL); SELECT ST_DISTANCE_SPHERE(NULL,NULL); --error ER_GIS_INVALID_DATA SELECT ST_DISTANCE_SPHERE(ST_GEOMFROMTEXT('POINT()'),ST_GEOMFROMTEXT('POINT(0 0)')); --error ER_GIS_INVALID_DATA SELECT ST_DISTANCE_SPHERE(ST_GEOMFROMTEXT('POINT(a 0)'),ST_GEOMFROMTEXT('POINT(0 0)')); --error ER_GIS_INVALID_DATA SELECT ST_DISTANCE_SPHERE(ST_GEOMFROMTEXT('POINT(! 0)'),ST_GEOMFROMTEXT('POINT(0 0)')); --error ER_PARSE_ERROR SELECT ST_DISTANCE_SPHERE(ST_GEOMFROMTEXT('POINT('!' 0)'),ST_GEOMFROMTEXT('POINT(0 0)')); --error ER_GIS_INVALID_DATA SELECT ST_DISTANCE_SPHERE(ST_GEOMFROMTEXT('POINT(12,34 0)'),ST_GEOMFROMTEXT('POINT(0 0)')); --error ER_GIS_INVALID_DATA SELECT ST_DISTANCE_SPHERE(ST_GEOMFROMTEXT('MULTIPOINT()'),ST_GEOMFROMTEXT('POINT(0 0)')); --error ER_GIS_INVALID_DATA SELECT ST_DISTANCE_SPHERE(ST_GEOMFROMTEXT('MULTIPOINT(1 12,34 a)'),ST_GEOMFROMTEXT('POINT(0 0)')); --error ER_GIS_INVALID_DATA SELECT ST_DISTANCE_SPHERE(ST_GEOMFROMTEXT('MULTIPOINT(1 12,34 0,1)'),ST_GEOMFROMTEXT('POINT(0 0)')); --error ER_PARSE_ERROR SELECT ST_DISTANCE_SPHERE(ST_GEOMFROMTEXT('MULTIPOINT(1 1,2 2,'!' 0)'),ST_GEOMFROMTEXT('POINT(0 0)')); --error ER_PARSE_ERROR SELECT ST_DISTANCE_SPHERE(,); --error ER_PARSE_ERROR SELECT ST_DISTANCE_SPHERE(ST_GEOMFROMTEXT(@star_of_elems),); --error ER_PARSE_ERROR SELECT ST_DISTANCE_SPHERE(,ST_GEOMFROMTEXT(@star_top)); --error ER_GIS_UNSUPPORTED_ARGUMENT SELECT ST_DISTANCE_SPHERE(ST_GEOMFROMTEXT('POINT(0 1)'), ST_GEOMFROMTEXT('LINESTRING(0 0,10 10)')); --error ER_GIS_UNSUPPORTED_ARGUMENT SELECT ST_DISTANCE_SPHERE(ST_GEOMFROMTEXT('POINT(0 1)'), ST_GEOMFROMTEXT('POLYGON((0 0,0 5,5 5,5 0,0 0))')); --error ER_GIS_UNSUPPORTED_ARGUMENT SELECT ST_DISTANCE_SPHERE(ST_GEOMFROMTEXT('POINT(0 1)'), ST_GEOMFROMTEXT('GEOMETRYCOLLECTION(POINT(0 0))')); --error ER_GIS_UNSUPPORTED_ARGUMENT SELECT ST_DISTANCE_SPHERE(ST_GEOMFROMTEXT('GEOMETRYCOLLECTION(POINT(1 1))'), ST_GEOMFROMTEXT('POINT(0 0)')); --error ER_GIS_UNSUPPORTED_ARGUMENT SELECT ST_DISTANCE_SPHERE(ST_GEOMFROMTEXT('POINT(0 1)'), ST_GEOMFROMTEXT('GEOMETRYCOLLECTION()')); --error ER_GIS_UNSUPPORTED_ARGUMENT SELECT ST_DISTANCE_SPHERE(ST_GEOMFROMTEXT('POINT(0 1)'), ST_GEOMFROMTEXT('GEOMETRYCOLLECTION(GEOMETRYCOLLECTION(POINT(0 0)))')); --error ER_GIS_UNSUPPORTED_ARGUMENT SELECT ST_DISTANCE_SPHERE(ST_GEOMFROMTEXT('POINT(0 1)'), ST_GEOMFROMTEXT('GEOMETRYCOLLECTION(POINT(0 0),GEOMETRYCOLLECTION())')); --error ER_GIS_UNSUPPORTED_ARGUMENT SELECT ST_DISTANCE_SPHERE(ST_GEOMFROMTEXT('MULTIPOINT(0 1)'), ST_GEOMFROMTEXT('LINESTRING(0 0,10 10)')); --error ER_GIS_UNSUPPORTED_ARGUMENT SELECT ST_DISTANCE_SPHERE(ST_GEOMFROMTEXT('MULTIPOINT(0 1)'), ST_GEOMFROMTEXT('POLYGON((0 0,0 5,5 5,5 0,0 0))')); --error ER_GIS_UNSUPPORTED_ARGUMENT SELECT ST_DISTANCE_SPHERE(ST_GEOMFROMTEXT('MULTIPOINT(0 1)'), ST_GEOMFROMTEXT('GEOMETRYCOLLECTION(POINT(0 0))')); --error ER_GIS_UNSUPPORTED_ARGUMENT SELECT ST_DISTANCE_SPHERE(ST_GEOMFROMTEXT('GEOMETRYCOLLECTION(MULTIPOINT(1 1))'), ST_GEOMFROMTEXT('POINT(0 0)')); --error ER_GIS_UNSUPPORTED_ARGUMENT SELECT ST_DISTANCE_SPHERE(ST_GEOMFROMTEXT('MULTIPOINT(0 1)'), ST_GEOMFROMTEXT('GEOMETRYCOLLECTION()')); --error ER_GIS_UNSUPPORTED_ARGUMENT SELECT ST_DISTANCE_SPHERE(ST_GEOMFROMTEXT('MULTIPOINT(0 1)'), ST_GEOMFROMTEXT('GEOMETRYCOLLECTION(GEOMETRYCOLLECTION(POINT(0 0)))')); --error ER_GIS_UNSUPPORTED_ARGUMENT SELECT ST_DISTANCE_SPHERE(ST_GEOMFROMTEXT('MULTIPOINT(0 1)'), ST_GEOMFROMTEXT('GEOMETRYCOLLECTION(POINT(0 0),GEOMETRYCOLLECTION())')); --error ER_GIS_UNSUPPORTED_ARGUMENT SELECT ST_DISTANCE_SPHERE(ST_GEOMFROMTEXT('GEOMETRYCOLLECTION()'), ST_GEOMFROMTEXT('GEOMETRYCOLLECTION()')); --error ER_WRONG_ARGUMENTS SELECT ST_DISTANCE_SPHERE(ST_GEOMFROMTEXT('POINT(1 1)'), ST_GEOMFROMTEXT('POINT(0 0)'), -200); --error ER_WRONG_ARGUMENTS SELECT ST_DISTANCE_SPHERE(ST_GEOMFROMTEXT('POINT(1 1)'), ST_GEOMFROMTEXT('POINT(0 0)'), -1); --error ER_WRONG_ARGUMENTS SELECT ST_DISTANCE_SPHERE(ST_GEOMFROMTEXT('POINT(1 1)'), ST_GEOMFROMTEXT('POINT(0 0)'), 0); --error ER_WRONG_ARGUMENTS SELECT ST_DISTANCE_SPHERE(ST_GEOMFROMTEXT('POINT(200 1)'), ST_GEOMFROMTEXT('POINT(0 0)'), 200); --error ER_WRONG_ARGUMENTS SELECT ST_DISTANCE_SPHERE(ST_GEOMFROMTEXT('POINT(20 1)'), ST_GEOMFROMTEXT('POINT(0 100)'), 200); --error ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT SELECT ST_DISTANCE_SPHERE(ST_GEOMFROMTEXT('POINT(1 1)'), ST_GEOMFROMTEXT('POINT(0 0)'), 200, 300); --echo # Clean up DROP TABLE gis_geometrycollection;