Mercurial > gemma
annotate pkg/controllers/octreecross.go @ 792:ce23a4192788
Removed dead code.
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Thu, 27 Sep 2018 09:55:25 +0200 |
parents | 3d927e06b92c |
children | 0cc97135717c |
rev | line source |
---|---|
753
e6f8d58434f4
Added stub for octree based cross sections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
1 package controllers |
e6f8d58434f4
Added stub for octree based cross sections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
2 |
e6f8d58434f4
Added stub for octree based cross sections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
3 import ( |
e6f8d58434f4
Added stub for octree based cross sections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
4 "context" |
e6f8d58434f4
Added stub for octree based cross sections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
5 "database/sql" |
e6f8d58434f4
Added stub for octree based cross sections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
6 "log" |
e6f8d58434f4
Added stub for octree based cross sections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
7 "net/http" |
e6f8d58434f4
Added stub for octree based cross sections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
8 "time" |
e6f8d58434f4
Added stub for octree based cross sections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
9 |
e6f8d58434f4
Added stub for octree based cross sections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
10 "gemma.intevation.de/gemma/pkg/models" |
e6f8d58434f4
Added stub for octree based cross sections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
11 "gemma.intevation.de/gemma/pkg/octree" |
e6f8d58434f4
Added stub for octree based cross sections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
12 ) |
e6f8d58434f4
Added stub for octree based cross sections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
13 |
766
afc635ab9f5b
Project the result data of the cross sections which are calculated in UTM back to WGS84.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
763
diff
changeset
|
14 const WGS84 = 4326 |
afc635ab9f5b
Project the result data of the cross sections which are calculated in UTM back to WGS84.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
763
diff
changeset
|
15 |
753
e6f8d58434f4
Added stub for octree based cross sections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
16 func reproject( |
762
01ba06da8f46
Factored repojection of coordinates to own logic as we need it to reproject the
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
761
diff
changeset
|
17 rp *models.Reprojector, |
01ba06da8f46
Factored repojection of coordinates to own logic as we need it to reproject the
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
761
diff
changeset
|
18 src models.GeoJSONLineCoordinates, |
753
e6f8d58434f4
Added stub for octree based cross sections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
19 ctx context.Context, |
e6f8d58434f4
Added stub for octree based cross sections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
20 ) (models.GeoJSONLineCoordinates, error) { |
e6f8d58434f4
Added stub for octree based cross sections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
21 |
e6f8d58434f4
Added stub for octree based cross sections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
22 dst := make(models.GeoJSONLineCoordinates, len(src)) |
e6f8d58434f4
Added stub for octree based cross sections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
23 for i, s := range src { |
762
01ba06da8f46
Factored repojection of coordinates to own logic as we need it to reproject the
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
761
diff
changeset
|
24 var err error |
01ba06da8f46
Factored repojection of coordinates to own logic as we need it to reproject the
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
761
diff
changeset
|
25 if dst[i].Lat, dst[i].Lon, err = rp.Reproject( |
01ba06da8f46
Factored repojection of coordinates to own logic as we need it to reproject the
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
761
diff
changeset
|
26 s.Lat, s.Lon, ctx, |
01ba06da8f46
Factored repojection of coordinates to own logic as we need it to reproject the
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
761
diff
changeset
|
27 ); err != nil { |
753
e6f8d58434f4
Added stub for octree based cross sections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
28 return nil, err |
e6f8d58434f4
Added stub for octree based cross sections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
29 } |
e6f8d58434f4
Added stub for octree based cross sections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
30 } |
e6f8d58434f4
Added stub for octree based cross sections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
31 return dst, nil |
e6f8d58434f4
Added stub for octree based cross sections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
32 } |
e6f8d58434f4
Added stub for octree based cross sections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
33 |
763
d05bc3e34338
More infrastructure for the octree driven cross section endpoint.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
762
diff
changeset
|
34 func projectBack( |
d05bc3e34338
More infrastructure for the octree driven cross section endpoint.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
762
diff
changeset
|
35 rp *models.Reprojector, |
d05bc3e34338
More infrastructure for the octree driven cross section endpoint.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
762
diff
changeset
|
36 lines octree.MultiLineStringZ, |
d05bc3e34338
More infrastructure for the octree driven cross section endpoint.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
762
diff
changeset
|
37 ctx context.Context, |
d05bc3e34338
More infrastructure for the octree driven cross section endpoint.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
762
diff
changeset
|
38 ) (models.GeoJSONMultiLineCoordinatesZ, error) { |
766
afc635ab9f5b
Project the result data of the cross sections which are calculated in UTM back to WGS84.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
763
diff
changeset
|
39 |
afc635ab9f5b
Project the result data of the cross sections which are calculated in UTM back to WGS84.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
763
diff
changeset
|
40 out := make(models.GeoJSONMultiLineCoordinatesZ, len(lines)) |
afc635ab9f5b
Project the result data of the cross sections which are calculated in UTM back to WGS84.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
763
diff
changeset
|
41 |
afc635ab9f5b
Project the result data of the cross sections which are calculated in UTM back to WGS84.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
763
diff
changeset
|
42 for i, segment := range lines { |
afc635ab9f5b
Project the result data of the cross sections which are calculated in UTM back to WGS84.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
763
diff
changeset
|
43 |
afc635ab9f5b
Project the result data of the cross sections which are calculated in UTM back to WGS84.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
763
diff
changeset
|
44 coords := make(models.GeoJSONLineCoordinatesZ, len(segment)) |
afc635ab9f5b
Project the result data of the cross sections which are calculated in UTM back to WGS84.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
763
diff
changeset
|
45 out[i] = coords |
afc635ab9f5b
Project the result data of the cross sections which are calculated in UTM back to WGS84.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
763
diff
changeset
|
46 for j, v := range segment { |
afc635ab9f5b
Project the result data of the cross sections which are calculated in UTM back to WGS84.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
763
diff
changeset
|
47 lat, lon, err := rp.Reproject(v.X, v.Y, ctx) |
afc635ab9f5b
Project the result data of the cross sections which are calculated in UTM back to WGS84.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
763
diff
changeset
|
48 if err != nil { |
afc635ab9f5b
Project the result data of the cross sections which are calculated in UTM back to WGS84.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
763
diff
changeset
|
49 return nil, err |
afc635ab9f5b
Project the result data of the cross sections which are calculated in UTM back to WGS84.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
763
diff
changeset
|
50 } |
afc635ab9f5b
Project the result data of the cross sections which are calculated in UTM back to WGS84.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
763
diff
changeset
|
51 coords[j] = models.GeoJSONCoordinateZ{Lat: lat, Lon: lon, Z: v.Z} |
afc635ab9f5b
Project the result data of the cross sections which are calculated in UTM back to WGS84.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
763
diff
changeset
|
52 } |
afc635ab9f5b
Project the result data of the cross sections which are calculated in UTM back to WGS84.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
763
diff
changeset
|
53 } |
afc635ab9f5b
Project the result data of the cross sections which are calculated in UTM back to WGS84.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
763
diff
changeset
|
54 return out, nil |
763
d05bc3e34338
More infrastructure for the octree driven cross section endpoint.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
762
diff
changeset
|
55 } |
d05bc3e34338
More infrastructure for the octree driven cross section endpoint.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
762
diff
changeset
|
56 |
753
e6f8d58434f4
Added stub for octree based cross sections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
57 func octreeCrossSection( |
e6f8d58434f4
Added stub for octree based cross sections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
58 input interface{}, |
e6f8d58434f4
Added stub for octree based cross sections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
59 req *http.Request, |
e6f8d58434f4
Added stub for octree based cross sections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
60 conn *sql.Conn, |
e6f8d58434f4
Added stub for octree based cross sections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
61 ) (jr JSONResult, err error) { |
e6f8d58434f4
Added stub for octree based cross sections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
62 |
e6f8d58434f4
Added stub for octree based cross sections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
63 csi := input.(*models.CrossSectionInput) |
e6f8d58434f4
Added stub for octree based cross sections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
64 |
e6f8d58434f4
Added stub for octree based cross sections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
65 start := time.Now() |
e6f8d58434f4
Added stub for octree based cross sections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
66 |
e6f8d58434f4
Added stub for octree based cross sections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
67 tree, err := octree.Cache.Get( |
e6f8d58434f4
Added stub for octree based cross sections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
68 csi.Properties.Bottleneck, csi.Properties.Date.Time, |
e6f8d58434f4
Added stub for octree based cross sections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
69 conn, req.Context()) |
e6f8d58434f4
Added stub for octree based cross sections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
70 |
e6f8d58434f4
Added stub for octree based cross sections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
71 log.Printf("loading octree took: %s\n", time.Since(start)) |
e6f8d58434f4
Added stub for octree based cross sections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
72 if err != nil { |
e6f8d58434f4
Added stub for octree based cross sections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
73 return |
e6f8d58434f4
Added stub for octree based cross sections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
74 } |
e6f8d58434f4
Added stub for octree based cross sections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
75 |
e6f8d58434f4
Added stub for octree based cross sections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
76 // The coordinate system of the octree is an UTM projection. |
e6f8d58434f4
Added stub for octree based cross sections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
77 // The input coordinates are in WGS84. |
e6f8d58434f4
Added stub for octree based cross sections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
78 // So we need to reproject them. |
e6f8d58434f4
Added stub for octree based cross sections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
79 |
e6f8d58434f4
Added stub for octree based cross sections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
80 start = time.Now() |
e6f8d58434f4
Added stub for octree based cross sections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
81 |
762
01ba06da8f46
Factored repojection of coordinates to own logic as we need it to reproject the
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
761
diff
changeset
|
82 var rp *models.Reprojector |
01ba06da8f46
Factored repojection of coordinates to own logic as we need it to reproject the
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
761
diff
changeset
|
83 if rp, err = models.NewReprojector( |
753
e6f8d58434f4
Added stub for octree based cross sections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
84 conn, req.Context(), |
766
afc635ab9f5b
Project the result data of the cross sections which are calculated in UTM back to WGS84.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
763
diff
changeset
|
85 WGS84, tree.EPSG, |
762
01ba06da8f46
Factored repojection of coordinates to own logic as we need it to reproject the
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
761
diff
changeset
|
86 ); err != nil { |
01ba06da8f46
Factored repojection of coordinates to own logic as we need it to reproject the
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
761
diff
changeset
|
87 return |
01ba06da8f46
Factored repojection of coordinates to own logic as we need it to reproject the
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
761
diff
changeset
|
88 } |
01ba06da8f46
Factored repojection of coordinates to own logic as we need it to reproject the
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
761
diff
changeset
|
89 defer rp.Close() |
01ba06da8f46
Factored repojection of coordinates to own logic as we need it to reproject the
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
761
diff
changeset
|
90 |
01ba06da8f46
Factored repojection of coordinates to own logic as we need it to reproject the
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
761
diff
changeset
|
91 coords, err := reproject(rp, csi.Geometry.Coordinates, req.Context()) |
753
e6f8d58434f4
Added stub for octree based cross sections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
92 |
e6f8d58434f4
Added stub for octree based cross sections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
93 log.Printf("transforming input coords took: %s\n", time.Since(start)) |
e6f8d58434f4
Added stub for octree based cross sections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
94 if err != nil { |
e6f8d58434f4
Added stub for octree based cross sections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
95 return |
e6f8d58434f4
Added stub for octree based cross sections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
96 } |
e6f8d58434f4
Added stub for octree based cross sections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
97 |
763
d05bc3e34338
More infrastructure for the octree driven cross section endpoint.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
762
diff
changeset
|
98 start = time.Now() |
d05bc3e34338
More infrastructure for the octree driven cross section endpoint.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
762
diff
changeset
|
99 |
d05bc3e34338
More infrastructure for the octree driven cross section endpoint.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
762
diff
changeset
|
100 var segments octree.MultiLineStringZ |
d05bc3e34338
More infrastructure for the octree driven cross section endpoint.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
762
diff
changeset
|
101 |
753
e6f8d58434f4
Added stub for octree based cross sections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
102 for i := 0; i < len(coords)-1; i++ { |
756
5e14000829d1
Complete vertical octree traversal. Seems not very selective.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
755
diff
changeset
|
103 c1 := &coords[i] |
5e14000829d1
Complete vertical octree traversal. Seems not very selective.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
755
diff
changeset
|
104 c2 := &coords[i+1] |
763
d05bc3e34338
More infrastructure for the octree driven cross section endpoint.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
762
diff
changeset
|
105 |
787
3d927e06b92c
Triangle intersection. WIP. Currently interpolation is messed up.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
766
diff
changeset
|
106 verticalLine := octree.NewVerticalLine(c1.Lat, c1.Lon, c2.Lat, c2.Lon) |
3d927e06b92c
Triangle intersection. WIP. Currently interpolation is messed up.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
766
diff
changeset
|
107 |
763
d05bc3e34338
More infrastructure for the octree driven cross section endpoint.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
762
diff
changeset
|
108 var line octree.MultiLineStringZ |
d05bc3e34338
More infrastructure for the octree driven cross section endpoint.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
762
diff
changeset
|
109 tree.Vertical(c1.Lat, c1.Lon, c2.Lat, c2.Lon, func(t *octree.Triangle) { |
787
3d927e06b92c
Triangle intersection. WIP. Currently interpolation is messed up.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
766
diff
changeset
|
110 if ls := verticalLine.Intersection(t); len(ls) > 0 { |
763
d05bc3e34338
More infrastructure for the octree driven cross section endpoint.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
762
diff
changeset
|
111 line = append(line) |
d05bc3e34338
More infrastructure for the octree driven cross section endpoint.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
762
diff
changeset
|
112 } |
756
5e14000829d1
Complete vertical octree traversal. Seems not very selective.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
755
diff
changeset
|
113 }) |
763
d05bc3e34338
More infrastructure for the octree driven cross section endpoint.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
762
diff
changeset
|
114 |
d05bc3e34338
More infrastructure for the octree driven cross section endpoint.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
762
diff
changeset
|
115 if len(line) > 0 { |
d05bc3e34338
More infrastructure for the octree driven cross section endpoint.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
762
diff
changeset
|
116 // They are all on the segment (c1.Lat, c1.Lon) - (c2.Lat, c2.Lon). |
d05bc3e34338
More infrastructure for the octree driven cross section endpoint.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
762
diff
changeset
|
117 // Sort them by project them on this line. |
d05bc3e34338
More infrastructure for the octree driven cross section endpoint.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
762
diff
changeset
|
118 segments = append(segments, line.JoinOnLine(c1.Lat, c1.Lon, c2.Lat, c2.Lon)...) |
d05bc3e34338
More infrastructure for the octree driven cross section endpoint.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
762
diff
changeset
|
119 } |
d05bc3e34338
More infrastructure for the octree driven cross section endpoint.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
762
diff
changeset
|
120 |
d05bc3e34338
More infrastructure for the octree driven cross section endpoint.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
762
diff
changeset
|
121 } |
d05bc3e34338
More infrastructure for the octree driven cross section endpoint.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
762
diff
changeset
|
122 log.Printf("octree traversal took: %s\n", time.Since(start)) |
766
afc635ab9f5b
Project the result data of the cross sections which are calculated in UTM back to WGS84.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
763
diff
changeset
|
123 |
afc635ab9f5b
Project the result data of the cross sections which are calculated in UTM back to WGS84.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
763
diff
changeset
|
124 // The result have to be WGS84. So project the result back. |
763
d05bc3e34338
More infrastructure for the octree driven cross section endpoint.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
762
diff
changeset
|
125 start = time.Now() |
d05bc3e34338
More infrastructure for the octree driven cross section endpoint.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
762
diff
changeset
|
126 |
766
afc635ab9f5b
Project the result data of the cross sections which are calculated in UTM back to WGS84.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
763
diff
changeset
|
127 rp.FromEPSG, rp.ToEPSG = tree.EPSG, WGS84 |
afc635ab9f5b
Project the result data of the cross sections which are calculated in UTM back to WGS84.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
763
diff
changeset
|
128 |
763
d05bc3e34338
More infrastructure for the octree driven cross section endpoint.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
762
diff
changeset
|
129 var joined models.GeoJSONMultiLineCoordinatesZ |
d05bc3e34338
More infrastructure for the octree driven cross section endpoint.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
762
diff
changeset
|
130 joined, err = projectBack(rp, segments, req.Context()) |
d05bc3e34338
More infrastructure for the octree driven cross section endpoint.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
762
diff
changeset
|
131 |
d05bc3e34338
More infrastructure for the octree driven cross section endpoint.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
762
diff
changeset
|
132 log.Printf("projecting back took: %s\n", time.Since(start)) |
d05bc3e34338
More infrastructure for the octree driven cross section endpoint.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
762
diff
changeset
|
133 if err != nil { |
d05bc3e34338
More infrastructure for the octree driven cross section endpoint.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
762
diff
changeset
|
134 return |
d05bc3e34338
More infrastructure for the octree driven cross section endpoint.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
762
diff
changeset
|
135 } |
d05bc3e34338
More infrastructure for the octree driven cross section endpoint.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
762
diff
changeset
|
136 |
d05bc3e34338
More infrastructure for the octree driven cross section endpoint.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
762
diff
changeset
|
137 jr = JSONResult{ |
d05bc3e34338
More infrastructure for the octree driven cross section endpoint.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
762
diff
changeset
|
138 Result: &models.CrossSectionOutput{ |
d05bc3e34338
More infrastructure for the octree driven cross section endpoint.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
762
diff
changeset
|
139 Type: "Feature", |
d05bc3e34338
More infrastructure for the octree driven cross section endpoint.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
762
diff
changeset
|
140 Geometry: models.CrossSectionOutputGeometry{ |
d05bc3e34338
More infrastructure for the octree driven cross section endpoint.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
762
diff
changeset
|
141 Type: "MultiLineString", |
d05bc3e34338
More infrastructure for the octree driven cross section endpoint.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
762
diff
changeset
|
142 Coordinates: joined, |
d05bc3e34338
More infrastructure for the octree driven cross section endpoint.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
762
diff
changeset
|
143 }, |
d05bc3e34338
More infrastructure for the octree driven cross section endpoint.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
762
diff
changeset
|
144 Properties: map[string]interface{}{}, |
d05bc3e34338
More infrastructure for the octree driven cross section endpoint.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
762
diff
changeset
|
145 }, |
753
e6f8d58434f4
Added stub for octree based cross sections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
146 } |
e6f8d58434f4
Added stub for octree based cross sections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
147 |
e6f8d58434f4
Added stub for octree based cross sections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
148 return |
e6f8d58434f4
Added stub for octree based cross sections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
149 } |