Mercurial > gemma
changeset 921:52cb0b82b490
Simplify contour lines on storage
Simplifying with a tolerance of 0.1 m can significantly reduce
storage requirements and improve performance of a WMS on top of the
results without visible losses for high resolution data.
author | Tom Gottfried <tom@intevation.de> |
---|---|
date | Thu, 04 Oct 2018 18:53:22 +0200 |
parents | 862cc5ba4d1d |
children | 1334756abb72 |
files | cmd/octree2contour/main.go cmd/octree2contour/store.go |
diffstat | 2 files changed, 9 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/cmd/octree2contour/main.go Thu Oct 04 17:46:59 2018 +0200 +++ b/cmd/octree2contour/main.go Thu Oct 04 18:53:22 2018 +0200 @@ -13,7 +13,8 @@ var ( one = flag.Bool("o", false, "create only a single contour") - step = flag.Float64("s", 0.5, "step with") + step = flag.Float64("s", 0.5, "step width") + tol = flag.Float64("t", 0.1, "tolerance for simplification") max = flag.Float64("m", 10, "max height from lowest point") bottleneck = flag.String("bottleneck", "", "bottleneck id") date = flag.String("date", "", "date info") @@ -111,7 +112,7 @@ all := process(tree) log.Printf("processing took: %v\n", time.Since(start)) start = time.Now() - if err = store(all, tree.EPSG, *bottleneck, dateInfo); err != nil { + if err = store(all, tree.EPSG, *bottleneck, dateInfo, *tol); err != nil { log.Printf("error: %v\n", err) } log.Printf("storing took: %v\n", time.Since(start))
--- a/cmd/octree2contour/store.go Thu Oct 04 17:46:59 2018 +0200 +++ b/cmd/octree2contour/store.go Thu Oct 04 18:53:22 2018 +0200 @@ -30,7 +30,10 @@ ST_CollectionExtract( ST_Intersection( ST_Transform(sr.area::geometry, $3::integer), - ST_LineMerge(ST_Force2D(ST_GeomFromWKB($2, $3::integer))) + ST_SimplifyPreserveTopology( + ST_LineMerge(ST_Force2D(ST_GeomFromWKB($2, $3::integer))), + $6 + ) ), 2 ) @@ -45,6 +48,7 @@ func store( all []result, epsg uint32, bottleneck string, date time.Time, + tol float64, ) error { return run(func(db *sql.DB) error { @@ -68,6 +72,7 @@ if _, err := stmt.Exec( r.h, r.lines.AsWKB(), epsg, bottleneck, date, + tol, ); err != nil { return err }