Mercurial > gemma
diff pkg/mesh/raster.go @ 5601:1222b777f51f
Made golint finally happy.
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Sat, 06 Aug 2022 02:09:57 +0200 |
parents | 5f47eeea988d |
children | d2ccf6bb6940 |
line wrap: on
line diff
--- a/pkg/mesh/raster.go Sat Aug 06 00:46:21 2022 +0200 +++ b/pkg/mesh/raster.go Sat Aug 06 02:09:57 2022 +0200 @@ -26,6 +26,8 @@ "gemma.intevation.de/gemma/pkg/wkb" ) +// Raster represents a 2D cell raster with a given extend. +// The cells are equally sized in X and Y direction. type Raster struct { BBox Box2D CellSize float64 @@ -36,6 +38,8 @@ const noData = -math.MaxFloat64 +// NewRaster creates a new Raster with the given extend +// and cell size. func NewRaster(bbox Box2D, cellSize float64) *Raster { width, height := bbox.Size() @@ -61,6 +65,9 @@ } } +// Rasterize fills the raster with the evaluation data +// received via the given eval function. The cell values +// 4x oversampled, func (r *Raster) Rasterize(eval func(float64, float64) (float64, bool)) { var wg sync.WaitGroup @@ -117,6 +124,9 @@ wg.Wait() } +// Diff updates the cell values of the raster with difference +// of this raster and the values from the gien eval function. +// The data will 4x over-sampled. func (r *Raster) Diff(eval func(float64, float64) (float64, bool)) { var wg sync.WaitGroup @@ -181,6 +191,9 @@ wg.Wait() } +// ZExtent returns the z-range of the raster. +// The last return value is false if the raster +// only consists of no data values. func (r *Raster) ZExtent() (float64, float64, bool) { min, max := math.MaxFloat64, -math.MaxFloat64 for _, v := range r.Cells { @@ -197,6 +210,8 @@ return min, max, min != math.MaxFloat64 } +// Trace generates contour lines of this raster given +// the given class breaks. func (r *Raster) Trace(heights ClassBreaks) []wkb.MultiPolygonGeom { start := time.Now()