Giter VIP home page Giter VIP logo

jeancochrane / mellow-bike-map Goto Github PK

View Code? Open in Web Editor NEW
13.0 5.0 5.0 1.25 MB

๐Ÿšฒ Web app and routing API for finding safe, chill bike routes. Like Google Maps if it took you through cozy side streets.

Home Page: https://mellowbikemap.com

License: MIT License

Makefile 0.94% Dockerfile 1.77% Shell 8.54% Python 35.49% CSS 2.85% HTML 19.86% JavaScript 30.54%
django routing bikes openstreetmap pgrouting postgis

mellow-bike-map's Introduction

Mellow Bike Map

๐Ÿšฒ Web app and routing API for finding safe, chill bike routes. Like Google Maps if it took you through cozy side streets.

Example image of the web app

Developing

Development requires Docker and Docker Compose.

Build containers:

docker compose build

Run migrations:

docker compose run --rm app ./manage.py migrate

Import the data (note that the full data import can take quite a bit of memory, so make sure to adjust your Docker preferences to allow Docker at least 6GB of RAM):

docker compose run --rm -w /app postgres make db/import/chicago.table
docker compose run --rm -w /app app make db/import/mellowroute.fixture

Start the app service:

docker-compose up

The app will be available on http://localhost:8000.

Mapping

To begin mapping, make sure you've created an admin user with docker-compose run --rm app ./manage.py createsuperuser and log in to the mapping dashboard at http://localhost:8000/neighborhoods.

On this page, you'll see a map of neighborhoods along with the routes that have already been mapped above a table with links to edit those neighborhoods.

Adding neighborhoods

If you're mapping for this project, there are most likely already a set of neighborhoods available for you to choose from at http://localhost:8000/neighborhoods, in which case you can skip to Adding routes.

However, if you need to add a new neighborhood, you can do so by selecting the "Create new neighborhood" button at the top-right corner of the page and defining a name, slug, and a bounding box for the new neighborhood.

To edit the name, slug, or bounding box for an existing neighborhood, choose the "Edit neighborhood" link next to the neighborhood's name in the table. Editing a neighborhood's bounding box is particularly important because it will change the filter for the underlying streets that are available when you edit routes, streets, or paths for that neighborhood.

Adding routes

On http://localhost:8000/neighborhoods, Find a neighborhood to map and choose one of the following options:

  • Edit routes: Add official bike routes in this neighborhood (non-mellow streets).
  • Edit streets: Add mellow streets in this neighborhood.
  • Edit paths: Add protected off-street bike routes to this neighborhood.

Exporting routes

To export a set of mapped routes and submit it in a pull request, use the Django dumpdata command to output the data to a fixture file using the name of the region you've mapped. For example, use this command to export the North Side:

docker-compose run --rm app ./manage.py dumpdata mbm.mellowroute -o mbm/fixtures/north-side.json

Then add this fixture file to version control and commit it:

git add mbm/fixtures/north-side.json
git commit

mellow-bike-map's People

Contributors

jeancochrane avatar kalilsn avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

mellow-bike-map's Issues

Viewport gets stuck on the map on mobile

On mobile, if you scroll down past the search box to the map, the viewport gets stuck and you can't scroll back up to the search box.

This may become obsolete due to #21 but I figured it was worth tracking anyway.

Allow user to control relative weight of routes, paths, and streets

After #3 is done, it would be nice to allow the user to control the relative weight of each of the three types of routes. One idea would be to have three tiers of importance (high, medium, and low), pass those through to the API, and adjust the scale factor in the query to update the weight.

Show approximate route time on search

User testing suggestion: since pgr_djikstra() returns the total cost of a given route, we should be able to return an approximate time for a given route by assuming a certain speed (this blog post suggests 11-18 mph) and multiplying it by the cost.

The one snag is that in order to prioritize mellow streets we cheat by reducing the cost in the query:

