Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/hbhargava7/northstar-server
Backend components of the NorthStar safe routing project.
https://github.com/hbhargava7/northstar-server
Last synced: 7 days ago
JSON representation
Backend components of the NorthStar safe routing project.
- Host: GitHub
- URL: https://github.com/hbhargava7/northstar-server
- Owner: hbhargava7
- Created: 2016-11-11T23:11:38.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2017-01-10T18:03:12.000Z (almost 8 years ago)
- Last Synced: 2024-10-28T10:19:28.852Z (about 2 months ago)
- Language: Python
- Homepage:
- Size: 26.9 MB
- Stars: 0
- Watchers: 6
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# NorthStar Server
This is the server back-end portion of NorthStar, a navigation app designed to provide users with routes that are both fast and safe. Currently configured for the city of Berkeley, California, we use publicly available crime data to build a crime-density model and subsequently solve the biobjective optimization problem of route length versus route safety. The iPhone app allows an authenticated user to specify start and end points, visualize and choose whether to navigate using the fastest, safest, or overall-optimized path, and finally visualize turn-by-turn navigational instructions for the selected path. The server portion contains logic for data acquisition and management, model computation, route optimization, and other logistical tasks required for the app to operate.The iOS client component of this application can be found [in this repository](https://github.com/hbhargava7/NorthStar-iOS-Client).
Configuration
------------
This project was developed using `virtualenv` to manage Python dependencies. Environment can be initialized from the root directory by:
```
source virtualenvironment/bin/activate
```
Note that there are substantial issues with the virtual environment at this point and you may be better served working without it for the time being. At present, any dependencies added must be installed manually on the server.The application uses `Flask` to manage RESTful queries, and the `Flask` server may be started by:
```
set flask_app = app.py
py -m app.py
```
The `app.py` file can be modified to run on a specific local IP address, or left as `0.0.0.0` to have the server listen for connections on all IP addresses.Crime Function
--------------
To find the crime risk at a particular location p, we look for crimes in a 100m radius and estimate a risk factor according to the equation:![Gaussian Kernel](https://github.com/hbhargava7/NorthStar-Server/blob/master/images/Screen%20Shot%202016-11-13%20at%201.36.07%20AM.png)
The risk along an edge of the graph is the integral over 1m segments along the edge.
We route on a graph of Berkeley that takes into account the function above.Data Collection and Routing
---------------------------
* Crime data from [Berkeley Open Data](https://data.cityofberkeley.info/Public-Safety/Berkeley-PD-Calls-for-Service/k2nh-s5h5)
* `CrimeDataParser.py` for parsing data from Berkeley Open Data API
* `CrimeDataParser2.py` for parsing json output from Berkeley Open Data
* `MapDataParser.py` for storage of nodes and edges in dictionaries, data from [OpenStreetMap](https://www.openstreetmap.org)
* `Routing.py` for A-star search algorithm. The function returns three different paths:
* Path of shortest length (ignoring risk)
* Safest path (weighing risk function heavily)
* Optimal path (weighing both distance to destination and risk intelligently)
* `Utils.py` for Crime Density function and Haversine conversion
* The Haversine formula converts from degrees to meters, used for segmentation of edges:
![Haversine](https://github.com/hbhargava7/NorthStar-Server/blob/master/images/Screen%20Shot%202016-11-13%20at%201.55.29%20AM.png)
Dependencies
------------
This application relies upon the following dependencies, which are intended to be fully managed by `virtualenv` and `pip` (see Configuration):
* `numpy` for general mathematical computations
* `matplotlib` for graphics generation and data visualization
* `lxml` and `osmread` to read OpenStreetMap json files
* `mysql` to set up database and retrieve relevant information