Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions .github/workflows/openanc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: OpenANC – Pages deploy + optional data refresh
on:
push: { branches: [ main ] }
workflow_dispatch: {}
schedule: [ { cron: '0 11 * * 1' } ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with: { python-version: '3.11' }
- name: Install deps (optional)
run: |
python -m pip install -U pip || true
pip install geopandas shapely pyogrio pandas pydantic || true
- name: Refresh data (optional)
run: |
if [ -f scripts/fetch_sources.py ]; then
mkdir -p .cache/raw
python scripts/fetch_sources.py --out .cache/raw || true
fi
if [ -f scripts/transform.py ]; then
python scripts/transform.py .cache/raw data/ || true
fi
if [ -f scripts/validate.py ]; then
python scripts/validate.py data/ --strict || true
fi
- name: Prepare docs
run: |
mkdir -p docs
if [ ! -f docs/index.html ]; then
echo '<!doctype html><meta charset="utf-8"><title>OpenANC</title><h1>OpenANC</h1><p>Site coming soon.</p>' > docs/index.html
fi
- uses: actions/upload-pages-artifact@v3
with: { path: ./docs }
deploy:
needs: build
permissions: { pages: write, id-token: write }
environment: { name: github-pages, url: ${{ steps.deployment.outputs.page_url }} }
runs-on: ubuntu-latest
steps:
- id: deployment
uses: actions/deploy-pages@v4
171 changes: 4 additions & 167 deletions docs/index.html
Original file line number Diff line number Diff line change
@@ -1,167 +1,4 @@
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="map.css">
<title>OpenANC : Map View</title>
<meta charset='utf-8' />
<meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' />

<!-- Pull in the mapbox libraries -->
<script src='https://api.mapbox.com/mapbox-gl-js/v2.15.0/mapbox-gl.js'></script>
<link href='https://api.mapbox.com/mapbox-gl-js/v2.15.0/mapbox-gl.css' rel='stylesheet' />



<!-- Google tag (gtag.js) -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-3V9Z79S3R9"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());

gtag('config', 'G-3V9Z79S3R9');
</script>

</head>


<body>
<a rel="me" href="https://dmv.community/@openanc"></a>

<!-- Set up the geocoder aesthetics and pull in the saved scripts necessary for it to run -->
<script src='https://api.mapbox.com/mapbox-gl-js/plugins/mapbox-gl-geocoder/v5.0.0/mapbox-gl-geocoder.min.js'></script>
<link rel='stylesheet' href='https://api.mapbox.com/mapbox-gl-js/plugins/mapbox-gl-geocoder/v5.0.0/mapbox-gl-geocoder.css' type='text/css' />
<script src="https://cdn.jsdelivr.net/npm/es6-promise@4/dist/es6-promise.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/es6-promise@4/dist/es6-promise.auto.min.js"></script>
<style>
#geocoder-container > div {
min-width:50%;
margin-left:25%;
}
</style>

<!-- Place the map -->
<div id='map'></div>

<!-- Set up the layer toggle menu -->
<div id='menu'>
<strong>OpenANC</strong>
<br/><a href="about.html">About</a>
<br/><a href="list.html">List View</a>
</div>



<!-- Place and title the info box -->
<div class='map-overlay' id='features'>
<div id='pd'><p>Click on the map to see district information
<!-- Add the dybamic district info -->
<div id='districts'>
</div>
</p></div></div>


<script>

// Set up the access token to be used
mapboxgl.accessToken = 'pk.eyJ1IjoiZGV2aW5icmFkeSIsImEiOiJjazB0aWMyb2IwYTJnM2hsb2twZm1namFoIn0.OUOlfILkB77LwrWhj_uqkQ';


// Set up the variables being pulled by the layer toggle menu
var layerList = document.getElementById('menu');
var inputs = layerList.getElementsByTagName('input');


// Set the initial mapbox style to be used
var which_layer = 'mapbox://styles/devinbrady/cl4yg387b000u14msjowbcvcq'

// Create a function that pulls in data from the toggle menu selections and updates the style being used
function switchLayer(layer) {
var layerId = layer.target.id;
map.setStyle('mapbox://styles/devinbrady/' + layerId);
which_layer = ('mapbox://styles/devinbrady/' + layerId);
}

// Create a for loop that lets the toggle memu switches happen repeatedly
for (var i = 0; i < inputs.length; i++) {
inputs[i].onclick = switchLayer;
}

// Pull in the map, using the style specified by the most recent value assigned to the variable which_layer (allSMDs at first, then whatever is selected in the toggle menu by the user)
var map = new mapboxgl.Map({
container: 'map',
style: which_layer
// zoom: 11
});


// wait for map to load before adjusting it
map.on('load', function() {

// make a pointer cursor
map.getCanvas().style.cursor = 'default';

// change info window on click
map.on('click', function (e) {
var districts = map.queryRenderedFeatures(e.point)
if (districts.length > 0) {
document.getElementById('pd').innerHTML = districts[0].properties['map_display_box']
} else {
document.getElementById('pd').innerHTML = '<p>Click on the map to see district information</p>';
}
});

});


const geocoder = new MapboxGeocoder({
accessToken: mapboxgl.accessToken,
mapboxgl: mapboxgl,
placeholder: 'Find an address'
})

geocoder.on('result', function (e) {
// wait until the map has finished flying to the searched point
map.once('moveend', function () {
// add the result as a point in the 'search_point' layer to show up as marker
var geocoder_result = e.result.geometry;

//project to use (pixel xy coordinates instead of lat/lon for WebGL)
var geocoder_point = map.project([e.result.center[0], e.result.center[1]]);

var smd_searched = map.queryRenderedFeatures(geocoder_point, {
layers: ['smd']
});

if (smd_searched.length > 0) {
document.getElementById('pd').innerHTML = smd_searched[0].properties['map_display_box']
} else {
document.getElementById('pd').innerHTML = '<p>Click on the map to see district information</p>';
}

});
});


map.addControl(
geocoder
);



// Add the "Find my location" button to the map
map.addControl(
new mapboxgl.GeolocateControl({
positionOptions: {
enableHighAccuracy: true
},
trackUserLocation: true
})
);


map.addControl(new mapboxgl.NavigationControl());

</script>
</body>
</html>
<!doctype html><meta charset="utf-8">
<title>OpenANC</title>
<h1>OpenANC</h1>
<p>Static site bootstrap. Data + map coming next.</p>
7 changes: 7 additions & 0 deletions scripts/config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
sources:
anc_boundaries: "<ADD_DC_OPEN_DATA_URL>"
smd_boundaries: "<ADD_DC_OPEN_DATA_URL>"
commissioners: "<ADD_OFFICIAL_URL>"
candidates: "<ADD_OFFICIAL_URL>"
output:
data_dir: "data"
1 change: 1 addition & 0 deletions scripts/fetch_sources.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
print("fetch: configure real URLs in scripts/config.yaml; skipping for now")
7 changes: 7 additions & 0 deletions scripts/transform.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import os, json, sys
out = "data"; os.makedirs(out, exist_ok=True)
with open(os.path.join(out, "commissioners.csv"), "w") as f:
f.write("smd,anc,name,email,term_start,term_end\n6B02,6B,Jane Doe,[email protected],2025-01-01,2026-12-31\n")
with open(os.path.join(out, "smds.geojson"), "w") as f:
json.dump({"type":"FeatureCollection","features":[]}, f)
print("transform: wrote placeholder data")
1 change: 1 addition & 0 deletions scripts/validate.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
print("validate: stub (no checks yet)")