diff --git a/README.md b/README.md index e3ce9ce..79863e6 100644 --- a/README.md +++ b/README.md @@ -16,6 +16,41 @@ See [sources](https://librarymap.hugh.run/sources). See [contributing](https://librarymap.hugh.run/contributing/), especially *[which files to update](https://librarymap.hugh.run/contributing/#which-files-to-update)*. +## Deployment + +The website for this project uses [git-webhooks](https://git.suboptimal.solutions/hugh/git-webhooks) with a customisation to run the `process.js` file that is found in this repository on each pull. The file is stored with the webhooks files so that everything can be `npm install`ed together. + +This `process.js` file syncs any changes from the csv files into the topojson attributes (e.g. when a library changes their ILS). + +## Updating the topojson + +### Update boundaries + +* make a copy of `/public_library_map/boundaries.geo.json` +* update in `qgis` +* save the copied file + +### Simplify to reduce the file size + +#### Option 1 + +* upload to https://mapshaper.org/ and 'simplify' the boundaries +* download the simplified version +* replace `/public_library_map/boundaries.geo.json` + +#### Option 2 + +```bash +sudo npm install -g mapshaper +mapshaper boundaries.geo.json snap -clean -o force precision=0.0001 format=geojson boundaries.geo.json +``` +### Turn it into `topojson`: + +```bash +sudo npm install -g topojson-server +geo2topo boundaries.geo.json -q 50000 > website/data/boundaries.topo.json +``` + ## Contributors Contributors are listed at [contributors.txt](contributors.txt). diff --git a/process.js b/process.js new file mode 100644 index 0000000..da505f5 --- /dev/null +++ b/process.js @@ -0,0 +1,35 @@ +import csv from 'csv-parser' +import fs from 'fs' + +const data_directory = '/srv/public_library_map/website/data' +// read json file into memory +const mapData = fs.readFileSync(`${data_directory}/boundaries.topo.json`) +let data = JSON.parse(mapData) +let geometries = data.objects['boundaries.geo'].geometries + +// read csv file +// 'data' should be a single line (excl headers) +fs.createReadStream(`${data_directory}/library_services_information.csv`) + .pipe(csv()) + .on('data', (data) => { + for (let feature in geometries) { + if (geometries[feature].properties.name == data.name) { + for (let k in data) { + if (k != "long_name" && k != "") { + geometries[feature].properties[k] = data[k] + } + } + } + } + }) + .on('end', () => { + // write back to object + data.objects['boundaries.geo'].geometries = geometries + // write back to file + try { + fs.writeFileSync(`${data_directory}/boundaries.topo.json`, JSON.stringify(data)) + } catch (err) { + console.err('ERROR writing topo file') + } + console.log('topo updated') + }) diff --git a/website/about/index.html b/website/about/index.html index 3582ce9..3fa27be 100644 --- a/website/about/index.html +++ b/website/about/index.html @@ -23,7 +23,7 @@
I’d love your help to make Library Map as accurate and useful as possible.
help wanted
to see if you can help. Most of these will be to do with updating data, like finding street addresses or other information.librarymap
@hugh
.run
and ask me to fix/add something.help wanted
to see if you can help. Most of these will be to do with updating data, like finding street addresses or other information.librarymap
@hugh
.run
and ask me to open a git.suboptimal.solutions
account for you, or just request that I fix/add something.There is a class outline for an introduction to Git and GitHub aimed at librarians at librarycarpentry.org
. This assumes you are using the command line. If you create or already have a GitHub account, you can also edit files directly in the browser, or use GitHub Desktop - both of which are probably less intimidating options if you don’t have any desire to learn how to use a command line/shell interface, or just want to make a single minor update.
There is a class outline for an introduction to Git and GitHub aimed at librarians at librarycarpentry.org
. This assumes you are using the command line.
To update information about library services (e.g. fines info, loan period etc) you should edit website/data/library_services_information.csv
.
To update information about library locations (e.g. street address, phone number, coordinates) you should edit the relevant csv location file:
+To update information about library services (e.g. fines info, loan period etc) you should edit website/data/library_services_information.csv
.
To update information about library locations (e.g. street address, phone number, coordinates) you should edit the relevant csv location file:
website/data/indigenous_knowledge_centre_locations.csv
website/data/mechanics_institute_locations.csv
Currently we’re missing data for some library services in relation to standard loan periods and fines for overdue items. Any acurate and specific information about fines for South and Western Australia would be particularly helpful.
It’s likely that some library location data is inaccurate — especially for New South Wales. It’s also possible that the address data is wrong (even though the location shown may be correct), and in some cases it is missing.
-It’s possible that some of the fines data for Queensland is a little off. This came from the State Library of Queensland but some of the data was wrong (e.g. Gold Coast Libraries does not charge overdue fines, but the SLQ report says it does).
+It’s possible that some of the fines data for Queensland is a little off. This came from the State Library of Queensland but some of the data was wrong (e.g. Gold Coast Libraries does not charge overdue fines, but the SLQ report says it does).
I am particularly interested if you know of data sources for entire regions, states, or Australia — especially if they’re reliably kept up to date.
If you can fill in any of these blanks, please update the relevant CSV file and send a pull request. If your data is coming from somewhere in particular, you should also add that to sources.md
in the relevant table.