comparison pkg/octree/tin.go @ 1692:f4dcbe8941a1

Octree: Resolved the remaing golint issues with this package.
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Mon, 31 Dec 2018 11:13:49 +0100
parents de09bd3b5c05
children 63475c8e710e
comparison
equal deleted inserted replaced
1691:de09bd3b5c05 1692:f4dcbe8941a1
30 var ( 30 var (
31 errNoByteSlice = errors.New("Not a byte slice") 31 errNoByteSlice = errors.New("Not a byte slice")
32 errTooLessPoints = errors.New("Too less points") 32 errTooLessPoints = errors.New("Too less points")
33 ) 33 )
34 34
35 // Tin stores a mesh of triangles with common vertices.
35 type Tin struct { 36 type Tin struct {
36 EPSG uint32 37 // EPSG holds the projection.
37 Vertices []Vertex 38 EPSG uint32
39 // Vertices are the shared vertices.
40 Vertices []Vertex
41 // Triangles are the triangles.
38 Triangles [][]int32 42 Triangles [][]int32
39 43
44 // Min is the lower left corner of the bbox.
40 Min Vertex 45 Min Vertex
46 // Max is the upper right corner of the bbox.
41 Max Vertex 47 Max Vertex
42 } 48 }
43 49
50 // FromWKB constructs the TIN from a WKB representation.
51 // Shared vertices are identified and referenced by the
52 // same index.
44 func (t *Tin) FromWKB(data []byte) error { 53 func (t *Tin) FromWKB(data []byte) error {
45 log.Printf("info: data length %d\n", len(data)) 54 log.Printf("info: data length %d\n", len(data))
46 55
47 r := bytes.NewReader(data) 56 r := bytes.NewReader(data)
48 57
199 WHERE ST_Covers(trans.area, triangles.poly)` 208 WHERE ST_Covers(trans.area, triangles.poly)`
200 209
201 loadTinByIDSQL = tinSQLPrefix + `WHERE id = $2` + tinSQLSuffix 210 loadTinByIDSQL = tinSQLPrefix + `WHERE id = $2` + tinSQLSuffix
202 ) 211 )
203 212
213 // GenerateTinByID generated a TIN by triangulating a point cloud
214 // from the database.
204 func GenerateTinByID( 215 func GenerateTinByID(
205 ctx context.Context, 216 ctx context.Context,
206 conn *sql.Conn, 217 conn *sql.Conn,
207 id int64, 218 id int64,
208 epsg uint32, 219 epsg uint32,
217 } 228 }
218 tin.EPSG = epsg 229 tin.EPSG = epsg
219 return &tin, nil 230 return &tin, nil
220 } 231 }
221 232
233 // Scan implements the sql.Scanner interface.
222 func (t *Tin) Scan(raw interface{}) error { 234 func (t *Tin) Scan(raw interface{}) error {
223 if raw == nil { 235 if raw == nil {
224 return nil 236 return nil
225 } 237 }
226 data, ok := raw.([]byte) 238 data, ok := raw.([]byte)