Mercurial > gemma
changeset 1182:936dd3714325
cross sections: As the triangles in the octree are already clipped against the area
of the soundind result there is no need to clip the cross section result against
this area.
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Thu, 15 Nov 2018 15:50:02 +0100 |
parents | 1335e088e7ef |
children | 1d4801145a2d |
files | pkg/controllers/cross.go |
diffstat | 1 files changed, 7 insertions(+), 37 deletions(-) [+] |
line wrap: on
line diff
--- a/pkg/controllers/cross.go Thu Nov 15 13:47:04 2018 +0100 +++ b/pkg/controllers/cross.go Thu Nov 15 15:50:02 2018 +0100 @@ -45,50 +45,21 @@ return dst, nil } -func projectBack( - rp *models.Reprojector, - lines octree.MultiLineStringZ, - ctx context.Context, -) (models.GeoJSONMultiLineCoordinatesZ, error) { - - out := make(models.GeoJSONMultiLineCoordinatesZ, len(lines)) - - for i, segment := range lines { +const projectBackSQL = ` +SELECT ST_AsBinary( + ST_Transform(ST_GeomFromWKB($2, $1::integer), 4326))` - coords := make(models.GeoJSONLineCoordinatesZ, len(segment)) - out[i] = coords - for j, v := range segment { - lat, lon, err := rp.Reproject(v.X, v.Y, ctx) - if err != nil { - return nil, err - } - coords[j] = models.GeoJSONCoordinateZ{Lat: lat, Lon: lon, Z: v.Z} - } - } - return out, nil -} - -const clipSQL = ` -SELECT ST_AsBinary(ST_Transform(ST_Multi(ST_Intersection( - ST_Transform(area::geometry, $1::integer), - ST_GeomFromWKB($2, $1::integer))), 4326)) -FROM waterway.sounding_results -WHERE bottleneck_id = $3 AND date_info = $4::date` - -func clipAgainstArea( +func projectBack( line octree.MultiLineStringZ, epsg uint32, - bottleneck string, - dateInfo time.Time, conn *sql.Conn, ctx context.Context, ) (models.GeoJSONMultiLineCoordinatesZ, error) { var mls models.GeoJSONMultiLineCoordinatesZ err := conn.QueryRowContext( - ctx, clipSQL, + ctx, projectBackSQL, epsg, line.AsWKB(), - bottleneck, dateInfo, ).Scan(&mls) return mls, err @@ -177,13 +148,12 @@ start = time.Now() var joined models.GeoJSONMultiLineCoordinatesZ - joined, err = clipAgainstArea( + joined, err = projectBack( segments, tree.EPSG, - csi.Properties.Bottleneck, csi.Properties.Date.Time, conn, req.Context(), ) - log.Printf("clipping and projecting back took: %s\n", time.Since(start)) + log.Printf("projecting back took: %s\n", time.Since(start)) if err != nil { return }