Extract lat/lon from geography (point)
Is there a way to extract lat/lon from a geography (point, in this case)? I'm getting a geo point as an input into an endpoint and want to use the lat/lng in a distance calculation, but the distance calculation only accepts decimal values, and thus I must extract lat/lng from the input.
In this case using GET data GET lat yields nothing, and storing the input as a variable in the debugger appears to return a PostGIS data type (POINT(lat lng)), where nothing can be extracted.
Converting to text and doing a substring isn't ideal.
Is there any ST_X/ST_Y PostGIS equivalent given it looks like the geography point data type is being used here?
Best Answer
-
That makes way more sense to be passing it in to be used as a geo point datatype.
Can you try using the utility functionGet All Input
. You should be able to use that input variable and select the object and use dot notation to get its values.
I'm hopeful this will work 🤞
Answers
-
How is the input being passed? Is it formatted as a string (and presumably with escaped characters?
This worked for me, where I pass the geo point as an escaped string: -
I'm passing it in as a properly structured geo point object (input type: geo_point), which is detected and used correctly. Extracting the lat/lng individually is the issue.
I've worked around it for now by inputting two decimals for each lat and lng, using those where I need it in the distance calculation, and then rebuilding the geo_point object as a new variable inside my function stack for use in a WITHIN filter elsewhere.
-
That works! Now, you said it makes way more sense, why is that if it needs additional post-processing just like constructing the geo-point over again?
-
To be completely transparent, I had assumed you were trying to use text because you had mentioned substrings.
Otherwise, thepoint
is just a datatype that's recognized as thatdatatype
. An object is an object, an array is recognized as an array, etc. Hope this helps :)
Categories
- All Categories
- 53 ? Announcements
- 47 ? Releases
- 37 ? Welcome
- 983 ? Help! I'm a Noob
- 125 ? No-Code Front-Ends
- 633 ? Working with APIs
- 439 ? Transforming data
- 126 ? Connect Xano to ...
- 50 ?? Find an Expert
- 348 ❓Other questions
- 35 ? Security
- 22 ✂️ Snippets
- 19 ? Showcase
- 7 ?️ Xano Chatter
- 62 ? Video Tutorials
- 171 ? Request a feature
- 229 ? Report a Bug
- 19 ? Templates & Extensions
- 7 ? Feedback