The "distance" function should be this:

    distance_function = ( 
        (6371 
        * func.acos(func.cos(func.radians(bindparam('origin_lat')))
                    * func.cos(func.radians(places_table.c.latitude))
                    * func.cos(func.radians(places_table.c.longitude) - 
                               func.radians(bindparam('origin_lng'))
                              ) 
                    + func.sin(func.radians(bindparam('origin_lat'))) 
                    * func.sin(func.radians(places_table.c.latitude))
                  )
        ) 
      ) 

(We're taking the acos of the whole shebang, not just the "origin_lat")

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/sqlalchemy/-/eZ22zz7xgJEJ.
To post to this group, send email to sqlalchemy@googlegroups.com.
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.

Reply via email to