Skip to content

Commit b8226d7

Browse files
committed
Improve UI: add fire icons, let relief be visible under city areas
1 parent 1f2e0f5 commit b8226d7

File tree

3 files changed

+69
-30
lines changed

3 files changed

+69
-30
lines changed

client/renderMap.js

+68-29
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ function showMap(centerX, centerY, zoom, style, opt, source) {
339339
function cityAreasLayer() {
340340
const baseUrl = 'https://tigerweb.geo.census.gov/arcgis/rest/services/TIGERweb/tigerWMS_Current/MapServer' + '/28';
341341
function style(feat) {
342-
const fclr = 'rgba(255,220,255,1.0)';
342+
const fclr = 'rgba(255,220,255,0.4)';
343343
const sclr = 'rgba(155,120,155,1)';
344344
return new ol.style.Style({
345345
fill: new ol.style.Fill({
@@ -360,7 +360,7 @@ function showMap(centerX, centerY, zoom, style, opt, source) {
360360
function unincAreasLayer() {
361361
const baseUrl = 'https://tigerweb.geo.census.gov/arcgis/rest/services/TIGERweb/tigerWMS_Current/MapServer' + '/30';
362362
function style(feat) {
363-
const fclr = 'rgba(255,230,255,1.0)';
363+
const fclr = 'rgba(255,230,255,0.4)';
364364
const sclr = 'rgba(155,130,155,1)';
365365
return new ol.style.Style({
366366
fill: new ol.style.Fill({
@@ -517,8 +517,8 @@ function showMap(centerX, centerY, zoom, style, opt, source) {
517517
topZindex: -50,
518518
},
519519
'Last 12-24 hrs': {
520-
sclr: 'rgba(255,165,0,0.6)',
521-
fclr: 'rgba(255,165,0,0.1)',
520+
sclr: 'rgba(255,255,0,0.6)',
521+
fclr: 'rgba(255,255,0,0.1)',
522522
topZindex: -25,
523523
},
524524
'Last 6-12 hrs': {
@@ -533,32 +533,65 @@ function showMap(centerX, centerY, zoom, style, opt, source) {
533533
},
534534
};
535535

536-
function infraredStyle(time) {
536+
function infraredStyleRect(time) {
537537
const s = infraredStyles[time];
538538
if (!s) {
539539
return null;
540540
}
541541
const sclr = s.sclr;
542542
const fclr = s.fclr;
543543
const topZindex = s.topZindex;
544-
return [
545-
new ol.style.Style({
546-
zIndex: topZindex,
547-
fill: zoom > 12.5 ? null : new ol.style.Fill({
548-
color: fclr,
544+
return function(feat) {
545+
return [
546+
new ol.style.Style({
547+
zIndex: topZindex,
548+
fill: zoom > 12.5 ? null : new ol.style.Fill({
549+
color: fclr,
550+
}),
551+
stroke: new ol.style.Stroke({color: sclr, width: zoom>=12.5 ? 3 : 1, lineDash: [3, 3]}),
549552
}),
550-
stroke: new ol.style.Stroke({color: sclr, width: zoom>=12.5 ? 3 : 1, lineDash: [3, 3]}),
551-
}),
552-
];
553+
];
554+
};
553555
}
554556

555-
const afmStyles = {
556-
'12_to_24hr_fire': infraredStyle('Last 12-24 hrs'),
557-
'06_to_12hr_fire': infraredStyle('Last 6-12 hrs'),
558-
'00_to_06hr_fire': infraredStyle('Active Burning'),
559-
'prev_6_days_fire': infraredStyle('Last 24-48 hrs'),
557+
function infraredStyleIcon(time) {
558+
const s = infraredStyles[time];
559+
if (!s) {
560+
return null;
561+
}
562+
const sclr = s.sclr;
563+
const fclr = s.fclr;
564+
const topZindex = s.topZindex;
565+
return function(feat) {
566+
const c = ol.extent.getCenter(feat.getGeometry().getExtent());
567+
return [
568+
new ol.style.Style({
569+
// latitude bounds here: https://epsg.io/3857
570+
// we want northern items 'behind' southern ones
571+
zIndex: topZindex + (20048966.10-c[1])/(20048966.10*2.0) - 2.1,
572+
fill: zoom > 12.5 ? null : new ol.style.Fill({
573+
color: fclr,
574+
}),
575+
stroke: new ol.style.Stroke({color: sclr, width: zoom>=12.5 ? 3 : 1, lineDash: [3, 3]}),
576+
}),
577+
new ol.style.Style({
578+
geometry: new ol.geom.Point(c),
579+
zIndex: topZindex + (20048966.10-c[1])/(20048966.10*2.0) - 1.1,
580+
image: new ol.style.Icon({src: '/imgs/redfire.png', scale: 1.0/25.0, anchor: [0.5, 0.9]}),
581+
}),
582+
];
583+
};
584+
}
585+
586+
const afmStylesIcons = {
587+
'00_to_06hr_fire': infraredStyleIcon('Active Burning'),
588+
'06_to_12hr_fire': infraredStyleIcon('Last 6-12 hrs'),
589+
'12_to_24hr_fire': infraredStyleRect('Last 12-24 hrs'),
590+
// 'prev_6_days_fire': infraredStyleRect('Last 24-48 hrs'),
560591
};
561592

593+
const afmStyles = afmStylesIcons;
594+
562595
function kmlStyle(sclr, fclr) {
563596
return new ol.style.Style({
564597
fill: new ol.style.Fill({
@@ -577,17 +610,17 @@ function showMap(centerX, centerY, zoom, style, opt, source) {
577610
}),
578611
};
579612

580-
function afmKmlLayer(url) {
613+
function afmKmlLayer(url, type) {
581614
const modisCredit = 'MODIS (RSAC/USFS/NASA)';
582615
const viirsCredit = 'VIIRS I (NASA/NOAA S-NPP)';
583-
const legend = 'Rectangles indicate satellite inferences of ≥1 fire in area (red: ≤12hrs, orange: ≤24hrs, as of the satellite readings which may be hours and days old)';
616+
const legend = 'Rectangles and small fire icons indicate satellite inferences of ≥1 fire in area (red: ≤12hrs, yellow: ≤24hrs, as of the satellite readings which may be hours and days old)';
584617
const afmCredit = 'U.S. Forest Service Active Fire Mapping';
585618

586619
function stylesFunc(feat) {
587620
const name = feat.get('styleUrl');
588621
const parts = name.split('/');
589622
const styleName = parts[parts.length - 1];
590-
return afmStyles[styleName] || null;
623+
return (afmStyles[styleName] || (() => null))(feat);
591624
}
592625
return new ol.layer.Vector({
593626
style: stylesFunc,
@@ -701,10 +734,16 @@ function showMap(centerX, centerY, zoom, style, opt, source) {
701734
'features': events.map(eventFeature),
702735
};
703736
function style(feat) {
704-
return new ol.style.Style({
705-
// text: namedTextStyle(feat),
706-
image: new ol.style.Icon({src: '/imgs/fire.png', color: '#ffffff', scale: 1.0/9.0}),
707-
});
737+
return [
738+
new ol.style.Style({
739+
// text: namedTextStyle(feat),
740+
image: new ol.style.Icon({src: '/imgs/fire.png', color: '#ffffff', scale: 1.0/9.0, anchor: [0.5, 0.9]}),
741+
}),
742+
new ol.style.Style({
743+
// text: namedTextStyle(feat),
744+
image: new ol.style.Icon({src: whiteDot, color: '#ff0000', scale: 1.0/3.0}),
745+
}),
746+
];
708747
}
709748
return new ol.layer.Vector({
710749
source: new ol.source.Vector({
@@ -802,13 +841,13 @@ function showMap(centerX, centerY, zoom, style, opt, source) {
802841
} else if (config === 'Summits') {
803842
return summitsVectorLayer();
804843
} else if (config === 'AFM-MODIS') {
805-
return afmKmlLayer('../kml/modis.kml');
844+
return afmKmlLayer('../kml/modis.kml', 'modis');
806845
} else if (config === 'AFM-VIIRS-I') {
807-
return afmKmlLayer('../kml/viirs-i.kml');
846+
return afmKmlLayer('../kml/viirs-i.kml', 'viirs');
808847
} else if (config === 'AFM-MODIS-AK') {
809-
return afmKmlLayer('../kml/modis-alaska.kml');
848+
return afmKmlLayer('../kml/modis-alaska.kml', 'modis');
810849
} else if (config === 'AFM-VIIRS-I-AK') {
811-
return afmKmlLayer('../kml/viirs-i-alaska.kml');
850+
return afmKmlLayer('../kml/viirs-i-alaska.kml', 'viirs');
812851
} else if (config === 'Events') {
813852
return eventsVectorLayer(events);
814853
}

imgs/redfire.png

18.2 KB
Loading

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
"debug": "node --inspect main.js",
2828
"cleanstart": "yarn clean; node main.js",
2929
"test": "nyc mocha './{,!(node_modules)/**/}test/*.js'",
30-
"e2e-test": "yarn clean && nyc node --inspect main.js run --once --force-update --fail-on-error --max-updates-per-loop=3 --html-snapshots --skip-updates-older-than-hours=48",
30+
"e2e-test": "yarn clean && nyc node main.js run --once --force-update --fail-on-error --max-updates-per-loop=3 --html-snapshots --skip-updates-older-than-hours=48",
3131
"test-coverage": "yarn clean && yarn test && yarn report-coverage",
3232
"e2e-test-coverage-visualdiff": "yarn clean && yarn e2e-test && yarn report-e2e-coverage && yarn report-visualdiff",
3333
"e2e-test-visualdiff": "yarn clean && yarn e2e-test && yarn report-visualdiff",

0 commit comments

Comments
 (0)