diff pkg/octree/contours.go @ 977:4a2ca0e20006

Fixed build error. Copied file to the wrong place and said 'go build' to another wrong place. Argh.
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Thu, 18 Oct 2018 17:30:53 +0200
parents c397fdd8c327
children a244b18cb916
line wrap: on
line diff
--- a/pkg/octree/contours.go	Thu Oct 18 17:05:54 2018 +0200
+++ b/pkg/octree/contours.go	Thu Oct 18 17:30:53 2018 +0200
@@ -1,73 +1,18 @@
 package octree
 
 import (
-	"database/sql"
 	"runtime"
 	"sync"
 )
 
-const (
-	contourStepWidth = 0.5
-	contourTolerance = 0.1
-)
-
-type contourResult struct {
-	height float64
-	lines  MultiLineStringZ
+type ContourResult struct {
+	Height float64
+	Lines  MultiLineStringZ
 }
 
-const (
-	insertContourSQL = `
-INSERT INTO waterway.sounding_results_contour_lines (
-  sounding_result_id,
-  height,
-  lines
-)
-SELECT
-  $1,
-  $2,
-  ST_Transform(
-    ST_Multi(
-      ST_CollectionExtract(
-        ST_Intersection(
-          ST_Transform(sr.area::geometry, $3::integer),
-          ST_SimplifyPreserveTopology(
-            ST_GeomFromWKB($4, $3::integer),
-            $5
-          )
-        ),
-        2
-      )
-    ),
-    4326
-  )
-FROM waterway.sounding_results sr
-WHERE id = $1
-`
-)
+func DoContours(tree *Tree, step float64, store func(*ContourResult)) {
 
-func generateContours(tree *Tree, tx *sql.Tx, id int64) error {
-	stmt, err := tx.Prepare(insertContourSQL)
-	if err != nil {
-		return err
-	}
-	defer stmt.Close()
-
-	doContours(tree, contourStepWidth, func(res *contourResult) {
-		if err == nil {
-			_, err = stmt.Exec(
-				id, res.height, tree.EPSG,
-				res.lines.AsWKB2D(),
-				contourTolerance)
-		}
-	})
-
-	return err
-}
-
-func doContours(tree *Tree, step float64, store func(*contourResult)) {
-
-	results := make(chan *contourResult)
+	results := make(chan *ContourResult)
 	done := make(chan struct{})
 	jobs := make(chan float64)
 
@@ -98,7 +43,7 @@
 func processLevels(
 	tree *Tree,
 	jobs <-chan float64,
-	results chan<- *contourResult,
+	results chan<- *ContourResult,
 	wg *sync.WaitGroup,
 ) {
 	defer wg.Done()
@@ -111,6 +56,6 @@
 			}
 		})
 		lines = lines.Merge()
-		results <- &contourResult{h, lines}
+		results <- &ContourResult{h, lines}
 	}
 }