I am trying to follow the very basic tutorial of Geo Library for Amazon DynamoDB given here https://www.npmjs.com/package/dynamodb-geo. Even after following the steps mentioned in link, my myGeoTableManager.queryRadius() call is not giving me any result. Below are the steps that I follow.
I created the dynamoDB table with below script
require("dotenv").config();
var AWS= require('aws-sdk');
AWS.config.update({accessKeyId: process.env.accessKeyId, secretAccessKey: process.env.secretAccessKey, region: "us-east-1"});
const ddb = new AWS.DynamoDB();
const ddbGeo = require('dynamodb-geo');
const config = new ddbGeo.GeoDataManagerConfiguration(ddb, 'locationData');
config.hashKeyLength = 5;
const createTableInput = ddbGeo.GeoTableUtil.getCreateTableRequest(config);
// Tweak the schema as desired
createTableInput.ProvisionedThroughput.ReadCapacityUnits = 5;
console.log('Creating table with schema:');
console.dir(createTableInput, { depth: null });
// Create the table
ddb.createTable(createTableInput).promise()
// Wait for it to become ready
.then(function () { return ddb.waitFor('tableExists', { TableName: 'locationData' }).promise() })
.then(function () { console.log('Table created and ready!') });
Then I insert and query data in dynamoDB using below script.
require("dotenv").config();
var AWS= require('aws-sdk');
AWS.config.update({accessKeyId: process.env.accessKeyId, secretAccessKey: process.env.secretAccessKey, region: "us-east-1"});
const ddb = new AWS.DynamoDB();
const ddbGeo = require('dynamodb-geo');
const config = new ddbGeo.GeoDataManagerConfiguration(ddb, 'locationData');
config.hashKeyLength = 5;
const myGeoTableManager = new ddbGeo.GeoDataManager(config);
myGeoTableManager.putPoint({
RangeKeyValue: { S: '1234' },
GeoPoint: {
latitude: 28.749472,
longitude: 77.056534
},
PutItemInput: {
Item: {
country: { S: 'country1' },
capital: { S: 'capital1' }
},
}
}).promise()
.then(function() { console.log('Insert Done!') });
myGeoTableManager.putPoint({
RangeKeyValue: { S: '5678' },
GeoPoint: {
latitude: 28.749999,
longitude: 77.056999
},
PutItemInput: {
Item: {
country: { S: 'country2' },
capital: { S: 'capital2' }
},
}
}).promise()
.then(function() { console.log('Insert Done!') });
myGeoTableManager.queryRadius({
RadiusInMeter: 100000,
CenterPoint: {
latitude: 28.749888,
longitude: 77.056888
}
}).then((locations) => {
console.log(locations);
});
Even with exactly same latitude and longitude, myGeoTableManager.queryRadius() is giving me empty response.