-
Notifications
You must be signed in to change notification settings - Fork 9
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
Task/zone units frontend #3204
Merged
Merged
Task/zone units frontend #3204
Changes from 12 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
1a0fef2
Point ASA map to pmtiles and change property references
conbrad 26bc25f
Fix test
conbrad 687562d
Front frontend endpoint
conbrad a6b7065
Renaming zones to shapes
conbrad f7af506
Trigger Build
conbrad a03eb75
Trigger Build
conbrad 98ed0be
Merge branch 'main' into task/zone-units-frontend
conbrad fa947bf
Bump dev database cpu limits for sfms processing of zone units
conbrad 21b2031
Migration to compute combustible area of zone units
conbrad a27664a
Merge branch 'main' into task/zone-units-frontend
conbrad 85d6cd9
zone -> shape
conbrad 7924e82
Merge branch 'main' into task/zone-units-frontend
conbrad b82ea4b
Fix alembic graph
conbrad c850200
Merge branch 'task/zone-units-frontend' of github.com:bcgov/wps into …
conbrad File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
66 changes: 66 additions & 0 deletions
66
api/alembic/versions/d5115b761e39_compute_zone_unit_combustible_area.py
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,66 @@ | ||
"""compute zone unit combustible area | ||
|
||
Revision ID: d5115b761e39 | ||
Revises: 5b745fe0bd7a | ||
Create Date: 2023-10-31 12:24:36.889483 | ||
|
||
""" | ||
from alembic import op | ||
import sqlalchemy as sa | ||
import geoalchemy2 | ||
from sqlalchemy.orm.session import Session | ||
from app.auto_spatial_advisory.calculate_combustible_land_area import calculate_combustible_area_by_fire_zone, get_fuel_types_from_object_store | ||
|
||
# revision identifiers, used by Alembic. | ||
revision = 'd5115b761e39' | ||
down_revision = '5b745fe0bd7a' | ||
branch_labels = None | ||
depends_on = None | ||
|
||
shape_type_table = sa.Table('advisory_shape_types', sa.MetaData(), | ||
sa.Column('id', sa.Integer), | ||
sa.Column('name', sa.String)) | ||
|
||
shape_table = sa.Table('advisory_shapes', sa.MetaData(), | ||
sa.Column('id', sa.Integer), | ||
sa.Column('source_identifier', sa.String), | ||
sa.Column('shape_type', sa.Integer), | ||
sa.Column('geom', geoalchemy2.Geometry)) | ||
|
||
|
||
def get_fire_zone_unit_shape_type_id(session: Session): | ||
statement = shape_type_table.select().where(shape_type_table.c.name == 'fire_zone_unit') | ||
result = session.execute(statement).fetchone() | ||
return result.id | ||
|
||
|
||
def get_fire_zone_units(session: Session, fire_zone_type_id: int): | ||
statement = shape_table.select().where(shape_table.c.shape_type == fire_zone_type_id) | ||
result = session.execute(statement).fetchall() | ||
return result | ||
|
||
|
||
def upgrade(): | ||
session = Session(bind=op.get_bind()) | ||
|
||
with get_fuel_types_from_object_store() as fuel_types: | ||
# fetch all fire zones from DB | ||
fire_zone_shape_type_id = get_fire_zone_unit_shape_type_id(session) | ||
zone_units = get_fire_zone_units(session, fire_zone_shape_type_id) | ||
|
||
zone_areas = calculate_combustible_area_by_fire_zone(fuel_types, zone_units) | ||
for tuple in zone_areas: | ||
op.execute('UPDATE advisory_shapes SET combustible_area={} WHERE source_identifier LIKE \'{}\''.format( | ||
tuple[1], tuple[0]) | ||
) | ||
|
||
|
||
def downgrade(): | ||
session = Session(bind=op.get_bind()) | ||
fire_zone_shape_id = get_fire_zone_unit_shape_type_id(session) | ||
zones = get_fire_zone_units(session, fire_zone_shape_id) | ||
|
||
for zone in zones: | ||
op.execute('UPDATE advisory_shapes SET combustible_area = NULL WHERE source_identifier LIKE \'{}\''.format( | ||
str(zone.source_identifier) | ||
)) |
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
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
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
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
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
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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.