Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add core tests - file management & package.json rules #749

Merged
merged 1 commit into from
May 18, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions packages/turf-along/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@
"homepage": "https://github.com/Turfjs/turf",
"devDependencies": {
"benchmark": "^1.0.0",
"tape": "^3.5.0",
"@turf/helpers": "^4.3.0"
"tape": "^3.5.0"
},
"dependencies": {
"@turf/bearing": "^4.3.0",
Expand Down
21 changes: 0 additions & 21 deletions packages/turf-along/test/types.ts

This file was deleted.

7 changes: 7 additions & 0 deletions packages/turf-along/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import {lineString} from '@turf/helpers'
import * as along from './'

const line = lineString([[0, 0], [10, 10]]);

along(line, 5);
along(line, 5, 'miles');
2 changes: 1 addition & 1 deletion packages/turf-bbox-clip/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"bbox",
"clip"
],
"author": "Tim Channell <@tcql>",
"author": "Turf Authors",
"contributors": [
"Tim Channell <@tcql>",
"Vladimir Agafonkin <@mourner>",
Expand Down
13 changes: 0 additions & 13 deletions packages/turf-bbox-clip/test/types.ts

This file was deleted.

7 changes: 7 additions & 0 deletions packages/turf-bbox-clip/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import {polygon, BBox} from '@turf/helpers'
import * as bboxClip from './'

const bbox: BBox = [0, 0, 10, 10];
const poly = polygon([[[2, 2], [8, 4], [12, 8], [3, 7], [2, 2]]])

const clipped = bboxClip(poly, bbox);
17 changes: 17 additions & 0 deletions packages/turf-bbox/bench.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
const load = require('load-json-file');
const Benchmark = require('benchmark');
const {lineString} = require('@turf/helpers');
const bbox = require('./');

const line = lineString([[-74, 40], [-78, 42], [-82, 35]]);

/**
* Benchmark Results
*
*/
const suite = new Benchmark.Suite('turf-bbox');
suite
.add('line', () => bbox(line))
.on('cycle', e => console.log(String(e.target)))
.on('complete', () => {})
.run();
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {
multiPoint, multiLineString, multiPolygon,
featureCollection, geometryCollection
} from '@turf/helpers'
import * as buffer from '../'
import * as buffer from './'

// Standard Geometry
const pt = point([100, 0]);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {point} from '@turf/helpers'
import * as circle from '../index'
import * as circle from './'

const center = point([-75.343, 39.984]);
const unit = 'kilometers';
Expand Down
2 changes: 1 addition & 1 deletion packages/turf-collect/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"homepage": "https://github.com/Turfjs/turf",
"author": "Turf Authors",
"contributors": [
"Rowan Winsemius"
"Rowan Winsemius <@rowanwins>"
],
"license": "MIT",
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion packages/turf-difference/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,6 @@
"@turf/helpers": "^4.3.0",
"@turf/invariant": "^4.3.0",
"@turf/meta": "^4.3.0",
"jsts": "^1.4.0"
"jsts": "1.3.0"
}
}
10 changes: 6 additions & 4 deletions packages/turf-explode/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
var featureCollection = require('@turf/helpers').featureCollection;
var featureEach = require('@turf/meta').featureEach;
var coordEach = require('@turf/meta').coordEach;
var point = require('@turf/helpers').point;
var meta = require('@turf/meta');
var helpers = require('@turf/helpers');
var point = helpers.point;
var coordEach = meta.coordEach;
var featureEach = meta.featureEach;
var featureCollection = helpers.featureCollection;

