Mercurial > gemma
view cmd/srsimplify/main.go @ 4325:124a5a7fe8d6
enchange wms styling
* Enable opacity in SLD templates by splitting the corresponding
`_fill` value. The place of the change is in the handlers which are
specfic to geoserver templates. Adding it there keeps the way how opacity
is styled consistent with WFS styles towards the default values
in the database and the client.
author | Bernhard Reiter <bernhard@intevation.de> |
---|---|
date | Wed, 04 Sep 2019 15:30:08 +0200 |
parents | 545304d3ff93 |
children |
line wrap: on
line source
// This is Free Software under GNU Affero General Public License v >= 3.0 // without warranty, see README.md and license for details. // // SPDX-License-Identifier: AGPL-3.0-or-later // License-Filename: LICENSES/AGPL-3.0.txt // // Copyright (C) 2019 by via donau // – Österreichische Wasserstraßen-Gesellschaft mbH // Software engineering by Intevation GmbH // // Author(s): // * Sascha L. Teichmann <sascha.teichmann@intevation.de> package main import ( "bufio" "flag" "fmt" "io" "log" "os" "strconv" "strings" "gemma.intevation.de/gemma/pkg/octree" ) func loadXYZ(r io.Reader) (octree.MultiPointZ, error) { scanner := bufio.NewScanner(r) points := make(octree.MultiPointZ, 0, 2000000) var x, y, z float64 var err error for scanner.Scan() { line := strings.TrimSpace(scanner.Text()) if len(line) == 0 || strings.HasPrefix(line, "#") { continue } parts := strings.SplitN(line, " ", 3) if len(parts) != 3 { continue } if x, err = strconv.ParseFloat(parts[0], 64); err != nil { return nil, err } if y, err = strconv.ParseFloat(parts[1], 64); err != nil { return nil, err } if z, err = strconv.ParseFloat(parts[2], 64); err != nil { return nil, err } points = append(points, octree.Vertex{X: x, Y: y, Z: z}) } return points, nil } func storeXYZ(points octree.MultiPointZ, w io.Writer) error { out := bufio.NewWriter(w) for i := range points { fmt.Fprintf(out, "%.5f,%.5f,%.5f\n", points[i].X, points[i].Y, points[i].Z) } return out.Flush() } func main() { var tolerance float64 flag.Float64Var(&tolerance, "t", 0.1, "accepted tolerance (shorthand)") flag.Float64Var(&tolerance, "tolerance", 0.1, "accepted tolerance") flag.Parse() points, err := loadXYZ(os.Stdin) if err != nil { log.Fatalf("err: %v\n", err) } points = points.Simplify(tolerance) if err := storeXYZ(points, os.Stdout); err != nil { log.Fatalf("err: %v\n", err) } }