Skip to content

Commit

Permalink
Proper fire zone unit label (#3902)
Browse files Browse the repository at this point in the history
  • Loading branch information
dgboss authored Sep 5, 2024
1 parent d2ee27f commit 30f0c07
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion web/src/features/fba/components/map/featureStylers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,9 +150,29 @@ export const getAdvisoryFillColor = (fireShapeStatus: FireShapeStatus) => {
}
}

/**
* Given an OpenLayers feature from the fire zone unit label layer, return a label to display on the map.
* @param feature The feature of interest from the fire zone unit layer.
* @returns A string to be used as a label on the map.
*/
const getFireZoneUnitLabel = (feature: RenderFeature | ol.Feature<Geometry>) => {
const fireZoneId = feature.getProperties().FIRE_ZONE_
let fireZoneUnit = feature.getProperties().FIRE_ZON_1
// Fire zone unit labels sometimes include a geographic place name as a reference. eg. Skeena Zone (Kalum).
// If present, we want to display the geographic location on the second line of the label.
if (fireZoneUnit && fireZoneUnit.indexOf('(') > 0) {
const index = fireZoneUnit.indexOf('(')
const prefix = fireZoneUnit.substring(0, index).trim()
const suffix = fireZoneUnit.substring(index)
fireZoneUnit = `${prefix}\n${suffix}`
}

return `${fireZoneId}-${fireZoneUnit}`
}

export const fireShapeLabelStyler = (selectedFireShape: FireShape | undefined) => {
const a = (feature: RenderFeature | ol.Feature<Geometry>): Style => {
const text = feature.getProperties().FIRE_ZONE.replace(' Fire Zone', '\nFire Zone')
const text = getFireZoneUnitLabel(feature)
const feature_fire_shape_id = feature.getProperties().OBJECTID
const selected =
!isUndefined(selectedFireShape) && feature_fire_shape_id === selectedFireShape.fire_shape_id ? true : false
Expand Down

0 comments on commit 30f0c07

Please sign in to comment.