pax_global_header00006660000000000000000000000064125415417310014515gustar00rootroot0000000000000052 comment=5e1eb8d099109f530e1962b45b4d384ff27aa4c7 node-srs-0.4.8+dfsg/000077500000000000000000000000001254154173100141775ustar00rootroot00000000000000node-srs-0.4.8+dfsg/.gitignore000066400000000000000000000000651254154173100161700ustar00rootroot00000000000000build .DS_Store *.o *.a lib/binding *pyc node_modulesnode-srs-0.4.8+dfsg/.npmignore000066400000000000000000000000651254154173100161770ustar00rootroot00000000000000build .DS_Store *.o *.a lib/binding *pyc node_modulesnode-srs-0.4.8+dfsg/.travis.yml000066400000000000000000000041551254154173100163150ustar00rootroot00000000000000language: cpp os: - linux - osx compiler: - clang env: matrix: - NODE_VERSION="0.10.38" JOBS=8 - NODE_VERSION="0.12.2" JOBS=8 - NODE_VERSION="iojs-v2.0.0" JOBS=8 global: - secure: J5pbPr7g29oKVLrGpKXUQQUV5TJpMf2/TkPZZXezZdO5ywR7M2PfFOUOqexKUylcLyLmEgDilSJhhTLHYz+wx42VPbCTB7Q3sSZdhM0RUXc5mO4BcRKoEUHkIy2Ibp6SbcfzupT/oELFLiZSiS2xojldVMoUAs8IzLGcYStO7Jc= - secure: 1cPR5S+Gg4JiA3j8cvjKxSY3AshM0inXzHB/i/7P/ZjnxdvQQuZ48lK0e3TFvXQVTbA0rWYYrwuo62Fb9fc9bA8hDoOU2aruoF6hcEyuAbG7ERGRRJO9g6XaZKW1G0yK18T+1X6OBP7eXNZEPxl0OqBL8l3MKO3vuGxR3+5VQ0A= before_install: - COMMIT_MESSAGE=$(git show -s --format=%B $TRAVIS_COMMIT | tr -d '\n') - echo $COMMIT_MESSAGE - export PATH=`pwd`/node_modules/.bin:$PATH # here we set up the node version on the fly based on the matrix value. # This is done manually so that it is easy to flip the 'language' to # objective-c in another branch (to run the same travis.yml on OS X) - rm -rf ~/.nvm && git clone --depth 1 https://github.com/creationix/nvm.git ~/.nvm - source ~/.nvm/nvm.sh - nvm install $NODE_VERSION - nvm use $NODE_VERSION - node --version - npm --version - platform=$(uname -s | sed "y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/") install: # test building from source - npm install --build-from-source --clang=1 - node-pre-gyp package testpackage - npm test before_script: # test publishing and installing from remote if # [publish binary] is present in commit message - echo "before_script" - PUBLISH_BINARY=false - echo $COMMIT_MESSAGE - if test "${COMMIT_MESSAGE#*'[publish binary]'}" != "$COMMIT_MESSAGE"; then echo yes;PUBLISH_BINARY=true; fi; - echo $PUBLISH_BINARY - if [[ $PUBLISH_BINARY == true ]]; then node-pre-gyp unpublish publish info; rm -rf {build,lib/binding}; npm install --fallback-to-build=false; npm test; fi script: # test building with against shared gdal - rm -rf ./build - rm -rf ./lib/binding - if [[ "$platform" == 'linux' ]]; then sudo apt-get -qq update; sudo apt-get --force-yes -qq install libgdal-dev libgdal1-dev libgdal1h=1.10.0-1~precise1; npm install --build-from-source --shared_gdal --clang=1; npm test; fi; node-srs-0.4.8+dfsg/CHANGELOG.md000066400000000000000000000052301254154173100160100ustar00rootroot00000000000000# changelog 0.4.8 - Upgraded to nan@1.8.4 - Upgraded to node-pre-gyp@0.6.7 0.4.7 - Added support (and pre-build binaries) for io.js 1.2.x and node v0.12.x - Upgraded to nan@1.7.0 - Upgraded to node-pre-gyp@0.6.4 0.4.6 - Removed getenv workaround for Visual Studio 2013 0.4.5 - Upgraded bundled node-pre-gyp 0.4.4 - Upgraded to GDAL 1.11.1 - Stopped providing binaries for node v0.8.x - Now providing binaries against Visual Studio 2014 (pass --toolset=v140) and use binaries from https://github.com/mapbox/node-cpp11 0.4.3 - No changes: just re-published to try to avoid npm shasum error upon download 0.4.2 - Now supporting node v0.11.x 0.4.1 - Now shipping binaries for OS X, Windows, and Ubuntu Linux 0.4.0 - Now builds on FreeBSD - `srs.jsonCrs` added for detecting projection inside JSON object representing GeoJSON. Pass the result to `srs.parse` - `srs.parse` no longer supports being passed a filepath to a GeoJSON. 0.3.12 - Fixed generation of valid `srs_settings.js` on windows (#39) - Fixed detection of some ESRI variant projections (#38) - Added preliminary appveyor.yml for continuous builds on windows 0.3.11 - Removed binary stripping on OS X which may cause link problems on mavericks - Move to Mapbox organization 0.3.10 - Improved support for topojson 0.3.9 - `--runtime_link` option fixed to only apply when `--shared_gdal` is passed. 0.3.8 - Build fixes for windows 0.3.7 - Build fix for python3 (#33) 0.3.6 - Build fixes to avoid possible undefined symbol errors are runtime on ubuntu linux - Additional travis.ci testing of 32bit builds 0.3.5 - Minor test fixes to work with variable external gdal versions 0.3.4 - Changed name of build option to configure against shared gdal lib. Now pass `npm install --shared_gdal` (to be consistent with older node-srs). 0.3.3 - Now building against internal `osr` again by default. Pass `npm install --gdal=shared` to build against systemwide GDAL (#30) - Now forcing canonical wgs84/epsg:4326 represenation - Now translating `+init` syntax to `+proj` for known projections (epsg:4326 and epsg:3857) - Various fixes to detect more projections 0.3.2 - Re-enabled optional linking with `gdal-config --dep-libs` by passing `npm install --runtime_link=static` 0.3.1 - Removed build linking to gdal libs / gdal-config --dep-libs, now only linking to libgdal itself by default 0.3.0 - Now using node-gyp for build - Now requiring Node >= 0.6.13 (for node-gyp support) - Node v0.10.x support - Now requiring external libgdal - Better detection of more spherical mercator variants - Better detection of +init=epsg based mercator srs and auto-transformation to +proj syntax node-srs-0.4.8+dfsg/LICENSE.txt000066400000000000000000000031121254154173100160170ustar00rootroot00000000000000Copyright (c) 2011, Dane Springmeyer All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of the author nor the names of other contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. This project also includes code and files from GDAL, see GDAL_LICENSE for more details.node-srs-0.4.8+dfsg/Makefile000077500000000000000000000014351254154173100156450ustar00rootroot00000000000000#http://www.gnu.org/prep/standards/html_node/Standard-Targets.html#Standard-Targets all: build ./node_modules: npm install --build-from-source build: ./node_modules ./node_modules/.bin/node-pre-gyp build --loglevel=error debug: ./node_modules/.bin/node-pre-gyp rebuild --debug verbose: ./node_modules/.bin/node-pre-gyp rebuild --loglevel=verbose clean: @rm -rf ./build rm -rf lib/binding/ rm -rf ./node_modules/ grind: valgrind --leak-check=full node node_modules/.bin/_mocha rebuild: @make clean @make ifndef only test: @PATH="./node_modules/mocha/bin:${PATH}" && NODE_PATH="./lib:$(NODE_PATH)" mocha -R spec else test: @PATH="./node_modules/mocha/bin:${PATH}" && NODE_PATH="./lib:$(NODE_PATH)" mocha -R spec test/${only}.test.js endif check: test .PHONY: test clean build node-srs-0.4.8+dfsg/README.md000066400000000000000000000117361254154173100154660ustar00rootroot00000000000000# Node-Srs Linux: [![Build Status](https://secure.travis-ci.org/mapbox/node-srs.svg)](http://travis-ci.org/mapbox/node-srs) Windows: [![Build status](https://ci.appveyor.com/api/projects/status/ff1n3h7h506i4vx0)](https://ci.appveyor.com/project/Mapbox/node-srs) This module tries to detect projections, also known as "spatial reference systems". It works similiarly to [gdalsrsinfo](http://www.gdal.org/gdalsrsinfo.html). `node-srs` supports parsing a variety of textual representations of projections, like the formats known as `OGC WKT`, `ESRI WKT`, `OGC CRS URN`, or `proj4`. It supports [shapefiles](http://en.wikipedia.org/wiki/Shapefile) and [GeoJSON](http://geojson.org/). Shapefiles optionally come with a separate .prj and inside the `.prj` the text is usually in the `ESRI WKT` format. GeoJSON optionally contains a `crs` property that declares projection as `OGC CRS URN`. Detecting projections is important for applications like TileMill, which - through Mapnik - needs the `proj4` representation of a projection to create coordinate transformations for re-projecting vector or raster data on the fly. `node-srs` includes a variety of hacks to determine if your projection looks like `web mercator` (epsg:3857) or `wgs84` (epsg:4326) and if so returns the canonical representations of these projections (according to @springmeyer). This ensures applications like TileMill can avoid unneeded projection. It is common for data out in the wild in web mercator projection to store slightly different projection strings based on the software that created the files. `node-srs` ensures a consistent final `proj4` representation is returned for all of the variety of representations of web mercator. This is critical because even mercator to mercator transformations are expensive if proj4 is asked to do this for large datasets. `node-srs` does not support looking for, or detecting, projection information in formats like GeoTIFF, PostGIS, or SQLite. Rather for those formats you would need to extract the projection information yourself and then pass it to `node-srs`. ## API ### `srs.parse(string)` Parse a string of projection specification data and return an object describing the detected projection. If the SRS cannot be parsed, throws a `TypeError` describing the issue. ## Example Detect a proj4 literal string as spherical mercator: ```js > var srs = require('srs'); > srs.parse('+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs') { proj4: '+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0.0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs +over', srid: 3857, auth: 'EPSG', pretty_wkt: 'PROJCS["WGS 84 / Pseudo-Mercator",\n GEOGCS["WGS 84",\n DATUM["WGS_1984",\n SPHEROID["WGS 84",6378137,298.257223563,\n AUTHORITY["EPSG","7030"]],\n AUTHORITY["EPSG","6326"]],\n PRIMEM["Greenwich",0,\n AUTHORITY["EPSG","8901"]],\n UNIT["degree",0.0174532925199433,\n AUTHORITY["EPSG","9122"]],\n AUTHORITY["EPSG","4326"]],\n UNIT["metre",1,\n AUTHORITY["EPSG","9001"]],\n PROJECTION["Mercator_1SP"],\n PARAMETER["central_meridian",0],\n PARAMETER["scale_factor",1],\n PARAMETER["false_easting",0],\n PARAMETER["false_northing",0],\n EXTENSION["PROJ4","+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs"],\n AUTHORITY["EPSG","3857"],\n AXIS["X",EAST],\n AXIS["Y",NORTH]]', esri: false, name: 'Google Maps Global Mercator', valid: true, is_geographic: false, input: '+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs' } ``` Detect a WKT string as WGS84: ```js > srs.parse('GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137,298.257223563]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]]') { input: 'GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137,298.257223563]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]]', proj4: '+proj=longlat +ellps=WGS84 +no_defs', srid: 4326, auth: 'EPSG', pretty_wkt: 'GEOGCS["GCS_WGS_1984",\n DATUM["D_WGS_1984",\n SPHEROID["WGS_1984",6378137,298.257223563]],\n PRIMEM["Greenwich",0],\n UNIT["Degree",0.017453292519943295],\n AUTHORITY["EPSG","4326"]]', esri: false, name: 'GCS_WGS_1984', valid: true, is_geographic: true } ``` ## Depends - Node >= 0.6.13 (development headers) - No other required dependencies (though can optionally depend on external `libgdal`) ## Installation Install from binary: npm install Install from source: npm install --build-from-source From source: git clone git://github.com/mapbox/node-srs.git cd node-srs npm install Against external libgdal (avoids compiling internal copy of libosr) npm install --build-from-source --shared_gdal ## Test npm test ## License BSD, see LICENSE.txt node-srs-0.4.8+dfsg/appveyor.yml000066400000000000000000000070131254154173100165700ustar00rootroot00000000000000environment: node_pre_gyp_accessKeyId: secure: 7DrSVc5eIGtmMcki5H+iRft+Tk3MJTwDBQEUuJHWaQ4= node_pre_gyp_secretAccessKey: secure: 1amwJJw9fu0j6dXnc5KsAQbSYf7Cjw/dapT6OZWABa6nc52grkKeLQ+DGaOfQz8i matrix: - nodejs_version: 0.10.36 platform: x86 msvs_toolset: 12 - nodejs_version: 0.10.36 platform: x64 msvs_toolset: 12 - nodejs_version: 0.12.0 platform: x86 msvs_toolset: 12 - nodejs_version: 0.12.0 platform: x64 msvs_toolset: 12 # custom 64 bit visual studio 2014 builds - nodejs_version: 0.10.36 platform: x64 msvs_toolset: 14 TOOLSET_ARGS: --dist-url=https://s3.amazonaws.com/mapbox/node-cpp11 --toolset=v140 - nodejs_version: 0.10.36 platform: x86 msvs_toolset: 14 TOOLSET_ARGS: --dist-url=https://s3.amazonaws.com/mapbox/node-cpp11 --toolset=v140 - nodejs_version: 0.11.14 platform: x86 msvs_toolset: 14 TOOLSET_ARGS: --dist-url=https://s3.amazonaws.com/mapbox/node-cpp11 --toolset=v140 - nodejs_version: 0.11.14 platform: x64 msvs_toolset: 14 TOOLSET_ARGS: --dist-url=https://s3.amazonaws.com/mapbox/node-cpp11 --toolset=v140 - nodejs_version: 0.12.0 platform: x86 msvs_toolset: 14 TOOLSET_ARGS: --dist-url=https://s3.amazonaws.com/mapbox/node-cpp11 --toolset=v140 - nodejs_version: 0.12.0 platform: x64 msvs_toolset: 14 TOOLSET_ARGS: --dist-url=https://s3.amazonaws.com/mapbox/node-cpp11 --toolset=v140 os: Visual Studio 2014 CTP4 install: # add local node to path (since we install it for msvs_toolset == 14) - SET PATH=%CD%;%PATH%; # add local node-pre-gyp dir to path - SET PATH=node_modules\.bin;%PATH% # use 64 bit python if platform is 64 bit - if "%PLATFORM%" == "x64" set PATH=C:\Python27-x64;%PATH% - SET ARCHPATH= - if %platform% == x64 (SET ARCHPATH=x64/) # install node version per visual studio toolset - if "%msvs_toolset%" == "12" powershell Install-Product node $env:nodejs_version $env:Platform - if "%msvs_toolset%" == "14" powershell Write-Output "fetching https://mapbox.s3.amazonaws.com/node-cpp11/v$env:nodejs_version/${env:ARCHPATH}node.exe" - if "%msvs_toolset%" == "14" powershell Start-FileDownload "https://mapbox.s3.amazonaws.com/node-cpp11/v$env:nodejs_version/${env:ARCHPATH}node.exe" - node -v - node -e "console.log(process.argv,process.execPath)" - SET PATH=C:\Program Files (x86)\MSBuild\%msvs_toolset%.0\bin;%PATH% - SET PATH=C:\Program Files (x86)\Microsoft Visual Studio %msvs_toolset%.0\VC\bin;%PATH% - if %platform% == x64 CALL "C:\Program Files (x86)\Microsoft Visual Studio %msvs_toolset%.0\VC\vcvarsall.bat" amd64 - if %platform% == x86 CALL "C:\Program Files (x86)\Microsoft Visual Studio %msvs_toolset%.0\VC\vcvarsall.bat" amd64_x86 - npm install --build-from-source --msvs_version=2013 %TOOLSET_ARGS% --loglevel=http - node_modules\.bin\node-pre-gyp reveal module --silent > module.txt - SET /p MODULE= node_path.txt - SET /p NODE_EXE_PATH= -1) { return force_merc({input:arg}); } if (code === 4326) { return force_wgs84({input:arg}); } } } for (var hack in constants.known_esri_variant_special_cases) { var obj = constants.known_esri_variant_special_cases[hack]; if (arg.indexOf(obj[0]) > -1) { arg = arg.replace(obj[0],obj[1]); } } var result; var esri_try = false; try { result = srs._parse(arg); } catch (err) { if (arg.indexOf('ESRI::') !== 0) { try { esri_try = true; result = srs._parse('ESRI::' + arg); } catch (esri_err) { throw err; // throw original error } } else { throw err; } } // if the first parse succeeded without throwing // but still failed to detect the proj4 string then // we need to try harder and assume an ESRI variant if (result.proj4 === undefined && esri_try === false && arg.indexOf('ESRI::') !== 0) { try { var esri_result = srs._parse('ESRI::' + arg); // success detecting proj4 as ESRI variant? if (esri_result.proj4) { result = esri_result; } } catch (err) { // pass } } // force wgs84 variants to canonical if (result.srid === 4326) { return force_wgs84(result); } // detect mercator variants and // replace with canonical.spherical_mercator if (result.name in oc(constants.merc_names)) { // this should be a fast track for many .prj files return force_merc(result); } else if (result.srid in oc(constants.merc_srids)) { return force_merc(result); } else if (result.proj4 !== undefined && result.proj4.indexOf('+proj=merc') != -1) { // catch case of gdal's translation to proj4 being used as input if (result.proj4 === '+proj=merc +lon_0=0 +lat_ts=0 +x_0=0 +y_0=0 +ellps=WGS84 +units=m +no_defs') { return force_merc(result); } else if (result.proj4 === '+proj=merc +lon_0=0 +lat_ts=0 +x_0=0 +y_0=0 +a=6378137 +b=6378137 +units=m +no_defs') { return force_merc(result); } // break into parts // TODO - sort and remove less critical pairs var parts = split_proj(result.proj4); if (JSON.stringify(parts) === canonical_stringify) { return force_merc(result); } } // detect OSGB variant and fix the srid // https://github.com/mapbox/node-srs/issues/25 if (!result.srid && result.name == 'OSGB 1936 / British National Grid') { result.srid = 27700; result.auth = 27700; } return result; }; function jsonCrs(gj) { if (gj.crs && gj.crs.properties) { if (gj.crs.properties.urn) { return gj.crs.properties.urn; } else if (gj.crs.properties.name) { return gj.crs.properties.name; } } else { return canonical.wgs84.proj4; } } function oc(a) { var o = {}; for (var i = 0; i < a.length; i++) { o[a[i]] = ''; } return o; } function force_merc(result) { var new_srs = canonical.spherical_mercator; new_srs.input = result.input; return new_srs; } function force_wgs84(result) { var new_srs = canonical.wgs84; new_srs.input = result.input; return new_srs; } // push all C++ symbols into js module for (var k in srs) { exports[k] = srs[k]; } // make available objects from js exports.settings = srs_settings; exports.canonical = canonical; exports.split_proj = split_proj; exports.parse = parse; exports.jsonCrs = jsonCrs; node-srs-0.4.8+dfsg/package.json000066400000000000000000000021351254154173100164660ustar00rootroot00000000000000{ "name": "srs", "version": "0.4.8", "main": "./lib/index.js", "description": "Spatial reference library for node", "keywords": [ "map", "projection", "spatialreference", "srid", "proj4", "mercator", "gdal", "ogr", "osr" ], "binary": { "module_name" : "srs", "module_path" : "./lib/binding/{node_abi}-{platform}-{arch}", "host" : "https://mapbox-node-binary.s3.amazonaws.com", "remote_path" : "./{name}/v{version}/{toolset}/", "package_name": "{node_abi}-{platform}-{arch}.tar.gz" }, "url": "http://github.com/mapbox/node-srs", "repository": { "type": "git", "url": "git://github.com/mapbox/node-srs.git" }, "dependencies": { "nan": "~1.8.4", "node-pre-gyp": "~0.6.7" }, "bundledDependencies": [ "node-pre-gyp" ], "author": "Dane Springmeyer ", "licenses": [ "BSD" ], "scripts": { "prepublish": "npm ls", "install": "node-pre-gyp install --fallback-to-build", "test": "mocha -R spec" }, "devDependencies": { "mocha": "1.x", "aws-sdk": "~2.0.25" } } node-srs-0.4.8+dfsg/scripts/000077500000000000000000000000001254154173100156665ustar00rootroot00000000000000node-srs-0.4.8+dfsg/scripts/package_osx.sh000077500000000000000000000015021254154173100205070ustar00rootroot00000000000000#!/bin/bash set -e CURRENT_DIR="$( cd "$( dirname $BASH_SOURCE )" && pwd )" cd $CURRENT_DIR/../ source ~/.nvm/nvm.sh nvm install 0.10 nvm use 0.10 npm install node-pre-gyp npm install aws-sdk ./node_modules/.bin/node-pre-gyp info npm cache clean rm -rf sdk function doit () { NVER=$1 nvm install $1 nvm use $1 npm install --build-from-source npm test node ./node_modules/.bin/node-pre-gyp package testpackage node ./node_modules/.bin/node-pre-gyp testpackage npm ls node ./node_modules/.bin/node-pre-gyp publish node ./node_modules/.bin/node-pre-gyp info rm -rf {build,lib/binding} npm install --fallback-to-build=false npm test } doit 0.10.33 doit 0.11.14 # to avoid then publishing with node v0.11.x # https://github.com/npm/npm/issues/5515#issuecomment-46688278 nvm use 0.10 node-srs-0.4.8+dfsg/src/000077500000000000000000000000001254154173100147665ustar00rootroot00000000000000node-srs-0.4.8+dfsg/src/srs.cc000066400000000000000000000131371254154173100161110ustar00rootroot00000000000000// v8 #include // node #include #include #include // stl #include #include #include #include // osr #include "ogr_spatialref.h" #include "cpl_error.h" // CPLE_AppDefined #include "cpl_conv.h" // CPLFree #include "cpl_string.h" // CPLString using namespace node; using namespace v8; #define TOSTR(obj) (*String::Utf8Value((obj)->ToString())) /* OGRERR_DICT = { 1 : (OGRException, "Not enough data."), 2 : (OGRException, "Not enough memory."), 3 : (OGRException, "Unsupported geometry type."), 4 : (OGRException, "Unsupported operation."), 5 : (OGRException, "Corrupt data."), 6 : (OGRException, "OGR failure."), 7 : (SRSException, "Unsupported SRS."), 8 : (OGRException, "Invalid handle."), } */ NAN_METHOD(parse) { NanScope(); if (args.Length() != 1 || !args[0]->IsString()) return NanThrowTypeError("first argument must be srs string in any form readable by OGR, like WKT (.prj file) or a proj4 string"); Local result = NanNew(); result->Set(NanNew("input"), args[0]->ToString()); result->Set(NanNew("proj4"), NanUndefined()); result->Set(NanNew("srid"), NanUndefined()); result->Set(NanNew("auth"), NanUndefined()); result->Set(NanNew("pretty_wkt"), NanUndefined()); result->Set(NanNew("esri"), NanUndefined()); result->Set(NanNew("name"), NanUndefined()); std::string wkt_string = TOSTR(args[0]->ToString()); const char *wkt_char = wkt_string.data(); bool error = false; std::string err_msg; OGRSpatialReference oSRS; if( oSRS.SetFromUserInput(wkt_char) != OGRERR_NONE ) { error = true; std::ostringstream s; s << "OGR Error type #" << CPLE_AppDefined << " problem occured importing from srs wkt: " << wkt_string << ".\n";; err_msg = s.str(); // try again to import from ESRI oSRS.Clear(); char **wkt_lines = NULL; wkt_lines = CSLTokenizeString2( wkt_char, " \t\n", CSLT_HONOURSTRINGS | CSLT_ALLOWEMPTYTOKENS ); if( oSRS.importFromESRI(wkt_lines) != OGRERR_NONE ) { error = true; oSRS.Clear(); } else { error = false; result->Set(NanNew("esri"), NanNew(true)); } } else { error = false; if (wkt_string.substr(0,6) == "ESRI::") { result->Set(NanNew("esri"), NanNew(true)); } else { result->Set(NanNew("esri"), NanNew(false)); } } if (error) { return NanThrowError(err_msg.c_str()); } else { char *srs_output = NULL; if (oSRS.Validate() == OGRERR_NONE) { result->Set(NanNew("valid"), NanNew(true)); } else if (oSRS.Validate() == OGRERR_UNSUPPORTED_SRS) { result->Set(NanNew("valid"), NanNew(false)); } else { result->Set(NanNew("valid"), NanNew(false)); } if (oSRS.exportToProj4( &srs_output ) == OGRERR_NONE ) { // proj4 strings from osr have an uneeded trailing slash, so we trim it... result->Set(NanNew("proj4"), NanNew(CPLString(srs_output).Trim().c_str())); } CPLFree( srs_output ); if (oSRS.AutoIdentifyEPSG() != OGRERR_NONE ) { // do nothing } if (oSRS.IsGeographic()) { result->Set(NanNew("is_geographic"), NanNew(true)); const char *code = oSRS.GetAuthorityCode("GEOGCS"); if (code) { result->Set(NanNew("srid"), NanNew(atoi(code))); } const char *auth = oSRS.GetAuthorityName("GEOGCS"); if (auth) { result->Set(NanNew("auth"), NanNew(auth)); } const char *name = oSRS.GetAttrValue("GEOGCS"); if (name) { result->Set(NanNew("name"), NanNew(name)); } } else { result->Set(NanNew("is_geographic"), NanNew(false)); const char *code = oSRS.GetAuthorityCode("PROJCS"); if (code) { result->Set(NanNew("srid"), NanNew(atoi(code))); } const char *auth = oSRS.GetAuthorityName("PROJCS"); if (auth) { result->Set(NanNew("auth"), NanNew(auth)); } const char *name = oSRS.GetAttrValue("PROJCS"); if (name) { result->Set(NanNew("name"), NanNew(name)); } } char *srs_output2 = NULL; if (oSRS.exportToPrettyWkt( &srs_output2 , 0) == OGRERR_NONE ) { result->Set(NanNew("pretty_wkt"), NanNew(srs_output2)); } CPLFree(srs_output2); NanReturnValue(result); } } extern "C" { static void init (Handle target) { NODE_SET_METHOD(target, "_parse", parse); // versions of deps Local versions = NanNew(); versions->Set(NanNew("node"), NanNew(NODE_VERSION+1)); versions->Set(NanNew("v8"), NanNew(V8::GetVersion())); target->Set(NanNew("versions"), versions); } NODE_MODULE(srs, init); } node-srs-0.4.8+dfsg/test/000077500000000000000000000000001254154173100151565ustar00rootroot00000000000000node-srs-0.4.8+dfsg/test/data/000077500000000000000000000000001254154173100160675ustar00rootroot00000000000000node-srs-0.4.8+dfsg/test/data/27700_esri_wkt.prj000066400000000000000000000006371254154173100212000ustar00rootroot00000000000000PROJCS["OSGB 1936 / British National Grid",GEOGCS["OSGB 1936",DATUM["D_OSGB_1936",SPHEROID["Airy_1830",6377563.396,299.3249646]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]],PROJECTION["Transverse_Mercator"],PARAMETER["latitude_of_origin",49],PARAMETER["central_meridian",-2],PARAMETER["scale_factor",0.9996012717],PARAMETER["false_easting",400000],PARAMETER["false_northing",-100000],UNIT["Meter",1]]node-srs-0.4.8+dfsg/test/data/27700_ogc_wkt.prj000066400000000000000000000011701254154173100207770ustar00rootroot00000000000000PROJCS["OSGB 1936 / British National Grid",GEOGCS["OSGB 1936",DATUM["OSGB_1936",SPHEROID["Airy 1830",6377563.396,299.3249646,AUTHORITY["EPSG","7001"]],AUTHORITY["EPSG","6277"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.01745329251994328,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4277"]],UNIT["metre",1,AUTHORITY["EPSG","9001"]],PROJECTION["Transverse_Mercator"],PARAMETER["latitude_of_origin",49],PARAMETER["central_meridian",-2],PARAMETER["scale_factor",0.9996012717],PARAMETER["false_easting",400000],PARAMETER["false_northing",-100000],AUTHORITY["EPSG","27700"],AXIS["Easting",EAST],AXIS["Northing",NORTH]]node-srs-0.4.8+dfsg/test/data/3395-non-spherical-merc.prj000066400000000000000000000001051254154173100226670ustar00rootroot00000000000000+proj=merc +lon_0=0 +k=1 +x_0=0 +y_0=0 +datum=WGS84 +units=m +no_defsnode-srs-0.4.8+dfsg/test/data/3857-ogr-1.10.0-wkt.prj000066400000000000000000000005271254154173100213210ustar00rootroot00000000000000PROJCS["WGS_84_Pseudo_Mercator",GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137,298.257223563]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]],PROJECTION["Mercator"],PARAMETER["central_meridian",0],PARAMETER["false_easting",0],PARAMETER["false_northing",0],UNIT["Meter",1],PARAMETER["standard_parallel_1",0.0]]node-srs-0.4.8+dfsg/test/data/4326.esri.prj000066400000000000000000000002171254154173100201430ustar00rootroot00000000000000GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137,298.257223563]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]]node-srs-0.4.8+dfsg/test/data/4326.prj000066400000000000000000000002171254154173100172020ustar00rootroot00000000000000GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137,298.257223563]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]]node-srs-0.4.8+dfsg/test/data/900913.esri.prj000066400000000000000000000006001254154173100203060ustar00rootroot00000000000000PROJCS["Google_Maps_Global_Mercator",GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137,298.257223563]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]],PROJECTION["Mercator_2SP"],PARAMETER["standard_parallel_1",0],PARAMETER["latitude_of_origin",0],PARAMETER["central_meridian",0],PARAMETER["false_easting",0],PARAMETER["false_northing",0],UNIT["Meter",1]]node-srs-0.4.8+dfsg/test/data/admin-0-poly.prj000077500000000000000000000005041254154173100210140ustar00rootroot00000000000000PROJCS["Mercator_2SP",GEOGCS["unnamed ellipse",DATUM["D_unknown",SPHEROID["Unknown",6378137,0]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]],PROJECTION["Mercator_2SP"],PARAMETER["standard_parallel_1",0],PARAMETER["central_meridian",0],PARAMETER["false_easting",0],PARAMETER["false_northing",0],UNIT["Meter",1]]node-srs-0.4.8+dfsg/test/data/bogus_mercator2sp.prj000066400000000000000000000005041254154173100222430ustar00rootroot00000000000000PROJCS["Mercator_2SP",GEOGCS["unnamed ellipse",DATUM["D_unknown",SPHEROID["Unknown",6378137,0]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]],PROJECTION["Mercator_2SP"],PARAMETER["standard_parallel_1",0],PARAMETER["central_meridian",0],PARAMETER["false_easting",0],PARAMETER["false_northing",0],UNIT["Meter",1]]node-srs-0.4.8+dfsg/test/data/cali.prj000066400000000000000000000010671254154173100175200ustar00rootroot00000000000000PROJCS["NAD_1983_StatePlane_California_III_FIPS_0403_Feet",GEOGCS["GCS_North_American_1983",DATUM["D_North_American_1983",SPHEROID["GRS_1980",6378137.0,298.257222101]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],PROJECTION["Lambert_Conformal_Conic"],PARAMETER["False_Easting",6561666.666666666],PARAMETER["False_Northing",1640416.666666667],PARAMETER["Central_Meridian",-120.5],PARAMETER["Standard_Parallel_1",37.06666666666667],PARAMETER["Standard_Parallel_2",38.43333333333333],PARAMETER["Latitude_Of_Origin",36.5],UNIT["Foot_US",0.3048006096012192]]node-srs-0.4.8+dfsg/test/data/esri-mercator-1sp.prj000066400000000000000000000005721254154173100220650ustar00rootroot00000000000000PROJCS["Mercator_1SP",GEOGCS["GCS_Geographic Coordinate System",DATUM["D_WGS_1984_MAJOR_AUXILIARY_SPHERE",SPHEROID["Sphere_Radius_6378137_m",6378137,0]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]],PROJECTION["Mercator"],PARAMETER["central_meridian",0],PARAMETER["standard_parallel_1",0],PARAMETER["false_easting",0],PARAMETER["false_northing",0],UNIT["Meter",1]] node-srs-0.4.8+dfsg/test/data/esri_webmerc.prj000066400000000000000000000006331254154173100212540ustar00rootroot00000000000000PROJCS["WGS_1984_Web_Mercator",GEOGCS["GCS_WGS_1984_Major_Auxiliary_Sphere",DATUM["D_WGS_1984_Major_Auxiliary_Sphere",SPHEROID["WGS_1984_Major_Auxiliary_Sphere",6378137.0,0.0]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],PROJECTION["Mercator"],PARAMETER["False_Easting",0.0],PARAMETER["False_Northing",0.0],PARAMETER["Central_Meridian",0.0],PARAMETER["Standard_Parallel_1",0.0],UNIT["Meter",1.0]]node-srs-0.4.8+dfsg/test/data/esri_webmerc_auxshpere.prj000066400000000000000000000006511254154173100233400ustar00rootroot00000000000000PROJCS["WGS_1984_Web_Mercator_Auxiliary_Sphere",GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137.0,298.257223563]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],PROJECTION["Mercator_Auxiliary_Sphere"],PARAMETER["False_Easting",0.0],PARAMETER["False_Northing",0.0],PARAMETER["Central_Meridian",0.0],PARAMETER["Standard_Parallel_1",0.0],PARAMETER["Auxiliary_Sphere_Type",0.0],UNIT["Meter",1.0]]node-srs-0.4.8+dfsg/test/data/esri_webmerc_auxshpere2.prj000066400000000000000000000010311254154173100234130ustar00rootroot00000000000000PROJCS["WGS_1984_Web_Mercator_Auxiliary_Sphere", GEOGCS["GCS_WGS_1984", DATUM["D_WGS_1984", SPHEROID["WGS_1984",6378137.0,298.257223563]], PRIMEM["Greenwich",0.0], UNIT["Degree",0.0174532925199433]], PROJECTION["Mercator_Auxiliary_Sphere"], PARAMETER["False_Easting",0.0], PARAMETER["False_Northing",0.0], PARAMETER["Central_Meridian",0.0], PARAMETER["Standard_Parallel_1",0.0], PARAMETER["Auxiliary_Sphere_Type",0.0], UNIT["Meter",1.0], AUTHORITY["ESRI","102100"]]node-srs-0.4.8+dfsg/test/data/maryland.prj000077500000000000000000000007671254154173100204300ustar00rootroot00000000000000PROJCS["NAD_1983_StatePlane_Maryland_FIPS_1900",GEOGCS["GCS_North_American_1983",DATUM["D_North_American_1983",SPHEROID["GRS_1980",6378137.0,298.257222101]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],PROJECTION["Lambert_Conformal_Conic"],PARAMETER["False_Easting",400000.0],PARAMETER["False_Northing",0.0],PARAMETER["Central_Meridian",-77.0],PARAMETER["Standard_Parallel_1",38.3],PARAMETER["Standard_Parallel_2",39.45],PARAMETER["Latitude_Of_Origin",37.66666666666666],UNIT["Meter",1.0]]node-srs-0.4.8+dfsg/test/data/mystery-api000066400000000000000000000002721254154173100202760ustar00rootroot00000000000000 { "type":"Feature", "id":"OpenLayers.Feature.Vector_314", "properties":{}, "geometry":{ "type":"Point", "coordinates":[97.03125, 39.7265625] } }node-srs-0.4.8+dfsg/test/data/osm_landusages.prj000066400000000000000000000006321254154173100216110ustar00rootroot00000000000000PROJCS["Popular_Visualisation_CRS_Mercator_deprecated",GEOGCS["GCS_Popular Visualisation CRS",DATUM["D_Popular_Visualisation_Datum",SPHEROID["Popular_Visualisation_Sphere",6378137,0]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]],PROJECTION["Mercator"],PARAMETER["central_meridian",0],PARAMETER["false_easting",0],PARAMETER["false_northing",0],UNIT["Meter",1],PARAMETER["standard_parallel_1",0.0]]node-srs-0.4.8+dfsg/test/data/prj2epsg-wkt-3857.prj000066400000000000000000000014761254154173100215570ustar00rootroot00000000000000PROJCS["WGS 84 / Pseudo-Mercator", GEOGCS["WGS 84", DATUM["World Geodetic System 1984", SPHEROID["WGS 84", 6378137.0, 298.257223563, AUTHORITY["EPSG","7030"]], AUTHORITY["EPSG","6326"]], PRIMEM["Greenwich", 0.0, AUTHORITY["EPSG","8901"]], UNIT["degree", 0.017453292519943295], AXIS["Geodetic longitude", EAST], AXIS["Geodetic latitude", NORTH], AUTHORITY["EPSG","4326"]], PROJECTION["Popular Visualisation Pseudo Mercator", AUTHORITY["EPSG","1024"]], PARAMETER["semi_minor", 6378137.0], PARAMETER["latitude_of_origin", 0.0], PARAMETER["central_meridian", 0.0], PARAMETER["scale_factor", 1.0], PARAMETER["false_easting", 0.0], PARAMETER["false_northing", 0.0], UNIT["m", 1.0], AXIS["Easting", EAST], AXIS["Northing", NORTH], AUTHORITY["EPSG","3857"]] node-srs-0.4.8+dfsg/test/data/simplified-land-polygons-complete-3857.prj000066400000000000000000000015171254154173100257330ustar00rootroot00000000000000PROJCS["WGS 84 / Pseudo-Mercator", GEOGCS["WGS 84", DATUM["WGS_1984", SPHEROID["WGS 84",6378137,298.257223563, AUTHORITY["EPSG","7030"]], AUTHORITY["EPSG","6326"]], PRIMEM["Greenwich",0, AUTHORITY["EPSG","8901"]], UNIT["degree",0.0174532925199433, AUTHORITY["EPSG","9122"]], AUTHORITY["EPSG","4326"]], PROJECTION["Mercator_1SP"], PARAMETER["central_meridian",0], PARAMETER["scale_factor",1], PARAMETER["false_easting",0], PARAMETER["false_northing",0], UNIT["metre",1, AUTHORITY["EPSG","9001"]], AXIS["X",EAST], AXIS["Y",NORTH], EXTENSION["PROJ4","+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs"], AUTHORITY["EPSG","3857"]] node-srs-0.4.8+dfsg/test/data/sr-org-6-esriwkt.prj000066400000000000000000000007231254154173100216500ustar00rootroot00000000000000PROJCS["Mercator_2SP",GEOGCS["unnamed ellipse",DATUM["D_unknown",SPHEROID["Unknown",6378137,0]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]],PROJECTION["Mercator_2SP"],PARAMETER["standard_parallel_1",0],PARAMETER["central_meridian",0],PARAMETER["false_easting",0],PARAMETER["false_northing",0],UNIT["Meter",1],EXTENSION["PROJ4","+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs"]]node-srs-0.4.8+dfsg/test/data/sr-org-6-ogcwkt.prj000066400000000000000000000007121254154173100214540ustar00rootroot00000000000000PROJCS["unnamed",GEOGCS["unnamed ellipse",DATUM["unknown",SPHEROID["unnamed",6378137,0]],PRIMEM["Greenwich",0],UNIT["degree",0.0174532925199433]],PROJECTION["Mercator_2SP"],PARAMETER["standard_parallel_1",0],PARAMETER["central_meridian",0],PARAMETER["false_easting",0],PARAMETER["false_northing",0],UNIT["Meter",1],EXTENSION["PROJ4","+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs"]]node-srs-0.4.8+dfsg/test/data/test.json000066400000000000000000000004701254154173100177420ustar00rootroot00000000000000 { "type":"Feature", "id":"OpenLayers.Feature.Vector_314", "properties":{}, "geometry":{ "type":"Point", "coordinates":[97.03125, 39.7265625] }, "crs":{ "type":"OGC", "properties":{ "urn":"urn:ogc:def:crs:OGC:1.3:CRS84" } } }node-srs-0.4.8+dfsg/test/data/transverse_merc_kasey.prj000066400000000000000000000006661254154173100232120ustar00rootroot00000000000000PROJCS["Transverse_Mercator",GEOGCS["GCS_Clarke 1866",DATUM["D_unknown",SPHEROID["clrk66",6378206.4,294.9786982]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]],PROJECTION["Transverse_Mercator"],PARAMETER["latitude_of_origin",35.83333333333334],PARAMETER["central_meridian",-90.5],PARAMETER["scale_factor",0.9999333333333333],PARAMETER["false_easting",500000],PARAMETER["false_northing",0],UNIT["Foot_US",0.30480060960121924]]node-srs-0.4.8+dfsg/test/data/transverse_merc_kasey_custom_grids.prj000066400000000000000000000007541254154173100257720ustar00rootroot00000000000000PROJCS["unnamed",GEOGCS["Clarke 1866",DATUM["unknown",SPHEROID["clrk66",6378206.4,294.9786982139006],EXTENSION["PROJ4_GRIDS","@conus,@alaska,@ntv2_0.gsb,@ntv1_can.dat"]],PRIMEM["Greenwich",0],UNIT["degree",0.0174532925199433]],PROJECTION["Transverse_Mercator"],PARAMETER["latitude_of_origin",35.83333333333334],PARAMETER["central_meridian",-90.5],PARAMETER["scale_factor",0.9999333333333333],PARAMETER["false_easting",500000],PARAMETER["false_northing",0],UNIT["Foot_US",0.3048006096012192]] node-srs-0.4.8+dfsg/test/data/world_borders_merc.prj000077500000000000000000000005101254154173100224600ustar00rootroot00000000000000PROJCS["Mercator_2SP",GEOGCS["GCS_unnamed ellipse",DATUM["D_unknown",SPHEROID["Unknown",6378137,0]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]],PROJECTION["Mercator_2SP"],PARAMETER["standard_parallel_1",0],PARAMETER["central_meridian",0],PARAMETER["false_easting",0],PARAMETER["false_northing",0],UNIT["Meter",1]]node-srs-0.4.8+dfsg/test/data/world_extent_merc.geojson000066400000000000000000000006461254154173100232070ustar00rootroot00000000000000{ "crs": { "type": "name", "properties": { "name": "epsg:900913" } }, "type": "FeatureCollection", "features": [ { "type": "Feature", "properties": { "FID": 0.000000 }, "geometry": { "type": "Polygon", "coordinates": [[ [-20037508.34,-20037508.34], [-20037508.34,20037508.34], [20037508.34,20037508.34], [20037508.34,-20037508.34], [-20037508.34,-20037508.34] ]] } } ] } node-srs-0.4.8+dfsg/test/data/world_extent_wgs84.geojson000066400000000000000000000005151254154173100232300ustar00rootroot00000000000000{ "type": "FeatureCollection", "features": [ { "type": "Feature", "properties": { "FID": 0.000000 }, "geometry": { "type": "Polygon", "coordinates": [ [ [ -180.0, -85.051129 ], [ -180.0, 85.051129 ], [ 180.0, 85.051129 ], [ 180.0, -85.051129 ], [ -180.0, -85.051129 ] ] ] } } ] } node-srs-0.4.8+dfsg/test/esri_variant.test.js000066400000000000000000000007531254154173100211650ustar00rootroot00000000000000var srs = require('../'); var fs = require('fs'); var assert = require('assert'); // http://spatialreference.org/ref/esri/102685/ // http://spatialreference.org/ref/sr-org/7058/ describe('maryland ESRI variant', function() { it('detects proj if parsed as ESRI::', function(done) { var ref = srs.parse(fs.readFileSync('./test/data/maryland.prj')); assert.ok(ref.proj4); assert.equal(ref.name,'NAD_1983_StatePlane_Maryland_FIPS_1900'); done(); }); }); node-srs-0.4.8+dfsg/test/geojson.test.js000066400000000000000000000017201254154173100201360ustar00rootroot00000000000000var srs = require('../'); var assert = require('assert'); var fs = require('fs'); var util = require('./util'); describe('GeoJSON', function() { it('should detect mercator', function() { var merc = srs.parse(srs.jsonCrs(JSON.parse(fs.readFileSync('./test/data/world_extent_merc.geojson')))); assert.equal(merc.proj4, srs.canonical.spherical_mercator.proj4); }); it('should detect wgs84', function() { var parsed = srs.parse(srs.jsonCrs(JSON.parse(fs.readFileSync('./test/data/world_extent_wgs84.geojson')))); util.assert_wgs84(parsed); }); it('should detect wgs84 2', function() { var parsed = srs.parse(srs.jsonCrs(JSON.parse(fs.readFileSync('./test/data/test.json')))); util.assert_wgs84(parsed); }); it('should detect with no ext', function() { var parsed = srs.parse(srs.jsonCrs(JSON.parse(fs.readFileSync('./test/data/mystery-api')))); util.assert_wgs84(parsed); }); }); node-srs-0.4.8+dfsg/test/invalid.test.js000066400000000000000000000014301254154173100201160ustar00rootroot00000000000000var srs = require('../'); var fs = require('fs'); var assert = require('assert'); // http://spatialreference.org/ref/esri/102685/ // http://spatialreference.org/ref/sr-org/7058/ describe('throws on invalid input', function() { it('detects proj if parsed as ESRI::', function() { assert.throws(function() { var ref = srs.parse('PROCS[]'); }); }); it('init=epsg:3857', function() { assert.throws(function() { srs.parse('init=epsg:3857'); }); }); it('+init=epsg', function() { assert.throws(function() { srs.parse('+init=epsg'); }); }); it('+init=epsg:500', function() { assert.throws(function() { assert.ok(srs.parse('+init=epsg:500')); }); }); }); node-srs-0.4.8+dfsg/test/qgis-qpj.test.js000066400000000000000000000016241254154173100202300ustar00rootroot00000000000000var srs = require('../'); var fs = require('fs'); var assert = require('assert'); describe('qgis qpj format', function() { it('detects custom grids inside qgis transverse mercator projection', function(done) { var qgis = srs.parse(fs.readFileSync('./test/data/transverse_merc_kasey_custom_grids.prj')); var normal = srs.parse(fs.readFileSync('./test/data/transverse_merc_kasey.prj')); assert.ok(normal.proj4); assert.ok(qgis.proj4); assert.ok(qgis.proj4.indexOf('nadgrids=@conus') > 0); assert.ok(qgis.proj4.indexOf('proj=tmerc') > 0); assert.ok(qgis.proj4.indexOf('ellps=clrk66') > 0); assert.ok(normal.proj4.indexOf('nadgrids=@conus') == -1); assert.ok(normal.name,'Transverse_Mercator'); assert.ok(normal.proj4.indexOf('proj=tmerc') > 0); assert.ok(normal.proj4.indexOf('ellps=clrk66') > 0); done(); }); }); node-srs-0.4.8+dfsg/test/shapefile.27700.test.js000066400000000000000000000053761254154173100211230ustar00rootroot00000000000000var srs = require('../'); var fs = require('fs'); var assert = require('assert'); describe('OSGB 1936', function() { it('should report that it was parsed as esri if ESRI:: was manually prepended', function() { var esri_srs = fs.readFileSync('./test/data/27700_esri_wkt.prj').toString(); var esri_result = srs.parse('ESRI::'+esri_srs); assert.equal(esri_result.esri,true); }); // https://github.com/mapbox/node-srs/issues/25 it('should detect OGC format for OSGB 1936 / British National Grid', function() { var ogc_srs = fs.readFileSync('./test/data/27700_ogc_wkt.prj').toString(); var ogc = srs.parse(ogc_srs); assert.equal(ogc.srid,27700); assert.equal(ogc.name,'OSGB 1936 / British National Grid'); assert.equal(ogc.esri,false); assert.equal(ogc.proj4.indexOf('datum=OSGB36') > -1,true); assert.equal(ogc.proj4.indexOf('proj=tmerc') > -1,true); // not stable across gdal versions //assert.equal(ogc.proj4,'+proj=tmerc +lat_0=49 +lon_0=-2 +k=0.9996012717 +x_0=400000 +y_0=-100000 +datum=OSGB36 +units=m +no_defs'); }); // https://github.com/mapbox/node-srs/issues/25 it('should detect correct proj4 for ESRI format for OSGB 1936 / British National Grid', function() { var esri_srs = fs.readFileSync('./test/data/27700_esri_wkt.prj').toString(); // parse by forcing ESRI:: prepend var esri_result = srs.parse('ESRI::'+esri_srs); assert.equal(esri_result.name,'OSGB 1936 / British National Grid'); // should be: // +proj=tmerc +lat_0=49 +lon_0=-2 +k=0.9996012717 +x_0=400000 +y_0=-100000 +datum=OSGB36 +units=m +no_defs // not: // +proj=tmerc +lat_0=49 +lon_0=-2 +k=0.9996012717 +x_0=400000 +y_0=-100000 +ellps=airy +units=m +no_defs assert.equal(esri_result.proj4.indexOf('datum=OSGB36') > -1,true); assert.equal(esri_result.proj4.indexOf('proj=tmerc') > -1,true); // not stable across gdal versions //var expected = '+proj=tmerc +lat_0=49 +lon_0=-2 +k=0.9996012717 +x_0=400000 +y_0=-100000 +datum=OSGB36 +units=m +no_defs'; //assert.equal(esri_result.proj4,expected); // and test parsing without forcing ESRI:: prepend var esri_result2 = srs.parse(esri_srs); //assert.equal(esri_result2.proj4,expected); assert.equal(esri_result2.proj4.indexOf('datum=OSGB36') > -1,true); assert.equal(esri_result2.proj4.indexOf('proj=tmerc') > -1,true); }); it('should detect correct srid for ESRI format for OSGB 1936 / British National Grid', function() { var esri_srs = fs.readFileSync('./test/data/27700_esri_wkt.prj').toString(); var esri_result = srs.parse(esri_srs); assert.equal(esri_result.srid,27700); }); });node-srs-0.4.8+dfsg/test/shapefile.3857.test.js000066400000000000000000000425271254154173100210510ustar00rootroot00000000000000var srs = require('../'); var fs = require('fs'); var assert = require('assert'); var expected = srs.canonical.spherical_mercator; describe('Mercator', function() { it('should detect non-spherical mercator', function() { // non spherical merc's - should not match //# WGS 84 / PDC Mercator (deprecated) //<3349> +proj=merc +lon_0=-150 +k=1 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m +no_defs <> // typo NAD83(NSRS2007) / Michigan Central //check_result('+init=epsg:3587',srs.canonical.spherical_mercator, false); var not_3857 = { srid: undefined, auth: undefined, esri: false, is_geographic: false, valid: true }; var srid3349 = '+proj=merc +lon_0=-150 +k=1 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m +no_defs'; var parsed = srs.parse(srid3349); assert.ok(parsed.proj4); assert.equal(parsed.proj4.indexOf('+nadgrids=@null'), -1); assert.equal(parsed.srid, not_3857.srid); assert.equal(parsed.auth, not_3857.auth); assert.equal(parsed.esri, not_3857.esri); assert.equal(parsed.is_geographic, not_3857.is_geographic); assert.equal(parsed.valid, not_3857.valid); var epsg3395 = fs.readFileSync('./test/data/3395-non-spherical-merc.prj').toString(); parsed = srs.parse(epsg3395); assert.ok(parsed.proj4); assert.equal(parsed.proj4.indexOf('+nadgrids=@null'), -1); assert.equal(parsed.srid, not_3857.srid); assert.equal(parsed.auth, not_3857.auth); assert.equal(parsed.esri, not_3857.esri); assert.equal(parsed.is_geographic, not_3857.is_geographic); assert.equal(parsed.valid, not_3857.valid); }); /* EPSG:900913 aka. Spherical Mercator http://wiki.openstreetmap.org/wiki/EPSG:3857 */ // https://github.com/mapbox/node-srs/issues/27 it('should detect qgis/ogr wkt', function() { var val = fs.readFileSync('./test/data/3857-ogr-1.10.0-wkt.prj').toString(); var parsed = srs.parse(val); assert.ok(parsed.proj4); //assert.equal(parsed.proj4,''); assert.equal(parsed.srid, expected.srid); assert.equal(parsed.auth, expected.auth); assert.equal(parsed.esri, expected.esri); assert.equal(parsed.is_geographic, expected.is_geographic); assert.equal(parsed.valid, expected.valid); }); it('should detect qgis/ogr wkt', function() { var val = fs.readFileSync('./test/data/world_borders_merc.prj').toString(); var parsed = srs.parse(val); assert.ok(parsed.proj4); //assert.equal(parsed.proj4,''); assert.equal(parsed.srid, expected.srid); assert.equal(parsed.auth, expected.auth); assert.equal(parsed.esri, expected.esri); assert.equal(parsed.is_geographic, expected.is_geographic); assert.equal(parsed.valid, expected.valid); }); it('should detect sr-org produced by older ogr version', function() { var val = fs.readFileSync('./test/data/sr-org-6-esriwkt.prj').toString(); var parsed = srs.parse(val); assert.ok(parsed.proj4); //assert.equal(parsed.proj4,''); assert.equal(parsed.srid, expected.srid); assert.equal(parsed.auth, expected.auth); assert.equal(parsed.esri, expected.esri); assert.equal(parsed.is_geographic, expected.is_geographic); assert.equal(parsed.valid, expected.valid); }); it('should detect sr-ogr6', function() { var val = '+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs'; var parsed = srs.parse(val); assert.ok(parsed.proj4); //assert.equal(parsed.proj4,''); assert.equal(parsed.srid, expected.srid); assert.equal(parsed.auth, expected.auth); assert.equal(parsed.esri, expected.esri); assert.equal(parsed.is_geographic, expected.is_geographic); assert.equal(parsed.valid, expected.valid); }); it('should detect http://prj2epsg.org/epsg/3857', function() { var val = fs.readFileSync('./test/data/prj2epsg-wkt-3857.prj').toString(); var parsed = srs.parse(val); assert.ok(parsed.proj4); //assert.equal(parsed.proj4,''); assert.equal(parsed.srid, expected.srid); assert.equal(parsed.auth, expected.auth); assert.equal(parsed.esri, expected.esri); assert.equal(parsed.is_geographic, expected.is_geographic); assert.equal(parsed.valid, expected.valid); }); it('should detect +over stripped', function() { var val = '+proj=merc +lon_0=0 +lat_ts=0 +x_0=0 +y_0=0 +ellps=WGS84 +units=m +no_defs'; var parsed = srs.parse(val); assert.ok(parsed.proj4); //assert.equal(parsed.proj4,''); assert.equal(parsed.srid, expected.srid); assert.equal(parsed.auth, expected.auth); assert.equal(parsed.esri, expected.esri); assert.equal(parsed.is_geographic, expected.is_geographic); assert.equal(parsed.valid, expected.valid); }); it('should detect proj 3857', function() { var val = '+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs'; var parsed = srs.parse(val); assert.ok(parsed.proj4); //assert.equal(parsed.proj4,''); assert.equal(parsed.srid, expected.srid); assert.equal(parsed.auth, expected.auth); assert.equal(parsed.esri, expected.esri); assert.equal(parsed.is_geographic, expected.is_geographic); assert.equal(parsed.valid, expected.valid); }); it('should detect 900913', function() { var val = '+init=epsg:900913'; var parsed = srs.parse(val); assert.ok(parsed.proj4); //assert.equal(parsed.proj4,''); assert.equal(parsed.srid, expected.srid); assert.equal(parsed.auth, expected.auth); assert.equal(parsed.esri, expected.esri); assert.equal(parsed.is_geographic, expected.is_geographic); assert.equal(parsed.valid, expected.valid); }); it('should detect esri 900913', function() { var val = fs.readFileSync('./test/data/900913.esri.prj').toString(); var parsed = srs.parse(val); assert.ok(parsed.proj4); //assert.equal(parsed.proj4,''); assert.equal(parsed.srid, expected.srid); assert.equal(parsed.auth, expected.auth); assert.equal(parsed.esri, expected.esri); assert.equal(parsed.is_geographic, expected.is_geographic); assert.equal(parsed.valid, expected.valid); }); it('should detect esri 900913 hint', function() { var val = 'ESRI::' + fs.readFileSync('./test/data/900913.esri.prj').toString(); var parsed = srs.parse(val); assert.ok(parsed.proj4); //assert.equal(parsed.proj4,''); assert.equal(parsed.srid, expected.srid); assert.equal(parsed.auth, expected.auth); assert.equal(parsed.esri, expected.esri); assert.equal(parsed.is_geographic, expected.is_geographic); assert.equal(parsed.valid, expected.valid); }); it('should detect esri webmerc', function() { var val = fs.readFileSync('./test/data/esri_webmerc.prj').toString(); var parsed = srs.parse(val); assert.ok(parsed.proj4); //assert.equal(parsed.proj4,''); assert.equal(parsed.srid, expected.srid); assert.equal(parsed.auth, expected.auth); assert.equal(parsed.esri, expected.esri); assert.equal(parsed.is_geographic, expected.is_geographic); assert.equal(parsed.valid, expected.valid); }); it('should detect esri webmerc hint', function() { var val = 'ESRI::' + fs.readFileSync('./test/data/esri_webmerc.prj').toString(); var parsed = srs.parse(val); assert.ok(parsed.proj4); //assert.equal(parsed.proj4,''); assert.equal(parsed.srid, expected.srid); assert.equal(parsed.auth, expected.auth); assert.equal(parsed.esri, expected.esri); assert.equal(parsed.is_geographic, expected.is_geographic); assert.equal(parsed.valid, expected.valid); }); it('should detect esri webmerc aux', function() { var val = fs.readFileSync('./test/data/esri_webmerc_auxshpere.prj').toString(); var parsed = srs.parse(val); assert.ok(parsed.proj4); //assert.equal(parsed.proj4,''); assert.equal(parsed.srid, expected.srid); assert.equal(parsed.auth, expected.auth); assert.equal(parsed.esri, expected.esri); assert.equal(parsed.is_geographic, expected.is_geographic); assert.equal(parsed.valid, expected.valid); }); it('should detect webmerc aux hint', function() { var val = 'ESRI::' + fs.readFileSync('./test/data/esri_webmerc_auxshpere.prj').toString(); var parsed = srs.parse(val); assert.ok(parsed.proj4); //assert.equal(parsed.proj4,''); assert.equal(parsed.srid, expected.srid); assert.equal(parsed.auth, expected.auth); assert.equal(parsed.esri, expected.esri); assert.equal(parsed.is_geographic, expected.is_geographic); assert.equal(parsed.valid, expected.valid); }); it('should detect esri webmerc aux2', function() { var val = fs.readFileSync('./test/data/esri_webmerc_auxshpere2.prj').toString(); var parsed = srs.parse(val); assert.ok(parsed.proj4); //assert.equal(parsed.proj4,''); assert.equal(parsed.srid, expected.srid); assert.equal(parsed.auth, expected.auth); assert.equal(parsed.esri, expected.esri); assert.equal(parsed.is_geographic, expected.is_geographic); assert.equal(parsed.valid, expected.valid); }); it('should detect esri webmerc aux2 hint', function() { var val = 'ESRI::' + fs.readFileSync('./test/data/esri_webmerc_auxshpere2.prj').toString(); var parsed = srs.parse(val); assert.ok(parsed.proj4); //assert.equal(parsed.proj4,''); assert.equal(parsed.srid, expected.srid); assert.equal(parsed.auth, expected.auth); assert.equal(parsed.esri, expected.esri); assert.equal(parsed.is_geographic, expected.is_geographic); assert.equal(parsed.valid, expected.valid); }); // https://github.com/mapbox/tilemill/issues/1759 it('should detect osm_landusages', function() { var val = 'ESRI::' + fs.readFileSync('./test/data/osm_landusages.prj').toString(); var parsed = srs.parse(val); assert.ok(parsed.proj4); //assert.equal(parsed.proj4,''); assert.equal(parsed.srid, expected.srid); assert.equal(parsed.auth, expected.auth); assert.equal(parsed.esri, expected.esri); assert.equal(parsed.is_geographic, expected.is_geographic); assert.equal(parsed.valid, expected.valid); }); it('should detect bogus proj 1', function() { var val = '+proj=merc +lon_0=0 +lat_ts=0 +x_0=0 +y_0=0 +ellps=WGS84 +units=m +no_defs +foo'; var parsed = srs.parse(val); assert.ok(parsed.proj4); //assert.equal(parsed.proj4,''); assert.equal(parsed.srid, expected.srid); assert.equal(parsed.auth, expected.auth); assert.equal(parsed.esri, expected.esri); assert.equal(parsed.is_geographic, expected.is_geographic); assert.equal(parsed.valid, expected.valid); }); it('should detect bogus proj 2', function() { var val = '+proj=merc +lon_0=0 +lat_ts=0 +x_0=0 +y_0=0 +a=6378137 +b=6378137 +units=m'; var parsed = srs.parse(val); assert.ok(parsed.proj4); //assert.equal(parsed.proj4,''); assert.equal(parsed.srid, expected.srid); assert.equal(parsed.auth, expected.auth); assert.equal(parsed.esri, expected.esri); assert.equal(parsed.is_geographic, expected.is_geographic); assert.equal(parsed.valid, expected.valid); }); /* Mercator_1SP and Mercator_2SP lots of confusion with these: http://trac.osgeo.org/gdal/ticket/2744 http://trac.osgeo.org/gdal/ticket/1797 http://www.remotesensing.org/geotiff/proj_list/mercator_2sp.html These are not spherical merc, but for our purposes we are going to ignore complexity and assume when these keywords are used in the top level name, aka the `PROJCS` then this is meant to be spherical mercator and may originate from some app or lonely soul grabbing a wkt in deparation from http://spatialreference.org/ref/sr-org/7299/ogcwkt/ which at the time of writing was equal to: PROJCS["Mercator_1SP",GEOGCS["GCS_Geographic Coordinate System",DATUM["D_WGS_1984_MAJOR_AUXILIARY_SPHERE",SPHEROID["Sphere_Radius_6378137_m",6378137,0]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]],PROJECTION["Mercator"],PARAMETER["central_meridian",0],PARAMETER["standard_parallel_1",0],PARAMETER["false_easting",0],PARAMETER["false_northing",0],UNIT["Meter",1]] or http://spatialreference.org/ref/sr-org/google-projection/esriwkt/: PROJCS["Mercator_2SP",GEOGCS["unnamed ellipse",DATUM["D_unknown",SPHEROID["Unknown",6378137,0]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]],PROJECTION["Mercator_2SP"],PARAMETER["standard_parallel_1",0],PARAMETER["central_meridian",0],PARAMETER["false_easting",0],PARAMETER["false_northing",0],UNIT["Meter",1]] */ it('should detect sr.org mercator1sp', function() { var val = 'ESRI::' + fs.readFileSync('./test/data/esri-mercator-1sp.prj').toString(); var parsed = srs.parse(val); assert.ok(parsed.proj4); assert.ok(parsed.proj4); //assert.equal(parsed.proj4,''); assert.equal(parsed.srid, expected.srid); assert.equal(parsed.auth, expected.auth); assert.equal(parsed.esri, expected.esri); assert.equal(parsed.is_geographic, expected.is_geographic); assert.equal(parsed.valid, expected.valid); }); it('should detect sr.org messed up mercator2sp', function() { var val = 'ESRI::' + fs.readFileSync('./test/data/bogus_mercator2sp.prj').toString(); var parsed = srs.parse(val); assert.ok(parsed.proj4); assert.ok(parsed.proj4); //assert.equal(parsed.proj4,''); assert.equal(parsed.srid, expected.srid); assert.equal(parsed.auth, expected.auth); assert.equal(parsed.esri, expected.esri); assert.equal(parsed.is_geographic, expected.is_geographic); assert.equal(parsed.valid, expected.valid); }); it('should detect openstreetmapdata.com as 3857', function() { var val = fs.readFileSync('./test/data/simplified-land-polygons-complete-3857.prj').toString(); var parsed = srs.parse(val); assert.ok(parsed.proj4); assert.ok(parsed.proj4); //assert.equal(parsed.proj4,''); assert.equal(parsed.srid, expected.srid); assert.equal(parsed.auth, expected.auth); assert.equal(parsed.esri, expected.esri); assert.equal(parsed.is_geographic, expected.is_geographic); assert.equal(parsed.valid, expected.valid); }); it('should detect +init=epsg:3857 as 3857', function() { var val = '+init=epsg:3857'; var parsed = srs.parse(val); assert.ok(parsed.proj4); //assert.equal(parsed.proj4,''); assert.equal(parsed.srid,expected.srid); assert.equal(parsed.auth,expected.auth); assert.equal(parsed.esri,expected.esri); assert.equal(parsed.is_geographic,expected.is_geographic); assert.equal(parsed.valid,expected.valid); }); it('should detect +init=esri:102100 as 3857', function() { var val = '+init=esri:102100'; var parsed = srs.parse(val); assert.ok(parsed.proj4); //assert.equal(parsed.proj4,''); assert.equal(parsed.srid,expected.srid); assert.equal(parsed.auth,expected.auth); assert.equal(parsed.esri,expected.esri); assert.equal(parsed.is_geographic,expected.is_geographic); assert.equal(parsed.valid,expected.valid); }); it('should detect +init=esri:102113 as 3857', function() { var val = '+init=esri:102113'; var parsed = srs.parse(val); assert.ok(parsed.proj4); //assert.equal(parsed.proj4,''); assert.equal(parsed.srid,expected.srid); assert.equal(parsed.auth,expected.auth); assert.equal(parsed.esri,expected.esri); assert.equal(parsed.is_geographic,expected.is_geographic); assert.equal(parsed.valid,expected.valid); }); it('should detect +init=epsg:3785 as 3857', function() { var val = '+init=epsg:3785'; var parsed = srs.parse(val); assert.ok(parsed.proj4); //assert.equal(parsed.proj4,''); assert.equal(parsed.srid,expected.srid); assert.equal(parsed.auth,expected.auth); assert.equal(parsed.esri,expected.esri); assert.equal(parsed.is_geographic,expected.is_geographic); assert.equal(parsed.valid,expected.valid); }); it('should detect +init=osgeo:41001 as 3857', function() { var val = '+init=osgeo:41001'; var parsed = srs.parse(val); assert.ok(parsed.proj4); //assert.equal(parsed.proj4,''); assert.equal(parsed.srid,expected.srid); assert.equal(parsed.auth,expected.auth); assert.equal(parsed.esri,expected.esri); assert.equal(parsed.is_geographic,expected.is_geographic); assert.equal(parsed.valid,expected.valid); }); }); node-srs-0.4.8+dfsg/test/shapefile.4326.test.js000066400000000000000000000041631254154173100210330ustar00rootroot00000000000000var srs = require('../'); var fs = require('fs'); var assert = require('assert'); var util = require('./util'); describe('WGS84', function() { it('should detect wgs84 proj4 init detection', function() { var parsed = srs.parse('+init=epsg:4326'); util.assert_wgs84(parsed); }); it('should detect wgs84 proj4 literal from gdal trunk detection', function() { // +datum=WGS84 var parsed = srs.parse('+proj=longlat +ellps=WGS84 +towgs84=0,0,0,0,0,0,0 +no_defs'); util.assert_wgs84(parsed); }); it('should detect wgs84 proj4 literal +datum will trigger addition to towgs detection', function() { // +datum will trigger addition to towgs var parsed = srs.parse('+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs'); util.assert_wgs84(parsed); }); it('should detect wgs84 wkt detection', function() { var val = 'GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.01745329251994328,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4326"]]'; var parsed = srs.parse(val); util.assert_wgs84(parsed); }); it('should detect wgs84 epsg detection', function() { var parsed = srs.parse('EPSG:4326'); util.assert_wgs84(parsed); }); it('should detect wgs84 common name detection', function() { var parsed = srs.parse('WGS84'); util.assert_wgs84(parsed); }); it('should detect wgs84 proj4 literal no datum detection', function() { var parsed = srs.parse('+proj=longlat +ellps=WGS84 +no_defs'); util.assert_wgs84(parsed); }); it('should detect wgs84 wkt from prj file', function() { var data = fs.readFileSync('./test/data/4326.esri.prj'); var parsed = srs.parse(data); util.assert_wgs84(parsed); }); it('should detect wgs84 wkt from another prj file', function() { var data = fs.readFileSync('./test/data/4326.prj'); var parsed = srs.parse(data); util.assert_wgs84(parsed); }); });node-srs-0.4.8+dfsg/test/split_proj.js000066400000000000000000000010131254154173100176740ustar00rootroot00000000000000var srs = require('../'); var assert = require('assert'); var util = require('./util'); describe('#split_proj', function() { it('splits on spaces', function() { assert.deepEqual(srs.split_proj('a=b'), {a:'b'}); assert.deepEqual(srs.split_proj('a=b c=d'), {a:'b',c:'d'}); assert.deepEqual(srs.split_proj('a=b c=0'), {a:'b',c:'0.0'}); assert.deepEqual(srs.split_proj('a=b c=2.0'), {a:'b',c:'2.0'}); assert.deepEqual(srs.split_proj('a=b +bar c=2.0'), {a:'b',c:'2.0'}); }); }); node-srs-0.4.8+dfsg/test/util.js000066400000000000000000000011051254154173100164660ustar00rootroot00000000000000var assert = require('assert'); var srs = require('../'); function assert_wgs84(parsed) { assert.ok(parsed.proj4); assert.equal(parsed.name, srs.canonical.wgs84.name); assert.equal(parsed.srid, srs.canonical.wgs84.srid); assert.equal(parsed.auth, srs.canonical.wgs84.auth); assert.equal(parsed.esri, srs.canonical.wgs84.esri); assert.equal(parsed.is_geographic, srs.canonical.wgs84.is_geographic); assert.equal(parsed.valid, srs.canonical.wgs84.valid); assert.equal(parsed.proj4, srs.canonical.wgs84.proj4); } exports.assert_wgs84 = assert_wgs84; node-srs-0.4.8+dfsg/test/version.test.js000066400000000000000000000005531254154173100201620ustar00rootroot00000000000000var srs = require('../'); var fs = require('fs'); var assert = require('assert'); describe('Version check', function() { it('test version updated for release', function() { if (parseInt(process.version.split('.')[1]) > 4) { var info = require('../package.json'); assert.equal(info.version, srs.version); } }); }); node-srs-0.4.8+dfsg/vcbuild-2014.bat000066400000000000000000000003401254154173100167000ustar00rootroot00000000000000call node_modules\.bin\node-pre-gyp.cmd --msvs_version=2013 --toolset=v140 --dist-url=https://s3.amazonaws.com/mapbox/node-cpp11 --target=0.10.33 build call ..\v0.10.33-nodecpp11\Release\node.exe node_modules\mocha\bin\mochanode-srs-0.4.8+dfsg/vcbuild.bat000066400000000000000000000003071254154173100163170ustar00rootroot00000000000000set PROJ_LIB=C:\mapnik-v2.3.0\share\proj set GDAL_DATA=C:\mapnik-v2.3.0\share\gdal rd /q /s build del lib\\_srs.node npm install --nodedir=%HOMEPATH%/.node-gyp/0.10.21-mod set NODE_PATH=lib npm test