changeset 2473:19beb7d17337 octree-diff

Triangulate and build octree index.
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Tue, 26 Feb 2019 13:02:11 +0100
parents db0e4ab57977
children f3a9e125f630
files cmd/octreediff/main.go
diffstat 1 files changed, 25 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/cmd/octreediff/main.go	Tue Feb 26 12:22:04 2019 +0100
+++ b/cmd/octreediff/main.go	Tue Feb 26 13:02:11 2019 +0100
@@ -45,6 +45,10 @@
   ON sr.bottleneck_id = bn.id
 WHERE bn.bottleneck_id = $1 AND sr.date_info = $2::date
   AND sr.octree_index IS NOT NULL`
+
+	triangulateSQL = `
+SELECT ST_AsBinary(ST_DelaunayTriangles(ST_GeomFromWKB($1, $2::int), 0, 2))
+`
 )
 
 func check(err error) {
@@ -302,6 +306,27 @@
 
 		log.Printf("WKB size %.3fMB\n", float64(len(data))/(1024*1024))
 
+		var tin octree.Tin
+
+		if err := conn.QueryRowContext(
+			ctx,
+			triangulateSQL,
+			data,
+			first.EPSG,
+		).Scan(&tin); err != nil {
+			return err
+		}
+
+		now = time.Now()
+		log.Printf("triangulation took %v\n", now.Sub(last))
+		last = now
+
+		builder := octree.NewBuilder(&tin)
+		builder.Build()
+
+		now = time.Now()
+		log.Printf("building octree took %v\n", now.Sub(last))
+		last = now
 		return nil
 	})
 }