CASE
WHEN mellow.type = ''path'' THEN way.cost * 0.1
WHEN mellow.type = ''street'' THEN way.cost * 0.25
WHEN way.oneway = ''YES'' THEN way.cost * 0.5
WHEN mellow.type = ''route'' THEN way.cost * 0.75
ELSE way.cost
END AS cost,
CASE
WHEN mellow.type = ''path'' THEN way.reverse_cost * 0.1
WHEN mellow.type = ''street'' THEN way.reverse_cost * 0.25
WHEN way.oneway = ''YES'' THEN way.reverse_cost * 0.5
WHEN mellow.type = ''route'' THEN way.reverse_cost * 0.75
ELSE way.reverse_cost
END AS reverse_cost

So in order to get the true cost we'll need to either figure out how to adjust the pgr_djisktra() query to return the unaltered cost, or run an additional query after we get the route to confirm its true cost.

Add geocoding

Right now the app requires the user to input OSM IDs in order to retrieve a route. Switch this up so that the API can receive address strings and geocode them.

Add JS tests

The frontend is pretty complex now, so we should set up some basic JS tests.

Add simple About page

Prompt users to tell us about routes we may have missed. This could either be a CAPTCHA-protected form or, probably easier, just a link to tweet at us.

Prioritize low-speed streets

Related to #8, update the query and the API response to show which streets in the generated route are mellow or not. Also return which type of mellow route they are (#3).

Add docs for adding mellow routes

Right now the admin interface for adding routes is completely undocumented. Add some docs, including steps for exporting fixtures.

Data import bug

I cloned this repo, ran docker-compose build, and then hit this error on the next step in the README:

Beas-MBP:mellow-bike-map beamalsky$ docker-compose -f docker-compose.yml -f db/docker-compose.yml run --rm make
Creating network "mellow-bike-map_default" with the default driver
Creating volume "mellow-bike-map_mellow-bike-map-db-data" with default driver
Creating volume "mellow-bike-map_mellow-bike-map-node-modules" with default driver
Creating mellow-bike-map-postgres ... done
Building make
Step 1/4 : FROM mdillon/postgis:11
 ---> b2a8fefe8a63
Step 2/4 : RUN apt-get update && apt-get install -y --no-install-recommends     build-essential gcc make cmake gdal-bin postgresql-server-dev-11     expat libexpat1-dev libboost-dev libboost-graph-dev libboost-program-options-dev libpqxx-dev     wget ca-certificates
 ---> Using cache
 ---> ce2f9c425429
Step 3/4 : RUN wget -O pgrouting-3.1.0.tar.gz https://github.com/pgRouting/pgrouting/archive/v3.1.0.tar.gz &&     tar xvfz pgrouting-3.1.0.tar.gz &&     cd pgrouting-3.1.0 &&     mkdir build &&     cd build &&     cmake .. &&     make &&     make install &&     cd / && rm -Rf pgrouting-3.1.0*
 ---> Using cache
 ---> 8700ee10c6bc
Step 4/4 : RUN wget -O osm2pgrouting-2.3.6.tar.gz https://github.com/pgRouting/osm2pgrouting/archive/v2.3.6.tar.gz &&     tar xvfz osm2pgrouting-2.3.6.tar.gz &&     cd osm2pgrouting-2.3.6 &&     cmake -H. -Bbuild &&     cd build &&     make &&     make install &&     cd / && rm -Rf osm2pgrouting-2.3.6*
 ---> Using cache
 ---> e708efbda884

Successfully built e708efbda884
Successfully tagged mellow-bike-map-make:latest
WARNING: Image for service make was built because it did not already exist. To rebuild this image you must use `docker-compose build` or `docker-compose up --build`.
python manage.py loaddata app/mbm/fixtures/mellowroute.json && touch db/import/mellowroute.table
python: can't open file 'manage.py': [Errno 2] No such file or directory
Makefile:5: recipe for target 'db/import/mellowroute.table' failed
make: *** [db/import/mellowroute.table] Error 2
Beas-MBP:mellow-bike-map beamalsky$ docker-compose -f docker-compose.yml -f db/docker-compose.yml run --rm make
Starting mellow-bike-map-postgres ... done
python manage.py loaddata app/mbm/fixtures/mellowroute.json && touch db/import/mellowroute.table
python: can't open file 'manage.py': [Errno 2] No such file or directory
Makefile:5: recipe for target 'db/import/mellowroute.table' failed
make: *** [db/import/mellowroute.table] Error 2

