fix: render hazard sounding depths
This commit is contained in:
@@ -301,6 +301,31 @@ function runtimeHazardSymbol(props){
|
||||
if([4,5].includes(watlev))return "OBSTRN03";
|
||||
return "OBSTRN01";
|
||||
}
|
||||
function runtimeHazardDepthText(props){
|
||||
const csp=String((props && props.s52_runtime_csp) || "");
|
||||
const canonical=String((props && props.canonical_object_type) || "");
|
||||
const watlev=runtimeNumber(props,"s52_watlev_code",-9);
|
||||
const hasVal=props && props.least_depth_m!==undefined && props.least_depth_m!==null && props.least_depth_m!=="";
|
||||
if(!hasVal)return "";
|
||||
const valsou=runtimeNumber(props,"least_depth_m",null);
|
||||
if(valsou===null || runtimeHazardIsolated(props))return "";
|
||||
|
||||
let sounding=false;
|
||||
if(csp==="WRECKS02"){
|
||||
sounding=true;
|
||||
}else if(csp==="OBSTRN04"){
|
||||
if(canonical==="underwater_rock"){
|
||||
sounding=!(valsou<=20 && [4,5].includes(watlev));
|
||||
}else{
|
||||
sounding=![1,2].includes(watlev);
|
||||
}
|
||||
}
|
||||
if(!sounding)return "";
|
||||
|
||||
const rounded=Math.round(valsou*10)/10;
|
||||
return Number.isInteger(rounded) ? String(rounded) : rounded.toFixed(1);
|
||||
}
|
||||
|
||||
function refreshRuntimeHazards(){
|
||||
if(!debugRuntimePreview.checked || !leftMap.getSource("cm95") || !leftMap.isSourceLoaded("cm95"))return;
|
||||
const source=leftMap.getSource(RUNTIME_HAZARD_SOURCE_ID);
|
||||
@@ -327,6 +352,8 @@ function refreshRuntimeHazards(){
|
||||
properties:{
|
||||
runtime_symbol:symbol,
|
||||
runtime_csp:csp,
|
||||
runtime_depth_text:runtimeHazardDepthText(props),
|
||||
runtime_depth_m:props.least_depth_m==null?"":String(props.least_depth_m),
|
||||
source_feature_id:feature.id==null?"":String(feature.id)
|
||||
}
|
||||
});
|
||||
@@ -347,7 +374,17 @@ function addRuntimeHazardLayer(map){
|
||||
"icon-image":["get","runtime_symbol"],
|
||||
"icon-size":1,
|
||||
"icon-allow-overlap":true,
|
||||
"icon-ignore-placement":true
|
||||
"icon-ignore-placement":true,
|
||||
"text-field":["get","runtime_depth_text"],
|
||||
"text-size":11,
|
||||
"text-anchor":"center",
|
||||
"text-allow-overlap":true,
|
||||
"text-ignore-placement":true
|
||||
},
|
||||
paint:{
|
||||
"text-color":"#30383b",
|
||||
"text-halo-color":"rgba(216,237,245,0.7)",
|
||||
"text-halo-width":0.35
|
||||
}
|
||||
});
|
||||
setTimeout(refreshRuntimeHazards,0);
|
||||
|
||||
Reference in New Issue
Block a user