Skip to content

Commit

Permalink
Add 0.25 km buffer around focused area when filtering POIs to include…
Browse files Browse the repository at this point in the history
… things just outside the area that still might be relevant (such as trailheads adjacent to wilderness areas)
  • Loading branch information
quincylvania committed Jul 31, 2024
1 parent 4931d10 commit 1c032e2
Show file tree
Hide file tree
Showing 7 changed files with 88 additions and 6 deletions.
52 changes: 52 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Build and deploy site to GitHub Pages

on:
# Runs on pushes targeting the default branch
push:
branches: ["main"]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
pages: write
id-token: write

# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
concurrency:
group: "pages"
cancel-in-progress: false

jobs:
# Build job
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Pages
uses: actions/configure-pages@v5
- name: Install
run: npm install
- name: Build
run: npm run build
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
# Upload entire repository
path: '.'

# Deployment job
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
needs: build
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.DS_Store
node_modules
package-lock.json
dist
9 changes: 4 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,10 @@ We also collaborate via the [#opentrailmap](https://osmus.slack.com/archives/ope
### Development setup
1. [Clone the repository](https://docs.github.com/en/repositories/creating-and-managing-repositories/cloning-a-repository)
2. Open your terminal and `cd` into the repo's directory
3. Run `node serve.js` to start the development server
4. Visit [http://localhost:4001](http://localhost:4001) in your browser
5. That's it!

OpenTrailMap currently has no package dependencies.
3. Run `npm install` and `npm run build` (first-time setup only)
4. Run `node serve.js` to start the development server
5. Visit [http://localhost:4001](http://localhost:4001) in your browser
6. That's it!

## License

Expand Down
1 change: 1 addition & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ <h1 id="focus-meta" style="display: none;"><span style="flex-basis: 100%;"><span
</div>
<div id="sidebar"></div>
</div>
<script type="application/javascript" src="dist/turf-buffer.js"></script>
<script type="application/javascript" src="js/mapController.js"></script>
<script type="application/javascript" src="js/sidebarController.js"></script>
<script type="application/javascript" src="js/dataController.js"></script>
Expand Down
3 changes: 2 additions & 1 deletion js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -230,14 +230,15 @@ function compositeGeoJson(features) {
coordinates = coordinates.concat(feature.geometry.coordinates);
}
});
return {
var unbuffered = {
type: "Feature",
geometry: {
type: "MultiPolygon",
coordinates: coordinates,
},
properties: features.length ? features[0].properties : {}
};
return coordinates.length ? turfBuffer.buffer(unbuffered, 0.25, {units: 'kilometers'}) : unbuffered;
}

var focusAreaGeoJson;
Expand Down
11 changes: 11 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,18 @@
{
"name": "opentrailmap",
"type": "module",
"version": "0.0.1",
"scripts": {
"build": "rollup --config rollup.config.js",
"serve": "node ./serve.js"
},
"devDependencies": {
"@rollup/plugin-commonjs": "^26.0.1",
"@rollup/plugin-node-resolve": "^15.2.3",
"rollup": "^4.19.1",
"rollup-plugin-polyfill-node": "^0.13.0"
},
"dependencies": {
"@turf/buffer": "^7.0.0"
}
}
17 changes: 17 additions & 0 deletions rollup.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { nodeResolve } from '@rollup/plugin-node-resolve';
import nodePolyfills from 'rollup-plugin-polyfill-node';
import commonjs from '@rollup/plugin-commonjs';

export default {
input: 'node_modules/@turf/buffer/dist/esm/index.js',
output: {
name: 'turfBuffer',
file: 'dist/turf-buffer.js',
format: 'iife',
},
plugins: [
nodeResolve(),
commonjs(),
nodePolyfills(),
]
};

0 comments on commit 1c032e2

Please sign in to comment.