Hello. I'm trying to select all rows within X meters from a lat/long point. These was already discussed here: https://groups.google.com/forum/#!searchin/web2py/st_distance|sort:relevance/web2py/Js8amC9SMoY/Ds-X3ysFAgAJ
Anyway I don't reach to find the way to have the good result. Here is the db in postgis: db.define_table('events', Field('title', type='string', requires=IS_NOT_EMPTY(), label=T('Title')), Field('latitude', type='string', requires=IS_NOT_EMPTY(), label=T('Latitude')), Field('longitude', type='string', requires=IS_NOT_EMPTY(), label=T('Longitude')), Field('geojson_point', 'geometry()', compute=lambda r: "POINT(" + r['longitude'] + " " + r['latitude'] + ")")) As I take lat/long from a form I compute the geometry field for having the point. Here is in the controller the function for having the select result: def get_geojson_locations(): events = db(db.events. geojson_point.st_distance(geoPoint(45.070309, 7.686580999999933)) < 5000).select(db.events.id, db.events.title, db.events. geojson_point.st_asgeojson()) features= [{"type": "Feature", "properties": { "popupContent": "<a href='" + URL('default', 'mtb_tour', vars=dict(event_id=event[db.events.id])) + "'>" + event[db.events.title] + "</a>" }, "geometry": loads_json(event[db.events. geojson_point.st_asgeojson()])} for event in events] return response.json({"type": "FeatureCollection", 'features': features}) So in Geometry I've got a point in degrees. Of course making comparations between degrees and meters couldn't work. Do I have to convert the geojson_point from geometry to geography type? If yes how can I do it? Here it seems that it's possible 'on the fly' adding ::geography. Is it possible with web2py? http://gis.stackexchange.com/questions/76967/what-is-the-unit-used-in-st-distance Thanks. -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.