Package Exports
- terraformer
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (terraformer) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Terraformer
- Convert to and from ArcGIS JSON Geometries, WKT and GeoJSON
- Manipulate GeoJSON with methods like
addVertex
- Find out if GeoJSON shapes intersect or contain each other
- Get properties like bounding boxes, envelopes, and convex hull of GeoJSON objects
- Respresent circles as GeoJSON Features
- Convert to and from Geographic Coordinates and Esri Web Mercator spatial references
Gizipped and minified all Terraformer modules comes to about 9.6kb. The core library is 2.8kb and includes GeoJSON parsing, helper methods, bounding boxes and spatial reference conversions. Other features are available as add-in modules as needed.
Using
Node.js
Terraformer on Node.js is split into multiple small packages for easy consumption.
$ npm install terraformer
$ npm install terraformer-rtree
$ npm install terraformer-wkt-parser
$ npm install terraformer-arcgis-parser
Browser
Terraformer can be used in the browser with a simple browser include.
<!-- Load the main terraformer library -->
<script src="terraformer.min.js" type="text/javascript"></script>
<!-- Load the wkt parser -->
<script src="wkt.min.js" type="text/javascript"></script>
<!-- Load the arcgis parser -->
<script src="arcgis.min.js" type="text/javascript"></script>
<!-- Load the rtree index -->
<script src="rtree.min.js" type="text/javascript"></script>
AMD (Require.js and Dojo)
Terraformer also works with AMD loaders like RequireJS and Dojo.
RequireJS
First you should register the Terraformer modules with RequireJS
requirejs.config({
//In order for proper loading of depenencies in Terraformer modules set the path up in requirejs.config
paths: {
terraformer: "/the/path/to/terraformer"
}
});
Then you can load Terraformer modules in your require
statements.
requirejs([
"terraformer/terraformer",
"terraformer/wkt",
"terraformer/rtree",
], function (Terraformer, TerraformerWKT, RTree) {
// Do stuff with terraformer core, wkt parser, and rtree
};
Dojo
Dojo includes a built in AMD loader. To use Terraformer with Dojo setup the path to Terraformer in your dojoConfig
.
dojoConfig= {
async: true,
packages: [{
name: "terraformer",
location: "/the/path/to/terraformer"
}]
}
You can then include Terraformer in your Dojo code
require([
"terraformer/terraformer",
"terraformer/arcgis",
"terraformer/rtree",
], function (Terraformer, TerraformerArcGIS, RTree) {
// Do stuff with terraformer core, arcgis parser, and rtree
});
WebWorkers
Sample code and examples coming soon...
Documentation
Basics
Parsers
Indexes
Tools
Examples
- Visualize and search US County data with the ArcGIS Javascript API and
Terraformer.GeoStore
- View GeoJSON on and ArcGIS map with Terraformer
- Visualize Well Known text on a Google map
- Use Terraformer with Require JS and Leaflet
- Create a simple timezone API with Terraformer and Node JS
- Visualize Well Known Text with the ArcGIS Javascript API and
Terraformer.RTree
Testing
Tests are written in Jasmine and can be run through $ grunt
or $ npm install
then $ npm test
. To run the tests run the following commands to setup PhantomJS and Grunt...
$ npm install grunt -g
$ brew install phantomjs
Then run the tests with $ grunt
which will buld all the files and then run the tests. You can also run $ grunt watch
which will run the tests when source files change.
Building
Running the $ grunt build
command will build the libraries to dist/node
and dist/browser
. If you want to build with a different version number run $ grunt build-versioned
.
Future Features
- GeoJSON validation
- Google Maps format support
- Leaflet format support
Known Issues
The following are known issues that we have acknowledged but have not or will not fix. See individual issues for details.
- Convert an array of ArcGIS Geometries/Graphics to a GeometryCollection/FeatureCollection. https://github.com/Esri/Terraformer/issues/104
[](Esri Tags: Terraformer GeoJSON WKT Well-Known-Text) [](Esri Language: JavaScript)