The goal of the project is to transform the real world position of geographic coordinate system (latitude and longitude) onto the coordinate (x, y) of BART's rail track diagram.
The problem with morphing geolocations onto schematic diagram around one core idea: How do we project the geolocation to the diagram more accurate?
We can then break this down into two further questions:
- How can we convert the geolocation onto the diagram?
- Where should we project the point on graph between two stations?
This web page provides a list of all of the BART stations with their full names, abbreviations, latitude, longitude and addresses. https://api.bart.gov/docs/stn/stns.aspx
- bart_json.txt: real bart location in latitude and longitude
- station_names_BART.csv: bart station id and its corresponding name
- AerialStructuresAndTrainControl.csv: Input data in latitude and longitude
- Real Map Visulization (Google Map API)
- yellow dot: input geolocation data
- purple dot: bart location
- Schematic Diagram with its corresponding bart station
- green dot: bart station
The algorithm constist of two goals:
- Use a straight-forward way to project the real location on the graph.
- Try to be efficient and save the run time for the algorithm.
- Calculating the distance between given point and bart station and find the first closest and second closest bart id, and its distance.
- use distance formula d=√((x_2-x_1)²+(y_2-y_1)²) to find the distance between any two points
- Project the given point onto the diagram by ratio calculation
- ratio function:
- ratio dist on real map & ratio dist on the diagram
- (distance between the given point to the cloest bart) / (two bart distance on real map) = dis / (two bart distance on the diagram)
- find a point along a line a certain distance away from another point
- Draw all the projected points on the given diagram.
- Seperate station IDs into 12 groups and write them in a dictionary.
- Ideas: There are total 12 straight lines, we store the line-segment group name as key, and stations id on the corresponding line as value. Once we know the closest station for the given point, then we can target the specific line segment (key) based on its closest station id (value). Next, the final step is to project the point on closest line segment.
- Set the boundary so that the input data can only be in Bay Area.
- Example: If given an input geolocation in New York, the system will output "The input location is out of boundary, please try again."
If the given point is located in the line where the distances between two bart station are very uneven, it may cause the bug like the following example and we need to mannually fix this special case.