Launch Week Day 5: Introducing Reachability for PHP.Learn More
Socket
Book a DemoSign in
Socket

arc

Package Overview
Dependencies
Maintainers
2
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

arc - npm Package Compare versions

Comparing version
0.1.0
to
0.1.1
+30
bower.json
{
"name": "arc.js",
"main": "index.js",
"version": "0.1.0",
"homepage": "https://github.com/springmeyer/arc.js",
"authors": [
"Dane Springmeyer <dane@dbsgeo.com>"
],
"description": "great circle routes in javascript",
"moduleType": [
"globals",
"node"
],
"keywords": [
"maps",
"spherical",
"globe",
"rhumb line",
"crow flies",
"great circle"
],
"license": "BSD",
"ignore": [
"**/.*",
"node_modules",
"bower_components",
"test",
"tests"
]
}
Copyright (c) Dane Springmeyer
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in
the documentation and/or other materials provided with the
distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+1
-1

@@ -249,3 +249,3 @@ 'use strict';

if (typeof window === 'undefined') {
if (typeof module !== 'undefined' && typeof module.exports !== 'undefined') {
// nodejs

@@ -252,0 +252,0 @@ module.exports.Coord = Coord;

# v0.1.1
- Support browserify (https://github.com/springmeyer/arc.js/pull/26)
# v0.1.0

@@ -7,2 +10,2 @@

- Added mocha tests
- Fixed jshint strict errors
- Fixed jshint strict errors
{
"name": "arc",
"version": "0.1.0",
"version": "0.1.1",
"description": "draw great circle arcs",

@@ -31,7 +31,15 @@ "url": "https://github.com/springmeyer/arc.js",

"scripts": {
"test": "mocha -R spec"
"test": "tape test/*.js"
},
"devDependencies": {
"mocha": "~1.17.1"
"tape": "~2.12.1"
},
"testling": {
"files": "test/*.js",
"browsers": [
"chrome/22..latest",
"firefox/16..latest",
"safari/latest"
]
}
}
+55
-30
# arc.js
> Calculate great circles routes as lines in GeoJSON or WKT format.
Calculate great circles routes as lines in GeoJSON or WKT format.
Algorithms from http://williams.best.vwh.net/avform.htm#Intermediate

@@ -10,16 +9,30 @@

## Install
# Usage
```bash
$ npm install --save arc
```
Require the library in node.js like:
```bash
$ bower install --save arc.js
```
var arc = require('arc');
## License
Use in the browser like:
BSD
<script src="./arc.js"></script>
## Usage
Require the library in node.js like:
```js
var arc = require('arc');
```
# API
Use in the browser like:
```html
<script src="./arc.js"></script>
```
## API
**1)** Create start and end coordinates

@@ -29,4 +42,6 @@

var start = { x: -122, y: 48 };
var end = { x: -77, y: 39 };
```js
var start = { x: -122, y: 48 };
var end = { x: -77, y: 39 };
```

@@ -39,3 +54,5 @@ Note that `x` here is longitude in degrees and `y` is latitude in degrees.

var generator = new arc.GreatCircle(start, end, {'name': 'Seattle to DC'});
```js
var generator = new arc.GreatCircle(start, end, {'name': 'Seattle to DC'});
```

@@ -46,3 +63,5 @@ **3)** Generate a line arc

var line = generator.Arc(100,{offset:10});
```js
var line = generator.Arc(100,{offset:10});
```

@@ -52,12 +71,14 @@ The `line` will be a raw sequence of the start and end coordinates plus an arc of

> line
{ properties: { name: 'Seattle to DC' },
coords:
[ [ -122, 48.00000000000001 ],
[ -112.06161978373486, 47.7241672604096 ],
[ -102.38404317022653, 46.60813199882492 ],
[ -93.22718895342909, 44.716217302635705 ],
[ -84.74823988299501, 42.14415510795357 ],
[ -77, 38.99999999999999 ] ],
length: 6 }
```js
> line
{ properties: { name: 'Seattle to DC' },
coords:
[ [ -122, 48.00000000000001 ],
[ -112.06161978373486, 47.7241672604096 ],
[ -102.38404317022653, 46.60813199882492 ],
[ -93.22718895342909, 44.716217302635705 ],
[ -84.74823988299501, 42.14415510795357 ],
[ -77, 38.99999999999999 ] ],
length: 6 }
```

@@ -74,14 +95,18 @@ #### Arc options

> line.json();
{ geometry:
{ type: 'LineString',
coordinates: [ [Object], [Object], [Object], [Object], [Object], [Object] ] },
type: 'Feature',
properties: { name: 'Seattle to DC' } }
```js
> line.json();
{ geometry:
{ type: 'LineString',
coordinates: [ [Object], [Object], [Object], [Object], [Object], [Object] ] },
type: 'Feature',
properties: { name: 'Seattle to DC' } }
```
Or to WKT (Well known text):
> line.wkt();
'LINESTRING(-122 48.00000000000001,-112.06161978373486 47.7241672604096,-102.38404317022653 46.60813199882492,-93.22718895342909 44.716217302635705,-84.74823988299501 42.14415510795357,-77 38.99999999999999)'
```js
> line.wkt();
'LINESTRING(-122 48.00000000000001,-112.06161978373486 47.7241672604096,-102.38404317022653 46.60813199882492,-93.22718895342909 44.716217302635705,-84.74823988299501 42.14415510795357,-77 38.99999999999999)'
```
It is then up to you to add up these features to create fully fledged geodata. See the examples/ directory for sample code to create GeoJSON feature collection from multiple routes.
'use strict';
var test = require('tape').test;
var arc = require('../');
var assert = require('assert');
describe('Coord', function() {
it('#constructor', function() {
var coord = new arc.Coord(0,0);
assert.equal(coord.lon,0);
assert.equal(coord.lat,0);
assert.equal(coord.x,0);
assert.equal(coord.y,0);
});
it('#view', function() {
var coord = new arc.Coord(0,0);
assert.equal(coord.view(),'0,0');
});
it('#antipode', function() {
var coord = new arc.Coord(0,0);
assert.equal(coord.antipode().view(),'-180,0');
});
test('Coord', function(t) {
var coord = new arc.Coord(0,0);
t.equal(coord.lon,0);
t.equal(coord.lat,0);
t.equal(coord.x,0);
t.equal(coord.y,0);
t.equal(coord.view(),'0,0');
t.equal(coord.antipode().view(),'-180,0');
t.end();
});
describe('Arc', function() {
it('#constructor', function() {
var a = new arc.Arc();
assert.deepEqual(a.properties, {});
test('Arc', function(t) {
var a = new arc.Arc();
t.deepEqual(a.properties, {});
t.equal(a.wkt(), '');
t.deepEqual(a.json(),{
'geometry': { 'type': 'LineString', 'coordinates': null },
'type': 'Feature', 'properties': {}
});
it('#wkt', function() {
var a = new arc.Arc();
assert.equal(a.wkt(), '');
});
it('#json', function() {
var a = new arc.Arc();
assert.deepEqual(a.json(),{
'geometry': { 'type': 'LineString', 'coordinates': null },
'type': 'Feature', 'properties': {}
});
});
t.end();
});
describe('GreatCircle', function() {
it('#constructor', function() {
var a = new arc.GreatCircle({
x: 0, y: 0
}, {
x: 10, y: 0
});
assert.ok(a);
test('GreatCircle', function(t) {
var a = new arc.GreatCircle({
x: 0, y: 0
}, {
x: 10, y: 0
});
it('#interpolate', function() {
var a = new arc.GreatCircle({
x: 0, y: 0
}, {
x: 10, y: 0
});
assert.deepEqual(a.interpolate(0), [0, 0]);
assert.deepEqual(a.interpolate(1), [10, 0]);
});
t.ok(a);
t.deepEqual(a.interpolate(0), [0, 0]);
t.deepEqual(a.interpolate(1), [10, 0]);
t.end();
});

@@ -83,13 +61,12 @@

describe('Routes', function() {
test('Routes', function(t) {
routes.forEach(function(route,idx) {
it(route[2].name, function() {
var gc = new arc.GreatCircle(route[0], route[1], route[2]);
var line = gc.Arc(3);
//console.log(JSON.stringify(line))
assert.deepEqual(line,arcs[idx]);
});
var gc = new arc.GreatCircle(route[0], route[1], route[2]);
var line = gc.Arc(3);
//console.log(JSON.stringify(line))
t.deepEqual(line,arcs[idx]);
});
t.end();
});

Sorry, the diff of this file is not supported yet