Build a Geospatial App with Redis 3.2- Andrew Bass, Sean Yesmunt, Sergio Prada, Deanna Shih, Coding...
-
Upload
redis-labs -
Category
Technology
-
view
121 -
download
0
Transcript of Build a Geospatial App with Redis 3.2- Andrew Bass, Sean Yesmunt, Sergio Prada, Deanna Shih, Coding...
Please visit:
http://bit.do/redis
We will be using this data for our presentation!
Redis 3.2 and GeospatialAndrew Bass, Deanna Shih, and Sean Yesmunt
• Students at Coding House in Fremont, CA • Andrew Bass • Deanna Shih • Sean Yesmunt • Sergio Pradapaceme.us
3
Who are we?
• Stable as of May 6, 2016
• Includes a new set of GEO commands for geo indexing
• Simply put, saves locations and compares them
• Geo indexed data is a special sorted set
4
Redis 3.2 and GEO
GEOADD key longitude latitude member GEOHASH key member
• Longitude then Latitude
• Assumes Earth is a sphere
• Data is saved in sorted set as a Geohash
• ZREM can can be used to remove a member from the key
5
GEOADD & GEOHASH
Divide the world in half
Each half is 0 or 1
Save that bit, then keep dividing
Images from: mapzen.com/blog/geohashes-and-you/
@RedisConf 122.393 W, 37.768 N
or
0100110110010001111011110
Or, in GEOHASH9q8yyg72zpm0
Images from: mapzen.com/blog/geohashes-and-you/
Why?
8
Redis can compare the locations as a sorted set!City Geohash
San Francisco 9q8yyg7zpm0
San Jose 9q9k6mjng
Los Angeles 9q5ctr186
London gcpvj0duq
Beijing wx4g0bm6c
GEOPOS key member [member ...]
• Returns Longitude and Latitude for member of a key
• Since the data is converted to a string and back, it may be slightly different than the original GEOADD inputs
9
GEOPOS
10
Longitude and Latitude Accuracy
https://en.wikipedia.org/wiki/Decimal_degrees
GEODIST key member1 member2 [unit]
❖ Returns the distance between two members of a key
❖ Unit is defaulted to meters, but accepts:• m for meters
• km for kilometers
• mi for miles
• ft for feet
11
GEODIST
GEORADIUS key longitude latitude radius m|km|ft|mi [WITHCOORD] [WITHDIST] [WITHHASH] [COUNT count] [ASC|DESC]
• Returns members of a key within the radius from the coordinates • Options for including coordinates, distance, limit number of results,
and sort ascending or descending • Note, WITHHASH returns a 52bit integer, not the geohash.
12
GEORADIUS
GEORADIUSBYMEMBER key member radius m|km|ft|mi [WITHCOORD] [WITHDIST] [WITHHASH] [COUNT count] [ASC|DESC]
• Returns members of a key within the radius of the given member • Otherwise, same as GEORADIUS
13
GEORADIUSBYMEMBER
Demo AppFind people close to you who are also at
14
For another demo, check out paceme.us