comparison pkg/imports/wkb.go @ 4313:5da02dcc51f6

shape upload stretch import: Started to decode geometries and attributes from uploaded shape file.
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Tue, 03 Sep 2019 16:54:33 +0200
parents 8b75ac5e243e
children 046a07a33b19
comparison
equal deleted inserted replaced
4312:8926fc81e4de 4313:5da02dcc51f6
51 binary.Write(buf, binary.LittleEndian, math.Float64bits(lat)) 51 binary.Write(buf, binary.LittleEndian, math.Float64bits(lat))
52 binary.Write(buf, binary.LittleEndian, math.Float64bits(lon)) 52 binary.Write(buf, binary.LittleEndian, math.Float64bits(lon))
53 } 53 }
54 54
55 return buf.Bytes() 55 return buf.Bytes()
56 }
57
58 func (ls lineSlice) LinearRingGeom() wkb.LinearRingGeom {
59 lr := make(wkb.LinearRingGeom, len(ls))
60 for i, v := range ls {
61 lr[i].X = v[0]
62 lr[i].Y = v[1]
63 }
64 return lr
56 } 65 }
57 66
58 func (p pointSlice) asWKB() []byte { 67 func (p pointSlice) asWKB() []byte {
59 68
60 size := 1 + 4 + 2*8 69 size := 1 + 4 + 2*8
145 } 154 }
146 out[i] = line 155 out[i] = line
147 } 156 }
148 return out 157 return out
149 } 158 }
159
160 func (ps polygonSlice) MultiPolygonGeom() wkb.MultiPolygonGeom {
161
162 var mp wkb.MultiPolygonGeom
163 var curr wkb.PolygonGeom
164
165 for _, r := range ps {
166 lr := lineSlice(r).LinearRingGeom()
167 // A counter clockwise ring starts a new polygon.
168 if lr.CCW() {
169 if len(curr) > 0 {
170 mp = append(mp, curr)
171 curr = wkb.PolygonGeom{}
172 }
173 }
174 curr = append(curr, lr)
175 }
176
177 if len(curr) > 0 {
178 mp = append(mp, curr)
179 }
180
181 return mp
182 }