Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Well I have a simple GeoJSON point object with lat/long coordinates. The document also stores a score of sorts and what I plan to do is limit the results to a certain number say 20 (although still not quite sure) and then sort by the score. This way people will only view the most interesting locations no matter if they are looking at a street level view or on a national level.

The way rethinkDB advises is to query by intersections of circles. So on the client I calculate the center of the map, and then the radius based on the edges of the screen. Then I send that to construct the circle and get all points within the circle. I am just unsure how I can organize these results and cache them within Redis (or a better alternative) for ease of retrieval.



Okay, so presumably you are rendering this geojson in something like a google maps data layer, or some other kind of mapping library.

That means if you give it some GeoJSON which describes some points outside the normal screen bounding box you then that is okay - stuff on screen gets shown and stuff off screen doesn't get shown until you pan to it.

So far so good.

Now request and a circle 4 times too big and every time they move the screen, test if the ouside of the screen is outside that circle yet. Don't send another request till it is. Now you have a lot less requests for panning around.

But you want to cache, and all these very unique circles are hard to cache for right?

So instead of fetching a custom circle, divide up the world into a bunch of mathmatically calculated static squares [1]. When they view an area decide what square they are inside and query that. Like the 4xbig circle if you are feching some area outside the current view then it's around for when they pan. But critically - you can cache the result for a query for a square!

Hope this helps?

I haven't done this with rethinkdb.

[1] http://www.ra.ethz.ch/cdstore/www6/technical/paper130/pyrami...




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: