Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

arcnearby

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

arcnearby - npm Package Compare versions

Comparing version 0.0.2 to 0.0.3

21

arcnearby.js

@@ -96,3 +96,4 @@ var module = module || {}

/**
* Executes HTTP request to ArcGIS REST API
* Main wrapper for library
* Generates bounding box, executes HTTP request to ArcGIS REST API, sorts by distance
* @param {String} service Which ArcGIS service to query

@@ -103,9 +104,15 @@ * @param {Array} boundingBox The xmin,ymin,xmax,ymax bounding box to look for features within

*/
app.query = function(service, boundingBox, successCallback, errorCallback) {
var params = _.clone(app.options.params);
params.geometry = boundingBox;
var url = app.options.apiHost + app.options.apiPath + (app.options.services[service] || "") + "?" + app.serialize(params);
app.getNearby = function(service, coords, radius, successCallback, errorCallback) {
var url = url = app.options.apiHost + app.options.apiPath + (app.options.services[service] || "")
,params = _.clone(app.options.params);
params.geometry = app.getBoundingBox(coords, radius); // Get bounding box
url += "?" + app.serialize(params);
console.log(url);
request(url, function(error, response, body) {
(error) ? errorCallback(response, body) : successCallback(response, body);
request(url, function(error, response, body) { // Query REST service
if(error) {
errorCallback(response, body);
} else {
var data = JSON.parse(body);
successCallback((data.features !== undefined) ? app.sortByDistance(data.features, coords) : {}); // Sort by distance
}
});

@@ -112,0 +119,0 @@ };

@@ -0,18 +1,14 @@

/**
* Example usage of arcnearby
*/
var arcnearby = require("./arcnearby")
,_ = require("underscore");
(function(arcnearby) {
var coords = [39.9365,-75.1661]
,boundingBox = arcnearby.getBoundingBox(coords, 1.0);
arcnearby.query("cornerStores", boundingBox, function(response, body) {
var data = JSON.parse(body);
console.log("Found " + data.features.length + " results");
var sorted = arcnearby.sortByDistance(data.features, coords);
_.each(sorted, function(result) {
console.log(result.attributes);
});
}, function(resopnse) {
console.log("Error");
var coords = [39.9365,-75.1661];
arcnearby.getNearby("cornerStores", coords, 0.25, function(results) {
_.each(results, function(result) {
console.log(result.attributes);
});
})(arcnearby);
}, function(response, body) {
console.log("Error");
});
{
"name": "arcnearby",
"description": "Generate bounding box around center point and search ArcGIS REST service for features within it, sorted by distance",
"version": "0.0.2",
"version": "0.0.3",
"homepage": "https://github.com/timwis/ArcNearby",

@@ -6,0 +6,0 @@ "author": "Tim Wisniewski, Sarah Cordivano, David Walk",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc