It is not returning any figure, It is returning 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;
can anyone please help to make this memsql Geospatial Function work
Expanding on Damien_The_Unbeliever's answer above, the GEOGRAPHY_POINT syntax should not be inside a string. You can either define the point within a string in WKT syntax POINT(long lat)
, or using the GEOGRAPHY_POINT syntax (but not in a string).
So for your first query that wasn't working:
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)
You can correctly write it as either of these two:
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)