# Terraformer

Terraformer is an open source (MIT licensed) Javascript geo toolkit, built for the server and the browser.

## Link Getting Started Back to Top

Terraformer is broken into multiple small packages to give you the functionality that you need while still remaining extremely lightweight.

There are currently several packages in the Terraformer ecosystem.

- Terraformer - The core library for manipilating GeoJSON and performaing calculations. Most other modules rely on `terraformer`.
- ArcGIS Parser - Parses ArcGIS geometry objects to GeoJSON and vica-versa.
- WKT Parser - Parses basic WKT strings to and from GeoJSON.
- GeoStore - A JavaScript database for storing and querying collections of GeoJSON Features. GeoStores also need an index module and a backing store which are distributed as seperate modules.

### Link Browser Back to Top

Include the core Terraformer library with a `<script>` tag.

    <script src="http://cdn.webgeo.io/terraformer/1.0.1/terraformer.min.js"></script>

### Link Node.js Back to Top

Install the core module with NPM and then require it in your Node program.

    $ npm install terraformer

    var Terraformer = require('terraformer');

## Link Working with Primitives Back to Top

Most of the core Terraformer libray centers around using `Primitives` which wrap GeoJSON objects and provide additonal functionality.

You can create a new Terraformer.Primitive with any GeoJSON object.

    var polygon = new Terraformer.Primitive({
      "type": "Polygon",
      "coordinates": [
        [
          [-122.66589403152467, 45.52290150862236],
          [-122.66926288604736, 45.52291654238294],
          [-122.67115116119385, 45.518406234030586],
          [-122.67325401306151, 45.514000817199715],
          [-122.6684260368347, 45.5127377671934],
          [-122.66765356063841, 45.51694782364431],
          [-122.66589403152467, 45.52290150862236 ]
        ]
      ]
    });

    var point = new Terraformer.Primitive({
      "type": "Point",
      "coordinates": [-122.66947746276854, 45.51775972687403]
    });

Now that you have a point and a polygon primitive you can use many of the primitive helper methods

    // add a new vertex to our polygon
    polygon.insertVertex([-122.6708507537842, 45.513188859735436], 2);

    // figure out if our point is within our polygon
    point.within(polygon); // returns true

You can also have Terraformer perform many geometric operations like convex hulls and bounding boxes.

    var convexHull = polygon.convexHull();

    point.within(convexHull); // returns true

    var boundingBox = polygon.bbox(); // returns the geojson bounding box for this object.

## Link Whats Next? Back to Top

Start exploring all the options you have working with Primitives and the core library then start exploring other modules.

Terraformer GeoStore is a JavaScript database for indexing and querying large amounds of GeoJSON. You can use multuile types of spatial indexes and backing stores for your data.

You can also convert data between different formats like ArcGIS Geometries and Well Known Text. Remember Terraformer is a modular framework use only the pieces you need to complete your applicaiton.