Mercurial > gemma
annotate pkg/imports/wkb.go @ 2561:4d5f419a2318
client:pdf-gen: improve box drawing
* handle the case when the rectangle is not rounded (rounding=0)
author | Fadi Abbud <fadi.abbud@intevation.de> |
---|---|
date | Fri, 08 Mar 2019 16:49:40 +0100 |
parents | 63475c8e710e |
children | 8b75ac5e243e |
rev | line source |
---|---|
1785
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
1 // This is Free Software under GNU Affero General Public License v >= 3.0 |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
2 // without warranty, see README.md and license for details. |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
3 // |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
4 // SPDX-License-Identifier: AGPL-3.0-or-later |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
5 // License-Filename: LICENSES/AGPL-3.0.txt |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
6 // |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
7 // Copyright (C) 2018 by via donau |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
8 // – Österreichische Wasserstraßen-Gesellschaft mbH |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
9 // Software engineering by Intevation GmbH |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
10 // |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
11 // Author(s): |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
12 // * Sascha L. Teichmann <sascha.teichmann@intevation.de> |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
13 |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
14 package imports |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
15 |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
16 import ( |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
17 "bytes" |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
18 "encoding/binary" |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
19 "fmt" |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
20 "math" |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
21 |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
22 shp "github.com/jonas-p/go-shp" |
2471
63475c8e710e
Moved WKB constants to own package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1860
diff
changeset
|
23 |
63475c8e710e
Moved WKB constants to own package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1860
diff
changeset
|
24 "gemma.intevation.de/gemma/pkg/wkb" |
1785
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
25 ) |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
26 |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
27 type ( |
1860
f54ac71db1ac
Importer: Added point geoemtry to wkb datatypes.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1786
diff
changeset
|
28 pointSlice []float64 |
1785
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
29 lineSlice [][]float64 |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
30 polygonSlice [][][]float64 |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
31 ) |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
32 |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
33 func (l lineSlice) asWKB() []byte { |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
34 |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
35 size := 1 + 4 + 4 + len(l)*(2*8) |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
36 |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
37 buf := bytes.NewBuffer(make([]byte, 0, size)) |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
38 |
2471
63475c8e710e
Moved WKB constants to own package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1860
diff
changeset
|
39 binary.Write(buf, binary.LittleEndian, wkb.NDR) |
63475c8e710e
Moved WKB constants to own package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1860
diff
changeset
|
40 binary.Write(buf, binary.LittleEndian, wkb.LineString) |
1785
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
41 binary.Write(buf, binary.LittleEndian, uint32(len(l))) |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
42 |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
43 for _, c := range l { |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
44 var lat, lon float64 |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
45 if len(c) > 0 { |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
46 lat = c[0] |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
47 } |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
48 if len(c) > 1 { |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
49 lon = c[1] |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
50 } |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
51 binary.Write(buf, binary.LittleEndian, math.Float64bits(lat)) |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
52 binary.Write(buf, binary.LittleEndian, math.Float64bits(lon)) |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
53 } |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
54 |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
55 return buf.Bytes() |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
56 } |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
57 |
1860
f54ac71db1ac
Importer: Added point geoemtry to wkb datatypes.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1786
diff
changeset
|
58 func (p pointSlice) asWKB() []byte { |
f54ac71db1ac
Importer: Added point geoemtry to wkb datatypes.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1786
diff
changeset
|
59 |
f54ac71db1ac
Importer: Added point geoemtry to wkb datatypes.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1786
diff
changeset
|
60 size := 1 + 4 + 2*8 |
f54ac71db1ac
Importer: Added point geoemtry to wkb datatypes.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1786
diff
changeset
|
61 |
f54ac71db1ac
Importer: Added point geoemtry to wkb datatypes.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1786
diff
changeset
|
62 buf := bytes.NewBuffer(make([]byte, 0, size)) |
f54ac71db1ac
Importer: Added point geoemtry to wkb datatypes.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1786
diff
changeset
|
63 |
2471
63475c8e710e
Moved WKB constants to own package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1860
diff
changeset
|
64 binary.Write(buf, binary.LittleEndian, wkb.NDR) |
63475c8e710e
Moved WKB constants to own package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1860
diff
changeset
|
65 binary.Write(buf, binary.LittleEndian, wkb.Point) |
1860
f54ac71db1ac
Importer: Added point geoemtry to wkb datatypes.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1786
diff
changeset
|
66 |
f54ac71db1ac
Importer: Added point geoemtry to wkb datatypes.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1786
diff
changeset
|
67 var lat, lon float64 |
f54ac71db1ac
Importer: Added point geoemtry to wkb datatypes.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1786
diff
changeset
|
68 if len(p) > 0 { |
f54ac71db1ac
Importer: Added point geoemtry to wkb datatypes.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1786
diff
changeset
|
69 lat = p[0] |
f54ac71db1ac
Importer: Added point geoemtry to wkb datatypes.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1786
diff
changeset
|
70 } |
f54ac71db1ac
Importer: Added point geoemtry to wkb datatypes.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1786
diff
changeset
|
71 if len(p) > 1 { |
f54ac71db1ac
Importer: Added point geoemtry to wkb datatypes.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1786
diff
changeset
|
72 lon = p[1] |
f54ac71db1ac
Importer: Added point geoemtry to wkb datatypes.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1786
diff
changeset
|
73 } |
f54ac71db1ac
Importer: Added point geoemtry to wkb datatypes.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1786
diff
changeset
|
74 binary.Write(buf, binary.LittleEndian, math.Float64bits(lat)) |
f54ac71db1ac
Importer: Added point geoemtry to wkb datatypes.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1786
diff
changeset
|
75 binary.Write(buf, binary.LittleEndian, math.Float64bits(lon)) |
f54ac71db1ac
Importer: Added point geoemtry to wkb datatypes.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1786
diff
changeset
|
76 |
f54ac71db1ac
Importer: Added point geoemtry to wkb datatypes.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1786
diff
changeset
|
77 return buf.Bytes() |
f54ac71db1ac
Importer: Added point geoemtry to wkb datatypes.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1786
diff
changeset
|
78 } |
f54ac71db1ac
Importer: Added point geoemtry to wkb datatypes.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1786
diff
changeset
|
79 |
1785
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
80 func (p polygonSlice) asWKB() []byte { |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
81 if p == nil { |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
82 return nil |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
83 } |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
84 // pre-calculate size to avoid reallocations. |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
85 size := 1 + 4 + 4 |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
86 for _, ring := range p { |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
87 size += 4 + len(ring)*2*8 |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
88 } |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
89 |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
90 buf := bytes.NewBuffer(make([]byte, 0, size)) |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
91 |
2471
63475c8e710e
Moved WKB constants to own package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1860
diff
changeset
|
92 binary.Write(buf, binary.LittleEndian, wkb.NDR) |
63475c8e710e
Moved WKB constants to own package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1860
diff
changeset
|
93 binary.Write(buf, binary.LittleEndian, wkb.Polygon) |
1785
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
94 binary.Write(buf, binary.LittleEndian, uint32(len(p))) |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
95 |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
96 for _, ring := range p { |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
97 binary.Write(buf, binary.LittleEndian, uint32(len(ring))) |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
98 for _, v := range ring { |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
99 var lat, lon float64 |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
100 if len(v) > 0 { |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
101 lat = v[0] |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
102 } |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
103 if len(v) > 1 { |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
104 lon = v[1] |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
105 } |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
106 binary.Write(buf, binary.LittleEndian, math.Float64bits(lat)) |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
107 binary.Write(buf, binary.LittleEndian, math.Float64bits(lon)) |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
108 } |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
109 } |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
110 |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
111 return buf.Bytes() |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
112 } |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
113 |
1786
09349ca27dd7
Imports: Removed duplicated code path to store WKB polygons into database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1785
diff
changeset
|
114 func shapeToPolygon(s shp.Shape) (polygonSlice, error) { |
1785
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
115 switch p := s.(type) { |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
116 case *shp.Polygon: |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
117 return toPolygon(p.NumParts, p.Parts, p.Points), nil |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
118 case *shp.PolygonZ: |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
119 return toPolygon(p.NumParts, p.Parts, p.Points), nil |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
120 case *shp.PolygonM: |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
121 return toPolygon(p.NumParts, p.Parts, p.Points), nil |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
122 } |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
123 return nil, fmt.Errorf("Unsupported shape type %T", s) |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
124 } |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
125 |
1786
09349ca27dd7
Imports: Removed duplicated code path to store WKB polygons into database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1785
diff
changeset
|
126 func toPolygon(numParts int32, parts []int32, points []shp.Point) polygonSlice { |
09349ca27dd7
Imports: Removed duplicated code path to store WKB polygons into database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1785
diff
changeset
|
127 out := make(polygonSlice, numParts) |
1785
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
128 var pos int32 |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
129 |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
130 for i := range out { |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
131 var howMany int32 |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
132 if i+1 >= len(parts) { |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
133 howMany = int32(len(points)) - pos |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
134 } else { |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
135 howMany = parts[i+1] - parts[i] |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
136 } |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
137 |
1786
09349ca27dd7
Imports: Removed duplicated code path to store WKB polygons into database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1785
diff
changeset
|
138 line := make([][]float64, howMany) |
09349ca27dd7
Imports: Removed duplicated code path to store WKB polygons into database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1785
diff
changeset
|
139 vertices := make([]float64, 2*howMany) |
1785
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
140 for j := int32(0); j < howMany; j, pos = j+1, pos+1 { |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
141 p := &points[pos] |
1786
09349ca27dd7
Imports: Removed duplicated code path to store WKB polygons into database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1785
diff
changeset
|
142 vertex := vertices[j*2 : j*2+2] |
09349ca27dd7
Imports: Removed duplicated code path to store WKB polygons into database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1785
diff
changeset
|
143 vertex[0], vertex[1] = p.X, p.Y |
09349ca27dd7
Imports: Removed duplicated code path to store WKB polygons into database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1785
diff
changeset
|
144 line[j] = vertex |
1785
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
145 } |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
146 out[i] = line |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
147 } |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
148 return out |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
149 } |