Socket
Socket
Sign inDemoInstall

terraformer-wkt-parser

Package Overview
Dependencies
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

terraformer-wkt-parser - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

coverage/base.css

9

bower.json
{
"name": "terraformer-wkt-parser",
"version": "1.0.0",
"main": "terraformer-wkt-parser.js",
"ignore": [
".jshintrc",
"**/*.txt"
],
"main": "terraformer-wkt-parser.min.js",
"ignore" : ["versions", "spec", "examples", "test"],
"dependencies": {
"terraformer": "~0.1.x"
"terraformer": "~1.0.0"
}
}

@@ -6,7 +6,7 @@ var fs = require('fs');

grunt.initConfig({
//aws: grunt.file.readJSON(process.env.HOME + '/terraformer-s3.json'),
pkg: grunt.file.readJSON('package.json'),
meta: {
version: '0.0.1',
banner: '/*! Terraformer JS - <%= meta.version %> - <%= grunt.template.today("yyyy-mm-dd") %>\n' +
banner: '/*! Terraformer JS - <%= pkg.version %> - <%= grunt.template.today("yyyy-mm-dd") %>\n' +
'* https://github.com/esri/terraformer-wkt-parser\n' +

@@ -19,3 +19,4 @@ '* Copyright (c) <%= grunt.template.today("yyyy") %> Esri, Inc.\n' +

options: {
report: 'gzip'
report: 'gzip',
banner: '<%= meta.banner %>'
},

@@ -25,2 +26,6 @@ wkt: {

dest: 'terraformer-wkt-parser.min.js'
},
versioned: {
src: ["terraformer-wkt-parser.js"],
dest: 'versions/terraformer-wkt-parser-<%= pkg.version %>.min.js'
}

@@ -44,3 +49,2 @@ },

src: [
"node_modules/terraformer/terraformer.js",
"terraformer-wkt-parser.js"

@@ -50,3 +54,5 @@ ],

specs: 'spec/*Spec.js',
helpers: 'spec/*Helpers.js',
helpers: [
"node_modules/terraformer/terraformer.js"
],
//keepRunner: true,

@@ -60,6 +66,6 @@ outfile: 'SpecRunner.html',

thresholds: {
lines: 50,
statements: 50,
branches: 50,
functions: 50
lines: 70,
statements: 70,
branches: 70,
functions: 70
}

@@ -81,5 +87,33 @@ }

all: ['spec/']
},
s3: {
options: {
key: '<%= aws.key %>',
secret: '<%= aws.secret %>',
bucket: '<%= aws.bucket %>',
access: 'public-read',
headers: {
// 1 Year cache policy (1000 * 60 * 60 * 24 * 365)
"Cache-Control": "max-age=630720000, public",
"Expires": new Date(Date.now() + 63072000000).toUTCString()
}
},
dev: {
upload: [
{
src: 'versions/terraformer-wkt-parser-<%= pkg.version %>.min.js',
dest: 'terraformer-wkt-parser/<%= pkg.version %>/terraformer-wkt-parser.min.js'
}
]
},
}
});
var awsExists = fs.existsSync(process.env.HOME + '/terraformer-s3.json');
if (awsExists) {
grunt.config.set('aws', grunt.file.readJSON(process.env.HOME + '/terraformer-s3.json'));
}
grunt.registerTask('wkt-parser', 'Building WKT Parser', function() {

@@ -107,5 +141,7 @@ var grammar = fs.readFileSync('./src/wkt.yy', 'utf8');

grunt.loadNpmTasks('grunt-jasmine-node');
grunt.loadNpmTasks('grunt-s3');
grunt.registerTask('test', [ 'wkt-parser', 'vows', 'jasmine', 'jasmine_node' ]);
grunt.registerTask('default', [ 'wkt-parser', 'vows', 'jasmine', 'jasmine_node', 'uglify' ]);
};
grunt.registerTask('default', [ 'test' ]);
grunt.registerTask('version', [ 'test', 'uglify', 's3' ]);
};
{
"name": "terraformer-wkt-parser",
"version": "1.0.0",
"version": "1.0.1",
"description": "Well-Known Text parser",

@@ -33,5 +33,6 @@ "main": "terraformer-wkt-parser.js",

"grunt-contrib-jasmine": "~0.4.2",
"grunt-jasmine-node": "git://github.com/magicmoose/grunt-jasmine-node.git",
"grunt-template-jasmine-istanbul": "~0.2.4"
"grunt-jasmine-node": "https://github.com/magicmoose/grunt-jasmine-node/tarball/master",
"grunt-template-jasmine-istanbul": "~0.2.4",
"grunt-s3": "~0.2.0-alpha.3"
}
}
# Terraformer Well-Known Text Parser
This package is part of the [Terraformer](https://github.com/Esri/Terraformer) project.
This package is part of the [Terraformer](http://terraformer.io) project.

@@ -19,26 +19,25 @@ A bare-bones WKT parser. Given a WKT primitive, it parses and returns a `Terraformer Primitive`.

## Usage
## Documentation
### Node.js
For full documentation check out the [offical website](http://terraformer.io/wkt-parser/).
var wkt = require('terraformer-wkt-parser');
// parse a WKT file, convert it into a primitive
var primitive = wkt.parse('LINESTRING (30 10, 10 30, 40 40)');
// take a primitive and convert it into a WKT representation
var polygon = wkt.convert(
{
"type": "Polygon",
"coordinates": [
[ [100.0, 0.0], [101.0, 0.0], [101.0, 1.0], [100.0, 1.0], [100.0, 0.0] ],
[ [100.2, 0.2], [100.8, 0.2], [100.8, 0.8], [100.2, 0.8], [100.2, 0.2] ]
]
}
);
```js
var wkt = require('terraformer-wkt-parser');
### Browser
// parse a WKT file, convert it into a primitive
var primitive = wkt.parse('LINESTRING (30 10, 10 30, 40 40)');
The Terraformer-WKT-Parser can be used in the browser with some simple includes.
// take a primitive and convert it into a WKT representation
var polygon = wkt.convert(
{
"type": "Polygon",
"coordinates": [
[ [100.0, 0.0], [101.0, 0.0], [101.0, 1.0], [100.0, 1.0], [100.0, 0.0] ],
[ [100.2, 0.2], [100.8, 0.2], [100.8, 0.8], [100.2, 0.8], [100.2, 0.2] ]
]
}
);
```
```html
<!-- Load the main Terraformer library -->

@@ -54,50 +53,18 @@ <script src="terraformer.min.js" type="text/javascript"></script>

</script>
```
### AMD (Require.js and Dojo)
## Resources
Terraformer also works with AMD loaders like [RequireJS](http://requirejs.org/) and [Dojo](http://dojotoolkit.org/).
* [Terraformer Website](http://terraformer.io)
* [twitter@EsriPDX](http://twitter.com/esripdx)
##### RequireJS
## Issues
First you should register the Terraformer modules with RequireJS
Find a bug or want to request a new feature? Please let us know by submitting an issue.
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"
}
});
## Contributing
Then you can load Terraformer modules in your `require` statements.
Esri welcomes contributions from anyone and everyone. Please see our [guidelines for contributing](https://github.com/esri/contributing).
requirejs([
"terraformer/terraformer",
"terraformer/terraformer-wkt-parser"
], function (Terraformer, TerraformerWKT) {
// Do stuff with terraformer core, wkt parser
};
##### 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/terraformer-wkt-parser"
], function (Terraformer, TerraformerWKT) {
// Do stuff with terraformer core, and wkt parser
});
[](Esri Tags: Terraformer GeoJSON WKT Well-Known-Text)
[](Esri Language: JavaScript)

@@ -1,521 +0,710 @@

var gs;
if(typeof module === "object"){
var Terraformer = require("../dist/node/terraformer.js");
Terraformer.RTree = require("../dist/node/RTree/index.js").RTree;
Terraformer.Store = {};
Terraformer.Store.Memory = require("../src/Store/Memory.js").Memory;
Terraformer.GeoStore = require("../dist/node/GeoStore/index.js").GeoStore;
var Terraformer = require("terraformer");
Terraformer.WKT = require("../terraformer-wkt-parser");
}
describe("geostore", function() {
describe("with a memory store and rtree", function(){
beforeEach(function() {
this.addMatchers({
toBeInstanceOfClass: function(classRef){
return this.actual instanceof classRef;
}
});
});
it("should throw an error when initalized without a store or index", function(){
expect(function() {
gs = new Terraformer.GeoStore({});
}).toThrow();
expect(gs).toBeFalsy();
});
describe("WKT Convert", function () {
it("should create with a Memory store and an RTree", function(){
expect(function() {
gs = new Terraformer.GeoStore({
store: new Terraformer.Store.Memory(),
index: new Terraformer.RTree()
});
}).not.toThrow();
expect(gs).toBeTruthy();
});
it("should convert a POINT", function () {
var input = {
type: "Point",
coordinates: [ 30, 10 ]
};
it("should throw an error when a feautre without an id is added", function(){
expect(function() {
gs.add({"type":"Feature","properties":{"name":"Multnomah"},"geometry":{"type":"Polygon","coordinates":[[[-122.926547,45.725029],[-122.762239,45.730506],[-122.247407,45.549767],[-121.924267,45.648352],[-121.820205,45.462136],[-122.356945,45.462136],[-122.745808,45.434751],[-122.926547,45.725029]]]}});
}).toThrow();
});
var output = Terraformer.WKT.convert(input);
it("should throw an error adding invalid features to a store", function(){
expect(function() {
gs.add({
"type": "FeatureCollection",
"features":[
{"type":"Polygon","coordinates":[[[-123.134671,45.779798],[-122.926547,45.725029],[-122.745808,45.434751],[-122.866301,45.319735],[-123.063471,45.401889],[-123.463287,45.434751],[-123.359225,45.779798],[-123.134671,45.779798]]]},
{"type":"Feature","properties":{"name":"Clackamas"},"geometry":{"type":"Polygon","coordinates":[[[-122.356945,45.462136],[-121.820205,45.462136],[-121.694236,45.259489],[-121.732574,44.887057],[-122.395284,44.887057],[-122.84987,45.259489],[-122.866301,45.319735],[-122.745808,45.434751],[-122.356945,45.462136]]]}}
]
});
}).toThrow();
});
expect(output).toEqual("POINT (30 10)");
});
it("should throw an error when a GeoJSON object that is not a feature or a feautre collections is added", function(){
expect(function() {
gs.add({"type":"Polygon","coordinates":[[[-122.926547,45.725029],[-122.762239,45.730506],[-122.247407,45.549767],[-121.924267,45.648352],[-121.820205,45.462136],[-122.356945,45.462136],[-122.745808,45.434751],[-122.926547,45.725029]]]});
}).toThrow();
});
it("should convert a POINT with Z", function () {
var input = {
type: "Point",
coordinates: [ 30, 10, 10 ]
};
it("should add features to a store", function(){
gs.add({"type":"Feature","id":"41051","properties":{"name":"Multnomah"},"geometry":{"type":"Polygon","coordinates":[[[-122.926547,45.725029],[-122.762239,45.730506],[-122.247407,45.549767],[-121.924267,45.648352],[-121.820205,45.462136],[-122.356945,45.462136],[-122.745808,45.434751],[-122.926547,45.725029]]]}});
expect(gs.store.data[41051]).toBeTruthy();
});
var output = Terraformer.WKT.convert(input);
it("should add features to a store and run a callback", function(){
var spy = jasmine.createSpy();
gs.add({
"type": "FeatureCollection",
"features":[
{"type":"Feature","id":"41067","properties":{"name":"Washington"},"geometry":{"type":"Polygon","coordinates":[[[-123.134671,45.779798],[-122.926547,45.725029],[-122.745808,45.434751],[-122.866301,45.319735],[-123.063471,45.401889],[-123.463287,45.434751],[-123.359225,45.779798],[-123.134671,45.779798]]]}},
{"type":"Feature","id":"41005","properties":{"name":"Clackamas"},"geometry":{"type":"Polygon","coordinates":[[[-122.356945,45.462136],[-121.820205,45.462136],[-121.694236,45.259489],[-121.732574,44.887057],[-122.395284,44.887057],[-122.84987,45.259489],[-122.866301,45.319735],[-122.745808,45.434751],[-122.356945,45.462136]]]}}
]
}, spy);
expect(spy.callCount).toEqual(1);
expect(gs.store.data[41067]).toBeTruthy();
expect(gs.store.data[41005]).toBeTruthy();
});
expect(output).toEqual("POINT Z (30 10 10)");
});
it("should find no results", function(){
var result;
gs.contains({
type:"Point",
coordinates: [0, 0]
}, function(error, found){
expect(found.length).toEqual(0);
});
});
it("should convert a POINT with M (nonstandard)", function () {
var input = {
properties: { m: true },
type: "Point",
coordinates: [ 30, 10, 10 ]
};
it("should find one result", function(){
var result;
gs.contains({
type:"Point",
coordinates: [-122.676048, 45.516544]
}, function(error, found){
expect(found.length).toEqual(1);
expect(found[0].id).toEqual("41051");
});
});
var output = Terraformer.WKT.convert(input);
expect(output).toEqual("POINT M (30 10 10)");
});
it("should remove a feature", function(){
var result;
var spy = jasmine.createSpy();
gs.remove("41051", spy);
expect(spy.callCount).toEqual(1);
expect(gs.store.data[41051]).toBeFalsy();
expect(gs.store.data[41067]).toBeTruthy();
});
it("should convert a POINT with Z and M", function () {
var input = {
type: "Point",
coordinates: [ 30, 10, 10, 12 ]
};
it("shouldn't find any results", function(){
var result;
gs.contains({
type:"Point",
coordinates: [-122.676048, 45.516544]
}, function(error, found){
expect(found.length).toEqual(0);
});
});
var output = Terraformer.WKT.convert(input);
it("should get a single result by id", function(){
var result;
gs.get("41067", function(error, found){
expect(found.id).toEqual("41067");
});
});
expect(output).toEqual("POINT ZM (30 10 10 12)");
});
it("should update a feature and run a successful query", function(){
var result;
var spy = jasmine.createSpy();
gs.update({"type":"Feature","id":"41067","properties":{"name":"Multnomah"},"geometry":{"type":"Polygon","coordinates":[[[-122.926547,45.725029],[-122.762239,45.730506],[-122.247407,45.549767],[-121.924267,45.648352],[-121.820205,45.462136],[-122.356945,45.462136],[-122.745808,45.434751],[-122.926547,45.725029]]]}}, spy);
expect(spy.callCount).toEqual(1);
gs.contains({
type:"Point",
coordinates: [-122.676048, 45.516544]
}, function(error, found){
expect(found.length).toEqual(1);
expect(found[0].id).toEqual("41067");
});
});
it("should convert an empty POINT", function () {
var input = {
type: "Point",
coordinates: [ ]
};
it("should update features in store and run a callback", function(){
var spy = jasmine.createSpy();
gs.update({"type":"Feature","id":"41067","properties":{"name":"Multnomah"},"geometry":{"type":"Polygon","coordinates":[[[-122.926547,45.725029],[-122.762239,45.730506],[-122.247407,45.549767],[-121.924267,45.648352],[-121.820205,45.462136],[-122.356945,45.462136],[-122.745808,45.434751],[-122.926547,45.725029]]]}}, spy);
expect(spy.callCount).toEqual(1);
});
var output = Terraformer.WKT.convert(input);
var serial;
expect(output).toEqual("POINT EMPTY");
});
it("should serialize a Memory store", function(){
var callback = jasmine.createSpy("callback");
gs.store.serialize(callback);
expect(callback).toHaveBeenCalled();
expect(callback).toHaveBeenCalledWith(null, JSON.stringify(gs.store.data));
});
it("should convert a POLYGON", function () {
var input = {
type: "Polygon",
coordinates: [ [ [ 30, 10 ], [ 20, 20 ], [ 30, 20 ] ] ]
};
it("should deserialize a memory store", function(){
var spy = jasmine.createSpy();
var serial;
gs.store.serialize(function(error, data){
serial = data;
});
gs = new Terraformer.GeoStore({
store: new Terraformer.Store.Memory().deserialize(serial),
index: new Terraformer.RTree()
});
expect(gs.store.data[41005]).toBeTruthy();
expect(gs.store.data[41067]).toBeTruthy();
});
var output = Terraformer.WKT.convert(input);
var badStore = new Terraformer.GeoStore({
store: {
get: function(id, callback){
return callback("ERROR", null);
},
add: function(geo, callback){
return callback("ERROR", null);
},
remove: function(id, callback){
return callback("ERROR", null);
},
update: function(geo, callback){
return callback("ERROR", null);
}
},
index: new Terraformer.RTree()
});
expect(output).toEqual("POLYGON ((30 10, 20 20, 30 20))");
});
it("should run an error callback when the store rejects the deferred when adding an item", function(){
var spy = jasmine.createSpy();
badStore.add({"type":"Feature","id":"41067","properties":{"name":"Multnomah"},"geometry":{"type":"Polygon","coordinates":[[[-122.926547,45.725029],[-122.762239,45.730506],[-122.247407,45.549767],[-121.924267,45.648352],[-121.820205,45.462136],[-122.356945,45.462136],[-122.745808,45.434751],[-122.926547,45.725029]]]}}, spy);
expect(spy).toHaveBeenCalledWith("ERROR", null);
});
it("should convert a POLYGON with Z", function () {
var input = {
type: "Polygon",
coordinates: [ [ [ 30, 10, 1 ], [ 20, 20, 2 ], [ 30, 20, 3 ] ] ]
};
it("should run an error callback when the store rejects the deferred when updating an item", function(){
var spy = jasmine.createSpy();
badStore.update({"type":"Feature","id":"41067","properties":{"name":"Multnomah"},"geometry":{"type":"Polygon","coordinates":[[[-122.926547,45.725029],[-122.762239,45.730506],[-122.247407,45.549767],[-121.924267,45.648352],[-121.820205,45.462136],[-122.356945,45.462136],[-122.745808,45.434751],[-122.926547,45.725029]]]}}, spy);
expect(spy).toHaveBeenCalledWith('Could find feature', null);
});
var output = Terraformer.WKT.convert(input);
it("should return an error in the callback when the store cant get an item", function(){
var spy = jasmine.createSpy();
badStore.get("41067", spy);
expect(spy).toHaveBeenCalledWith("ERROR", null);
});
expect(output).toEqual("POLYGON Z ((30 10 1, 20 20 2, 30 20 3))");
});
it("should return an error in the callback when the store cant find a feature to remove", function(){
var spy = jasmine.createSpy();
badStore.remove("41067", spy);
expect(spy).toHaveBeenCalledWith('Could not get feature to remove', null);
});
it("should convert a POLYGON with ZM", function () {
var input = {
type: "Polygon",
coordinates: [ [ [ 30, 10, 1, 3 ], [ 20, 20, 2, 2 ], [ 30, 20, 3, 1 ] ] ]
};
it("should run an error callback when the store rejects the deferred when querying an item", function(){
var spy = jasmine.createSpy();
badStore.contains({
type:"Point",
coordinates: [-122.676048, 45.516544]
}, spy);
expect(spy).toHaveBeenCalledWith("Could not get all geometries", null);
});
var output = Terraformer.WKT.convert(input);
expect(output).toEqual("POLYGON ZM ((30 10 1 3, 20 20 2 2, 30 20 3 1))");
});
if(typeof navigator !== "undefined"){
describe("with a LocalStorage store and rtree", function(){
var gs;
it("should convert a POLYGON with M (nonstandard)", function () {
var input = {
properties: { m: true },
type: "Polygon",
coordinates: [ [ [ 30, 10, 1 ], [ 20, 20, 2 ], [ 30, 20, 3 ] ] ]
};
it("should create with a LocalStorage and an RTree", function(){
expect(function() {
gs = new Terraformer.GeoStore({
store: new Terraformer.Store.LocalStorage(),
index: new Terraformer.RTree()
});
}).not.toThrow();
expect(gs).toBeTruthy();
});
var output = Terraformer.WKT.convert(input);
it("should find one result", function(){
var result;
gs.add({"type":"Feature","id":"41051","properties":{"name":"Multnomah"},"geometry":{"type":"Polygon","coordinates":[[[-122.926547,45.725029],[-122.762239,45.730506],[-122.247407,45.549767],[-121.924267,45.648352],[-121.820205,45.462136],[-122.356945,45.462136],[-122.745808,45.434751],[-122.926547,45.725029]]]}});
gs.add({"type":"Feature","id":"41067","properties":{"name":"Washington"},"geometry":{"type":"Polygon","coordinates":[[[-123.134671,45.779798],[-122.926547,45.725029],[-122.745808,45.434751],[-122.866301,45.319735],[-123.063471,45.401889],[-123.463287,45.434751],[-123.359225,45.779798],[-123.134671,45.779798]]]}});
gs.contains({
type:"Point",
coordinates: [-122.676048, 45.516544]
}, function(error, found){
expect(found.length).toEqual(1);
expect(found[0].id).toEqual("41051");
});
});
expect(output).toEqual("POLYGON M ((30 10 1, 20 20 2, 30 20 3))");
});
it("shouldn't find any results if a feature is removed", function(){
var result;
gs.remove("41051");
gs.within({
type:"Point",
coordinates: [-122.676048, 45.516544]
}, function(error, found){
expect(found.length).toEqual(0);
});
});
it("should convert an EMPTY POLYGON", function () {
var input = {
type: "Polygon",
coordinates: [ ]
};
it("should update a feature and run a successful query", function(){
var result;
gs.update({"type":"Feature","id":"41067","properties":{"name":"Multnomah"},"geometry":{"type":"Polygon","coordinates":[[[-122.926547,45.725029],[-122.762239,45.730506],[-122.247407,45.549767],[-121.924267,45.648352],[-121.820205,45.462136],[-122.356945,45.462136],[-122.745808,45.434751],[-122.926547,45.725029]]]}});
gs.contains({
type:"Point",
coordinates: [-122.676048, 45.516544]
}, function( error, found){
expect(found.length).toEqual(1);
expect(found[0].id).toEqual("41067");
});
});
var output = Terraformer.WKT.convert(input);
it("should throw an error when a feautre without an id is updated", function(){
expect(function() {
gs.update({"type":"Feature","properties":{"name":"Multnomah"},"geometry":{"type":"Polygon","coordinates":[[[-122.926547,45.725029],[-122.762239,45.730506],[-122.247407,45.549767],[-121.924267,45.648352],[-121.820205,45.462136],[-122.356945,45.462136],[-122.745808,45.434751],[-122.926547,45.725029]]]}});
}).toThrow();
});
expect(output).toEqual("POLYGON EMPTY");
});
it("should throw an error when a GeoJSON object that is not a feature or a feautre collections is updated", function(){
expect(function() {
gs.update({"type":"Polygon","coordinates":[[[-122.926547,45.725029],[-122.762239,45.730506],[-122.247407,45.549767],[-121.924267,45.648352],[-121.820205,45.462136],[-122.356945,45.462136],[-122.745808,45.434751],[-122.926547,45.725029]]]});
}).toThrow();
});
it("should convert a MULTIPOINT", function () {
var input = {
type: "MultiPoint",
coordinates: [ [ 30, 10 ], [ 20, 20 ], [ 30, 20 ] ]
};
it("should serialize a LocalStore store", function(){
var callback = jasmine.createSpy("callback");
gs.store.serialize(callback);
expect(callback).toHaveBeenCalled();
});
var output = Terraformer.WKT.convert(input);
it("should deserialize a LocalStore store", function(){
var spy = jasmine.createSpy();
var serial;
gs.store.serialize(function(error, data){
serial = data;
});
gs = new Terraformer.GeoStore({
store: new Terraformer.Store.LocalStorage().deserialize(serial),
index: new Terraformer.RTree()
});
expect(window.localStorage[gs.store._key+"_41067"]).toBeTruthy();
});
});
expect(output).toEqual("MULTIPOINT (30 10, 20 20, 30 20)");
});
}
it("should convert a MULTIPOINT with Z", function () {
var input = {
type: "MultiPoint",
coordinates: [ [ 30, 10, 1 ], [ 20, 20, 2 ], [ 30, 20, 3 ] ]
};
describe("with a memory store and rtree and within", function(){
var gs;
var output = Terraformer.WKT.convert(input);
it("should create with a Memory store and an RTree", function(){
expect(function() {
gs = new Terraformer.GeoStore({
store: new Terraformer.Store.Memory(),
index: new Terraformer.RTree()
});
}).not.toThrow();
expect(gs).toBeTruthy();
});
expect(output).toEqual("MULTIPOINT Z (30 10 1, 20 20 2, 30 20 3)");
});
it("should be able to add coordinates", function(){
expect(function() {
gs.add({ "id": 1, "type": "Feature", "geometry": { "type": "Polygon", "coordinates": [ [ [ -122.655849602879201, 45.538304922840894, 0.0 ], [ -122.655691867426299, 45.538304448196108, 0.0 ], [ -122.655692285611451, 45.538236031205983, 0.0 ], [ -122.655850019628431, 45.538236506773742, 0.0 ], [ -122.655849602879201, 45.538304922840894, 0.0 ] ] ] } });
gs.add({ "id": 2, "type": "Feature", "geometry": { "type": "Polygon", "coordinates": [ [ [ -122.589480827112766, 45.477987695417717, 0.0 ], [ -122.589481271327131, 45.477926424718063, 0.0 ], [ -122.589631424206658, 45.477926964033657, 0.0 ], [ -122.589630980154141, 45.477988234733886, 0.0 ], [ -122.589480827112766, 45.477987695417717, 0.0 ] ] ] } });
}).not.toThrow();
expect(gs).toBeTruthy();
});
it("should convert a MULTIPOINT with ZM", function () {
var input = {
type: "MultiPoint",
coordinates: [ [ 30, 10, 1, 2 ], [ 20, 20, 3, 4 ], [ 30, 20, 5, 6 ] ]
};
it("should be able to find the correct id using within", function(){
gs.within({
"type": "Polygon",
"coordinates": [ [ [ -122.655849602879201, 45.538304922840894, 0.0 ], [ -122.655691867426299, 45.538304448196108, 0.0 ], [ -122.655692285611451, 45.538236031205983, 0.0 ], [ -122.655850019628431, 45.538236506773742, 0.0 ], [ -122.655849602879201, 45.538304922840894, 0.0 ] ] ]
}, function (err, res) {
expect(res[0].id).toEqual(1);
});
});
var output = Terraformer.WKT.convert(input);
expect(output).toEqual("MULTIPOINT ZM (30 10 1 2, 20 20 3 4, 30 20 5 6)");
});
describe("with a memory store and streams", function(){
var gs;
it("should convert a MULTIPOINT with M (nonstandard)", function () {
var input = {
properties: { m: true },
type: "MultiPoint",
coordinates: [ [ 30, 10, 1 ], [ 20, 20, 2 ], [ 30, 20, 3 ] ]
};
it("should create with a Memory store and an RTree", function(){
expect(function() {
gs = new Terraformer.GeoStore({
store: new Terraformer.Store.Memory(),
index: new Terraformer.RTree()
});
}).not.toThrow();
expect(gs).toBeTruthy();
});
var output = Terraformer.WKT.convert(input);
it("should be able to add coordinates", function(){
expect(function() {
gs.add({ "id": 1, "type": "Feature", "geometry": { "type": "Polygon", "coordinates": [ [ [ -122.655849602879201, 45.538304922840894, 0.0 ], [ -122.655691867426299, 45.538304448196108, 0.0 ], [ -122.655692285611451, 45.538236031205983, 0.0 ], [ -122.655850019628431, 45.538236506773742, 0.0 ], [ -122.655849602879201, 45.538304922840894, 0.0 ] ] ] } });
gs.add({ "id": 2, "type": "Feature", "geometry": { "type": "Polygon", "coordinates": [ [ [ -122.589480827112766, 45.477987695417717, 0.0 ], [ -122.589481271327131, 45.477926424718063, 0.0 ], [ -122.589631424206658, 45.477926964033657, 0.0 ], [ -122.589630980154141, 45.477988234733886, 0.0 ], [ -122.589480827112766, 45.477987695417717, 0.0 ] ] ] } });
}).not.toThrow();
expect(gs).toBeTruthy();
});
expect(output).toEqual("MULTIPOINT M (30 10 1, 20 20 2, 30 20 3)");
});
it("should be able to create a Stream", function(){
expect(gs.createReadStream()).toBeTruthy();
});
it("should convert an EMPTY MULTIPOINT", function () {
var input = {
type: "MultiPoint",
coordinates: [ ]
};
it("should be able to use within and get data streamed to it", function(){
var completed = 0;
var s = gs.createReadStream();
var spy = jasmine.createSpy();
s.on("end", spy);
gs.within({
"type": "Polygon",
"coordinates": [ [ [ -122.655849602879201, 45.538304922840894, 0.0 ], [ -122.655691867426299, 45.538304448196108, 0.0 ], [ -122.655692285611451, 45.538236031205983, 0.0 ], [ -122.655850019628431, 45.538236506773742, 0.0 ], [ -122.655849602879201, 45.538304922840894, 0.0 ] ] ]
});
var output = Terraformer.WKT.convert(input);
expect(spy.callCount).toEqual(1);
});
expect(output).toEqual("MULTIPOINT EMPTY");
});
describe("with a memory store and alternate indexes and within", function(){
var gs;
it("should convert a LINESTRING with Z", function () {
var input = {
type: "LineString",
coordinates: [ [ 30, 10, 2 ], [ 20, 20, 1 ], [ 30, 20, 0 ] ]
};
it("should create with a Memory store and an RTree", function(){
expect(function() {
gs = new Terraformer.GeoStore({
store: new Terraformer.Store.Memory(),
index: new Terraformer.RTree()
});
}).not.toThrow();
expect(gs).toBeTruthy();
});
var output = Terraformer.WKT.convert(input);
it("should be able to add coordinates", function(){
expect(function() {
gs.add({ "id": 1, "type": "Feature", "geometry": { "type": "Polygon", "coordinates": [ [ [ -122.655849602879201, 45.538304922840894, 0.0 ], [ -122.655691867426299, 45.538304448196108, 0.0 ], [ -122.655692285611451, 45.538236031205983, 0.0 ], [ -122.655850019628431, 45.538236506773742, 0.0 ], [ -122.655849602879201, 45.538304922840894, 0.0 ] ] ] } });
gs.add({ "id": 2, "type": "Feature", "geometry": { "type": "Polygon", "coordinates": [ [ [ -122.589480827112766, 45.477987695417717, 0.0 ], [ -122.589481271327131, 45.477926424718063, 0.0 ], [ -122.589631424206658, 45.477926964033657, 0.0 ], [ -122.589630980154141, 45.477988234733886, 0.0 ], [ -122.589480827112766, 45.477987695417717, 0.0 ] ] ] } });
}).not.toThrow();
expect(gs).toBeTruthy();
});
expect(output).toEqual("LINESTRING Z (30 10 2, 20 20 1, 30 20 0)");
});
it("should be able to find the correct id using within", function(){
gs.within({
"type": "Polygon",
"coordinates": [ [ [ -122.655849602879201, 45.538304922840894, 0.0 ], [ -122.655691867426299, 45.538304448196108, 0.0 ], [ -122.655692285611451, 45.538236031205983, 0.0 ], [ -122.655850019628431, 45.538236506773742, 0.0 ], [ -122.655849602879201, 45.538304922840894, 0.0 ] ] ]
}, function (err, res) {
expect(res[0].id).toEqual(1);
});
});
it("should convert a LINESTRING with ZM", function () {
var input = {
type: "LineString",
coordinates: [ [ 30, 10, 1, 2 ], [ 20, 20, 3, 4 ], [ 30, 20, 5, 6 ] ]
};
it("should be able to eliminate the result with an alternate index", function(){
gs.addIndex({ property: "crime", index: function (value, callback) { callback(null, { 1: false }); }});
gs.within({
"type": "Polygon",
"coordinates": [ [ [ -122.655849602879201, 45.538304922840894, 0.0 ], [ -122.655691867426299, 45.538304448196108, 0.0 ], [ -122.655692285611451, 45.538236031205983, 0.0 ], [ -122.655850019628431, 45.538236506773742, 0.0 ], [ -122.655849602879201, 45.538304922840894, 0.0 ] ] ]
},
{
"crime":
{
"equals": "arson"
}
},
function (err, res) {
expect(res.length).toEqual(0);
});
});
var output = Terraformer.WKT.convert(input);
it("should be able to not eliminate the result with an alternate index", function(){
gs._alternate_indexes = [ ];
gs.addIndex({ property: "crime", index: function (value, callback) { callback(null, { 1: true }); }});
gs.within({
"type": "Polygon",
"coordinates": [ [ [ -122.655849602879201, 45.538304922840894, 0.0 ], [ -122.655691867426299, 45.538304448196108, 0.0 ], [ -122.655692285611451, 45.538236031205983, 0.0 ], [ -122.655850019628431, 45.538236506773742, 0.0 ], [ -122.655849602879201, 45.538304922840894, 0.0 ] ] ]
},
{
"crime":
{
"equals": "arson"
}
},
function (err, res) {
expect(res.length).toEqual(1);
});
});
expect(output).toEqual("LINESTRING ZM (30 10 1 2, 20 20 3 4, 30 20 5 6)");
});
it("should convert a LINESTRING with M (nonstandard)", function () {
var input = {
properties: { m: true },
type: "LineString",
coordinates: [ [ 30, 10, 1 ], [ 20, 20, 2 ], [ 30, 20, 3 ] ]
};
var output = Terraformer.WKT.convert(input);
expect(output).toEqual("LINESTRING M (30 10 1, 20 20 2, 30 20 3)");
});
describe("with a memory store and alternate indexes and contains", function(){
var gs;
it("should convert an EMPTY LINESTRING", function () {
var input = {
type: "LineString",
coordinates: [ ]
};
it("should create with a Memory store and an RTree", function(){
expect(function() {
gs = new Terraformer.GeoStore({
store: new Terraformer.Store.Memory(),
index: new Terraformer.RTree()
});
}).not.toThrow();
expect(gs).toBeTruthy();
});
var output = Terraformer.WKT.convert(input);
it("should be able to add coordinates", function(){
expect(function() {
gs.add({"type":"Feature","id":1,"properties":{"name":"Multnomah"},"geometry":{"type":"Polygon","coordinates":[[[-122.926547,45.725029],[-122.762239,45.730506],[-122.247407,45.549767],[-121.924267,45.648352],[-121.820205,45.462136],[-122.356945,45.462136],[-122.745808,45.434751],[-122.926547,45.725029]]]}});
gs.add({"type":"Feature","id":2,"properties":{"name":"Washington"},"geometry":{"type":"Polygon","coordinates":[[[-123.134671,45.779798],[-122.926547,45.725029],[-122.745808,45.434751],[-122.866301,45.319735],[-123.063471,45.401889],[-123.463287,45.434751],[-123.359225,45.779798],[-123.134671,45.779798]]]}});
}).not.toThrow();
expect(gs).toBeTruthy();
});
expect(output).toEqual("LINESTRING EMPTY");
});
it("should find no results", function(){
var result;
gs.contains({
type:"Point",
coordinates: [0, 0]
}, function(error, found){
expect(found.length).toEqual(0);
});
});
it("should convert a LINESTRING", function () {
var input = {
type: "LineString",
coordinates: [ [ 30, 10 ], [ 20, 20 ], [ 30, 20 ] ]
};
it("should find one result", function(){
var result;
gs.contains({
type:"Point",
coordinates: [-122.676048, 45.516544]
}, function(error, found){
console.log(found);
expect(found.length).toEqual(1);
expect(found[0].id).toEqual(1);
});
});
var output = Terraformer.WKT.convert(input);
expect(output).toEqual("LINESTRING (30 10, 20 20, 30 20)");
});
it("should be able to eliminate the result with an alternate index", function(){
gs.addIndex({ property: "crime", index: function (value, callback) { callback(null, { 1: false }); }});
var result;
gs.contains({
type:"Point",
coordinates: [-122.676048, 45.516544]
},
{
"crime":
{
"equals": "arson"
}
},
function(error, found){
expect(found.length).toEqual(0);
});
});
it("should convert a MULTILINESTRING", function () {
var input = {
type: "MultiLineString",
coordinates: [ [ [ 30, 10 ], [ 20, 20 ], [ 30, 20 ] ] ]
};
it("should be able to not eliminate the result with an alternate index", function(){
gs._alternate_indexes = [ ];
gs.addIndex({ property: "crime", index: function (value, callback) { callback(null, { 1: true }); }});
gs.contains({
"type": "Polygon",
"coordinates": [ [ [ -122.655849602879201, 45.538304922840894, 0.0 ], [ -122.655691867426299, 45.538304448196108, 0.0 ], [ -122.655692285611451, 45.538236031205983, 0.0 ], [ -122.655850019628431, 45.538236506773742, 0.0 ], [ -122.655849602879201, 45.538304922840894, 0.0 ] ] ]
},
{
"crime":
{
"equals": "arson"
}
},
function (err, res) {
expect(res.length).toEqual(1);
});
});
var output = Terraformer.WKT.convert(input);
expect(output).toEqual("MULTILINESTRING ((30 10, 20 20, 30 20))");
});
it("should convert a MULTILINESTRING with Z", function () {
var input = {
type: "MultiLineString",
coordinates: [ [ [ 30, 10, 1 ], [ 20, 20, 2 ], [ 30, 20, 3 ] ] ]
};
var output = Terraformer.WKT.convert(input);
expect(output).toEqual("MULTILINESTRING Z ((30 10 1, 20 20 2, 30 20 3))");
});
it("should convert a MULTILINESTRING with Z and M", function () {
var input = {
type: "MultiLineString",
coordinates: [ [ [ 30, 10, 1, 2 ], [ 20, 20, 3, 4 ], [ 30, 20, 5, 6 ] ] ]
};
var output = Terraformer.WKT.convert(input);
expect(output).toEqual("MULTILINESTRING ZM ((30 10 1 2, 20 20 3 4, 30 20 5 6))");
});
it("should convert a MULTILINESTRING with M (nonstandard)", function () {
var input = {
properties: { m: true },
type: "MultiLineString",
coordinates: [ [ [ 30, 10, 1 ], [ 20, 20, 2 ], [ 30, 20, 3 ] ] ]
};
var output = Terraformer.WKT.convert(input);
expect(output).toEqual("MULTILINESTRING M ((30 10 1, 20 20 2, 30 20 3))");
});
it("should convert an EMPTY MULTILINESTRING", function () {
var input = {
type: "MultiLineString",
coordinates: [ ]
};
var output = Terraformer.WKT.convert(input);
expect(output).toEqual("MULTILINESTRING EMPTY");
});
it("should convert a MULTIPOLYGON", function () {
var input = { "type": "MultiPolygon",
"coordinates": [
[[[102.0, 2.0], [103.0, 2.0], [103.0, 3.0], [102.0, 3.0], [102.0, 2.0]]],
[[[100.0, 0.0], [101.0, 0.0], [101.0, 1.0], [100.0, 1.0], [100.0, 0.0]],
[[100.2, 0.2], [100.8, 0.2], [100.8, 0.8], [100.2, 0.8], [100.2, 0.2]]]
]
};
var output = Terraformer.WKT.convert(input);
expect(output).toEqual("MULTIPOLYGON (((102 2, 103 2, 103 3, 102 3, 102 2)), ((100 0, 101 0, 101 1, 100 1, 100 0), (100.2 0.2, 100.8 0.2, 100.8 0.8, 100.2 0.8, 100.2 0.2)))");
});
it("should convert a MULTIPOLYGON with Z", function () {
var input = { "type": "MultiPolygon",
"coordinates": [
[[[102.0, 2.0, 1], [103.0, 2.0, 2], [103.0, 3.0, 3], [102.0, 3.0, 4], [102.0, 2.0, 5]]],
[[[100.0, 0.0], [101.0, 0.0], [101.0, 1.0], [100.0, 1.0], [100.0, 0.0]],
[[100.2, 0.2], [100.8, 0.2], [100.8, 0.8], [100.2, 0.8], [100.2, 0.2]]]
]
};
var output = Terraformer.WKT.convert(input);
expect(output).toEqual("MULTIPOLYGON Z (((102 2 1, 103 2 2, 103 3 3, 102 3 4, 102 2 5)), ((100 0, 101 0, 101 1, 100 1, 100 0), (100.2 0.2, 100.8 0.2, 100.8 0.8, 100.2 0.8, 100.2 0.2)))");
});
it("should convert a MULTIPOLYGON with Z and M", function () {
var input = { "type": "MultiPolygon",
"coordinates": [
[[[102.0, 2.0, 1, 2], [103.0, 2.0, 3, 4], [103.0, 3.0, 5, 6], [102.0, 3.0, 7, 8], [102.0, 2.0, 9, 10]]],
[[[100.0, 0.0], [101.0, 0.0], [101.0, 1.0], [100.0, 1.0], [100.0, 0.0]],
[[100.2, 0.2], [100.8, 0.2], [100.8, 0.8], [100.2, 0.8], [100.2, 0.2]]]
]
};
var output = Terraformer.WKT.convert(input);
expect(output).toEqual("MULTIPOLYGON ZM (((102 2 1 2, 103 2 3 4, 103 3 5 6, 102 3 7 8, 102 2 9 10)), ((100 0, 101 0, 101 1, 100 1, 100 0), (100.2 0.2, 100.8 0.2, 100.8 0.8, 100.2 0.8, 100.2 0.2)))");
});
it("should convert a MULTIPOLYGON with M (nonstandard)", function () {
var input = { "type": "MultiPolygon",
properties: { m: true },
"coordinates": [
[[[102.0, 2.0, 1], [103.0, 2.0, 2], [103.0, 3.0, 3], [102.0, 3.0, 4], [102.0, 2.0, 5]]],
[[[100.0, 0.0], [101.0, 0.0], [101.0, 1.0], [100.0, 1.0], [100.0, 0.0]],
[[100.2, 0.2], [100.8, 0.2], [100.8, 0.8], [100.2, 0.8], [100.2, 0.2]]]
]
};
var output = Terraformer.WKT.convert(input);
expect(output).toEqual("MULTIPOLYGON M (((102 2 1, 103 2 2, 103 3 3, 102 3 4, 102 2 5)), ((100 0, 101 0, 101 1, 100 1, 100 0), (100.2 0.2, 100.8 0.2, 100.8 0.8, 100.2 0.8, 100.2 0.2)))");
});
it("should convert an EMPTY MULTIPOLYGON", function () {
var input = { "type": "MultiPolygon",
"coordinates": [ ]
};
var output = Terraformer.WKT.convert(input);
expect(output).toEqual("MULTIPOLYGON EMPTY");
});
it("should fail a conversion on an unknown type", function () {
var input = { "type": "MultiPolygonLikeThingy",
"coordinates": [ ]
};
var error;
try {
var output = Terraformer.WKT.convert(input);
} catch (err) {
error = err.toString();
}
expect(error).toEqual("Error: Unknown Type: MultiPolygonLikeThingy");
});
});
describe("WKT Parser", function() {
it("should parse a POINT", function(){
var input = "POINT (30 10)";
var output = new Terraformer.WKT.parse(input);
expect(output.coordinates).toEqual([30,10]);
expect(output).toBeInstanceOfClass(Terraformer.Point);
expect(output.type).toEqual("Point");
});
it("should parse an EMPTY POINT", function(){
var input = "POINT EMPTY";
var output = new Terraformer.WKT.parse(input);
expect(output.coordinates).toEqual([ ]);
expect(output).toBeInstanceOfClass(Terraformer.Point);
expect(output.type).toEqual("Point");
});
it("should parse a POINT with a Z coordinate", function(){
var input = "POINT Z (30 10 20)";
var output = new Terraformer.WKT.parse(input);
expect(output.coordinates).toEqual([30,10,20]);
expect(output).toBeInstanceOfClass(Terraformer.Point);
expect(output.type).toEqual("Point");
});
it("should parse a POINT with a M coordinate", function(){
var input = "POINT M (30 10 20)";
var output = new Terraformer.WKT.parse(input);
expect(output.coordinates).toEqual([30,10,20]);
expect(output).toBeInstanceOfClass(Terraformer.Point);
expect(output.type).toEqual("Point");
});
it("should parse a POINT with Z and M coordinates", function(){
var input = "POINT ZM (30 10 20 15)";
var output = new Terraformer.WKT.parse(input);
expect(output.coordinates).toEqual([30,10,20,15]);
expect(output).toBeInstanceOfClass(Terraformer.Point);
expect(output.type).toEqual("Point");
});
it("should parse a LINESTRING", function(){
var input = "LINESTRING (30 10, 10 30, 40 40)";
var output = new Terraformer.WKT.parse(input);
expect(output.coordinates).toEqual([ [30,10], [10,30], [40,40] ]);
expect(output).toBeInstanceOfClass(Terraformer.LineString);
expect(output.type).toEqual("LineString");
});
it("should parse an EMPTY LINESTRING", function(){
var input = "LINESTRING EMPTY";
var output = new Terraformer.WKT.parse(input);
expect(output.coordinates).toEqual([ ]);
expect(output).toBeInstanceOfClass(Terraformer.LineString);
expect(output.type).toEqual("LineString");
});
it("should parse a LINESTRING with a Z coordinate", function(){
var input = "LINESTRING Z (30 10 5, 10 30 15, 40 40 25)";
var output = new Terraformer.WKT.parse(input);
expect(output.coordinates).toEqual([ [30,10,5], [10,30,15], [40,40,25] ]);
expect(output).toBeInstanceOfClass(Terraformer.LineString);
expect(output.type).toEqual("LineString");
});
it("should parse a LINESTRING with a M coordinate", function(){
var input = "LINESTRING M (30 10 5, 10 30 15, 40 40 25)";
var output = new Terraformer.WKT.parse(input);
expect(output.coordinates).toEqual([ [30,10,5], [10,30,15], [40,40,25] ]);
expect(output).toBeInstanceOfClass(Terraformer.LineString);
expect(output.type).toEqual("LineString");
});
it("should parse a LINESTRING with Z and M coordinates", function(){
var input = "LINESTRING ZM (30 10 5 2, 10 30 15 8, 40 40 25 16)";
var output = new Terraformer.WKT.parse(input);
expect(output.coordinates).toEqual([ [30,10,5,2], [10,30,15,8], [40,40,25,16] ]);
expect(output).toBeInstanceOfClass(Terraformer.LineString);
expect(output.type).toEqual("LineString");
});
it("should parse a POLYGON", function(){
var input = "POLYGON ((30 10, 10 20, 20 40, 40 40, 30 10))";
var output = new Terraformer.WKT.parse(input);
expect(output.coordinates).toEqual([ [ [30, 10], [10, 20], [20, 40], [40, 40], [30, 10] ] ]);
expect(output).toBeInstanceOfClass(Terraformer.Polygon);
expect(output.type).toEqual("Polygon");
});
it("should parse an EMPTY POLYGON", function(){
var input = "POLYGON EMPTY";
var output = new Terraformer.WKT.parse(input);
expect(output.coordinates).toEqual([ ]);
expect(output).toBeInstanceOfClass(Terraformer.Polygon);
expect(output.type).toEqual("Polygon");
});
it("should parse a POLYGON with a Z coordinate", function(){
var input = "POLYGON Z ((30 10 4, 10 20 6, 20 40 8, 40 40 1, 30 10 3))";
var output = new Terraformer.WKT.parse(input);
expect(output.coordinates).toEqual([ [ [30, 10, 4], [10, 20, 6], [20, 40, 8], [40, 40, 1], [30, 10, 3] ] ]);
expect(output).toBeInstanceOfClass(Terraformer.Polygon);
expect(output.type).toEqual("Polygon");
});
it("should parse a POLYGON with a M coordinate", function(){
var input = "POLYGON M ((30 10 4, 10 20 6, 20 40 8, 40 40 1, 30 10 3))";
var output = new Terraformer.WKT.parse(input);
expect(output.coordinates).toEqual([ [ [30, 10, 4], [10, 20, 6], [20, 40, 8], [40, 40, 1], [30, 10, 3] ] ]);
expect(output).toBeInstanceOfClass(Terraformer.Polygon);
expect(output.type).toEqual("Polygon");
});
it("should parse a POLYGON with Z and M coordinates", function(){
var input = "POLYGON ZM ((30 10 4 1, 10 20 6 3, 20 40 8 5, 40 40 1 7, 30 10 3 9))";
var output = new Terraformer.WKT.parse(input);
expect(output.coordinates).toEqual([ [ [30, 10, 4, 1], [10, 20, 6, 3], [20, 40, 8, 5], [40, 40, 1, 7], [30, 10, 3, 9] ] ]);
expect(output).toBeInstanceOfClass(Terraformer.Polygon);
expect(output.type).toEqual("Polygon");
});
it("should parse a POLYGON with a hole", function(){
var input = "POLYGON ((35 10, 10 20, 15 40, 45 45, 35 10),(20 30, 35 35, 30 20, 20 30))";
var output = new Terraformer.WKT.parse(input);
expect(output.coordinates).toEqual([
[ [35, 10],[10, 20],[15, 40],[45, 45],[35, 10] ],
[ [20, 30],[35, 35],[30, 20],[20, 30] ]
]);
expect(output).toBeInstanceOfClass(Terraformer.Polygon);
expect(output.type).toEqual("Polygon");
});
it("should parse a MULTIPOINT", function(){
var input = "MULTIPOINT ((10 40), (40 30), (20 20), (30 10))";
var output = new Terraformer.WKT.parse(input);
expect(output.coordinates).toEqual([ [10, 40],[40, 30], [20,20], [30,10] ]);
expect(output).toBeInstanceOfClass(Terraformer.MultiPoint);
expect(output.type).toEqual("MultiPoint");
});
it("should parse an EMPTY MULTIPOINT", function(){
var input = "MULTIPOINT EMPTY";
var output = new Terraformer.WKT.parse(input);
expect(output.coordinates).toEqual([ ]);
expect(output).toBeInstanceOfClass(Terraformer.MultiPoint);
expect(output.type).toEqual("MultiPoint");
});
it("should parse a MULTIPOINT with a Z coordinate", function(){
var input = "MULTIPOINT Z ((10 40 1), (40 30 2), (20 20 3), (30 10 4))";
var output = new Terraformer.WKT.parse(input);
expect(output.coordinates).toEqual([ [10, 40, 1],[40, 30, 2], [20, 20, 3], [30, 10, 4] ]);
expect(output).toBeInstanceOfClass(Terraformer.MultiPoint);
expect(output.type).toEqual("MultiPoint");
});
it("should parse a MULTIPOINT with a M coordinate", function(){
var input = "MULTIPOINT M ((10 40 1), (40 30 2), (20 20 3), (30 10 4))";
var output = new Terraformer.WKT.parse(input);
expect(output.coordinates).toEqual([ [10, 40, 1],[40, 30, 2], [20, 20, 3], [30, 10, 4] ]);
expect(output).toBeInstanceOfClass(Terraformer.MultiPoint);
expect(output.type).toEqual("MultiPoint");
});
it("should parse a MULTIPOINT with Z and M coordinates", function(){
var input = "MULTIPOINT ZM ((10 40 1 8), (40 30 2 9), (20 20 3 8), (30 10 4 9))";
var output = new Terraformer.WKT.parse(input);
expect(output.coordinates).toEqual([ [10, 40, 1, 8],[40, 30, 2, 9], [20, 20, 3, 8], [30, 10, 4, 9] ]);
expect(output).toBeInstanceOfClass(Terraformer.MultiPoint);
expect(output.type).toEqual("MultiPoint");
});
it("should parse a MULTIPOINT with alternate syntax", function(){
var input = "MULTIPOINT (10 40, 40 30, 20 20, 30 10)";
var output = new Terraformer.WKT.parse(input);
expect(output.coordinates).toEqual([ [10, 40],[40, 30], [20,20], [30,10] ]);
expect(output).toBeInstanceOfClass(Terraformer.MultiPoint);
expect(output.type).toEqual("MultiPoint");
});
it("should parse a MULTIPOINT with alternate syntax and Z coordinates", function(){
var input = "MULTIPOINT Z (10 40 1, 40 30 2, 20 20 3, 30 10 4)";
var output = new Terraformer.WKT.parse(input);
expect(output.coordinates).toEqual([ [10, 40, 1],[40, 30, 2], [20, 20, 3], [30, 10, 4] ]);
expect(output).toBeInstanceOfClass(Terraformer.MultiPoint);
expect(output.type).toEqual("MultiPoint");
});
it("should parse a MULTIPOINT with alternate syntax and M coordinates", function(){
var input = "MULTIPOINT M (10 40 1, 40 30 2, 20 20 3, 30 10 4)";
var output = new Terraformer.WKT.parse(input);
expect(output.coordinates).toEqual([ [10, 40, 1],[40, 30, 2], [20, 20, 3], [30, 10, 4] ]);
expect(output).toBeInstanceOfClass(Terraformer.MultiPoint);
expect(output.type).toEqual("MultiPoint");
});
it("should parse a MULTIPOINT with alternate syntax and Z and M coordinates", function(){
var input = "MULTIPOINT ZM (10 40 1 2, 40 30 2 3, 20 20 3 4, 30 10 4 5)";
var output = new Terraformer.WKT.parse(input);
expect(output.coordinates).toEqual([ [10, 40, 1, 2],[40, 30, 2, 3], [20, 20, 3, 4], [30, 10, 4, 5] ]);
expect(output).toBeInstanceOfClass(Terraformer.MultiPoint);
expect(output.type).toEqual("MultiPoint");
});
it("should parse a MULTILINESTRING with alternate syntax", function(){
var input = "MULTILINESTRING ((10 10, 20 20, 10 40),(40 40, 30 30, 40 20, 30 10))";
var output = new Terraformer.WKT.parse(input);
expect(output.coordinates).toEqual([
[ [10,10],[20,20],[10,40] ],
[ [40,40],[30,30],[40,20],[30,10] ]
]);
expect(output).toBeInstanceOfClass(Terraformer.MultiLineString);
expect(output.type).toEqual("MultiLineString");
});
it("should parse an EMPTY MULTILINESTRING", function(){
var input = "MULTILINESTRING EMPTY";
var output = new Terraformer.WKT.parse(input);
expect(output.coordinates).toEqual([ ]);
expect(output).toBeInstanceOfClass(Terraformer.MultiLineString);
expect(output.type).toEqual("MultiLineString");
});
it("should parse a MULTILINESTRING with alternate syntax and Z coordinates", function(){
var input = "MULTILINESTRING Z ((10 10 10, 20 20 20, 10 40 30),(40 40 30, 30 30 20, 40 20 10, 30 10 10))";
var output = new Terraformer.WKT.parse(input);
expect(output.coordinates).toEqual([
[ [10,10,10],[20,20,20],[10,40,30] ],
[ [40,40,30],[30,30,20],[40,20,10],[30,10,10] ]
]);
expect(output).toBeInstanceOfClass(Terraformer.MultiLineString);
expect(output.type).toEqual("MultiLineString");
});
it("should parse a MULTILINESTRING with alternate syntax and M coordinates", function(){
var input = "MULTILINESTRING M ((10 10 10, 20 20 20, 10 40 30),(40 40 30, 30 30 20, 40 20 10, 30 10 10))";
var output = new Terraformer.WKT.parse(input);
expect(output.coordinates).toEqual([
[ [10,10,10],[20,20,20],[10,40,30] ],
[ [40,40,30],[30,30,20],[40,20,10],[30,10,10] ]
]);
expect(output).toBeInstanceOfClass(Terraformer.MultiLineString);
expect(output.type).toEqual("MultiLineString");
});
it("should parse a MULTILINESTRING with alternate syntax and Z and M coordinates", function(){
var input = "MULTILINESTRING ZM ((10 10 10 5, 20 20 20 4, 10 40 30 3),(40 40 30 2, 30 30 20 1, 40 20 10 2, 30 10 10 3))";
var output = new Terraformer.WKT.parse(input);
expect(output.coordinates).toEqual([
[ [10,10,10,5],[20,20,20,4],[10,40,30,3] ],
[ [40,40,30,2],[30,30,20,1],[40,20,10,2],[30,10,10,3] ]
]);
expect(output).toBeInstanceOfClass(Terraformer.MultiLineString);
expect(output.type).toEqual("MultiLineString");
});
it("should parse a MULTIPOLYGON", function(){
var input = "MULTIPOLYGON (((30 20, 10 40, 45 40, 30 20)),((15 5, 40 10, 10 20, 5 10, 15 5)))";
var output = new Terraformer.WKT.parse(input);
expect(output.coordinates).toEqual([
[
[ [30,20],[10,40],[45,40],[30,20] ]
],
[
[ [15,5],[40,10],[10,20],[5,10],[15,5] ]
]
]);
expect(output).toBeInstanceOfClass(Terraformer.MultiPolygon);
expect(output.type).toEqual("MultiPolygon");
});
it("should parse an EMPTY MULTIPOLYGON", function(){
var input = "MULTIPOLYGON EMPTY";
var output = new Terraformer.WKT.parse(input);
expect(output.coordinates).toEqual([ ]);
expect(output).toBeInstanceOfClass(Terraformer.MultiPolygon);
expect(output.type).toEqual("MultiPolygon");
});
it("should parse a MULTIPOLYGON with a Z coordinate", function(){
var input = "MULTIPOLYGON Z (((30 20 1, 10 40 2, 45 40 3, 30 20 4)),((15 5, 40 10, 10 20, 5 10, 15 5)))";
var output = new Terraformer.WKT.parse(input);
expect(output.coordinates).toEqual([
[
[ [30,20,1],[10,40,2],[45,40,3],[30,20,4] ]
],
[
[ [15,5],[40,10],[10,20],[5,10],[15,5] ]
]
]);
expect(output).toBeInstanceOfClass(Terraformer.MultiPolygon);
expect(output.type).toEqual("MultiPolygon");
});
it("should parse a MULTIPOLYGON with a M coordinate", function(){
var input = "MULTIPOLYGON M (((30 20 1, 10 40 2, 45 40 3, 30 20 4)),((15 5, 40 10, 10 20, 5 10, 15 5)))";
var output = new Terraformer.WKT.parse(input);
expect(output.coordinates).toEqual([
[
[ [30,20,1],[10,40,2],[45,40,3],[30,20,4] ]
],
[
[ [15,5],[40,10],[10,20],[5,10],[15,5] ]
]
]);
expect(output).toBeInstanceOfClass(Terraformer.MultiPolygon);
expect(output.type).toEqual("MultiPolygon");
});
it("should parse a MULTIPOLYGON with Z and M coordinates", function(){
var input = "MULTIPOLYGON ZM (((30 20 1 0, 10 40 2 1, 45 40 3 2, 30 20 4 3)),((15 5, 40 10, 10 20, 5 10, 15 5)))";
var output = new Terraformer.WKT.parse(input);
expect(output.coordinates).toEqual([
[
[ [30,20,1,0],[10,40,2,1],[45,40,3,2],[30,20,4,3] ]
],
[
[ [15,5],[40,10],[10,20],[5,10],[15,5] ]
]
]);
expect(output).toBeInstanceOfClass(Terraformer.MultiPolygon);
expect(output.type).toEqual("MultiPolygon");
});
it("should parse a MULTIPOLYGON with a hole", function(){
var input = "MULTIPOLYGON (((40 40, 20 45, 45 30, 40 40)),((20 35, 45 20, 30 5, 10 10, 10 30, 20 35),(30 20, 20 25, 20 15, 30 20)))";
var output = new Terraformer.WKT.parse(input);
expect(output.coordinates).toEqual([
[
[ [40,40], [20,45], [45,30], [40,40] ]
],
[
[ [20,35],[45,20],[30,5] ,[10,10],[10,30],[20,35] ],
[ [30,20], [20,25], [20,15],[30,20] ]
]
]);
expect(output).toBeInstanceOfClass(Terraformer.MultiPolygon);
expect(output.type).toEqual("MultiPolygon");
});
});

@@ -5,37 +5,16 @@ (function (root, factory) {

if(typeof module === 'object' && typeof module.exports === 'object') {
exports = module.exports = factory();
exports = module.exports = factory(require("terraformer"));
}
// AMD.
if(typeof define === 'function' && define.amd) {
define(["terraformer/terraformer"],factory);
}
// Browser Global.
if(typeof navigator === "object") {
if (typeof root.Terraformer === "undefined"){
root.Terraformer = {};
if (!root.Terraformer){
throw new Error("Terraformer.WKT requires the core Terraformer library. http://github.com/esri/terraformer")
}
root.Terraformer.WKT = factory();
root.Terraformer.WKT = factory(root.Terraformer);
}
}(this, function() {
}(this, function(Terraformer) {
var exports = { };
var Terraformer;
// Local Reference To Browser Global
if(typeof this.navigator === "object") {
Terraformer = this.Terraformer;
}
// Setup Node Dependencies
if(typeof module === 'object' && typeof module.exports === 'object') {
Terraformer = require('terraformer');
}
// Setup AMD Dependencies
if(arguments[0] && typeof define === 'function' && define.amd) {
Terraformer = arguments[0];
}
"SOURCE";

@@ -133,3 +112,3 @@

} catch (err) {
throw Error("Unable to parse", err);
throw Error("Unable to parse: " + err);
}

@@ -345,2 +324,2 @@

return exports;
}));
}));

@@ -5,37 +5,16 @@ (function (root, factory) {

if(typeof module === 'object' && typeof module.exports === 'object') {
exports = module.exports = factory();
exports = module.exports = factory(require("terraformer"));
}
// AMD.
if(typeof define === 'function' && define.amd) {
define(["terraformer/terraformer"],factory);
}
// Browser Global.
if(typeof navigator === "object") {
if (typeof root.Terraformer === "undefined"){
root.Terraformer = {};
if (!root.Terraformer){
throw new Error("Terraformer.WKT requires the core Terraformer library. http://github.com/esri/terraformer")
}
root.Terraformer.WKT = factory();
root.Terraformer.WKT = factory(root.Terraformer);
}
}(this, function() {
}(this, function(Terraformer) {
var exports = { };
var Terraformer;
// Local Reference To Browser Global
if(typeof this.navigator === "object") {
Terraformer = this.Terraformer;
}
// Setup Node Dependencies
if(typeof module === 'object' && typeof module.exports === 'object') {
Terraformer = require('terraformer');
}
// Setup AMD Dependencies
if(arguments[0] && typeof define === 'function' && define.amd) {
Terraformer = arguments[0];
}
/* Jison generated parser */

@@ -48,3 +27,4 @@ var parser = (function(){

productions_: [0,[3,2],[3,2],[3,2],[3,2],[3,2],[3,2],[11,2],[11,3],[11,4],[13,3],[13,1],[15,3],[15,1],[16,3],[4,4],[4,5],[4,5],[4,5],[4,2],[24,1],[24,3],[25,3],[25,1],[26,3],[27,3],[27,1],[6,4],[6,5],[6,5],[6,5],[6,2],[7,4],[7,5],[7,5],[7,5],[7,2],[8,4],[8,5],[8,5],[8,5],[8,2],[9,4],[9,5],[9,5],[9,5],[9,2],[10,4],[10,5],[10,5],[10,5],[10,2]],
performAction: function anonymous(yytext,yyleng,yylineno,yy,yystate,$,_$) {
performAction: function anonymous(yytext,yyleng,yylineno,yy,yystate,$,_$
/**/) {

@@ -435,3 +415,4 @@ var $0 = $.length - 1;

lexer.options = {};
lexer.performAction = function anonymous(yy,yy_,$avoiding_name_collisions,YY_START) {
lexer.performAction = function anonymous(yy,yy_,$avoiding_name_collisions,YY_START
/**/) {

@@ -574,3 +555,3 @@ var YYSTATE=YY_START

} catch (err) {
throw Error("Unable to parse", err);
throw Error("Unable to parse: " + err);
}

@@ -786,2 +767,2 @@

return exports;
}));
}));

@@ -1,1 +0,4 @@

!function(a,b){"object"==typeof module&&"object"==typeof module.exports&&(exports=module.exports=b()),"function"==typeof define&&define.amd&&define(["terraformer/terraformer"],b),"object"==typeof navigator&&("undefined"==typeof a.Terraformer&&(a.Terraformer={}),a.Terraformer.WKT=b())}(this,function(){function a(a){this.data=[a],this.type="PointArray"}function b(a){this.data=a,this.type="Ring"}function c(a){this.data=[a],this.type="RingList"}function d(a){this.data=[a],this.type="PolygonList"}function e(a){var b;try{b=p.parse(a)}catch(c){throw Error("Unable to parse",c)}return n.Primitive(b)}function f(a){for(var b=[],c="",d=0;d<a.length;d++)b.push(a[d].join(" "));return c+="("+b.join(", ")+")"}function g(a){var b="POINT ";return void 0===a.coordinates||0===a.coordinates.length?b+="EMPTY":(3===a.coordinates.length?b+=a.properties&&a.properties.m===!0?"M ":"Z ":4===a.coordinates.length&&(b+="ZM "),b+="("+a.coordinates.join(" ")+")")}function h(a){var b="LINESTRING ";return void 0===a.coordinates||0===a.coordinates.length||0===a.coordinates[0].length?b+="EMPTY":(3===a.coordinates[0].length?b+=a.properties&&a.properties.m===!0?"M ":"Z ":4===a.coordinates[0].length&&(b+="ZM "),b+=f(a.coordinates))}function i(a){var b="POLYGON ";if(void 0===a.coordinates||0===a.coordinates.length||0===a.coordinates[0].length)return b+="EMPTY";3===a.coordinates[0][0].length?b+=a.properties&&a.properties.m===!0?"M ":"Z ":4===a.coordinates[0][0].length&&(b+="ZM "),b+="(";for(var c=[],d=0;d<a.coordinates.length;d++)c.push(f(a.coordinates[d]));return b+=c.join(", "),b+=")"}function j(a){var b="MULTIPOINT ";return void 0===a.coordinates||0===a.coordinates.length||0===a.coordinates[0].length?b+="EMPTY":(3===a.coordinates[0].length?b+=a.properties&&a.properties.m===!0?"M ":"Z ":4===a.coordinates[0].length&&(b+="ZM "),b+=f(a.coordinates))}function k(a){var b="MULTILINESTRING ";if(void 0===a.coordinates||0===a.coordinates.length||0===a.coordinates[0].length)return b+="EMPTY";3===a.coordinates[0][0].length?b+=a.properties&&a.properties.m===!0?"M ":"Z ":4===a.coordinates[0][0].length&&(b+="ZM "),b+="(";for(var c=[],d=0;d<a.coordinates.length;d++)c.push(f(a.coordinates[d]));return b+=c.join(", "),b+=")"}function l(a){var b="MULTIPOLYGON ";if(void 0===a.coordinates||0===a.coordinates.length||0===a.coordinates[0].length)return b+="EMPTY";3===a.coordinates[0][0][0].length?b+=a.properties&&a.properties.m===!0?"M ":"Z ":4===a.coordinates[0][0][0].length&&(b+="ZM "),b+="(";for(var c=[],d=0;d<a.coordinates.length;d++){for(var e="(",g=[],h=0;h<a.coordinates[d].length;h++)g.push(f(a.coordinates[d][h]));e+=g.join(", "),e+=")",c.push(e)}return b+=c.join(", "),b+=")"}function m(a){switch(a.type){case"Point":return g(a);case"LineString":return h(a);case"Polygon":return i(a);case"MultiPoint":return j(a);case"MultiLineString":return k(a);case"MultiPolygon":return l(a);default:throw Error("Unknown Type: "+a.type)}}var n,o={};"object"==typeof this.navigator&&(n=this.Terraformer),"object"==typeof module&&"object"==typeof module.exports&&(n=require("terraformer")),arguments[0]&&"function"==typeof define&&define.amd&&(n=arguments[0]);var p=function(){function e(){this.yy={}}var f={trace:function(){},yy:{},symbols_:{error:2,expressions:3,point:4,EOF:5,linestring:6,polygon:7,multipoint:8,multilinestring:9,multipolygon:10,coordinate:11,DOUBLE_TOK:12,ptarray:13,COMMA:14,ring_list:15,ring:16,"(":17,")":18,POINT:19,Z:20,ZM:21,M:22,EMPTY:23,point_untagged:24,polygon_list:25,polygon_untagged:26,point_list:27,LINESTRING:28,POLYGON:29,MULTIPOINT:30,MULTILINESTRING:31,MULTIPOLYGON:32,$accept:0,$end:1},terminals_:{2:"error",5:"EOF",12:"DOUBLE_TOK",14:"COMMA",17:"(",18:")",19:"POINT",20:"Z",21:"ZM",22:"M",23:"EMPTY",28:"LINESTRING",29:"POLYGON",30:"MULTIPOINT",31:"MULTILINESTRING",32:"MULTIPOLYGON"},productions_:[0,[3,2],[3,2],[3,2],[3,2],[3,2],[3,2],[11,2],[11,3],[11,4],[13,3],[13,1],[15,3],[15,1],[16,3],[4,4],[4,5],[4,5],[4,5],[4,2],[24,1],[24,3],[25,3],[25,1],[26,3],[27,3],[27,1],[6,4],[6,5],[6,5],[6,5],[6,2],[7,4],[7,5],[7,5],[7,5],[7,2],[8,4],[8,5],[8,5],[8,5],[8,2],[9,4],[9,5],[9,5],[9,5],[9,2],[10,4],[10,5],[10,5],[10,5],[10,2]],performAction:function(e,f,g,h,i,j){var k=j.length-1;switch(i){case 1:return j[k-1];case 2:return j[k-1];case 3:return j[k-1];case 4:return j[k-1];case 5:return j[k-1];case 6:return j[k-1];case 7:this.$=new a([Number(j[k-1]),Number(j[k])]);break;case 8:this.$=new a([Number(j[k-2]),Number(j[k-1]),Number(j[k])]);break;case 9:this.$=new a([Number(j[k-3]),Number(j[k-2]),Number(j[k-1]),Number(j[k])]);break;case 10:this.$=j[k-2].addPoint(j[k]);break;case 11:this.$=j[k];break;case 12:this.$=j[k-2].addRing(j[k]);break;case 13:this.$=new c(j[k]);break;case 14:this.$=new b(j[k-1]);break;case 15:this.$={type:"Point",coordinates:j[k-1].data[0]};break;case 16:this.$={type:"Point",coordinates:j[k-1].data[0],properties:{z:!0}};break;case 17:this.$={type:"Point",coordinates:j[k-1].data[0],properties:{z:!0,m:!0}};break;case 18:this.$={type:"Point",coordinates:j[k-1].data[0],properties:{m:!0}};break;case 19:this.$={type:"Point",coordinates:[]};break;case 20:this.$=j[k];break;case 21:this.$=j[k-1];break;case 22:this.$=j[k-2].addPolygon(j[k]);break;case 23:this.$=new d(j[k]);break;case 24:this.$=j[k-1];break;case 25:this.$=j[k-2].addPoint(j[k]);break;case 26:this.$=j[k];break;case 27:this.$={type:"LineString",coordinates:j[k-1].data};break;case 28:this.$={type:"LineString",coordinates:j[k-1].data,properties:{z:!0}};break;case 29:this.$={type:"LineString",coordinates:j[k-1].data,properties:{m:!0}};break;case 30:this.$={type:"LineString",coordinates:j[k-1].data,properties:{z:!0,m:!0}};break;case 31:this.$={type:"LineString",coordinates:[]};break;case 32:this.$={type:"Polygon",coordinates:j[k-1].toJSON()};break;case 33:this.$={type:"Polygon",coordinates:j[k-1].toJSON(),properties:{z:!0}};break;case 34:this.$={type:"Polygon",coordinates:j[k-1].toJSON(),properties:{m:!0}};break;case 35:this.$={type:"Polygon",coordinates:j[k-1].toJSON(),properties:{z:!0,m:!0}};break;case 36:this.$={type:"Polygon",coordinates:[]};break;case 37:this.$={type:"MultiPoint",coordinates:j[k-1].data};break;case 38:this.$={type:"MultiPoint",coordinates:j[k-1].data,properties:{z:!0}};break;case 39:this.$={type:"MultiPoint",coordinates:j[k-1].data,properties:{m:!0}};break;case 40:this.$={type:"MultiPoint",coordinates:j[k-1].data,properties:{z:!0,m:!0}};break;case 41:this.$={type:"MultiPoint",coordinates:[]};break;case 42:this.$={type:"MultiLineString",coordinates:j[k-1].toJSON()};break;case 43:this.$={type:"MultiLineString",coordinates:j[k-1].toJSON(),properties:{z:!0}};break;case 44:this.$={type:"MultiLineString",coordinates:j[k-1].toJSON(),properties:{m:!0}};break;case 45:this.$={type:"MultiLineString",coordinates:j[k-1].toJSON(),properties:{z:!0,m:!0}};break;case 46:this.$={type:"MultiLineString",coordinates:[]};break;case 47:this.$={type:"MultiPolygon",coordinates:j[k-1].toJSON()};break;case 48:this.$={type:"MultiPolygon",coordinates:j[k-1].toJSON(),properties:{z:!0}};break;case 49:this.$={type:"MultiPolygon",coordinates:j[k-1].toJSON(),properties:{m:!0}};break;case 50:this.$={type:"MultiPolygon",coordinates:j[k-1].toJSON(),properties:{z:!0,m:!0}};break;case 51:this.$={type:"MultiPolygon",coordinates:[]}}},table:[{3:1,4:2,6:3,7:4,8:5,9:6,10:7,19:[1,8],28:[1,9],29:[1,10],30:[1,11],31:[1,12],32:[1,13]},{1:[3]},{5:[1,14]},{5:[1,15]},{5:[1,16]},{5:[1,17]},{5:[1,18]},{5:[1,19]},{17:[1,20],20:[1,21],21:[1,22],22:[1,23],23:[1,24]},{17:[1,25],20:[1,26],21:[1,28],22:[1,27],23:[1,29]},{17:[1,30],20:[1,31],21:[1,33],22:[1,32],23:[1,34]},{17:[1,35],20:[1,36],21:[1,38],22:[1,37],23:[1,39]},{17:[1,40],20:[1,41],21:[1,43],22:[1,42],23:[1,44]},{17:[1,45],20:[1,46],21:[1,48],22:[1,47],23:[1,49]},{1:[2,1]},{1:[2,2]},{1:[2,3]},{1:[2,4]},{1:[2,5]},{1:[2,6]},{11:51,12:[1,52],13:50},{17:[1,53]},{17:[1,54]},{17:[1,55]},{5:[2,19]},{11:58,12:[1,52],17:[1,59],24:57,27:56},{17:[1,60]},{17:[1,61]},{17:[1,62]},{5:[2,31]},{15:63,16:64,17:[1,65]},{17:[1,66]},{17:[1,67]},{17:[1,68]},{5:[2,36]},{11:58,12:[1,52],17:[1,59],24:57,27:69},{17:[1,70]},{17:[1,71]},{17:[1,72]},{5:[2,41]},{15:73,16:64,17:[1,65]},{17:[1,74]},{17:[1,75]},{17:[1,76]},{5:[2,46]},{17:[1,79],25:77,26:78},{17:[1,80]},{17:[1,81]},{17:[1,82]},{5:[2,51]},{14:[1,84],18:[1,83]},{14:[2,11],18:[2,11]},{12:[1,85]},{11:51,12:[1,52],13:86},{11:51,12:[1,52],13:87},{11:51,12:[1,52],13:88},{14:[1,90],18:[1,89]},{14:[2,26],18:[2,26]},{14:[2,20],18:[2,20]},{11:91,12:[1,52]},{11:58,12:[1,52],17:[1,59],24:57,27:92},{11:58,12:[1,52],17:[1,59],24:57,27:93},{11:58,12:[1,52],17:[1,59],24:57,27:94},{14:[1,96],18:[1,95]},{14:[2,13],18:[2,13]},{11:51,12:[1,52],13:97},{15:98,16:64,17:[1,65]},{15:99,16:64,17:[1,65]},{15:100,16:64,17:[1,65]},{14:[1,90],18:[1,101]},{11:58,12:[1,52],17:[1,59],24:57,27:102},{11:58,12:[1,52],17:[1,59],24:57,27:103},{11:58,12:[1,52],17:[1,59],24:57,27:104},{14:[1,96],18:[1,105]},{15:106,16:64,17:[1,65]},{15:107,16:64,17:[1,65]},{15:108,16:64,17:[1,65]},{14:[1,110],18:[1,109]},{14:[2,23],18:[2,23]},{15:111,16:64,17:[1,65]},{17:[1,79],25:112,26:78},{17:[1,79],25:113,26:78},{17:[1,79],25:114,26:78},{5:[2,15]},{11:115,12:[1,52]},{12:[1,116],14:[2,7],18:[2,7]},{14:[1,84],18:[1,117]},{14:[1,84],18:[1,118]},{14:[1,84],18:[1,119]},{5:[2,27]},{11:58,12:[1,52],17:[1,59],24:120},{18:[1,121]},{14:[1,90],18:[1,122]},{14:[1,90],18:[1,123]},{14:[1,90],18:[1,124]},{5:[2,32]},{16:125,17:[1,65]},{14:[1,84],18:[1,126]},{14:[1,96],18:[1,127]},{14:[1,96],18:[1,128]},{14:[1,96],18:[1,129]},{5:[2,37]},{14:[1,90],18:[1,130]},{14:[1,90],18:[1,131]},{14:[1,90],18:[1,132]},{5:[2,42]},{14:[1,96],18:[1,133]},{14:[1,96],18:[1,134]},{14:[1,96],18:[1,135]},{5:[2,47]},{17:[1,79],26:136},{14:[1,96],18:[1,137]},{14:[1,110],18:[1,138]},{14:[1,110],18:[1,139]},{14:[1,110],18:[1,140]},{14:[2,10],18:[2,10]},{12:[1,141],14:[2,8],18:[2,8]},{5:[2,16]},{5:[2,17]},{5:[2,18]},{14:[2,25],18:[2,25]},{14:[2,21],18:[2,21]},{5:[2,28]},{5:[2,29]},{5:[2,30]},{14:[2,12],18:[2,12]},{14:[2,14],18:[2,14]},{5:[2,33]},{5:[2,34]},{5:[2,35]},{5:[2,38]},{5:[2,39]},{5:[2,40]},{5:[2,43]},{5:[2,44]},{5:[2,45]},{14:[2,22],18:[2,22]},{14:[2,24],18:[2,24]},{5:[2,48]},{5:[2,49]},{5:[2,50]},{14:[2,9],18:[2,9]}],defaultActions:{14:[2,1],15:[2,2],16:[2,3],17:[2,4],18:[2,5],19:[2,6],24:[2,19],29:[2,31],34:[2,36],39:[2,41],44:[2,46],49:[2,51],83:[2,15],89:[2,27],95:[2,32],101:[2,37],105:[2,42],109:[2,47],117:[2,16],118:[2,17],119:[2,18],122:[2,28],123:[2,29],124:[2,30],127:[2,33],128:[2,34],129:[2,35],130:[2,38],131:[2,39],132:[2,40],133:[2,43],134:[2,44],135:[2,45],138:[2,48],139:[2,49],140:[2,50]},parseError:function(a){throw new Error(a)},parse:function(a){function b(){var a;return a=c.lexer.lex()||1,"number"!=typeof a&&(a=c.symbols_[a]||a),a}var c=this,d=[0],e=[null],f=[],g=this.table,h="",i=0,j=0,k=0;this.lexer.setInput(a),this.lexer.yy=this.yy,this.yy.lexer=this.lexer,this.yy.parser=this,"undefined"==typeof this.lexer.yylloc&&(this.lexer.yylloc={});var l=this.lexer.yylloc;f.push(l);var m=this.lexer.options&&this.lexer.options.ranges;"function"==typeof this.yy.parseError&&(this.parseError=this.yy.parseError);for(var n,o,p,q,r,s,t,u,v,w={};;){if(p=d[d.length-1],this.defaultActions[p]?q=this.defaultActions[p]:((null===n||"undefined"==typeof n)&&(n=b()),q=g[p]&&g[p][n]),"undefined"==typeof q||!q.length||!q[0]){var x="";if(!k){v=[];for(s in g[p])this.terminals_[s]&&s>2&&v.push("'"+this.terminals_[s]+"'");x=this.lexer.showPosition?"Parse error on line "+(i+1)+":\n"+this.lexer.showPosition()+"\nExpecting "+v.join(", ")+", got '"+(this.terminals_[n]||n)+"'":"Parse error on line "+(i+1)+": Unexpected "+(1==n?"end of input":"'"+(this.terminals_[n]||n)+"'"),this.parseError(x,{text:this.lexer.match,token:this.terminals_[n]||n,line:this.lexer.yylineno,loc:l,expected:v})}}if(q[0]instanceof Array&&q.length>1)throw new Error("Parse Error: multiple actions possible at state: "+p+", token: "+n);switch(q[0]){case 1:d.push(n),e.push(this.lexer.yytext),f.push(this.lexer.yylloc),d.push(q[1]),n=null,o?(n=o,o=null):(j=this.lexer.yyleng,h=this.lexer.yytext,i=this.lexer.yylineno,l=this.lexer.yylloc,k>0&&k--);break;case 2:if(t=this.productions_[q[1]][1],w.$=e[e.length-t],w._$={first_line:f[f.length-(t||1)].first_line,last_line:f[f.length-1].last_line,first_column:f[f.length-(t||1)].first_column,last_column:f[f.length-1].last_column},m&&(w._$.range=[f[f.length-(t||1)].range[0],f[f.length-1].range[1]]),r=this.performAction.call(w,h,j,i,this.yy,q[1],e,f),"undefined"!=typeof r)return r;t&&(d=d.slice(0,2*-1*t),e=e.slice(0,-1*t),f=f.slice(0,-1*t)),d.push(this.productions_[q[1]][0]),e.push(w.$),f.push(w._$),u=g[d[d.length-2]][d[d.length-1]],d.push(u);break;case 3:return!0}}return!0}},g=function(){var a={EOF:1,parseError:function(a,b){if(!this.yy.parser)throw new Error(a);this.yy.parser.parseError(a,b)},setInput:function(a){return this._input=a,this._more=this._less=this.done=!1,this.yylineno=this.yyleng=0,this.yytext=this.matched=this.match="",this.conditionStack=["INITIAL"],this.yylloc={first_line:1,first_column:0,last_line:1,last_column:0},this.options.ranges&&(this.yylloc.range=[0,0]),this.offset=0,this},input:function(){var a=this._input[0];this.yytext+=a,this.yyleng++,this.offset++,this.match+=a,this.matched+=a;var b=a.match(/(?:\r\n?|\n).*/g);return b?(this.yylineno++,this.yylloc.last_line++):this.yylloc.last_column++,this.options.ranges&&this.yylloc.range[1]++,this._input=this._input.slice(1),a},unput:function(a){var b=a.length,c=a.split(/(?:\r\n?|\n)/g);this._input=a+this._input,this.yytext=this.yytext.substr(0,this.yytext.length-b-1),this.offset-=b;var d=this.match.split(/(?:\r\n?|\n)/g);this.match=this.match.substr(0,this.match.length-1),this.matched=this.matched.substr(0,this.matched.length-1),c.length-1&&(this.yylineno-=c.length-1);var e=this.yylloc.range;return this.yylloc={first_line:this.yylloc.first_line,last_line:this.yylineno+1,first_column:this.yylloc.first_column,last_column:c?(c.length===d.length?this.yylloc.first_column:0)+d[d.length-c.length].length-c[0].length:this.yylloc.first_column-b},this.options.ranges&&(this.yylloc.range=[e[0],e[0]+this.yyleng-b]),this},more:function(){return this._more=!0,this},less:function(a){this.unput(this.match.slice(a))},pastInput:function(){var a=this.matched.substr(0,this.matched.length-this.match.length);return(a.length>20?"...":"")+a.substr(-20).replace(/\n/g,"")},upcomingInput:function(){var a=this.match;return a.length<20&&(a+=this._input.substr(0,20-a.length)),(a.substr(0,20)+(a.length>20?"...":"")).replace(/\n/g,"")},showPosition:function(){var a=this.pastInput(),b=new Array(a.length+1).join("-");return a+this.upcomingInput()+"\n"+b+"^"},next:function(){if(this.done)return this.EOF;this._input||(this.done=!0);var a,b,c,d,e;this._more||(this.yytext="",this.match="");for(var f=this._currentRules(),g=0;g<f.length&&(c=this._input.match(this.rules[f[g]]),!c||b&&!(c[0].length>b[0].length)||(b=c,d=g,this.options.flex));g++);return b?(e=b[0].match(/(?:\r\n?|\n).*/g),e&&(this.yylineno+=e.length),this.yylloc={first_line:this.yylloc.last_line,last_line:this.yylineno+1,first_column:this.yylloc.last_column,last_column:e?e[e.length-1].length-e[e.length-1].match(/\r?\n?/)[0].length:this.yylloc.last_column+b[0].length},this.yytext+=b[0],this.match+=b[0],this.matches=b,this.yyleng=this.yytext.length,this.options.ranges&&(this.yylloc.range=[this.offset,this.offset+=this.yyleng]),this._more=!1,this._input=this._input.slice(b[0].length),this.matched+=b[0],a=this.performAction.call(this,this.yy,this,f[d],this.conditionStack[this.conditionStack.length-1]),this.done&&this._input&&(this.done=!1),a?a:void 0):""===this._input?this.EOF:this.parseError("Lexical error on line "+(this.yylineno+1)+". Unrecognized text.\n"+this.showPosition(),{text:"",token:null,line:this.yylineno})},lex:function(){var a=this.next();return"undefined"!=typeof a?a:this.lex()},begin:function(a){this.conditionStack.push(a)},popState:function(){return this.conditionStack.pop()},_currentRules:function(){return this.conditions[this.conditionStack[this.conditionStack.length-1]].rules},topState:function(){return this.conditionStack[this.conditionStack.length-2]},pushState:function(a){this.begin(a)}};return a.options={},a.performAction=function(a,b,c,d){switch(c){case 0:break;case 1:return 17;case 2:return 18;case 3:return 12;case 4:return 19;case 5:return 28;case 6:return 29;case 7:return 30;case 8:return 31;case 9:return 32;case 10:return 14;case 11:return 23;case 12:return 22;case 13:return 20;case 14:return 21;case 15:return 5;case 16:return"INVALID"}},a.rules=[/^(?:\s+)/,/^(?:\()/,/^(?:\))/,/^(?:-?[0-9]+(\.[0-9]+)?)/,/^(?:POINT\b)/,/^(?:LINESTRING\b)/,/^(?:POLYGON\b)/,/^(?:MULTIPOINT\b)/,/^(?:MULTILINESTRING\b)/,/^(?:MULTIPOLYGON\b)/,/^(?:,)/,/^(?:EMPTY\b)/,/^(?:M\b)/,/^(?:Z\b)/,/^(?:ZM\b)/,/^(?:$)/,/^(?:.)/],a.conditions={INITIAL:{rules:[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16],inclusive:!0}},a}();return f.lexer=g,e.prototype=f,f.Parser=e,new e}();return a.prototype.addPoint=function(a){return"PointArray"===a.type?this.data=this.data.concat(a.data):this.data.push(a),this},a.prototype.toJSON=function(){return this.data},b.prototype.toJSON=function(){for(var a=[],b=0;b<this.data.data.length;b++)a.push(this.data.data[b]);return a},c.prototype.addRing=function(a){return this.data.push(a),this},c.prototype.toJSON=function(){for(var a=[],b=0;b<this.data.length;b++)a.push(this.data[b].toJSON());return 1===a.length?a:a},d.prototype.addPolygon=function(a){return this.data.push(a),this},d.prototype.toJSON=function(){for(var a=[],b=0;b<this.data.length;b++)a=a.concat([this.data[b].toJSON()]);return a},o.parser=p,o.Parser=p.Parser,o.parse=e,o.convert=m,o});
/*! Terraformer JS - 1.0.1 - 2015-06-02
* https://github.com/esri/terraformer-wkt-parser
* Copyright (c) 2015 Esri, Inc.
* Licensed MIT */!function(a,b){if("object"==typeof module&&"object"==typeof module.exports&&(exports=module.exports=b(require("terraformer"))),"object"==typeof navigator){if(!a.Terraformer)throw new Error("Terraformer.WKT requires the core Terraformer library. http://github.com/esri/terraformer");a.Terraformer.WKT=b(a.Terraformer)}}(this,function(a){function b(a){this.data=[a],this.type="PointArray"}function c(a){this.data=a,this.type="Ring"}function d(a){this.data=[a],this.type="RingList"}function e(a){this.data=[a],this.type="PolygonList"}function f(b){var c;try{c=p.parse(b)}catch(d){throw Error("Unable to parse: "+d)}return a.Primitive(c)}function g(a){for(var b=[],c="",d=0;d<a.length;d++)b.push(a[d].join(" "));return c+="("+b.join(", ")+")"}function h(a){var b="POINT ";return void 0===a.coordinates||0===a.coordinates.length?b+="EMPTY":(3===a.coordinates.length?b+=a.properties&&a.properties.m===!0?"M ":"Z ":4===a.coordinates.length&&(b+="ZM "),b+="("+a.coordinates.join(" ")+")")}function i(a){var b="LINESTRING ";return void 0===a.coordinates||0===a.coordinates.length||0===a.coordinates[0].length?b+="EMPTY":(3===a.coordinates[0].length?b+=a.properties&&a.properties.m===!0?"M ":"Z ":4===a.coordinates[0].length&&(b+="ZM "),b+=g(a.coordinates))}function j(a){var b="POLYGON ";if(void 0===a.coordinates||0===a.coordinates.length||0===a.coordinates[0].length)return b+="EMPTY";3===a.coordinates[0][0].length?b+=a.properties&&a.properties.m===!0?"M ":"Z ":4===a.coordinates[0][0].length&&(b+="ZM "),b+="(";for(var c=[],d=0;d<a.coordinates.length;d++)c.push(g(a.coordinates[d]));return b+=c.join(", "),b+=")"}function k(a){var b="MULTIPOINT ";return void 0===a.coordinates||0===a.coordinates.length||0===a.coordinates[0].length?b+="EMPTY":(3===a.coordinates[0].length?b+=a.properties&&a.properties.m===!0?"M ":"Z ":4===a.coordinates[0].length&&(b+="ZM "),b+=g(a.coordinates))}function l(a){var b="MULTILINESTRING ";if(void 0===a.coordinates||0===a.coordinates.length||0===a.coordinates[0].length)return b+="EMPTY";3===a.coordinates[0][0].length?b+=a.properties&&a.properties.m===!0?"M ":"Z ":4===a.coordinates[0][0].length&&(b+="ZM "),b+="(";for(var c=[],d=0;d<a.coordinates.length;d++)c.push(g(a.coordinates[d]));return b+=c.join(", "),b+=")"}function m(a){var b="MULTIPOLYGON ";if(void 0===a.coordinates||0===a.coordinates.length||0===a.coordinates[0].length)return b+="EMPTY";3===a.coordinates[0][0][0].length?b+=a.properties&&a.properties.m===!0?"M ":"Z ":4===a.coordinates[0][0][0].length&&(b+="ZM "),b+="(";for(var c=[],d=0;d<a.coordinates.length;d++){for(var e="(",f=[],h=0;h<a.coordinates[d].length;h++)f.push(g(a.coordinates[d][h]));e+=f.join(", "),e+=")",c.push(e)}return b+=c.join(", "),b+=")"}function n(a){switch(a.type){case"Point":return h(a);case"LineString":return i(a);case"Polygon":return j(a);case"MultiPoint":return k(a);case"MultiLineString":return l(a);case"MultiPolygon":return m(a);default:throw Error("Unknown Type: "+a.type)}}var o={},p=function(){function a(){this.yy={}}var f={trace:function(){},yy:{},symbols_:{error:2,expressions:3,point:4,EOF:5,linestring:6,polygon:7,multipoint:8,multilinestring:9,multipolygon:10,coordinate:11,DOUBLE_TOK:12,ptarray:13,COMMA:14,ring_list:15,ring:16,"(":17,")":18,POINT:19,Z:20,ZM:21,M:22,EMPTY:23,point_untagged:24,polygon_list:25,polygon_untagged:26,point_list:27,LINESTRING:28,POLYGON:29,MULTIPOINT:30,MULTILINESTRING:31,MULTIPOLYGON:32,$accept:0,$end:1},terminals_:{2:"error",5:"EOF",12:"DOUBLE_TOK",14:"COMMA",17:"(",18:")",19:"POINT",20:"Z",21:"ZM",22:"M",23:"EMPTY",28:"LINESTRING",29:"POLYGON",30:"MULTIPOINT",31:"MULTILINESTRING",32:"MULTIPOLYGON"},productions_:[0,[3,2],[3,2],[3,2],[3,2],[3,2],[3,2],[11,2],[11,3],[11,4],[13,3],[13,1],[15,3],[15,1],[16,3],[4,4],[4,5],[4,5],[4,5],[4,2],[24,1],[24,3],[25,3],[25,1],[26,3],[27,3],[27,1],[6,4],[6,5],[6,5],[6,5],[6,2],[7,4],[7,5],[7,5],[7,5],[7,2],[8,4],[8,5],[8,5],[8,5],[8,2],[9,4],[9,5],[9,5],[9,5],[9,2],[10,4],[10,5],[10,5],[10,5],[10,2]],performAction:function(a,f,g,h,i,j,k){var l=j.length-1;switch(i){case 1:return j[l-1];case 2:return j[l-1];case 3:return j[l-1];case 4:return j[l-1];case 5:return j[l-1];case 6:return j[l-1];case 7:this.$=new b([Number(j[l-1]),Number(j[l])]);break;case 8:this.$=new b([Number(j[l-2]),Number(j[l-1]),Number(j[l])]);break;case 9:this.$=new b([Number(j[l-3]),Number(j[l-2]),Number(j[l-1]),Number(j[l])]);break;case 10:this.$=j[l-2].addPoint(j[l]);break;case 11:this.$=j[l];break;case 12:this.$=j[l-2].addRing(j[l]);break;case 13:this.$=new d(j[l]);break;case 14:this.$=new c(j[l-1]);break;case 15:this.$={type:"Point",coordinates:j[l-1].data[0]};break;case 16:this.$={type:"Point",coordinates:j[l-1].data[0],properties:{z:!0}};break;case 17:this.$={type:"Point",coordinates:j[l-1].data[0],properties:{z:!0,m:!0}};break;case 18:this.$={type:"Point",coordinates:j[l-1].data[0],properties:{m:!0}};break;case 19:this.$={type:"Point",coordinates:[]};break;case 20:this.$=j[l];break;case 21:this.$=j[l-1];break;case 22:this.$=j[l-2].addPolygon(j[l]);break;case 23:this.$=new e(j[l]);break;case 24:this.$=j[l-1];break;case 25:this.$=j[l-2].addPoint(j[l]);break;case 26:this.$=j[l];break;case 27:this.$={type:"LineString",coordinates:j[l-1].data};break;case 28:this.$={type:"LineString",coordinates:j[l-1].data,properties:{z:!0}};break;case 29:this.$={type:"LineString",coordinates:j[l-1].data,properties:{m:!0}};break;case 30:this.$={type:"LineString",coordinates:j[l-1].data,properties:{z:!0,m:!0}};break;case 31:this.$={type:"LineString",coordinates:[]};break;case 32:this.$={type:"Polygon",coordinates:j[l-1].toJSON()};break;case 33:this.$={type:"Polygon",coordinates:j[l-1].toJSON(),properties:{z:!0}};break;case 34:this.$={type:"Polygon",coordinates:j[l-1].toJSON(),properties:{m:!0}};break;case 35:this.$={type:"Polygon",coordinates:j[l-1].toJSON(),properties:{z:!0,m:!0}};break;case 36:this.$={type:"Polygon",coordinates:[]};break;case 37:this.$={type:"MultiPoint",coordinates:j[l-1].data};break;case 38:this.$={type:"MultiPoint",coordinates:j[l-1].data,properties:{z:!0}};break;case 39:this.$={type:"MultiPoint",coordinates:j[l-1].data,properties:{m:!0}};break;case 40:this.$={type:"MultiPoint",coordinates:j[l-1].data,properties:{z:!0,m:!0}};break;case 41:this.$={type:"MultiPoint",coordinates:[]};break;case 42:this.$={type:"MultiLineString",coordinates:j[l-1].toJSON()};break;case 43:this.$={type:"MultiLineString",coordinates:j[l-1].toJSON(),properties:{z:!0}};break;case 44:this.$={type:"MultiLineString",coordinates:j[l-1].toJSON(),properties:{m:!0}};break;case 45:this.$={type:"MultiLineString",coordinates:j[l-1].toJSON(),properties:{z:!0,m:!0}};break;case 46:this.$={type:"MultiLineString",coordinates:[]};break;case 47:this.$={type:"MultiPolygon",coordinates:j[l-1].toJSON()};break;case 48:this.$={type:"MultiPolygon",coordinates:j[l-1].toJSON(),properties:{z:!0}};break;case 49:this.$={type:"MultiPolygon",coordinates:j[l-1].toJSON(),properties:{m:!0}};break;case 50:this.$={type:"MultiPolygon",coordinates:j[l-1].toJSON(),properties:{z:!0,m:!0}};break;case 51:this.$={type:"MultiPolygon",coordinates:[]}}},table:[{3:1,4:2,6:3,7:4,8:5,9:6,10:7,19:[1,8],28:[1,9],29:[1,10],30:[1,11],31:[1,12],32:[1,13]},{1:[3]},{5:[1,14]},{5:[1,15]},{5:[1,16]},{5:[1,17]},{5:[1,18]},{5:[1,19]},{17:[1,20],20:[1,21],21:[1,22],22:[1,23],23:[1,24]},{17:[1,25],20:[1,26],21:[1,28],22:[1,27],23:[1,29]},{17:[1,30],20:[1,31],21:[1,33],22:[1,32],23:[1,34]},{17:[1,35],20:[1,36],21:[1,38],22:[1,37],23:[1,39]},{17:[1,40],20:[1,41],21:[1,43],22:[1,42],23:[1,44]},{17:[1,45],20:[1,46],21:[1,48],22:[1,47],23:[1,49]},{1:[2,1]},{1:[2,2]},{1:[2,3]},{1:[2,4]},{1:[2,5]},{1:[2,6]},{11:51,12:[1,52],13:50},{17:[1,53]},{17:[1,54]},{17:[1,55]},{5:[2,19]},{11:58,12:[1,52],17:[1,59],24:57,27:56},{17:[1,60]},{17:[1,61]},{17:[1,62]},{5:[2,31]},{15:63,16:64,17:[1,65]},{17:[1,66]},{17:[1,67]},{17:[1,68]},{5:[2,36]},{11:58,12:[1,52],17:[1,59],24:57,27:69},{17:[1,70]},{17:[1,71]},{17:[1,72]},{5:[2,41]},{15:73,16:64,17:[1,65]},{17:[1,74]},{17:[1,75]},{17:[1,76]},{5:[2,46]},{17:[1,79],25:77,26:78},{17:[1,80]},{17:[1,81]},{17:[1,82]},{5:[2,51]},{14:[1,84],18:[1,83]},{14:[2,11],18:[2,11]},{12:[1,85]},{11:51,12:[1,52],13:86},{11:51,12:[1,52],13:87},{11:51,12:[1,52],13:88},{14:[1,90],18:[1,89]},{14:[2,26],18:[2,26]},{14:[2,20],18:[2,20]},{11:91,12:[1,52]},{11:58,12:[1,52],17:[1,59],24:57,27:92},{11:58,12:[1,52],17:[1,59],24:57,27:93},{11:58,12:[1,52],17:[1,59],24:57,27:94},{14:[1,96],18:[1,95]},{14:[2,13],18:[2,13]},{11:51,12:[1,52],13:97},{15:98,16:64,17:[1,65]},{15:99,16:64,17:[1,65]},{15:100,16:64,17:[1,65]},{14:[1,90],18:[1,101]},{11:58,12:[1,52],17:[1,59],24:57,27:102},{11:58,12:[1,52],17:[1,59],24:57,27:103},{11:58,12:[1,52],17:[1,59],24:57,27:104},{14:[1,96],18:[1,105]},{15:106,16:64,17:[1,65]},{15:107,16:64,17:[1,65]},{15:108,16:64,17:[1,65]},{14:[1,110],18:[1,109]},{14:[2,23],18:[2,23]},{15:111,16:64,17:[1,65]},{17:[1,79],25:112,26:78},{17:[1,79],25:113,26:78},{17:[1,79],25:114,26:78},{5:[2,15]},{11:115,12:[1,52]},{12:[1,116],14:[2,7],18:[2,7]},{14:[1,84],18:[1,117]},{14:[1,84],18:[1,118]},{14:[1,84],18:[1,119]},{5:[2,27]},{11:58,12:[1,52],17:[1,59],24:120},{18:[1,121]},{14:[1,90],18:[1,122]},{14:[1,90],18:[1,123]},{14:[1,90],18:[1,124]},{5:[2,32]},{16:125,17:[1,65]},{14:[1,84],18:[1,126]},{14:[1,96],18:[1,127]},{14:[1,96],18:[1,128]},{14:[1,96],18:[1,129]},{5:[2,37]},{14:[1,90],18:[1,130]},{14:[1,90],18:[1,131]},{14:[1,90],18:[1,132]},{5:[2,42]},{14:[1,96],18:[1,133]},{14:[1,96],18:[1,134]},{14:[1,96],18:[1,135]},{5:[2,47]},{17:[1,79],26:136},{14:[1,96],18:[1,137]},{14:[1,110],18:[1,138]},{14:[1,110],18:[1,139]},{14:[1,110],18:[1,140]},{14:[2,10],18:[2,10]},{12:[1,141],14:[2,8],18:[2,8]},{5:[2,16]},{5:[2,17]},{5:[2,18]},{14:[2,25],18:[2,25]},{14:[2,21],18:[2,21]},{5:[2,28]},{5:[2,29]},{5:[2,30]},{14:[2,12],18:[2,12]},{14:[2,14],18:[2,14]},{5:[2,33]},{5:[2,34]},{5:[2,35]},{5:[2,38]},{5:[2,39]},{5:[2,40]},{5:[2,43]},{5:[2,44]},{5:[2,45]},{14:[2,22],18:[2,22]},{14:[2,24],18:[2,24]},{5:[2,48]},{5:[2,49]},{5:[2,50]},{14:[2,9],18:[2,9]}],defaultActions:{14:[2,1],15:[2,2],16:[2,3],17:[2,4],18:[2,5],19:[2,6],24:[2,19],29:[2,31],34:[2,36],39:[2,41],44:[2,46],49:[2,51],83:[2,15],89:[2,27],95:[2,32],101:[2,37],105:[2,42],109:[2,47],117:[2,16],118:[2,17],119:[2,18],122:[2,28],123:[2,29],124:[2,30],127:[2,33],128:[2,34],129:[2,35],130:[2,38],131:[2,39],132:[2,40],133:[2,43],134:[2,44],135:[2,45],138:[2,48],139:[2,49],140:[2,50]},parseError:function(a,b){throw new Error(a)},parse:function(a){function b(){var a;return a=c.lexer.lex()||1,"number"!=typeof a&&(a=c.symbols_[a]||a),a}var c=this,d=[0],e=[null],f=[],g=this.table,h="",i=0,j=0,k=0;this.lexer.setInput(a),this.lexer.yy=this.yy,this.yy.lexer=this.lexer,this.yy.parser=this,"undefined"==typeof this.lexer.yylloc&&(this.lexer.yylloc={});var l=this.lexer.yylloc;f.push(l);var m=this.lexer.options&&this.lexer.options.ranges;"function"==typeof this.yy.parseError&&(this.parseError=this.yy.parseError);for(var n,o,p,q,r,s,t,u,v,w={};;){if(p=d[d.length-1],this.defaultActions[p]?q=this.defaultActions[p]:((null===n||"undefined"==typeof n)&&(n=b()),q=g[p]&&g[p][n]),"undefined"==typeof q||!q.length||!q[0]){var x="";if(!k){v=[];for(s in g[p])this.terminals_[s]&&s>2&&v.push("'"+this.terminals_[s]+"'");x=this.lexer.showPosition?"Parse error on line "+(i+1)+":\n"+this.lexer.showPosition()+"\nExpecting "+v.join(", ")+", got '"+(this.terminals_[n]||n)+"'":"Parse error on line "+(i+1)+": Unexpected "+(1==n?"end of input":"'"+(this.terminals_[n]||n)+"'"),this.parseError(x,{text:this.lexer.match,token:this.terminals_[n]||n,line:this.lexer.yylineno,loc:l,expected:v})}}if(q[0]instanceof Array&&q.length>1)throw new Error("Parse Error: multiple actions possible at state: "+p+", token: "+n);switch(q[0]){case 1:d.push(n),e.push(this.lexer.yytext),f.push(this.lexer.yylloc),d.push(q[1]),n=null,o?(n=o,o=null):(j=this.lexer.yyleng,h=this.lexer.yytext,i=this.lexer.yylineno,l=this.lexer.yylloc,k>0&&k--);break;case 2:if(t=this.productions_[q[1]][1],w.$=e[e.length-t],w._$={first_line:f[f.length-(t||1)].first_line,last_line:f[f.length-1].last_line,first_column:f[f.length-(t||1)].first_column,last_column:f[f.length-1].last_column},m&&(w._$.range=[f[f.length-(t||1)].range[0],f[f.length-1].range[1]]),r=this.performAction.call(w,h,j,i,this.yy,q[1],e,f),"undefined"!=typeof r)return r;t&&(d=d.slice(0,-1*t*2),e=e.slice(0,-1*t),f=f.slice(0,-1*t)),d.push(this.productions_[q[1]][0]),e.push(w.$),f.push(w._$),u=g[d[d.length-2]][d[d.length-1]],d.push(u);break;case 3:return!0}}return!0}},g=function(){var a={EOF:1,parseError:function(a,b){if(!this.yy.parser)throw new Error(a);this.yy.parser.parseError(a,b)},setInput:function(a){return this._input=a,this._more=this._less=this.done=!1,this.yylineno=this.yyleng=0,this.yytext=this.matched=this.match="",this.conditionStack=["INITIAL"],this.yylloc={first_line:1,first_column:0,last_line:1,last_column:0},this.options.ranges&&(this.yylloc.range=[0,0]),this.offset=0,this},input:function(){var a=this._input[0];this.yytext+=a,this.yyleng++,this.offset++,this.match+=a,this.matched+=a;var b=a.match(/(?:\r\n?|\n).*/g);return b?(this.yylineno++,this.yylloc.last_line++):this.yylloc.last_column++,this.options.ranges&&this.yylloc.range[1]++,this._input=this._input.slice(1),a},unput:function(a){var b=a.length,c=a.split(/(?:\r\n?|\n)/g);this._input=a+this._input,this.yytext=this.yytext.substr(0,this.yytext.length-b-1),this.offset-=b;var d=this.match.split(/(?:\r\n?|\n)/g);this.match=this.match.substr(0,this.match.length-1),this.matched=this.matched.substr(0,this.matched.length-1),c.length-1&&(this.yylineno-=c.length-1);var e=this.yylloc.range;return this.yylloc={first_line:this.yylloc.first_line,last_line:this.yylineno+1,first_column:this.yylloc.first_column,last_column:c?(c.length===d.length?this.yylloc.first_column:0)+d[d.length-c.length].length-c[0].length:this.yylloc.first_column-b},this.options.ranges&&(this.yylloc.range=[e[0],e[0]+this.yyleng-b]),this},more:function(){return this._more=!0,this},less:function(a){this.unput(this.match.slice(a))},pastInput:function(){var a=this.matched.substr(0,this.matched.length-this.match.length);return(a.length>20?"...":"")+a.substr(-20).replace(/\n/g,"")},upcomingInput:function(){var a=this.match;return a.length<20&&(a+=this._input.substr(0,20-a.length)),(a.substr(0,20)+(a.length>20?"...":"")).replace(/\n/g,"")},showPosition:function(){var a=this.pastInput(),b=new Array(a.length+1).join("-");return a+this.upcomingInput()+"\n"+b+"^"},next:function(){if(this.done)return this.EOF;this._input||(this.done=!0);var a,b,c,d,e;this._more||(this.yytext="",this.match="");for(var f=this._currentRules(),g=0;g<f.length&&(c=this._input.match(this.rules[f[g]]),!c||b&&!(c[0].length>b[0].length)||(b=c,d=g,this.options.flex));g++);return b?(e=b[0].match(/(?:\r\n?|\n).*/g),e&&(this.yylineno+=e.length),this.yylloc={first_line:this.yylloc.last_line,last_line:this.yylineno+1,first_column:this.yylloc.last_column,last_column:e?e[e.length-1].length-e[e.length-1].match(/\r?\n?/)[0].length:this.yylloc.last_column+b[0].length},this.yytext+=b[0],this.match+=b[0],this.matches=b,this.yyleng=this.yytext.length,this.options.ranges&&(this.yylloc.range=[this.offset,this.offset+=this.yyleng]),this._more=!1,this._input=this._input.slice(b[0].length),this.matched+=b[0],a=this.performAction.call(this,this.yy,this,f[d],this.conditionStack[this.conditionStack.length-1]),this.done&&this._input&&(this.done=!1),a?a:void 0):""===this._input?this.EOF:this.parseError("Lexical error on line "+(this.yylineno+1)+". Unrecognized text.\n"+this.showPosition(),{text:"",token:null,line:this.yylineno})},lex:function(){var a=this.next();return"undefined"!=typeof a?a:this.lex()},begin:function(a){this.conditionStack.push(a)},popState:function(){return this.conditionStack.pop()},_currentRules:function(){return this.conditions[this.conditionStack[this.conditionStack.length-1]].rules},topState:function(){return this.conditionStack[this.conditionStack.length-2]},pushState:function(a){this.begin(a)}};return a.options={},a.performAction=function(a,b,c,d){switch(c){case 0:break;case 1:return 17;case 2:return 18;case 3:return 12;case 4:return 19;case 5:return 28;case 6:return 29;case 7:return 30;case 8:return 31;case 9:return 32;case 10:return 14;case 11:return 23;case 12:return 22;case 13:return 20;case 14:return 21;case 15:return 5;case 16:return"INVALID"}},a.rules=[/^(?:\s+)/,/^(?:\()/,/^(?:\))/,/^(?:-?[0-9]+(\.[0-9]+)?)/,/^(?:POINT\b)/,/^(?:LINESTRING\b)/,/^(?:POLYGON\b)/,/^(?:MULTIPOINT\b)/,/^(?:MULTILINESTRING\b)/,/^(?:MULTIPOLYGON\b)/,/^(?:,)/,/^(?:EMPTY\b)/,/^(?:M\b)/,/^(?:Z\b)/,/^(?:ZM\b)/,/^(?:$)/,/^(?:.)/],a.conditions={INITIAL:{rules:[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16],inclusive:!0}},a}();return f.lexer=g,a.prototype=f,f.Parser=a,new a}();return b.prototype.addPoint=function(a){return"PointArray"===a.type?this.data=this.data.concat(a.data):this.data.push(a),this},b.prototype.toJSON=function(){return this.data},c.prototype.toJSON=function(){for(var a=[],b=0;b<this.data.data.length;b++)a.push(this.data.data[b]);return a},d.prototype.addRing=function(a){return this.data.push(a),this},d.prototype.toJSON=function(){for(var a=[],b=0;b<this.data.length;b++)a.push(this.data[b].toJSON());return 1===a.length?a:a},e.prototype.addPolygon=function(a){return this.data.push(a),this},e.prototype.toJSON=function(){for(var a=[],b=0;b<this.data.length;b++)a=a.concat([this.data[b].toJSON()]);return a},o.parser=p,o.Parser=p.Parser,o.parse=f,o.convert=n,o});

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc