Access long, lat from GeoPoint

#1

I am trying to write a query to access lat, long of a location, We are currently using GeoPoint to store lat, long, When I do a fetch TypeNameA.fetch({filter:"location.long==169.560303"}) It returns an error t.location_long_d does not exist, Is this is the right way to access long and lat ? or should I use geometry

0 Likes

#2

Looking at the Location type, i don’t see a field as ‘long’… I do see
Location.address.geometry.long.

You could try TypeNameA.fetch({filter:"location.address.geometry.long==169.560303"})

Unless you have adjjusted the Location type to have a ‘long’ field directlly on it?

0 Likes

#3

We are using the type GeoPoint, not Location in this case. We have a field called location which is of type GeoPoint but can’t seem to filter on location.long or location.lat.

0 Likes

#4

The GeoPoint is stored in an internal value in Postgres and currently only supports functions related to that (like “withinDistance”, etc.) So the lat/long aren’t stored in columns in c3 which is why you get that error. Postgis does have functions that enable you to access the lat/long coordinates so we should probably add support for accessing that (either via a function or implicitly, depending on what is possible). Please file a ticket requesting that.

0 Likes

#5

@trothwein how would one know that from looking at the type definition? Should the ‘lat’ and ‘long’ fields be marked as private?

0 Likes

#6

@trothwein where can I find documentation for the geo functions that are supported such as withinDistance?

0 Likes

#7

@Riley If I can do this implicitly then you wouldn’t need to know :). I think forcing the function is a fallback if the former turns out to be untenable.

0 Likes

#8

@rohit.sureka Do we have a place to document these types of filter functions (e.g. Postgis Geography/Geometry that we support)

0 Likes