Skip to content

Commit

Permalink
Merge pull request #398 from bcgov-c/alex/waterlicencedworks
Browse files Browse the repository at this point in the history
migration for licensed works layer
  • Loading branch information
AlexZorkin authored Aug 18, 2020
2 parents 84f8f3c + 2427c29 commit 0c57bd4
Show file tree
Hide file tree
Showing 12 changed files with 202 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
"""add licensed works layer
Revision ID: 369150228f9d
Revises: 603d93ba52ea
Create Date: 2020-08-10 02:52:28.638544
"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = '369150228f9d'
down_revision = '603d93ba52ea'
branch_labels = None
depends_on = None


def upgrade():
op.execute('SET search_path TO metadata')

# populate water_licensed_works info
op.execute("""
WITH ds_id AS (
INSERT INTO data_source (
data_source_id,
data_format_code,
name,
description,
source_url,
source_object_name,
data_table_name,
source_object_id,
create_user, create_date, update_user, update_date, effective_date, expiry_date
) VALUES (
NEXTVAL(pg_get_serial_sequence('data_source','data_source_id')),
'json',
'Water Licensed Works - Lines',
'Province-wide SDE layer showing linear works associated with a Water Licence',
'https://catalogue.data.gov.bc.ca/dataset/water-licensed-works-lines',
'WHSE_WATER_MANAGEMENT.WLS_WATER_LICENCED_WRK_LINE_SP',
'water_licensed_works',
'WATER_LICENCED_WORK_LINE_ID',
'ETL_USER', CURRENT_DATE, 'ETL_USER', CURRENT_DATE, CURRENT_DATE, '9999-12-31T23:59:59Z'
) RETURNING data_source_id
),
wms_id AS (
INSERT INTO wms_catalogue (
wms_catalogue_id,
description,
wms_name,
wms_style,
create_user, create_date, update_user, update_date, effective_date, expiry_date
) VALUES (
(select wms_catalogue_id from wms_catalogue order by wms_catalogue_id desc limit 1) + 1,
'Water Licensed Works - Lines',
'WHSE_WATER_MANAGEMENT.WLS_WATER_LICENCED_WRK_LINE_SP',
'',
'ETL_USER', CURRENT_DATE, 'ETL_USER', CURRENT_DATE, CURRENT_DATE, '9999-12-31T23:59:59Z'
) RETURNING wms_catalogue_id
)
INSERT INTO display_catalogue (
display_data_name,
display_name,
label_column,
label,
highlight_columns,
data_source_id,
wms_catalogue_id,
layer_category_code,
mapbox_layer_id,
mapbox_source_id,
create_user, create_date, update_user, update_date, effective_date, expiry_date
) SELECT
'water_licensed_works',
'Water Licensed Works - Lines',
'WATER_LICENCED_WORK_LINE_ID',
'Work Line ID',
ARRAY[
'WORKS_ID', 'FEATURE_CODE', 'DISPLAY_COLOUR'
],
ds_id.data_source_id,
wms_id.wms_catalogue_id,
'WATER_ADMINISTRATION',
'iit-water.448thhpa',
'iit-water.448thhpa',
'ETL_USER', CURRENT_DATE, 'ETL_USER', CURRENT_DATE, CURRENT_DATE, '9999-12-31T23:59:59Z'
FROM ds_id, wms_id ;
""")

op.execute('SET search_path TO public')



def downgrade():
pass
Binary file added frontend/src/assets/images/lines/conduit.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added frontend/src/assets/images/lines/ditch.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added frontend/src/assets/images/lines/flume.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added frontend/src/assets/images/lines/pipeline.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added frontend/src/assets/images/lines/spillway.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added frontend/src/assets/images/lines/tailrace.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added frontend/src/assets/images/lines/transmission.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
93 changes: 91 additions & 2 deletions frontend/src/components/map/MapLegend.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,23 @@ export default {
try {
mapLayerType = this.map.getLayer(layerID).type

// Add legend items for dashed licensed works layers
if (layerID === 'water_licensed_works') {
for (let i = 0; i < 5; i++) {
let layerName = i === 0 ? layerID : 'water_licensed_works_dash' + i
mapLayerPaint = this.getPaint(mapLayerType, layerName)
legendItems = this.getLegendItems(mapLayerPaint, mapLayerType, layerName)
var layerLegend = {
name: i === 0 ? 'Water Licensed Works - Lines' : '',
legendItems,
'plenty': true,
'className': 'grouped'
}
this.legend.push(layerLegend)
}
return
}

if (mapLayerType !== 'raster') {
mapLayerPaint = this.getPaint(mapLayerType, layerID)
legendItems = this.getLegendItems(mapLayerPaint, mapLayerType, layerID)
Expand Down Expand Up @@ -134,21 +151,22 @@ export default {
global.config.debug && console.log('[wally]', paint.color[i].constructor)
if (paint.color[i].constructor === Array) {
text = this.replaceLabelCode(paint.color[i].join(', '))
let image = this.lineImage(text)
color = paint.color[i + 1]
legendItems.push({
text,
color,
outlineColor: paint.outlineColor,
icon,
iconSize
iconSize,
image
})
}
}
return legendItems
}

// Streams with allocation restrictions

for (let i = 1; i < paint.color.length; i += 2) {
if (paint.color[i].constructor === Array) {
text = this.replaceLabelCode(paint.color[i][2].join(', '))
Expand Down Expand Up @@ -187,10 +205,81 @@ export default {
return 'Active Approvals'
case 'Refuse/Abandoned, Cancelled':
return 'Non-Active Approvals'
// Water Licensed Works
case 'DB25150000':
return 'Accessway'
case 'DB00100000':
return 'Access Road'
case 'EA06100200':
return 'Conduit - Water'
case 'GA08450000':
return 'Dam'
case 'GE09400000':
return 'Dike/Levee/Berm'
case 'GA08800000':
return 'Ditch'
case 'GB09150000':
return 'Dugout'
case 'GA11500000':
return 'Flume'
case 'GA21050000':
return 'Penstock'
case 'EA21400610':
return 'Pipeline - Water'
case 'GB22100000':
return 'Pond'
case 'GA05200200':
return 'Channel-Rearing'
case 'GB22100210':
return 'Pond-Rearing'
case 'GA05200210':
return 'Channel-Release'
case 'GB24300000':
return 'Reservoir'
case 'GB24300120':
return 'Reservoir - Balancing'
case 'DA25050180':
return 'Road (Paved Divided)'
case 'DA25100190':
return 'Road (Paved Undivided)'
case 'PI11500000':
return 'Spawning Channel'
case 'GA28550000':
return 'Spillway'
case 'EA16400110':
return 'Line (Transmission) - Electrical'
case 'GA30350000':
return 'Tailrace'
case 'DB25150000, DB00100000, DA25100190, DA25050180, GB24300120':
return 'Accessway, Access Road, Road (Paved Undivided), Road (Paved Divided), Reservoir - Balancing'
case 'GA21050000, GB22100000, GA05200200, GB22100210':
return 'Penstock, Pond, Channel-Rearing, Pond-Rearing'
default:
return code
}
},
lineImage (name) {
switch (name) {
case 'Conduit - Water':
return 'conduit.png'
case 'Ditch':
return 'ditch.png'
case 'Flume':
return 'flume.png'
case 'Pipeline - Water':
return 'pipeline.png'
case 'Channel-Release':
return 'releasechannel.png'
case 'Spillway':
return 'spillway.png'
case 'Tailrace':
return 'tailrace.png'
case 'Line (Transmission) - Electrical':
return 'transmission.png'
default:
return null
}
},
toggle () {
this.show = !this.show
}
Expand Down
3 changes: 2 additions & 1 deletion frontend/src/components/map/MapLegend.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
<h4 v-if="layer.plenty" :key='i' class="layerName">{{layer.name}}</h4>
<div v-for="(item, j) in layer.legendItems" v-bind:key="`legendItem${j}`" v-bind:class="layer.className">
<div v-if="!item.wmsIconUrl">
<v-icon v-if="!item.wmsIconUrl" :color="item.color" :size="item.iconSize" v-bind:style="{webkitTextStrokeWidth: item.strokeWidth, webkitTextStrokeColor: item.outlineColor}">{{item.icon}}</v-icon>
<v-icon v-if="!item.wmsIconUrl && !item.image" :color="item.color" :size="item.iconSize" v-bind:style="{webkitTextStrokeWidth: item.strokeWidth, webkitTextStrokeColor: item.outlineColor}">{{item.icon}}</v-icon>
<img v-if="item.image" class="" width="20" :src="require(`../../assets/images/lines/` + item.image)"/>
<span class="legendItem" v-if="layer.plenty">{{item.text}}</span>
<span class="layerName" v-else>{{layer.name}}</span>
</div>
Expand Down
14 changes: 13 additions & 1 deletion frontend/src/store/mapStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -247,14 +247,26 @@ export default {

// get list of layers that were deselected (they were in `prev`, but are not in payload),
// and sent an event to remove them.
prev.filter((l) => !selectedLayers.includes(l)).forEach((l) => dispatch('removeMapLayer', l))
prev.filter((l) => !selectedLayers.includes(l)).forEach((l) => {
dispatch('removeMapLayer', l)
if (l === 'water_licensed_works') {
for (let i = 1; i < 5; i++) {
commit('deactivateLayer', 'water_licensed_works_dash' + i)
}
}
})

// similarly, now get a list of layers that are in payload but weren't in the previous active layers.
selectedLayers.filter((l) => !prev.includes(l)).forEach((l) => {
// Customized Metrics - Track when a layer is selected
const layerName = state.mapLayers.find(e => e.display_data_name === l).display_name
window._paq && window._paq.push(['trackEvent', 'Layer', 'Activate Layer', layerName])
commit('activateLayer', l)
if (l === 'water_licensed_works') {
for (let i = 1; i < 5; i++) {
commit('activateLayer', 'water_licensed_works_dash' + i)
}
}
})

// reset the list of active layers
Expand Down

0 comments on commit 0c57bd4

Please sign in to comment.