Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix project areas layer #1698

Merged
merged 1 commit into from
Aug 23, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions src/planscape/martin/sql/martin_project_areas_by_scenario.sql
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,23 @@ CREATE OR REPLACE FUNCTION martin_project_areas_by_scenario(z integer, x integer
RETURNS bytea AS $$
DECLARE
p_mvt bytea;
p_intersecting_area geometry;
p_stand_size varchar;
BEGIN

SELECT INTO p_mvt ST_AsMVT(tile, 'project_areas_by_scenario', 4096, 'geom') FROM (

SELECT
pa.id as "id",
pa.scenario_id as "scenario_id",
pa.scenario_id::int as "scenario_id",
pa.name,
COALESCE(pa.data, '{}'::jsonb) ->> 'treatment_rank' as "rank",
ST_AsMVTGeom(
ST_Transform(pa.geometry, 3857),
ST_TileEnvelope(z, x, y),
4096, 64, true) AS geom
FROM stands_stand ss
FROM planning_projectarea pa
WHERE
pa.deleted_at is NULL AND
pa.scenario_id = (query_params::jsonb)->>'scenario_id' AND
pa.scenario_id = (query_params->>'scenario_id')::int AND
pa.geometry && ST_Transform(ST_TileEnvelope(z, x, y, margin => (64.0 / 4096)), 4269)
) as tile WHERE geom IS NOT NULL;

Expand Down
Loading