-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e6ecfff
commit 6530830
Showing
1 changed file
with
41 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
{% test expect_point_to_lie_in_area( | ||
model, | ||
model_point_column_point_geometry, | ||
model_point_column_area_id, | ||
model_area, | ||
model_area_column_id, | ||
model_area_column_area_geometry, | ||
area_buffer_zone | ||
) | ||
%} | ||
WITH areas AS ( | ||
SELECT | ||
{{ model_area_column_id }}, | ||
ST_BUFFER({{ model_area_column_area_geometry }}, {{ area_buffer_zone }}) AS area_geometry_with_buffer | ||
FROM {{ model_area }} | ||
), | ||
|
||
points AS ( | ||
SELECT * | ||
FROM {{ model }} | ||
WHERE {{ model_point_column_point_geometry }} IS NOT NULL | ||
), | ||
|
||
join_areas_on_points AS ( | ||
SELECT | ||
* | ||
FROM | ||
points | ||
JOIN areas | ||
ON points.{{ model_point_column_area_id }} = areas.{{ model_area_column_id }} | ||
) | ||
|
||
SELECT | ||
* | ||
FROM | ||
join_areas_on_points | ||
WHERE | ||
NOT ST_WITHIN({{ model_point_column_point_geometry }}, area_geometry_with_buffer) | ||
|
||
|
||
{% endtest %} |