57 lines
2.1 KiB
JavaScript
57 lines
2.1 KiB
JavaScript
function replaceUnavailable(value){
|
|
if(value===0) return 0;
|
|
if(value == null || value == NaN || value == "") return "n/a";
|
|
else return value;
|
|
}
|
|
|
|
function generate_custom_overlaygroup(){
|
|
if(!Array.isArray() || OverlayConfig.length >=1){
|
|
console.log("No valid overlay config present.");
|
|
return null;
|
|
}
|
|
|
|
return new ol.layer.Group({
|
|
combine: false,
|
|
title: 'Custom Information',
|
|
zIndex: layerSetZIndexBase['clientoverlay'],
|
|
layers : map(OverlayConfig, function(current_overlay){
|
|
|
|
console.log(current_overlay);
|
|
return new ol.layer.Tile({
|
|
title: 'Ground Infrastructure',
|
|
type: 'tiles',
|
|
opacity: 0.9,
|
|
visible:true,
|
|
extent: ol.proj.transformExtent([12.576354, 41.786571, 12.609483, 41.813856], 'EPSG:4326', 'EPSG:3857'),
|
|
zIndex: layerSetZIndexBase['clientoverlay']+1,
|
|
useInterimTilesOnError:false,
|
|
source: new ol.source.XYZ({
|
|
url: "/overlays/CIA/Ground Infrastructure/{z}/{x}/{-y}.png",
|
|
tilePixelRatio: 1.000000,
|
|
minZoom: 13,
|
|
maxZoom: 18
|
|
}),
|
|
maxResolution: Math.min(
|
|
ol.Sphere.getDistance(
|
|
[ground_infra_overlay_extent[0], ground_infra_overlay_extent[1]],
|
|
[ground_infra_overlay_extent[2], ground_infra_overlay_extent[1]]
|
|
),
|
|
ol.Sphere.getDistance(
|
|
[ground_infra_overlay_extent[0], ground_infra_overlay_extent[1]],
|
|
[ground_infra_overlay_extent[0], ground_infra_overlay_extent[3]]
|
|
)
|
|
)
|
|
}); // end return tile
|
|
}) // end map
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
// https://stackoverflow.com/questions/26246601/wildcard-string-comparison-in-javascript
|
|
// check if str matches against rule (e.g. whether D-ABCD matched D-*)
|
|
function matchRuleShort(str, rule) {
|
|
var escapeRegex = (str) => str.replace(/([.*+?^=!:${}()|\[\]\/\\])/g, "\\$1");
|
|
return new RegExp("^" + rule.split("*").map(escapeRegex).join(".*") + "$").test(str);
|
|
} |