Skip to content

Instantly share code, notes, and snippets.

@tmcw
Created November 5, 2015 20:14
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save tmcw/37ce3b662d568704cd97 to your computer and use it in GitHub Desktop.
Save tmcw/37ce3b662d568704cd97 to your computer and use it in GitHub Desktop.

To install:

  1. Clone this gist as a git repo
  2. npm install in it
  3. node index.js
var querystring = require('querystring');
var merc = new (require('sphericalmercator'))();
// customize this point - these are longitude, latitude coordinates
var projected = merc.forward([
-106.48223736908858,
35.02338757234806]);
var point = {
x: projected[0],
y: projected[1],
spatialReference: {
wkid:102100
}
};
var q = {
f: 'json',
geometry: JSON.stringify(point),
tolerance: '3',
returnGeometry: 'true',
mapExtent: '{"xmin":-11869218.033253865,"ymin":4141606.3456870574,"xmax":-11798437.345061889,"ymax":4187927.1848278116,"spatialReference":{"wkid":102100}}',
imageDisplay: '400,400,96',
geometryType: 'esriGeometryPoint',
sr: '102100',
layers: 'all:0'
};
var url = 'http://planthardiness.ars.usda.gov/ArcGIS/rest/services/uspz/MapServer/identify?' + querystring.stringify(q);
console.error(url);
var http = require('http');
http.get(url, function(res) {
res.pipe(process.stdout);
});
{
"name": "esri-query",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"proj4": "^2.3.12",
"sphericalmercator": "^1.0.4"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment