Skip to content

Latest commit

 

History

History
112 lines (88 loc) · 2.87 KB

README.md

File metadata and controls

112 lines (88 loc) · 2.87 KB

ptolemy

Build Status Build Status

ptolemy

A simple way to retrieve geographic projection information, in a variety of formats, from an EPSG SRID. Uses the EPSG.io database.

The following formats for projections are supported (Disclaimer: Not all SRIDs will support every format.):

  • prettywkt (Well Known Text as HTML)
  • wkt (OGC WKT)
  • esriwkt (ESRI WKT)
  • proj4
  • js (Proj4js - always be careful when using eval)
  • usgs
  • geoserver
  • mapfile (MapServer - MAPfile)
  • mapnik
  • sql (PostGIS)

Install

$ npm install ptolemy

Example

const ptolemy = new Ptolemy({
  adapters: [{name: 'skycatch'}, {name: 'epsgio'}]
});

ptolemy.getProjection('epsg:2004', 'proj4')
.then((res) => {
  console.log(res);
})
.catch((e) => {
  throw e;
});

// Result
{
  "crs": "epsg:2004",
  "name": "Montserrat 1958 / British West Indies Grid",
  "proj4": "+proj=tmerc +lat_0=0 +lon_0=-62 +k=0.9995000000000001 +x_0=400000 +y_0=0 +ellps=clrk80 +towgs84=174,359,365,0,0,0,0 +units=m +no_defs"
}

Bundling

To build this library, run:

gulp build

This will make a bundled version which is used when included in the browser.

Ptolemy Configuration

  • adapters array specify the source adapters that you want to use.
    • when specifying multiple adapters, ALL adapters will be queried. However only one of the responses will be returned because it is assumed that the projection information will be the same regardless of the source.
    • the skycatch adapter is incomplete and only uses hardcoded values right now

THE FOLLOWING USAGE IS DEPRECATED

var Ptolemy = require('ptolemy');

Ptolemy.get('epsg:2004', 'proj4')
.then((res) => {
  console.log(res);
})
.catch((e) => {
  throw e;
});

// Result
{
  "crs": "epsg:2004",
  "name": "Montserrat 1958 / British West Indies Grid",
  "proj4": "+proj=tmerc +lat_0=0 +lon_0=-62 +k=0.9995000000000001 +x_0=400000 +y_0=0 +ellps=clrk80 +towgs84=174,359,365,0,0,0,0 +units=m +no_defs"
}

Development + Testing

# Develop library locally
$ npm install
$ npm link
# In project that requires Ptolemy
$ npm link ptolemy # Now points to locally cloned Ptolemy

# Test
$ npm test

Resources for CRS Info

NOTE: The data from http://www.epsg-registry.org cannot be used without modification in Pix4D.

License

MIT License