Mercurial > gemma
annotate pkg/mesh/plane2d_test.go @ 5591:0011f50cf216 surveysperbottleneckid
Removed no longer used alternative api for surveys/ endpoint.
As bottlenecks in the summary for SR imports are now identified by
their id and no longer by the (not guarantied to be unique!) name,
there is no longer the need to request survey data by the name+date
tuple (which isn't reliable anyway). So the workaround was now
reversed.
author | Sascha Wilde <wilde@sha-bang.de> |
---|---|
date | Wed, 06 Apr 2022 13:30:29 +0200 |
parents | f4abfd0ee8ad |
children |
rev | line source |
---|---|
1017
a244b18cb916
Added GNU Affero General Public License.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
778
diff
changeset
|
1 // This is Free Software under GNU Affero General Public License v >= 3.0 |
a244b18cb916
Added GNU Affero General Public License.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
778
diff
changeset
|
2 // without warranty, see README.md and license for details. |
a244b18cb916
Added GNU Affero General Public License.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
778
diff
changeset
|
3 // |
a244b18cb916
Added GNU Affero General Public License.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
778
diff
changeset
|
4 // SPDX-License-Identifier: AGPL-3.0-or-later |
a244b18cb916
Added GNU Affero General Public License.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
778
diff
changeset
|
5 // License-Filename: LICENSES/AGPL-3.0.txt |
a244b18cb916
Added GNU Affero General Public License.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
778
diff
changeset
|
6 // |
a244b18cb916
Added GNU Affero General Public License.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
778
diff
changeset
|
7 // Copyright (C) 2018 by via donau |
a244b18cb916
Added GNU Affero General Public License.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
778
diff
changeset
|
8 // – Österreichische Wasserstraßen-Gesellschaft mbH |
a244b18cb916
Added GNU Affero General Public License.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
778
diff
changeset
|
9 // Software engineering by Intevation GmbH |
a244b18cb916
Added GNU Affero General Public License.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
778
diff
changeset
|
10 // |
a244b18cb916
Added GNU Affero General Public License.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
778
diff
changeset
|
11 // Author(s): |
a244b18cb916
Added GNU Affero General Public License.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
778
diff
changeset
|
12 // * Sascha L. Teichmann <sascha.teichmann@intevation.de> |
a244b18cb916
Added GNU Affero General Public License.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
778
diff
changeset
|
13 |
4827
f4abfd0ee8ad
Renamed octree package to mesh as there is no octree any more.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1017
diff
changeset
|
14 package mesh |
778
9be20bd0f131
Fixed a bug with 2d planes (lines) found while working on line intersections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
15 |
9be20bd0f131
Fixed a bug with 2d planes (lines) found while working on line intersections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
16 import ( |
9be20bd0f131
Fixed a bug with 2d planes (lines) found while working on line intersections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
17 "math" |
9be20bd0f131
Fixed a bug with 2d planes (lines) found while working on line intersections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
18 "testing" |
9be20bd0f131
Fixed a bug with 2d planes (lines) found while working on line intersections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
19 ) |
9be20bd0f131
Fixed a bug with 2d planes (lines) found while working on line intersections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
20 |
9be20bd0f131
Fixed a bug with 2d planes (lines) found while working on line intersections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
21 func TestIntersection(t *testing.T) { |
9be20bd0f131
Fixed a bug with 2d planes (lines) found while working on line intersections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
22 |
9be20bd0f131
Fixed a bug with 2d planes (lines) found while working on line intersections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
23 table := []struct { |
9be20bd0f131
Fixed a bug with 2d planes (lines) found while working on line intersections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
24 a [4]float64 |
9be20bd0f131
Fixed a bug with 2d planes (lines) found while working on line intersections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
25 b [4]float64 |
9be20bd0f131
Fixed a bug with 2d planes (lines) found while working on line intersections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
26 intersects bool |
9be20bd0f131
Fixed a bug with 2d planes (lines) found while working on line intersections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
27 x, y float64 |
9be20bd0f131
Fixed a bug with 2d planes (lines) found while working on line intersections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
28 }{ |
9be20bd0f131
Fixed a bug with 2d planes (lines) found while working on line intersections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
29 {[4]float64{-1, -1, 1, 1}, [4]float64{-1, 1, 1, -1}, true, 0, 0}, |
9be20bd0f131
Fixed a bug with 2d planes (lines) found while working on line intersections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
30 {[4]float64{0, 0, 1, 1}, [4]float64{0, 1, 1, 0}, true, 0.5, 0.5}, |
9be20bd0f131
Fixed a bug with 2d planes (lines) found while working on line intersections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
31 {[4]float64{0, 0, 1, 0}, [4]float64{0, 1, 1, 1}, false, 0, 0}, |
9be20bd0f131
Fixed a bug with 2d planes (lines) found while working on line intersections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
32 } |
9be20bd0f131
Fixed a bug with 2d planes (lines) found while working on line intersections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
33 |
9be20bd0f131
Fixed a bug with 2d planes (lines) found while working on line intersections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
34 for _, e := range table { |
9be20bd0f131
Fixed a bug with 2d planes (lines) found while working on line intersections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
35 p1 := NewPlane2D(e.a[0], e.a[1], e.a[2], e.a[3]) |
9be20bd0f131
Fixed a bug with 2d planes (lines) found while working on line intersections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
36 p2 := NewPlane2D(e.b[0], e.b[1], e.b[2], e.b[3]) |
9be20bd0f131
Fixed a bug with 2d planes (lines) found while working on line intersections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
37 x, y, intersects := p1.Intersection(p2) |
9be20bd0f131
Fixed a bug with 2d planes (lines) found while working on line intersections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
38 if intersects != e.intersects { |
9be20bd0f131
Fixed a bug with 2d planes (lines) found while working on line intersections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
39 t.Fatalf("Have %t want %t\n", intersects, e.intersects) |
9be20bd0f131
Fixed a bug with 2d planes (lines) found while working on line intersections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
40 } |
9be20bd0f131
Fixed a bug with 2d planes (lines) found while working on line intersections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
41 if e.intersects { |
9be20bd0f131
Fixed a bug with 2d planes (lines) found while working on line intersections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
42 if math.Abs(e.x-x) > epsPlane || math.Abs(e.y-y) > epsPlane { |
9be20bd0f131
Fixed a bug with 2d planes (lines) found while working on line intersections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
43 t.Fatalf("Have (%f, %f)t want (%f, %f)\n", x, y, e.x, e.y) |
9be20bd0f131
Fixed a bug with 2d planes (lines) found while working on line intersections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
44 } |
9be20bd0f131
Fixed a bug with 2d planes (lines) found while working on line intersections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
45 } |
9be20bd0f131
Fixed a bug with 2d planes (lines) found while working on line intersections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
46 } |
9be20bd0f131
Fixed a bug with 2d planes (lines) found while working on line intersections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
47 } |