forked from sharedstreets/sharedstreets-js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_graph.ts
45 lines (30 loc) · 1.35 KB
/
test_graph.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import { lineString } from "@turf/helpers";
import length from "@turf/length";
import * as fs from "fs";
import * as glob from "glob";
import * as path from "path";
import * as sharedstreetsPbf from "sharedstreets-pbf";
import * as sharedstreets from "./src/index";
import * as turfHelpers from '@turf/helpers';
import envelope from '@turf/envelope';
import { TileIndex } from './src/index';
import { TilePathGroup, TileType, TilePathParams } from './src/index';
import { CleanedPoints, CleanedLines } from "./src/geom";
import { polygon } from "@turf/envelope/node_modules/@turf/helpers";
import { Graph, GraphMode } from "./src/graph";
const test = require('tape');
test("sharedstreets -- graph test", async (t:any) => {
var params = new TilePathParams();
params.source = 'osm/planet-181224';
params.tileHierarchy = 7;
// test polygon (dc area)
const content = fs.readFileSync('test/geojson/test_route.geojson');
var lineIn:turfHelpers.FeatureCollection<turfHelpers.LineString> = JSON.parse(content.toLocaleString());
var graph = new Graph(envelope(lineIn), params);
await graph.buildGraph();
t.equal(graph.id, 'd626d5b0-0dec-3e6f-97ff-d9712228a282');
var results = await graph.matchGeom(lineIn.features[0]);
lineIn.features[0].geometry.coordinates.reverse();
var results2 = await graph.matchGeom(lineIn.features[0]);
t.end();
});