Comparing version 0.0.3 to 0.0.4
@@ -1,27 +0,6 @@ | ||
var module = module || {} | ||
var config = require("./config") | ||
,_ = require("underscore") | ||
,request = require("request"); | ||
(function(app, _, request) { | ||
app.options = { | ||
apiHost: "http://gis.phila.gov" | ||
,apiPath: "/arcgis/rest/services" | ||
,services: { | ||
farmersMarkets: "/PhilaGov/Farmers_Markets/MapServer/0/query" | ||
,cornerStores: "/PhilaGov/Healthy_Corner_Stores/MapServer/0/query" | ||
} | ||
,params: { | ||
where: "1=1" | ||
,outFields: "*" | ||
,geometry: "" | ||
,geometryType: "esriGeometryEnvelope" | ||
,spatialRel: "esriSpatialRelContains" | ||
,inSR: "4326" | ||
,outSR: "4326" | ||
,returnGeometryOnly: "True" | ||
,returnIdsOnly: "False" | ||
,f: "pjson" | ||
} | ||
}; | ||
(function(app, config, _, request) { | ||
@@ -61,3 +40,3 @@ /** | ||
]; | ||
console.log(boundingBox); | ||
//console.log(boundingBox); | ||
return boundingBox; | ||
@@ -100,12 +79,14 @@ }; | ||
* @param {String} service Which ArcGIS service to query | ||
* @param {Array} boundingBox The xmin,ymin,xmax,ymax bounding box to look for features within | ||
* @param {Array} coords Lat/lng of the center point to look around | ||
* @param {Number} radius Radius to look within in square miles | ||
* @param {Object} [overrideParams] Optional ArcGIS REST API parameters to override the query with (see config.js for params) | ||
* @param {Function} successCallback | ||
* @param {Function} errorCallback | ||
*/ | ||
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); | ||
app.getNearby = function(service, coords, radius, overrideParams, successCallback, errorCallback) { | ||
var url = config.apiHost + config.apiPath + (config.services[service] || "") | ||
,params = ( ! _.isEmpty(overrideParams)) ? _.defaults(overrideParams, config.params) : _.clone(config.params); | ||
params.geometry = app.getBoundingBox(coords, radius); // Get bounding box | ||
url += "?" + app.serialize(params); | ||
console.log(url); | ||
//console.log(url); | ||
request(url, function(error, response, body) { // Query REST service | ||
@@ -121,2 +102,2 @@ if(error) { | ||
})(module.exports, _, request); | ||
})(module.exports, config, _, request); |
@@ -8,3 +8,3 @@ /** | ||
var coords = [39.9365,-75.1661]; | ||
arcnearby.getNearby("cornerStores", coords, 0.25, function(results) { | ||
arcnearby.getNearby("cornerStores", coords, 0.25, {where: "STORE_LEVEL = 'Enhanced Healthy Corner Store'"}, function(results) { | ||
_.each(results, function(result) { | ||
@@ -11,0 +11,0 @@ console.log(result.attributes); |
{ | ||
"name": "arcnearby", | ||
"description": "Generate bounding box around center point and search ArcGIS REST service for features within it, sorted by distance", | ||
"version": "0.0.3", | ||
"version": "0.0.4", | ||
"homepage": "https://github.com/timwis/ArcNearby", | ||
@@ -6,0 +6,0 @@ "author": "Tim Wisniewski, Sarah Cordivano, David Walk", |
7289
7
124