comparison pkg/imports/wa.go @ 1796:904c7e853adc

Waterway area import: Clip features against responsibility area.
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Mon, 14 Jan 2019 16:21:31 +0100
parents 09349ca27dd7
children 1ecfcf46e4da
comparison
equal deleted inserted replaced
1795:1333f96f18d0 1796:904c7e853adc
79 Catccl *string `json:"ienc_catccl"` 79 Catccl *string `json:"ienc_catccl"`
80 Dirimp *string `json:"ienc_dirimp"` 80 Dirimp *string `json:"ienc_dirimp"`
81 } 81 }
82 82
83 const ( 83 const (
84 deleteWaterwayAreaSQL = `DELETE FROM waterway.waterway_area` 84 deleteWaterwayAreaSQL = `
85 WITH resp AS (
86 SELECT best_utm(area::geometry) AS t,
87 ST_Transform(area::geometry, best_utm(area::geometry)) AS a
88 FROM users.responsibility_areas
89 WHERE country = users.current_user_country()
90 )
91 DELETE FROM waterway.waterway_area
92 WHERE ST_Covers(
93 (SELECT a FROM resp),
94 ST_Transform(area::geometry, (SELECT t FROM resp)))
95 `
85 insertWaterwayAreaSQL = ` 96 insertWaterwayAreaSQL = `
97 WITH resp AS (
98 SELECT best_utm(area::geometry) AS t,
99 ST_Transform(area::geometry, best_utm(area::geometry)) AS a
100 FROM users.responsibility_areas
101 WHERE country = users.current_user_country()
102 )
86 INSERT INTO waterway.waterway_area (area, catccl, dirimp) 103 INSERT INTO waterway.waterway_area (area, catccl, dirimp)
87 VALUES ( 104 SELECT ST_Transform(clipped.geom, 4326)::geography, $3, $4 FROM (
88 ST_Transform(ST_GeomFromWKB($1, $2::integer), 4326)::geography, 105 SELECT (ST_Dump(
89 $3, 106 ST_Intersection(
90 $4 107 (SELECT a FROM resp),
91 )` 108 ST_Transform(
109 ST_GeomFromWKB($1, $2::integer),
110 (SELECT t FROM resp)
111 )
112 )
113 )).geom AS geom
114 ) AS clipped
115 WHERE clipped.geom IS NOT NULL
116 `
92 ) 117 )
93 118
94 // Do executes the actual waterway axis import. 119 // Do executes the actual waterway axis import.
95 func (wx *WaterwayArea) Do( 120 func (wx *WaterwayArea) Do(
96 ctx context.Context, 121 ctx context.Context,