taptipblard
taptipblard

Reputation: 521

How to create geospatial module with AWS lambda and dynamo db

First let me thank you for taking the time in reading my question.

My plan was to add latitude and longitude records on my persons records in dynamodb and then use a geo library, preferably written in nodejs, for calculating nearby persons in a given radius. So the plan was, for example, return the persons only from this 50 mile radius.

So far, the only geo-libraries i have tried allows me to pass lat and long to it and confirm if it is within the radius given. The problem with this is that I have to loop my whole dynamodb table to get results. Is there a reverse kind of function for this in which I pass a latlong point and radius to the geo library and then the geo library passes me some lat and long boundaries so that I can easily query it to dynamodb(ex. (lat<:latboundary1 AND lat>:latboundary 2) AND (long<:longboundary1 AND long>:longboundary 2) )

Upvotes: 4

Views: 2765

Answers (1)

Peter Fennema
Peter Fennema

Reputation: 1690

This nodejs library provides a function that calculates the bounding box based on a point and a radius. You can use the returned SW and NE points for your query.

.boundingCoordinates(distance, radius, inKilometers): Calculates the bounding coordinates of distance from the point and returns an array with the SW and NE points of the bounding box . If radius is not provided, the radius of the Earth will be used. The distance is calculated in miles unless inKilometers is true

Upvotes: 6

Related Questions