
RethinkDB 1.15: Geospatial queries - coffeemug
http://rethinkdb.com/blog/1.15-release/
======
CitizenKane
I've made a comment to this effect before, but seriously do yourself a favor
and check out Rethink. It's been great to work with, and has been 100% rock
solid. The only complaint I have is keeping up with the change of pace for
everything that's going on has been tricky ;).

It's great and fun to build apps with and all of the guys at Rethink are
incredibly helpful (even with my sometimes naive questions).

~~~
evmar
I tried it out recently. I discovered that the Go client has some important
issues.
[https://github.com/dancannon/gorethink/issues/125](https://github.com/dancannon/gorethink/issues/125)

I feel bad to bring this up because it is not the rethinkdb authors' fault (as
this is a third-party client) but from this user's perspective it took me some
debugging before I realized that rethinkdb wasn't necessarily slow.

~~~
_dancannon
Yeah there was an unfortunate bug with how I was encoding values being sent to
the database. I understand that it was frustrating and fixes should be coming
soon.

That being said this update brings a couple of great new features and I look
forward to see what else comes.

~~~
troyk
Thank you making a go driver, I've played with it a bit and the first thing
that jumped out at me is the documents passed to and from the database use a
special "gorethink" tag instead of the built-in "json" tags. I thought this
was odd since rethinkdb is a JSON database.

~~~
_dancannon
Yeah this is because I encode from json string > interface{} > final data
structure. This is so that I can process any psuedo-types such as times.

I am now looking to do this whole process in a much simpler way in the next
release which will solve the issue mentioned by evmar. I think its also worth
mentioning that both RethinkDB and my driver are not yet production ready but
both projects are getting there.

------
coffeemug
Hey guys, slava @ rethink here. I'll be around all day on HN to answer
questions.

We'll be doing a live webcast[1] today at 1:30pm PT showcasing geo features
and some example apps you can build with them, would love for you to join us!

[1] [http://www.meetup.com/RethinkDB-Bay-Area-Meetup-
Group/events...](http://www.meetup.com/RethinkDB-Bay-Area-Meetup-
Group/events/207435042/)

~~~
jimktrains2
Some of your documentation is 404ing.

How many dimensions are supported?

