-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathdemo.js
31 lines (24 loc) · 1.18 KB
/
demo.js
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
var jsts = require("../computational-geometry");
var factory = new jsts.geom.GeometryFactory();
var app = new jsts.geom.AxisParallelRectangle(0,0, 10,5, factory);
console.log("An axis-parallel rectangle with area "+app.getArea())
var srp0 = factory.createSimpleRectilinearPolygon([0,0, 10,10]); // square
var point0 = factory.createPointFromXY(3,3);
console.dir(point0)
console.log((srp0.contains(point0)? " contains ": " does not contain ")+point0)
process.exit(1)
var srp = new jsts.geom.SimpleRectilinearPolygon([0,0, 10,5, 20,20], factory);
console.log("An L-shaped simple rectilinear polygon with coordinates:")
console.dir(srp.getCoordinates());
console.dir(srp.isClosed());
console.dir(srp.contains(point0))
var covering = jsts.algorithm.minSquareCovering(srp);
console.log("A minimum square-covering:")
console.dir(covering);
var squares = factory.createSquaresTouchingPoints([{x:1,y:1}, {x:2,y:1}, {x:1,y:2}]);
console.log("A collection of "+squares.length+" squares spanned by points:")
console.dir(squares);
var disjointset = jsts.algorithm.maximumDisjointSet(squares);
console.log("A maximum disjoint set of "+disjointset.length+" squares:");
console.dir(disjointset);
process.exit(1);