/**
* Takes a feature or set of features and returns all positions as {@link Point|points}.
Expand Down
3 changes: 0 additions & 3 deletions packages/turf-explode/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,7 @@
},
"homepage": "https://github.com/Turfjs/turf",
"devDependencies": {
"@turf/helpers": "^4.3.0",
"benchmark": "^2.1.4",
"eslint": "^3.14.1",
"eslint-config-mourner": "^2.0.1",
"geojson-fixtures": "^0.6.1",
"load-json-file": "^2.0.0",
"tape": "^4.6.3",
Expand Down
2 changes: 1 addition & 1 deletion packages/turf-flatten/bench.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,6 @@ for (const {geojson, name} of fixtures) {
suite.add(name, () => flatten(geojson));
}
suite
.on('cycle', e => { console.log(String(e.target)); })
.on('cycle', e => console.log(String(e.target)))
.on('complete', () => {})
.run();
7 changes: 5 additions & 2 deletions packages/turf-flatten/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@
"gis",
"featurecollection"
],
"author": "Tom MacWright",
"author": "Turf Authors",
"contributors": [
"Tom MacWright <@tmcw>",
"Denis Carriere <@DenisCarriere>"
],
"license": "MIT",
"bugs": {
"url": "https://github.com/Turfjs/turf/issues"
Expand All @@ -37,7 +41,6 @@
},
"dependencies": {
"@turf/helpers": "^4.3.0",
"@turf/invariant": "^4.3.0",
"@turf/meta": "^4.3.0"
}
}
9 changes: 0 additions & 9 deletions packages/turf-flatten/test/types.ts

This file was deleted.

11 changes: 11 additions & 0 deletions packages/turf-flatten/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import {multiPoint, multiLineString, geometryCollection} from '@turf/helpers'
import * as flatten from './'

const multiPt = multiPoint([[0, 0], [10, 10]])
const multiLine = multiLineString([[[20, 20], [30, 30]], [[0, 0], [10, 10]]])

flatten(multiPt);
flatten(multiLine);
flatten(multiPt.geometry);
flatten(multiLine.geometry);
flatten(geometryCollection([multiPt.geometry, multiLine.geometry]));
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {featureCollection, point, lineString, geometryCollection} from '@turf/helpers'
import * as flip from '../'
import * as flip from './'

const pt = point([120.1234567, 40.1234567])
const ptGeom = pt.geometry
Expand Down
2 changes: 1 addition & 1 deletion packages/turf-great-circle/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/// <reference types="geojson" />

type Point = GeoJSON.Feature<GeoJSON.Point>;
type Point = GeoJSON.Feature<GeoJSON.Point> | GeoJSON.Point | Array<number>;
type LineString = GeoJSON.Feature<GeoJSON.LineString>;

/**
Expand Down
6 changes: 3 additions & 3 deletions packages/turf-great-circle/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ var getCoord = require('@turf/invariant').getCoord;
* Calculate great circles routes as {@link LineString}
*
* @name greatCircle
* @param {Feature<Point>} start source point feature
* @param {Feature<Point>} end destination point feature
* @param {*} [properties={}] line feature properties
* @param {Geometry|Feature<Point>|Array<number>} start source point feature
* @param {Geometry|Feature<Point>|Array<number>} end destination point feature
* @param {Object} [properties={}] line feature properties
* @param {number} [npoints=100] number of points
* @param {number} [offset=10] offset controls the likelyhood that lines will
* be split which cross the dateline. The higher the number the more likely.
Expand Down
7 changes: 3 additions & 4 deletions packages/turf-great-circle/test.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
const test = require('tape');
const fs = require('fs');
const test = require('tape');
const path = require('path');
const load = require('load-json-file');
const write = require('write-json-file');
const {featureCollection} = require('@turf/helpers');
const truncate = require('@turf/truncate');
const {featureCollection} = require('@turf/helpers');
const greatCircle = require('./');

const directories = {
Expand All @@ -22,8 +22,7 @@ let fixtures = fs.readdirSync(directories.in).map(filename => {

test('turf-great-circle', t => {
for (const {name, filename, geojson} of fixtures) {
const start = geojson.features[0];
const end = geojson.features[1];
const [start, end] = geojson.features;
const line = truncate(greatCircle(start, end));
const results = featureCollection([line, start, end]);

Expand Down
4 changes: 0 additions & 4 deletions packages/turf-great-circle/test/types.ts

This file was deleted.

12 changes: 12 additions & 0 deletions packages/turf-great-circle/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import {point} from '@turf/helpers'
import * as greatCircle from './'

const pt1 = point([0, 0])
const pt2 = point([60, 0])
greatCircle(pt1, pt2)
greatCircle(pt1.geometry, pt2.geometry)
greatCircle(pt1.geometry.coordinates, pt2.geometry.coordinates)
greatCircle(pt1, pt2, {'name': 'Seattle to DC'})
greatCircle(pt1, pt2, {}, 100)
greatCircle(pt1, pt2, {}, 100, 10)

Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {
point, lineString, polygon,
multiPoint, multiLineString, multiPolygon,
feature, featureCollection, geometryCollection,
radiansToDistance, distanceToDegrees, distanceToRadians} from '../'
radiansToDistance, distanceToDegrees, distanceToRadians} from './'

const pt = point([0, 1])
const line = lineString([[0, 1], [2, 3]])
Expand Down
11 changes: 6 additions & 5 deletions packages/turf-hex-grid/index.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
var point = require('@turf/helpers').point;
var polygon = require('@turf/helpers').polygon;
var distance = require('@turf/distance');
var featurecollection = require('@turf/helpers').featureCollection;
var helpers = require('@turf/helpers');
var point = helpers.point;
var polygon = helpers.polygon;
var featureCollection = helpers.featureCollection;

//Precompute cosines and sines of angles used in hexagon creation
// Precompute cosines and sines of angles used in hexagon creation
// for performance gain
var cosines = [];
var sines = [];
Expand Down Expand Up @@ -67,7 +68,7 @@ module.exports = function hexGrid(bbox, cellSize, units, triangles) {
y_adjust -= hex_height / 4;
}

var fc = featurecollection([]);
var fc = featureCollection([]);
for (var x = 0; x < x_count; x++) {
for (var y = 0; y <= y_count; y++) {

Expand Down
9 changes: 2 additions & 7 deletions packages/turf-hex-grid/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,22 +28,17 @@
"contributors": [
"jseppi",
"jvail",
"lyzidiamond",
"tmcw"
"Lyzi Diamond <@lyzidiamond>",
"Tom MacWright <@tmcw>"
],
"license": "MIT",
"bugs": {
"url": "https://github.com/Turfjs/turf/issues"
},
"homepage": "https://github.com/Turfjs/turf",
"devDependencies": {
"@turf/bbox-polygon": "^4.3.0",
"@turf/explode": "^4.3.0",
"@turf/inside": "^4.3.0",
"@turf/truncate": "^4.3.0",
"benchmark": "^2.1.4",
"eslint": "^3.15.0",
"eslint-config-mourner": "^2.0.1",
"load-json-file": "^2.0.0",
"tape": "^4.6.3",
"write-json-file": "^2.0.0"
Expand Down
42 changes: 21 additions & 21 deletions packages/turf-hex-grid/test.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
var test = require('tape');
var path = require('path');
var load = require('load-json-file');
var write = require('write-json-file');
var truncate = require('@turf/truncate');
var grid = require('.');
const test = require('tape');
const path = require('path');
const load = require('load-json-file');
const write = require('write-json-file');
const truncate = require('@turf/truncate');
const grid = require('./');

var directories = {
const directories = {
in: path.join(__dirname, 'test', 'in') + path.sep,
out: path.join(__dirname, 'test', 'out') + path.sep
};

var bbox1 = require(directories.in + 'bbox1.json');
var bbox2 = require(directories.in + 'bbox2.json');
var bbox3 = require(directories.in + 'bbox3.json');
var bbox4 = require(directories.in + 'bbox4.json');
const bbox1 = require(directories.in + 'bbox1.json');
const bbox2 = require(directories.in + 'bbox2.json');
const bbox3 = require(directories.in + 'bbox3.json');
const bbox4 = require(directories.in + 'bbox4.json');

test('hex-grid', function (t) {
var grid1 = truncate(grid(bbox1, 50, 'miles'));
var grid2 = truncate(grid(bbox2, 5, 'miles'));
var grid3 = truncate(grid(bbox3, 2, 'miles'));
var grid4 = truncate(grid(bbox4, 50, 'kilometers'));
test('hex-grid', t => {
const grid1 = truncate(grid(bbox1, 50, 'miles'));
const grid2 = truncate(grid(bbox2, 5, 'miles'));
const grid3 = truncate(grid(bbox3, 2, 'miles'));
const grid4 = truncate(grid(bbox4, 50, 'kilometers'));

t.ok(grid1.features.length, '50mi grid');
t.ok(grid2.features.length, '5mi grid');
Expand All @@ -42,11 +42,11 @@ test('hex-grid', function (t) {
t.end();
});

test('hex-tri-grid', function (t) {
var grid1 = truncate(grid(bbox1, 50, 'miles', true));
var grid2 = truncate(grid(bbox2, 5, 'miles', true));
var grid3 = truncate(grid(bbox3, 2, 'miles', true));
var grid4 = truncate(grid(bbox4, 50, 'kilometers', true));
test('hex-tri-grid', t => {
const grid1 = truncate(grid(bbox1, 50, 'miles', true));
const grid2 = truncate(grid(bbox2, 5, 'miles', true));
const grid3 = truncate(grid(bbox3, 2, 'miles', true));
const grid4 = truncate(grid(bbox4, 50, 'kilometers', true));

t.ok(grid1.features.length, '50mi grid');
t.ok(grid2.features.length, '5mi grid');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {BBox, Polygons} from '@turf/helpers'
import * as hexGrid from '../'
import * as hexGrid from './'

const bbox: BBox = [
-96.6357421875,
Expand Down
Loading