Skip to content

Commit

Permalink
New feature, Counties (US-GA only)
Browse files Browse the repository at this point in the history
This data is not shown by default and has to be selected in the layer
picker. The county data is taken from cwhelchel/QP-APRS-Tracker
which created geojson from kml county files.
  • Loading branch information
cwhelchel committed Oct 2, 2024
1 parent 8718617 commit 98de6b4
Show file tree
Hide file tree
Showing 5 changed files with 203 additions and 3 deletions.
27 changes: 26 additions & 1 deletion BoundaryLayers.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import VectorSource from 'ol/source/Vector';
import GeoJSON from 'ol/format/GeoJSON'
import LayerGroup from 'ol/layer/Group'
import Collection from 'ol/Collection.js';
import { Icon, Style, Stroke, Fill, Circle } from 'ol/style.js';
import { Icon, Style, Stroke, Fill, Circle, Text } from 'ol/style.js';

import LocData from './LayerData.js'

Expand All @@ -15,6 +15,12 @@ const stroke = new Stroke({
width: 1.25,
});

const countyStroke = new Stroke({
color: 'rgba(176,26,146,0.5)', // #b01a92
width: 1.1,

});

const defaultStyle = [
new Style({
stroke: stroke,
Expand All @@ -41,10 +47,26 @@ const trailStyle = [
}),
];

function createCountyStyle(county) {
const countyStyle = [
new Style({
stroke: countyStroke,
fill: new Fill({ color: 'rgba(176,26,146,0.05)' }),
text: new Text({text: county, stroke: countyStroke})
}),
];

return countyStyle;
}

const trailNames = [
"AT", "NCT NST", "PE NHT", "LC NHT", "MP NHT", "WARO NHT", "TOT NHT", "SAFE NHT"
];

function polygonStyleFunction(feature, resolution) {
return createCountyStyle(feature.get('name'));
}

/**
* Creates all the layers for the app
*
Expand All @@ -71,6 +93,9 @@ export default function initLayers() {
else if (trailNames.includes(obj.title)) {
var s = trailStyle;
}
else if (obj.title.startsWith('Counties')) {
var s = polygonStyleFunction;
}
else {
var s = defaultStyle;
}
Expand Down
1 change: 1 addition & 0 deletions LayerData.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ export default class LocData {
{ title: 'Parks', file: 'parks-US-FL.geojson' },
],
'US-GA': [
{ title: 'Counties', file: 'counties.geojson' },
{ title: 'AT', file: '..\/US-common\/at.geojson' },
{ title: 'TOT NHT', file: '..\/US-common\/tot.geojson' },
{ title: 'GA DNR', file: 'new_dnr20a.geojson' },
Expand Down
10 changes: 8 additions & 2 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,12 @@ function selectLayerGroup(layerGroup) {

// set each child visible
for (let i = 0; i < layerGroup.getLayersArray().length; i++) {
layerGroup.getLayersArray()[i].setProperties({ "visible": true });
let title = layerGroup.getLayersArray()[i].getProperties().title;

// dont auto select counties
if (title != "Counties") {
layerGroup.getLayersArray()[i].setProperties({ "visible": true });
}
}

// refresh redraw panel
Expand All @@ -264,8 +269,9 @@ map.on('pointermove', function (e) {
selected = f;
// only the features w/ pota markers have TITLE
const name = f.get('NAME');
const type = f.get('type');
const ignore = ["Appalachian trail", "PE_NHT", "MP NHT", "LC NHT", "WARO NHT", "NCT_NST", "TOT_NHT", "SAFE_NHT", "accuracy_feat", "pos_feat"]
if (f.get('TITLE') === undefined && !ignore.includes(name)) {
if (f.get('TITLE') === undefined && !ignore.includes(name) && type !== 'county') {
f.setStyle(selectStyle);
map.render();
hoverTitle = selected.get('NAME')
Expand Down
Loading

0 comments on commit 98de6b4

Please sign in to comment.