Do you know what's up here @jeancochrane? Looks like it's having trouble with the Django management command.

Map the South Side

Map the South Side of Chicago following the Reader map: https://www.google.com/maps/d/u/0/viewer?mid=17mPyCktdurhbwt9HcBZFSJrXmLBKioYs&ll=41.859429425065585%2C-87.63630865000006&z=13

For our purposes, the "South Side" includes all neighborhoods south of I-55 and south/east of the south branch of the river. This includes:

  • Bronzeville
  • Bridgeport/McKinley Park/Brighton Park
  • Hyde Park/Washington Park/Woodlawn
  • Englewood
  • Gage Park/Midway
  • South Shore/South Chicago
  • Chatham/Greater Grand Crossing
  • Auburn Gresham
  • Far Southwest Side

Continue factoring frontend code out of the main app module

The core app.js file, which is the entrypoint for the whole frontend application, is almost 400 lines. There's a lot of logic in there that could be named and encapsulated in a function for readability. It also includes some anonymous functions that should be named.

We should break as much code as we can out of that module and name any discrete pieces of logic, purely for readability. We shouldn't do this until we've written tests for the existing functionality in #42

Offer "Use my location" as a start/end option for routes

Use the geolocation API to request the user's location.

From an interface perspective, I think it would make the most sense to request the user's location when the page first loads, and if the user grants permission then show their location on the map. Then, in the Source input dropdown, offer Use my location as an option.

Show mellow routes on the map

Right now the frontend only shows you the calculated route, but it doesn't show which streets are marked as mellow. Update the map to always show these streets, with colors in a way such that it's easy for a user to tell which streets on their route are mellow.

Zoom to location on load

When you open the app, it should try to get your current location and set that as the default source location. It should also zoom to your gps marker once the location is found.

Show legend on the map

Similar to the original Mellow Bike Map, we should show a legend element on the map explaining what the different colors mean. Ideally this legend should be easy to toggle on and off so that it doesn't get in the way on mobile.

Improve map design

The map could use some love. Some things that stick out:

  • More friendly input/search elements
  • Loading spinner during API requests or responses
  • More subdued basemap
  • Better colors for routes

Feel free to do these all in one big PR or split them out as you see fit.

Bias autocomplete to chicago

Right now the autocomplete dropdown is biased based on your gps location, but that's unreliable and unnecessary. We should replace that code with hardcoded bounds for the city of chicago and consider setting strictBounds.

@jeancochrane suggests taking the coordinates for the Loop and adding a radius of ~20 miles, which is roughly the distance from the Loop to the furthest community that includes routes on our map (Hegewisch).

Deploy app to the web

A small DO droplet or EC2 instance will probably do. I think we'll need 16GB for the database, to be safe.

Split MellowWays into paths, routes, and streets

Right now all mellow routes are stored equally, but we would like to be able to distinguish between paths (protected from cars, e.g. the lakefront trail), routes (city-recommended bike paths, e.g. Milwaukee Ave) and streets (mellow streets). This will require changing the data model, updating the admin interface, and altering the routing algorithm to account for the three different types.

The Reader map uses the following color code to distinguish between the three types:

  • Green: streets
  • Pink: paths
  • Orange: routes

Investigate listed directions

See if there's a way that we can use pgrouting to generate a list of directions in addition to the route geometry.

Counterflow Bike Lanes

Looking to add new info to the map about the counterflow bike lane on Sunnyside near Welles park. It's already a mellow street, but it will only give directions in one direction, since it's a one-way street. I'm assuming that there's some issue with the underlying OSM data that makes this tricky. Any thoughts on counterflow lanes?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.