1

I saw a blog post that announced recent filtering support directly through Backand for MySQL points. However, my existing mysql database makes use of the Polygon types as I need to define areas that are more than circular.

At the moment, the Backand syncs the row with a type of String. Is there any way to retrieve my Point objects through the API? Is it possible to decode/encode the strings back into a MySQL Polygon object?

Thank you.

Alan
  • 1,510
  • 1
  • 18
  • 35

2 Answers2

2

You can always use Backand's Query with SQL syntax (the default is NoSQL) to use all the MySQL geo functionality. You can query ST_Distance, ST_Within and get the individual coordinates of the polygon. Here is a link how to get them how to access multipolygon coordinates in mysql Here is a link how to use MySQL for geo apps https://www.percona.com/blog/2013/10/21/using-the-new-mysql-spatial-functions-5-6-for-geo-enabled-applications/ To add parameters to your query, add them to the parameters input (comma delimited) and use them with the anchor icon, see the image below. In the left side of the screen, you get how to call it with angularjs $http syntax. enter image description here

Community
  • 1
  • 1
relly
  • 439
  • 3
  • 3
  • Thanks @relly, the query seems to work for polygons if I wrap the column `inAsText(polygonCol)` Backand was giving issues with the above, I solved by adding `as polygonCol` It must have been an issue with the brackets, casting removes them from the json result. Are you a Backand dev? Is stackoverflow the best place to report bugs at the minute? Thanks! – Alan Feb 22 '16 at 19:03
  • For anyone else reading, have a look at my answer below for an exact example with image. – Alan Feb 22 '16 at 19:12
  • 2
    I am part of the Backand dev team. Stackoverflow is a good place to ask questions that will contribute to the Backand developers community. – relly Feb 23 '16 at 13:32
2

To add to @relly 's answer, I created a custom query and returned the polygon column as text, making sure to cast the column name to something that doesn't contain brackets using 'as'.

Backand custom query to return a mysql polygon object as text

Alan
  • 1,510
  • 1
  • 18
  • 35