build a geospatial app with redis 3.2- andrew bass, sean yesmunt, sergio prada, deanna shih, coding...
TRANSCRIPT
![Page 1: Build a Geospatial App with Redis 3.2- Andrew Bass, Sean Yesmunt, Sergio Prada, Deanna Shih, Coding House](https://reader031.vdocuments.net/reader031/viewer/2022030303/587c04f91a28ab7c668b754b/html5/thumbnails/1.jpg)
Please visit:
http://bit.do/redis
We will be using this data for our presentation!
![Page 2: Build a Geospatial App with Redis 3.2- Andrew Bass, Sean Yesmunt, Sergio Prada, Deanna Shih, Coding House](https://reader031.vdocuments.net/reader031/viewer/2022030303/587c04f91a28ab7c668b754b/html5/thumbnails/2.jpg)
Redis 3.2 and GeospatialAndrew Bass, Deanna Shih, and Sean Yesmunt
![Page 3: Build a Geospatial App with Redis 3.2- Andrew Bass, Sean Yesmunt, Sergio Prada, Deanna Shih, Coding House](https://reader031.vdocuments.net/reader031/viewer/2022030303/587c04f91a28ab7c668b754b/html5/thumbnails/3.jpg)
• Students at Coding House in Fremont, CA • Andrew Bass • Deanna Shih • Sean Yesmunt • Sergio Pradapaceme.us
3
Who are we?
![Page 4: Build a Geospatial App with Redis 3.2- Andrew Bass, Sean Yesmunt, Sergio Prada, Deanna Shih, Coding House](https://reader031.vdocuments.net/reader031/viewer/2022030303/587c04f91a28ab7c668b754b/html5/thumbnails/4.jpg)
• 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
![Page 5: Build a Geospatial App with Redis 3.2- Andrew Bass, Sean Yesmunt, Sergio Prada, Deanna Shih, Coding House](https://reader031.vdocuments.net/reader031/viewer/2022030303/587c04f91a28ab7c668b754b/html5/thumbnails/5.jpg)
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
![Page 6: Build a Geospatial App with Redis 3.2- Andrew Bass, Sean Yesmunt, Sergio Prada, Deanna Shih, Coding House](https://reader031.vdocuments.net/reader031/viewer/2022030303/587c04f91a28ab7c668b754b/html5/thumbnails/6.jpg)
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/
![Page 7: Build a Geospatial App with Redis 3.2- Andrew Bass, Sean Yesmunt, Sergio Prada, Deanna Shih, Coding House](https://reader031.vdocuments.net/reader031/viewer/2022030303/587c04f91a28ab7c668b754b/html5/thumbnails/7.jpg)
@RedisConf 122.393 W, 37.768 N
or
0100110110010001111011110
Or, in GEOHASH9q8yyg72zpm0
Images from: mapzen.com/blog/geohashes-and-you/
![Page 8: Build a Geospatial App with Redis 3.2- Andrew Bass, Sean Yesmunt, Sergio Prada, Deanna Shih, Coding House](https://reader031.vdocuments.net/reader031/viewer/2022030303/587c04f91a28ab7c668b754b/html5/thumbnails/8.jpg)
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
![Page 9: Build a Geospatial App with Redis 3.2- Andrew Bass, Sean Yesmunt, Sergio Prada, Deanna Shih, Coding House](https://reader031.vdocuments.net/reader031/viewer/2022030303/587c04f91a28ab7c668b754b/html5/thumbnails/9.jpg)
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
![Page 10: Build a Geospatial App with Redis 3.2- Andrew Bass, Sean Yesmunt, Sergio Prada, Deanna Shih, Coding House](https://reader031.vdocuments.net/reader031/viewer/2022030303/587c04f91a28ab7c668b754b/html5/thumbnails/10.jpg)
10
Longitude and Latitude Accuracy
https://en.wikipedia.org/wiki/Decimal_degrees
![Page 11: Build a Geospatial App with Redis 3.2- Andrew Bass, Sean Yesmunt, Sergio Prada, Deanna Shih, Coding House](https://reader031.vdocuments.net/reader031/viewer/2022030303/587c04f91a28ab7c668b754b/html5/thumbnails/11.jpg)
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
![Page 12: Build a Geospatial App with Redis 3.2- Andrew Bass, Sean Yesmunt, Sergio Prada, Deanna Shih, Coding House](https://reader031.vdocuments.net/reader031/viewer/2022030303/587c04f91a28ab7c668b754b/html5/thumbnails/12.jpg)
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
![Page 13: Build a Geospatial App with Redis 3.2- Andrew Bass, Sean Yesmunt, Sergio Prada, Deanna Shih, Coding House](https://reader031.vdocuments.net/reader031/viewer/2022030303/587c04f91a28ab7c668b754b/html5/thumbnails/13.jpg)
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
![Page 14: Build a Geospatial App with Redis 3.2- Andrew Bass, Sean Yesmunt, Sergio Prada, Deanna Shih, Coding House](https://reader031.vdocuments.net/reader031/viewer/2022030303/587c04f91a28ab7c668b754b/html5/thumbnails/14.jpg)
Demo AppFind people close to you who are also at
14