comparison pkg/imports/wx.go @ 1795:1333f96f18d0

Waterway axis: Clip features against responsibility area of importing user.
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Mon, 14 Jan 2019 15:19:16 +0100
parents 614c6c766691
children 904c7e853adc
comparison
equal deleted inserted replaced
1794:de4543bfbad5 1795:1333f96f18d0
78 ObjNam string `json:"hydro_objnam"` 78 ObjNam string `json:"hydro_objnam"`
79 NObjNnm *string `json:"hydro_nobjnm"` 79 NObjNnm *string `json:"hydro_nobjnm"`
80 } 80 }
81 81
82 const ( 82 const (
83 deleteWaterwayAxisSQL = `DELETE FROM waterway.waterway_axis` 83 deleteWaterwayAxisSQL = `
84 WITH resp AS (
85 SELECT best_utm(area::geometry) AS t,
86 ST_Transform(area::geometry, best_utm(area::geometry)) AS a
87 FROM users.responsibility_areas
88 WHERE country = users.current_user_country()
89 )
90 DELETE FROM waterway.waterway_axis
91 WHERE ST_Covers(
92 (SELECT a FROM resp),
93 ST_Transform(wtwaxs::geometry, (SELECT t FROM resp)))
94 `
95
84 insertWaterwayAxisSQL = ` 96 insertWaterwayAxisSQL = `
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 )
85 INSERT INTO waterway.waterway_axis (wtwaxs, objnam, nobjnam) 103 INSERT INTO waterway.waterway_axis (wtwaxs, objnam, nobjnam)
86 VALUES ( 104 SELECT ST_Transform(clipped.geom, 4326), $3, $4 FROM (
87 ST_Transform(ST_GeomFromWKB($1, $2::integer), 4326)::geography, 105 SELECT (ST_Dump(
88 $3, 106 ST_Intersection(
89 $4 107 (SELECT a FROM resp),
90 )` 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 `
91 ) 117 )
92 118
93 // Do executes the actual waterway axis import. 119 // Do executes the actual waterway axis import.
94 func (wx *WaterwayAxis) Do( 120 func (wx *WaterwayAxis) Do(
95 ctx context.Context, 121 ctx context.Context,