它不返回任何数字,它返回null。
SELECT round(GEOGRAPHY_DISTANCE("GEOGRAPHY_POINT(-97.741890, 30.219940)", "POLYGON ((-97.11090087890626 33.08693925905123,-96.52862548828126 33.063924198120645,-96.56158447265626 32.80343616698929,-97.06970214843751 32.778037985363675,-97.11090087890626 33.08693925905123))"),0) FROM DUAL;
SELECT GEOGRAPHY_WITHIN_DISTANCE("GEOGRAPHY_POINT(96.843820, 32.926290)","POLYGON ((-97.11090087890626 33.08693925905123,-96.52862548828126 33.063924198120645,-96.56158447265626 32.80343616698929,-97.06970214843751 32.778037985363675,-97.11090087890626 33.08693925905123))",1000) from dual;
任何人都可以帮助使此memsql地理空间功能正常工作
答案 0 :(得分:0)
扩展上面的Damien_The_Unbeliever的答案,GEOGRAPHY_POINT语法不应放在字符串内。您可以使用WKT语法POINT(long lat)
或使用GEOGRAPHY_POINT语法(但不能使用字符串)在字符串内定义点。
因此对于第一个无效的查询:
memsql> SELECT round(GEOGRAPHY_DISTANCE("GEOGRAPHY_POINT(-97.741890, 30.219940)", "POLYGON ((-97.11090087890626 33.08693925905123,-96.52862548828126 33.063924198120645,-96.56158447265626 32.80343616698929,-97.06970214843751 32.778037985363675,-97.11090087890626 33.08693925905123))"),0) FROM DUAL;
+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| round(GEOGRAPHY_DISTANCE("GEOGRAPHY_POINT(-97.741890, 30.219940)", "POLYGON ((-97.11090087890626 33.08693925905123,-96.52862548828126 33.063924198120645,-96.56158447265626 32.80343616698929,-97.06970214843751 32.778037985363675,-97.11090087890626 33.086939 |
+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| NULL |
+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set, 1 warning (0.39 sec)
memsql> show warnings;
+---------+------+----------------------------------------------------+
| Level | Code | Message |
+---------+------+----------------------------------------------------+
| Warning | 1862 | You have an error in your WKT syntax at position 0 |
+---------+------+----------------------------------------------------+
1 row in set (0.00 sec)
您可以正确地将其写为以下两个之一:
memsql> SELECT round(GEOGRAPHY_DISTANCE("POINT(-97.741890 30.219940)", "POLYGON ((-97.11090087890626 33.08693925905123,-96.52862548828126 33.063924198120645,-96.56158447265626 32.80343616698929,-97.06970214843751 32.778037985363675,-97.11090087890626 33.08693925905123))"),0) FROM DUAL;
+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| round(GEOGRAPHY_DISTANCE("POINT(-97.741890 30.219940)", "POLYGON ((-97.11090087890626 33.08693925905123,-96.52862548828126 33.063924198120645,-96.56158447265626 32.80343616698929,-97.06970214843751 32.778037985363675,-97.11090087890626 33.08693925905123))" |
+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| 291334 |
+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.31 sec)
memsql> SELECT round(GEOGRAPHY_DISTANCE(GEOGRAPHY_POINT(-97.741890, 30.219940), "POLYGON ((-97.11090087890626 33.08693925905123,-96.52862548828126 33.063924198120645,-96.56158447265626 32.80343616698929,-97.06970214843751 32.778037985363675,-97.11090087890626 33.08693925905123))"),0) FROM DUAL;
+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| round(GEOGRAPHY_DISTANCE(GEOGRAPHY_POINT(-97.741890, 30.219940), "POLYGON ((-97.11090087890626 33.08693925905123,-96.52862548828126 33.063924198120645,-96.56158447265626 32.80343616698929,-97.06970214843751 32.778037985363675,-97.11090087890626 33.08693925 |
+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| 291334 |
+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.54 sec)