Also, does this support many projections, or just a few. I see "geoSystem:
'WGS84'" which isn't an EPGS identifier. Along those lines, are distance
calculations done on a geodesic, a plane, or is that configurable (some
projections are a planer, others aren't).

Also, what does this mean? geometry.distance(geometry[, {geoSystem: 'WGS84',
unit: 'm'}]) Does this do a correct interpolation of degrees to meters along
the path (again based on the projection) or is there a fixed constant?

EDIT: Are there commands to export WKT or WKB?

~~~
coffeemug
_> Some of your documentation is 404ing._

Thanks, will fix momentarily! EDIT: fixed, thanks!

 _> How many dimensions are supported?_

Two dimensions. The commands are designed primarily with Earth geometry in
mind to help people build location-aware apps.

 _> Also, does this support many projections, or just a few._

It supports WGS84 (a commonly used ellipsoid model) or a unit sphere.
Currently you can't use a plane. Check out
[http://rethinkdb.com/api/javascript/get_nearest/](http://rethinkdb.com/api/javascript/get_nearest/)
for an example.

 _> Does this do a correct interpolation of degrees to meters along the path_

The implementation is based on the S2 library
([https://code.google.com/p/s2-geometry-
library/](https://code.google.com/p/s2-geometry-library/)) also used by
PostGIS, which AFAIK does spherical linear interpolation.

 _> Are there commands to export WKT or WKB?_

No, currently only GeoJSON (which you could later post-process and export to
other formats with existing tools). This is a great idea, though, if there is
more demand for it we'll definitely add other exporters.

EDIT: all great questions, I opened an issue in the doc repo
([https://github.com/rethinkdb/docs/issues/521](https://github.com/rethinkdb/docs/issues/521))
-- we'll address all of these in the docs.

~~~
jimktrains2
> Two dimensions. The commands are designed primarily with Earth geometry

Earth has elevations:)

~~~
coffeemug
Yes, though most location-aware apps typically don't deal with those (yet :))
It would be a great addition, though.

~~~
jimktrains2
Very true:) I just found how you phrased it amusing:)

I don't mean to sound disparaging, for it's use-case it's a great addition:)

------
giulianob
I really appreciate their transparency with their stability report (
[http://rethinkdb.com/stability/](http://rethinkdb.com/stability/) ). It's
even linked right on the front page and shows what type of issues you can
expect at scale.

------
estefan
I wish every software project had a FAQ like this:
[http://rethinkdb.com/faq/](http://rethinkdb.com/faq/)

------
Animats
MySQL has had geospatial extensions for years. They even work. The underlying
table format is an R-tree, which, unfortunately, is only available for MyISAM.
Point in rectangle is very efficient, and other queries that can be expressed
as multiple point in rectangle tests are reasonably efficient. "Nearest" is
not efficient, but for many purposes ("find nearest McDonalds"), generating a
query rectangle for a reasonable driving distance, then sorting by distance,
is effective.

~~~
Gigablah
MySQL didn't properly support point-in-polygon until 5.6 though (before that
it used a MBR and you had to hack around it with a stored procedure)

------
altschuler
What's with the red ball always rolling by in the RethinkDB videos? :)

~~~
jaz46
Joey from RethinkDB here. In our first release video(v1.5), one of our
engineers rolled the ball across the office as a prank. The ball seems to
roll, stop, then magically continue rolling again. Since then, it has become a
tradition.

------
spb
Does Rethink allow arbitrary keys? Looking at the serialization format, it
looks like it has special $-surrounded keys, but I don't know if it also does
some kind of transformation so I can actually _use_ that kind of key name
without it being recognized as a special key by Rethink.

~~~
coffeemug
Yes, it allows arbitrary keys. The only one that's reserved by the database is
`$reql_type$`, and it's used for serialization of data structures that don't
have a native JSON representation (time, binary objects, geometry objects,
etc.)

~~~
spb
So if I try to define `$reql_type$`, it will throw an error? That means that I
can't store arbitrary data / use user data as a key. Can't something be done
about that at the driver / protocol level (eg. translating literal '$' to '$$'
and back again)?

------
imslavko
It is not clear from the changelog for me: do geospatial queries support
"changes feed" introduced in recent releases of RethinkDB? i.e. can I get
notification every time a new document within a range from a point appears in
the table? (w/o filtering data in application level)

~~~
neumino
Yes you can with a query like

r.table("users").changes().filter(function(change) { return
change("new_val")("location").distance( r.point(<someLongitude>,
<someLatitude>).lt(<someDistance>) })

------
jchrisa
Kudos for Rethink getting into geo. GeoCouch has been a huge adoption driver
for public data applications.

I think the real killer mix is geo + sync (because then you can trivially
share civic data). Maybe someday we'll see sync from Rethink?

~~~
coffeemug
What do you mean by sync? Something like
[http://rethinkdb.com/docs/changefeeds](http://rethinkdb.com/docs/changefeeds),
or do you mean something different?

~~~
apendleton
Probably Couch-style master-master replication (and an accompanying protocol
that allowed alternate implementations to sync in the same fashion with Couch,
e.g., PouchDB).

------
jrobn
Any plans for temporal support similar to what postgres does with range types
and exclusion constraints? This would be a great addition to Rethink.

~~~
coffeemug
Yes, this is definitely on the roadmap (though no ETA yet). Lots of people
have asked for this, so it will almost certainly make it into RethinkDB some
time next year.

------
goldenkey
I've continually been impressed by the pace at which RethinkDB improves in
both performance and developer usefulness. Keep it up!

------
cdnsteve
Is anyone offering this in a managed capacity like DynamoDB type setup in AWS
us-east? If so please let me know.

