8 import fields2cover
as f2c
11 assert pytest.approx(a) == pytest.approx(b)
15 ring = f2c.LinearRing();
16 ring.addPoint(-10, 0);
17 ring.addPoint(-10, 20);
18 ring.addPoint(10, 20);
20 ring.addPoint(-10, 0);
22 polygon.addRing(ring);
24 polys.addGeometry(polygon);
25 line = f2c.LineString();
26 line.addPoint(-20, -10);
29 swaths = f2c.Swaths();
30 near(swaths.size(), 0);
31 swaths.append(line, polys, 1.0);
32 near(swaths.size(), 1);
33 swaths.append(line, polys, 2.0);
34 near(swaths.size(), 2);
35 line.addPoint(-19.9, -10);
36 line.addPoint(-5, 5.1);
37 swaths.append(line, polys, 3.0);
38 near(swaths.size(), 4);
39 lines = f2c.MultiLineString();
40 lines.addGeometry(line);
41 lines.addGeometry(f2c.LineString(f2c.VectorPoint([f2c.Point(-10,0),f2c.Point(10,20)])));
42 swaths.append(lines, polygon, 4);
43 near(swaths.size(), 8);
44 swaths.append(lines, polys, 5);
45 near(swaths.size(), 12);
46 lines.addGeometry(f2c.LineString(f2c.VectorPoint(
47 [f2c.Point(1e5, 1e5),f2c.Point(1e5+1, 1e5+1)])));
48 swaths.append(lines, polys, 6);
49 near(swaths.size(), 16);
54 swaths = f2c.Swaths();
55 for i
in range(n - 1, 0, -1):
56 swaths.emplace_back(f2c.LineString(f2c.VectorPoint(
57 [f2c.Point(i, i), f2c.Point(i, i + 1)])), i, i);
60 near(swaths[i-1].getWidth(), i);
65 swaths = f2c.Swaths();
66 for i
in range(1, n + 1):
67 swaths.emplace_back(f2c.LineString(f2c.VectorPoint(
68 [f2c.Point(i, i), f2c.Point(i, i + 1)])), i);
69 swaths.reverseDirOddSwaths();
71 assert not (swaths[i].hasSameDir(swaths[i-1]));