# HG changeset patch # User Sascha L. Teichmann # Date 1538988890 -7200 # Node ID 9e210b00ace9bddb5a7325ae5f807594ca1e9a88 # Parent 2ebf677fc2e113cc2a33e113116093d86d25ca16# Parent 15bf101e1522d8cc6bdd1167e73de64537128377 Merged default into geo-style branch. diff -r 2ebf677fc2e1 -r 9e210b00ace9 client/src/application/Topbar.vue --- a/client/src/application/Topbar.vue Wed Oct 03 13:08:23 2018 +0200 +++ b/client/src/application/Topbar.vue Mon Oct 08 10:54:50 2018 +0200 @@ -5,13 +5,13 @@
- - + +
- -
    + +
    • {{entry.name}}
    • diff -r 2ebf677fc2e1 -r 9e210b00ace9 client/src/map/Maplayer.vue --- a/client/src/map/Maplayer.vue Wed Oct 03 13:08:23 2018 +0200 +++ b/client/src/map/Maplayer.vue Mon Oct 08 10:54:50 2018 +0200 @@ -295,16 +295,24 @@ // TODOISO call if new survey is selected updateBottleneckFilter(bottleneck_id, datestr) { console.log("updating filter with", bottleneck_id, datestr); - var wmsSrc = this.getLayerByName("Bottleneck isolines").data.getSource(); - // TODOISO check if this works - wmsSrc.updateParams({ - cql_filter: - "date_info='" + - datestr + - "' AND bottleneck_id='" + - bottleneck_id + - "'" - }); + var layer = this.getLayerByName("Bottleneck isolines"); + var wmsSrc = layer.data.getSource(); + + if (bottleneck_id != "does_not_exist") { + wmsSrc.updateParams({ + cql_filter: + "date_info='" + + datestr + + "' AND bottleneck_id='" + + bottleneck_id + + "'" + }); + layer.isVisible = true; + layer.data.setVisible(true); + } else { + layer.isVisible = false; + layer.data.setVisible(false); + } }, onBeforePrint(/* evt */) { // console.log("onBeforePrint(", evt ,")"); diff -r 2ebf677fc2e1 -r 9e210b00ace9 cmd/octree2contour/main.go --- a/cmd/octree2contour/main.go Wed Oct 03 13:08:23 2018 +0200 +++ b/cmd/octree2contour/main.go Mon Oct 08 10:54:50 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)) diff -r 2ebf677fc2e1 -r 9e210b00ace9 cmd/octree2contour/store.go --- a/cmd/octree2contour/store.go Wed Oct 03 13:08:23 2018 +0200 +++ b/cmd/octree2contour/store.go Mon Oct 08 10:54:50 2018 +0200 @@ -26,15 +26,20 @@ sr.id, $1, ST_Transform( - ST_Translate( - ST_Force3D( - ST_CollectionExtract( - ST_Force2D( - ST_Intersection( - ST_Transform(sr.area::geometry, $3::integer), - ST_SetSRID( - ST_GeomFromWKB($2), $3::integer))), 2)), 0.0, 0.0, $1::numeric), - 4326)::geography + ST_Multi( + ST_CollectionExtract( + ST_Intersection( + ST_Transform(sr.area::geometry, $3::integer), + ST_SimplifyPreserveTopology( + ST_LineMerge(ST_GeomFromWKB($2, $3::integer)), + $6 + ) + ), + 2 + ) + ), + 4326 + ) FROM waterway.sounding_results sr WHERE bottleneck_id = $4 AND date_info = $5 ` @@ -43,6 +48,7 @@ func store( all []result, epsg uint32, bottleneck string, date time.Time, + tol float64, ) error { return run(func(db *sql.DB) error { @@ -64,8 +70,9 @@ for _, r := range all { if _, err := stmt.Exec( - r.h, r.lines.AsWKB(), epsg, + r.h, r.lines.AsWKB2D(), epsg, bottleneck, date, + tol, ); err != nil { return err } diff -r 2ebf677fc2e1 -r 9e210b00ace9 pkg/octree/vertex.go --- a/pkg/octree/vertex.go Wed Oct 03 13:08:23 2018 +0200 +++ b/pkg/octree/vertex.go Mon Oct 08 10:54:50 2018 +0200 @@ -39,7 +39,9 @@ const ( wkbNDR byte = 1 + wkbLineString uint32 = 2 wkbLineStringZ uint32 = 1000 + 2 + wkbMultiLineString uint32 = 5 wkbMultiLineStringZ uint32 = 1000 + 5 ) @@ -294,20 +296,53 @@ func (mls MultiLineStringZ) AsWKB() []byte { - var buf bytes.Buffer + // pre-calculate size to avoid reallocations. + size := 1 + 4 + 4 + for _, ml := range mls { + size += 1 + 4 + 4 + len(ml)*3*8 + } - binary.Write(&buf, binary.LittleEndian, wkbNDR) - binary.Write(&buf, binary.LittleEndian, wkbMultiLineStringZ) - binary.Write(&buf, binary.LittleEndian, uint32(len(mls))) + buf := bytes.NewBuffer(make([]byte, 0, size)) + + binary.Write(buf, binary.LittleEndian, wkbNDR) + binary.Write(buf, binary.LittleEndian, wkbMultiLineStringZ) + binary.Write(buf, binary.LittleEndian, uint32(len(mls))) for _, ml := range mls { - binary.Write(&buf, binary.LittleEndian, wkbNDR) - binary.Write(&buf, binary.LittleEndian, wkbLineStringZ) - binary.Write(&buf, binary.LittleEndian, uint32(len(ml))) + binary.Write(buf, binary.LittleEndian, wkbNDR) + binary.Write(buf, binary.LittleEndian, wkbLineStringZ) + binary.Write(buf, binary.LittleEndian, uint32(len(ml))) for _, p := range ml { - binary.Write(&buf, binary.LittleEndian, math.Float64bits(p.X)) - binary.Write(&buf, binary.LittleEndian, math.Float64bits(p.Y)) - binary.Write(&buf, binary.LittleEndian, math.Float64bits(p.Z)) + binary.Write(buf, binary.LittleEndian, math.Float64bits(p.X)) + binary.Write(buf, binary.LittleEndian, math.Float64bits(p.Y)) + binary.Write(buf, binary.LittleEndian, math.Float64bits(p.Z)) + } + } + + return buf.Bytes() +} + +func (mls MultiLineStringZ) AsWKB2D() []byte { + + // pre-calculate size to avoid reallocations. + size := 1 + 4 + 4 + for _, ml := range mls { + size += 1 + 4 + 4 + len(ml)*2*8 + } + + buf := bytes.NewBuffer(make([]byte, 0, size)) + + binary.Write(buf, binary.LittleEndian, wkbNDR) + binary.Write(buf, binary.LittleEndian, wkbMultiLineString) + binary.Write(buf, binary.LittleEndian, uint32(len(mls))) + + for _, ml := range mls { + binary.Write(buf, binary.LittleEndian, wkbNDR) + binary.Write(buf, binary.LittleEndian, wkbLineString) + binary.Write(buf, binary.LittleEndian, uint32(len(ml))) + for _, p := range ml { + binary.Write(buf, binary.LittleEndian, math.Float64bits(p.X)) + binary.Write(buf, binary.LittleEndian, math.Float64bits(p.Y)) } } diff -r 2ebf677fc2e1 -r 9e210b00ace9 schema/gemma.sql --- a/schema/gemma.sql Wed Oct 03 13:08:23 2018 +0200 +++ b/schema/gemma.sql Mon Oct 08 10:54:50 2018 +0200 @@ -402,23 +402,14 @@ bottleneck_id varchar NOT NULL REFERENCES bottlenecks, date_info date NOT NULL, UNIQUE (bottleneck_id, date_info), - area geography(POLYGON, 4326), + area geography(POLYGON, 4326) NOT NULL, surtyp varchar REFERENCES survey_types, coverage varchar REFERENCES coverage_types, depth_reference char(3) NOT NULL REFERENCES depth_references, - point_cloud geography(MULTIPOINTZ, 4326), - -- XXX: We may raster the data later. - -- sounding_data raster NOT NULL, + point_cloud geography(MULTIPOINTZ, 4326) NOT NULL, staging_done boolean NOT NULL DEFAULT false ) - CREATE TABLE meshes ( - sounding_result_id int NOT NULL REFERENCES sounding_results, - geom geometry(polygonz) NOT NULL - ) - - CREATE INDEX meshes_gix ON meshes USING gist(geom) - CREATE TABLE octrees ( sounding_result_id int NOT NULL UNIQUE REFERENCES sounding_results, checksum varchar NOT NULL, @@ -428,7 +419,7 @@ CREATE TABLE sounding_results_contour_lines ( sounding_result_id int NOT NULL REFERENCES sounding_results, height numeric NOT NULL, - lines geography(multilinestringz, 4326) NOT NULL, + lines geography(multilinestring, 4326) NOT NULL, UNIQUE (sounding_result_id, height) ) -- A view to help geoserver serve contour lines. @@ -437,7 +428,7 @@ SELECT bottleneck_id, date_info, height, - CAST(lines AS geometry(multilinestringz, 4326)) AS lines + CAST(lines AS geometry(multilinestring, 4326)) AS lines FROM waterway.sounding_results_contour_lines cl JOIN waterway.sounding_results sr ON sr.id = cl.sounding_result_id