RestaurantHealth / RestaurantHealth

0 stars 0 forks source link

Refine nearest business search logic #5

Open bbodenmiller opened 8 years ago

bbodenmiller commented 8 years ago

We should consider refining the nearest business search logic so it can run faster.

Currently we are using: http://stackoverflow.com/a/11113010/1233435

This may be more accurate and faster: http://stackoverflow.com/a/5933294/1233435... at least the where clause from this should be used so we can limit the calculations.

Alternatively we might just want to switch to MongoDB so we can use the built in geospatial query operators like $nearSphere:

db.places.find(
   {
     location: {
        $nearSphere: {
           $geometry: {
              type : "Point",
              coordinates : [ -73.9667, 40.78 ]
           },
           $minDistance: 0,
           $maxDistance: 10
        }
     }
   }
)
bbodenmiller commented 8 years ago

Another option may be to use the data source API's within_circle(...) function to find nearest businesses/violations. I'm having an issue with the function and posted about that at https://stackoverflow.com/questions/32091300/combine-socrata-latitude-and-longitude-columns-to-form-point-type-location-colum.

bbodenmiller commented 8 years ago

There is also PostGIS, a spatial database extender for PostgreSQL object-relational database, which includes similar query options as MongoDB.