THESIS Paper
THESIS Paper
Submitted to the
May 2025
This is to certify that this undergraduate thesis, entitled Web Development of Bike Route
Panel Member
Panel Member
Panel Member
Thesis Adviser
Co-Thesis Adviser
The Philippines has over 11.2 million cyclists, with the government building helpful
infrastructure to accommodate them. However, they don’t pursue cycling due to concerns
of safety, backed by the 2397 recorded accidents faced by cyclists. This project aims to
develop a web-app that helps meet the navigational and safety needs of cyclists. Due to
time and resource constraints, this thesis focused on the Back-end development of the
route generator with the testing area limited to Quezon City. Data Filtering and Data
mining techniques are performed on external databases like Google, Strava, and Cyclosm.
Models are built from this data, and used as a filter overlay for the map of Quezon City to
highlight safe routes for the algorithm to analyze. Using this filtered map, and the
advisers, Engr. Jan Kevin Galicia, and Engr. . Maria Leonora Guico for their invaluable
guidance, and endless patience throughout this research. Their wise mentorship has been
Carlos Oppus and Dr. King Harold Recto - for their constructive feedback and undeniable
To my friends, who have provided not only intellectual support but a reason to
smile even in the most stressful and exhausting times. Their honest personalities and
Last but not least, I am profoundly grateful to my family. Though they may have
many expectations of me, their encouragement has pushed me to achieve what I thought I
could not. They are the foundation of my life, and I hope to make them proud with this
paper.
Thus, this research paper is not only the product of my effort but the culmination
of all the support and inspiration I have received from these wonderful people.
ABOUT THE AUTHOR
not only further his knowledge on this branch of technology but also in search of
This thesis reflects this desire. As a collaborative effort with his friend’s startup-company
Kabike, an app that would provide safe routes for bikers was ideated, to which Mr.
Bolong would provide the technical assistance. This research hopes to contribute
Filipino.
ABSTRACT.......................................................................................................................iii
ACKNOWLEDGEMENTS..............................................................................................iv
TABLE OF CONTENTS..................................................................................................vi
LIST OF TABLES..........................................................................................................viii
LIST OF FIGURES..........................................................................................................ix
CHAPTERS
1. INTRODUCTION..........................................................................................................1
3. METHODOLOGY.........................................................................................................8
3.4 Testing......................................................................................................................11
4.4 Testing......................................................................................................................36
5. CONCLUSION.............................................................................................................42
REFERENCES.................................................................................................................43
APPENDIX.......................................................................................................................45
AUTHOR IN ACTION....................................................................................................56
LIST OF TABLES
Table 1. list of routes for testing.....................................................................................12
List of Figures
Fig 1. Flow of Development (Left to Right)................................................................................................
Fig 2. Summary of algorithm functionality...............................................................................................
Fig 6. UI interface..........................................................................................................................................
Fig 11. A-Star traversal with Road Category Weighted map. .................................................................
INTRODUCTION
The Philippines is rated 9th out of 81 other countries for having the worst traffic situation
in ASEAN. It scored a time index of 44.64 minutes for a one-way commute, and attained
[1]. To alleviate these problems, the government has sought to improve existing
infrastructure, implement more public commuting, and build cycling infrastructure. They
have invested over Php 700M for expanding bike lanes spanning 564 km within the
Such a move allows over 11.2 million active cycling users in the Philippines to
utilize these new roads for commuting over private vehicles [3], 4 times more than
recorded active car owners [4]. Despite the improved infrastructure, road safety and
navigation concerns remain an issue for cyclists. In a report by the MMDA, over 2,397
cyclists were found in road crash accidents, with 33 being lethal [4].
Of the available solutions, bikers would opt for navigational apps to travel,
notably Google Maps, or Waze. Limitations occur when these applications only consider
the fastest paths to travel. Routes generated with this in mind don’t consider the potential
risk posed by the roads taken, especially for cyclists. Factors such as traffic density,
presence of bike lanes, and road quality are some of those which cyclists consider when
With these considerations in mind, a Bike Route Generator was proposed that
factors in the quality and the safety of the cycling journey. This is in conjunction with the
wider project of a commercial web-app “Kabike”. For the sake of clarity during
1. Build filtered dataset the structure and state of the road by accessing external
2. Construct the web page that coordinates the requests from the user, and sends
Quezon City, using collected data as to model optimal bike routes (mild slope,
4. Conduct tests to determine the performance and accuracy of the route generator
Biking is a sustainable and affordable solution towards the traffic problems the
nation is facing. There is a significant portion of the population that are willing to use
bikes as their primary form of transportation but lack the assurance of a safe and quality
journey due to problems with infrastructure and vehicles sharing the same routes. The
web-app will serve to meet the needs of the user by making routes that pose minimal risk,
and arrive at their destination within a reasonable time. This connects the user to relevant
data that can help in determining a good route, without the time-consuming process of
analyzing them. These features aim to contribute to the objective of Kabike, incentivizing
This thesis focused on the development of the Back-end code of the route
generator, one aspect of the wider Web-App of Kabike. Features such as web security,
Front-end design, and monetization is not part of the discussion. The web-server will
be constructed in this thesis. However, the extent of its development will only go as far
Kabike was intended to be a product that can operate all throughout the Philippine
nation, but the scope of the thesis’ functionality will only be Quezon City.
Although similar in function to Google Maps, this route generator focuses on the
biker demographic. It does not focus on providing the shortest path, but instead
focuses on the quality of the bike trip by providing routes that are safer (less traffic
dense, paved roads, a mild incline or decline), and contain bike-related architecture
Data is generated every second that passes, circulated and stored throughout
various databases in the web. A system was devised to take advantage of this, for the
context of tourism . It used both data mining and filtering techniques to sift through
databases for relevant data to be used, analyzed and reconfigured for the purpose for the
user. In this study, the created recommendation system data-mines databases filled with
browser histories, and data on search traffic on the internet to gather information on user
demand [6]. Using collaborative filtering techniques, it creates a sub-set from the data-
mined data that matches the top-rated/on demand destination with the preferences of the
user. This was made by going through the settings/preferences (distance, time,
destination) inputted by the user, and his/her travel profile, gathered through knowledge
based transfer learning [6]. A travel log will then be generated, filtered through
collaborative filtering to provide only a final set of recommended destinations, its reviews
and summarised relevant context of the place. It did achieve a good performance, proving
to have a high accuracy of around 85% within the shortest time when compared to other
Through leveraging data mining & filtering, information from user activity, data
subsets of their proposed taste via user digital activities can be created. Allowing for a
point of comparison in aligning distance, time and destination data towards the
characteristics of destinations; creating an almost perfect fit of where they want to go.
Such methods however must consider accuracy and quantity of information to create a
Being able to identify POIs within a user's current region, provide multiple routes
with least detrimental detours, and schedule an order of places to visit all bound within
the time budget of the user were shown to be difficult in implementing at the same time
[8]. In addressing this, the Multi-task Deep Travel Route Planning (MDTRP) framework
was developed.
preferences and POI attributes into a comprehensive database. It employs a deep attention
model to learn the probabilities of the next POIs based on input patterns from diverse
users. Additionally, the framework utilizes a beam search algorithm to explore multiple
feasible routes for each of the three planning tasks, optimizing the itinerary [8]. The
effectiveness of such has been rigorously evaluated using six public datasets, and it has
robust solution for multi-objective route planning in the tourism context [8].
tailoring travel experiences to the preferences and constraints of individual tourists. The
integration of user preferences, such as preferred POIs and time constraints, enables it to
specific preferences, it not only optimizes routes but also enhances the overall satisfaction
of travelers, ensuring they visit the places of their choice while adhering to their time
limitations.
2.3 Unique Routes using K-means Clustering Approach
Given the complexity of identifying route preferences, knowing what exact data
sets are needed in aligning to suggested routes is necessary. Aside from creating
which identifies common characteristics of data and builds data sets through it. This
process reduces redundancies for more efficient analysis and creates better
preferences, as insights are brought directly from its pool of data. As shown when a
survey was done to test that algorithm generated unique routes and whether the system
satisfaction [9]. Towards its importance in route design, such a model allows for
refined analysis of GPS data by highlighting significant data that bikers tend to do.
When engaging with Bike related information for research and development,
disaggregated data allows for detailed breakdown and straightforward approach when
it comes to analyzing or creating data sets. Limitations occur when open source
information such as Strava provides aggregate data that makes analysis difficult due to
the generalization of information in light of data privacy. In the study, data is layered
tracks to zones", and "Computation of way strings" discussing how to collate [10],
match and synthesize such information for analysis. Results showcase the potential of
aggregate data to be synthesized, and account for other route considerations that
Particular methods need to be taken to turn the subjective experience of safety into
measurable parameters that can be passed to a program. A software system was made,
under the context of the Swiss city of Zurich, that leveraged the present data on bike-
related accidents and passed it into a risk-assessment model to visualize how accident
prone a given area is [11]. This is calculated alongside a discomfort model that rates a
street by the quality of the road, the incline, and the distance of one point to the other.
Then with both of these models, a certain rating is granted towards an area. With all of
those ratings layered on top of the map of the city, the software recommends routes that
takes into account these variables, outputting a route that has a minimized risk and
discomfort overall rating [11]. Though this data is more accessible in bike-centered
countries like Switzerland (an aspect that the Philippines lack in), the process in which it
assesses the safety of certain streets could help guide in gathering data and finalizing the
methodology.
CHAPTER III
METHODOLOGY
continents, countries and regions. It offers a regularly updated dataset that describes the
layouts of the environments, such as road networks, land use, and administrative
boundaries. For the case of this research, data pertaining to road architecture, road class,
and road conditions are used. This aids the algorithm as to which roads to prioritize over
others, as some paths are much safer and easier to ride with a bike than others. One
example being, inclusion of bike networks/lanes on the roads which is important in bike
safety [5].
Tomtom is a global mapping technology company that provides an API of its own
name sake. With this, the geocoding services will be used in order to obtain addresses,
place names, and coordinates of these Points of Interests (POIs). The data present will be
used to allow the user to search for locations in the web-app instead of manually
configuring the coordinates of their starting and ending destinations. TomTom will be the
one to provide those coordinates and input it into the routing algorithm.
The data from these databases are imported into the django project. However, due
to the scope of this project, the coded algorithm will only call in locations within Quezon
City. These will serve to help build an objective statistic on desirable paths for a cyclist
that the algorithm can use in its route generation. Then using the Django API, an interface
will be provided to access the data to search for the starting and ending destination
(TomTom). Meanwhile Graphhopper will use the data obtained from Geofabrik, to
initialize priorities in certain segments of the map, to which the algorithm will navigate
through. The libraries from graphhopper will also be used by the algorithm for route
calculations.
Using Django, the base architecture of the web-app was developed. Here a web
page to house the web-app was made. At this stage of development, the main classes of
the web-app were developed for its base operation including features such as user request
retrieval, request parsing, data accessing, output packaging, and data visualization.
External tools for data management from Django and Graphhopper were also integrated.
Django provides the interface that allows the user to input their desired starting and
ending destinations. The Backend of Django, calls for the database contained in TomTom
to fetch names of POIs. Once the starting and ending destinations have been set, the
coordinates are fetched from TomTom which are then inputted to the routing algorithm.
The Algorithm is a system of functions that does the actual calculation to make the
route, factoring in inputs of the user and the data showing the situation of the roads. The
Before any calculations are done, the map is initialized using Graphhopper. This is
made through segments that connect at certain intersections until it makes a geographical
representation of Metro Manila. In these segments the routing algorithm provides certain
weights to certain segments given certain conditions that pertain to a safer and higher
quality bike route. If it impedes the bike route, they are given a lower weight. If it assists
the bike route they are given a higher weight. This final weighted map will be the
A-Star is a common navigation technique used to provide the shortest path for general
navigation. Graphhopper uses an optimized version for navigating a map that can be
accessed through its associated API. However, since the custom weighted map changes
the server routing logic in the API, the company only documents that only allows these
custom weighted maps to be used in self-hosted maps. Using these custom maps were
their public servers. Alongside this, self-hosting allows the use of OSM data from
geofabrik and TomTom to be used in generating the map itself instead of pre-fabricated
ones in graphHopper. If there was any missing data on the cloud-end of graphHopper it
cannot be uploaded with more data to fill in the gaps, allowing for better data
management. Finally this version of the API allows for unlimited queries into the
weighted map, which allows for testing without restrictions. Thus the API is called from a
server that is hosted by the researcher’s own device. It is through this navigation
technique that it will navigate the map. It will output the fastest route given the weighted
paths present. The paths with the higher weight are prioritized over ones with lower
weight. This will be displayed through Leaflet, an API that allows maps to be displayed.
3.4 Testing
Raw Performance/ Speed of execution will be judged by the response time when
given a certain cost of the inputs given. The cost is calculated by the amount of memory
used, the amount of data needed to calculate the route, and the wait time it takes to
calculate it [6]. Graphhopper contains a version of the A* star algorithm [11], that has a
function/ implementation of the algorithm, this will serve as a reference to test for
performance. As a general metric, google maps will be used as a frame of reference for
typical speeds of a routing algorithm. A timer will be set every time a route is initialized
with the inputs and ends once the route has been outputted. If the time increase from
google maps to the research’s routing algorithm is less than 50%, then the test is
randomly generated list of routes with starting and ending destinations was made with
ChatGPT, which will be inputted into each algorithm. This will be further used in the
Though the amount of routes used is relatively small due to time constraints, the
routes used covered the topographical and urban variation present in Quezon City. Routes
1 and 6 are near important institutions and main roads, while routes 2 and 3 are near
green less congested spaces. . Routes 4 and 5 are near residential and local streets. Route
The “Safety” of a route will be judged by the overall grade. As mentioned earlier
a weighted map was used in conjunction with the given data that push the routes to be
more safe. To determine the sufficiency in creating a “safe” route, 3 main categories were
taken into consideration. Here the list of routes from Table 1 are used.
- Slope
- Dictates how steep a road is. Steeper the elevation gain or loss, harder is
wherein:
(e/d) * 100
A to point B)
d = horizontal distance
the slope is. Positive value means uphill, and negative value means
downhill
- Based on the documentation for graphhopper [13], a more than 10% result
- If the 10 routes from table 1. fall below an average total slope of 5% then
- Road category
- This category dictates what type of road this is typically used for. Certain
roads are far more congested than others, thus more accessible for bikes.
Here the list of routes from table 1 are used. This is split into 3 categories:
- If at least 60% of the streets used in the road are categorized as “bike
friendly”, then this test is considered successful. This will be tested with
- Road surface
- As the name suggests, it dictates what surface the biker will ride on in the
route. There are various categories within road_surface however, some are
more preferable than others. Here the list of routes from table 1 are used.
- If at least 60% of the routes are on “hard and smooth” then this test is
considered a success
Data was gathered from two separate sources geofabrik and TomTom. Geofabrik
was used to setup the map for A* algorithm. This includes road networks, footpaths, road
surface types, road categories, elevation data and many more. This was stored in a file
meanwhile contains the addresses of the POIs in a country’s map alongside its associated
coordinates. This is called through a request by the backend of the Django Framework.
Whenever the algorithm is called by the code, the dataset was filtered to contain only
points within Quezon City to help decrease performance cost and maintain within the
A basic UI interface as shown in Fig. 3 was made using the Django framework. It
contains two search bars, wherein the user can search for 2 destinations, one for the
starting destination and the other for the ending destination. A map is provided at the
center, which is powered by Leaflet which defaults to the coordinates of Metro Manila.
When letters are typed in, TomTom will search for any relevant POIs the user will be
looking for, with a dropdown menu providing a list of at most 10 suggestions. It is only a
valid destination once the user clicks and then sets the destination contained in the
dropdown menu. A button was also developed to provide the current location of the user,
which can act as the starting destination as shown in fig 4. However, if the location is not
within the TomTom dataset a route will not be generated, and and error message is
presented by Django
Fig 6. UI interface
code, it will zoom in on the specified route and highlight a blue path along the
map. Alongside this, route details will be provided which direct the user where to
turn, and notify how long and how far the destination will be.
4.3 Algorithm and Code
Fig 9. Basic A-star traversal. The algorithm was built using an A-Star algorithm built-in
to graphhopper. In a basic map, it traverses the map to get from point A to point B to gain
the fastest ETA possible, sticking to direct paths whenever possible. However, to output a
bike-safe route, a weighted map was made, using the categories of slope, road category,
and road surface. To analyze the logic of the algorithm 4 separate routes were made with
the same starting and ending destinations. The basic A-star traversal where the shortest
route from starting to ending destination is shown in fig 10. Figs 11- 14 show how the
traversal as shown in Fig. 10, little has changed since it was observed that the majority of
the path was within 0-5% in terms of slopage. However early on in the route, it picked
general mac-arthur avenue over continuing down 9th avenue since the total segment
would contain around a 5-6% slopage down the entire path. Thus the algorithm detoured
to general mac-arthur avenue then turned right to 13th avenue to decrease the total
slopage to 3-4% percent. The difference between a 3% and around 5% slopage is the
weighted maps, Road categories were observed to garner the most amount of changes
from the base A-star Traversal as shown in Fig. 11. This version prioritizes categories of
roads that see little to no congestion in terms of traffic density. Categories such as
highways, and primary roads that see the majority of vehicles used to travel are avoided.
Thus roads such as 20th, and 15th avenue (highlighted in black) are given little weight.
The A-star algorithm instead travels through residential areas that are marked in the map
in white, as much as possible. However, as shown in its turn around colonel benny
avenue, if the path taken is still the most direct path towards the objective and there are no
weighted map as shown in Fig. 8, no discernable difference was observed. From the data,
it was observed that the route was primarily done on concrete or asphalt roads, which in
terms of safety would be categorized as “bike-safe” since it's a hard and smooth type of
road. However the change is more observable when the weighted map is used in
weighted map. The changes from the slope and road category maps were observed,
wherein it avoided steep roads (highlighted in orange) and congested primary avenues
(highlighted in black).
● Overview
● This coding project is divided into 2 main parts: the django project and the locally
○ Django Project
stable testing and installation. This was done through the command
work)
that holds the app. Most of the code run for the web-app is found
here
■ Folder was made within the django project directory with the name
○ Graphhopper
following links:
● Jar-file:
https://repo1.maven.org/maven2/com/graphhopper/graphho
pper-web/10.0/graphhopper-web-10.0.jar
● Config-file:
https://raw.githubusercontent.com/graphhopper/graphhoppe
r/10.x/config-example.yml
● osm-file-Philippines:
https://download.geofabrik.de/asia/philippines.html
■ The config file will be the most modified to create a weighted map
D"dw.graphhopper.datareader.file=philippines-latest.osm.pbf" -jar
server is running the algorithm can be used with the Django Project
● Code Breakdown
the project (as generated by the django framework) the files that will be
Table 3. Explanation of code for urls.py (under the app folder) url
patterns represent end points the code will access to request certain functions from
views.py.
logic for handling requests from the frontend and makes requests from APIs and outputs
12–13 def home(request): ... View function that renders the home.html
page when a user visits the site’s
homepage.
15–34 def get_route(request): ... View function that receives start and end
coordinates, sends them to GraphHopper,
and returns the route data.
16 start = request.GET.get('start', '') Gets the starting location from the user’s
request (URL parameter).
17 end = request.GET.get('end', '') Gets the ending location from the user’s
request (URL parameter).
18 if start and end: Checks if both start and end locations were
provided.
template for the web-application. It handles the inputs from the users and outputs the
1–2 <!DOCTYPE html> ... <html Declares the HTML document type and
lang="en"> sets language.
3–9 <head> <script src="axios"> imports dependencies (Leaflet for the
map and Axios for HTTP requests).
10–49 <style> ... </style> Internal CSS styles for the user
interface
54–65 <form id="location-form"> ... Creates inputs for start and end
</form> destinations
201 - 205 Total Distance & Time Displays the total route distance and
estimated time to go through route
194–216 (optional sections - slope, Adds details about surface, slope, and
surface, road class) road class if needed. In this code, only
road class is active.
225–226 </script> and </body> Ends the script and body sections.
Table 6. Config.yml is the configuration file that helps setup the GraphHopper
routing engine and setup its logic. This calls in the bike_safe.json file to make the
10–13 - name: bike ... Defines a vehicle profile called bike that
will be used for routing.
25–27 - type: http ... Opens the application server at port 8989
on localhost.
29–31 - type: http ... Opens the admin server at port 8990 on
localhost.
Table 7. Explanation of code in Bike_safe.json file. It contains the constraints
and weightings that will be made to the map that will be traversed. Characteristics such as
2–19 "priority": [ ... ] Defines how different road properties affect priority
(favorability) of a road segment.
20 average_slope > 0.10 Penalizes steep slopes over 10% — multiply by 0.5.
21 average_slope > 0.05 Slight penalty for moderate slopes (5% to 10%) —
multiply by 0.85.
28 if: true → limit_to Uses the encoded value bike_average_speed to set the
bike_average_speed maximum speed for route calculations.
30 distance_influence: 50.0 Sets how much distance affects route choice — higher
values prefer shorter distances over better priority
weighting.
4.4 Testing
GraphHopper (s)
from the server, using their public domain, the performance of graphHopper was around
0.934s on average. The main difference between the A* traversal algorithm used with
standard graphHopper and the research algorithm’s, was the use of the weighted map
which twists its routing logic and the self-hosting the API on a local machine. Thus it can
be concluded that this is the main reason for the performance cost increase. The
difference is still in seconds, which is still relatively low. The routing algorithm is still
usable. However, given the typical rate of routing algorithms like google maps being near
instant, there could be a perceived defect from typical users if it is not as fast as google
maps. Nevertheless the raw performance test is considered a failure, and will be a point
1 0.012% s
2 -0.62
3 0.38
4 -0.10
5 0.08
6 0.07
7 0.44
8 -0.17
9 -0.58%
10 0.53%
average 0.0042%
observed in table 9 the average slope of the routes generated were relatively flat. A flat
surface means little deviation in terms of effort exerted towards maneuvering the bike, in
turn allowing better control over the bike. Across the results shown in table 3, it averaged
around 0.0042% which falls under the 5% metric as stated. Given that Quezon City is
relatively hilly in certain areas the slope reduction along the routes taken was significant.
Thus the algorithm was successful in minimizing the slope of the routes generated.
Table 10. Percentage of Hard and Smooth surface roads taken.
1 33.49% a
2 71.74% b
3 61.88% l
4 57.33% e
5 71.21%
6 61.84%
7 76.77
8 86.49%
9 57.6%
10 62.3%
average 64.7%
10 shows that 64.7% of the roads used were bike friendly (asphalt, paved and concrete
roads fall under this category). It was noted that 41.74% of the data was missing. For the
sake of testing, they were considered as non-hard and smooth surfaces, so as to account
for the worst-case scenario wherein all of those missing data would be non-bike friendly
surfaces. Nevertheless even in this worst case scenario, the routing algorithm was able to
output routes to which contain a more than average bike-friendly surface along the paths
it took.
1 48.82%
2 36.67%
3 59.46%
4 54.67%
5 49.23%
6 59.26%
7 58.16%
8 69.12%
9 42.31%
10 62.3%
average 54.0%
It was observed that on average 54% of the paths taken were on roads that were
considered to be bike friendly, whereas they were generally on non-congested and traffic
heavy avenues. The middling results was traced to the amount of categories present in the
dataset, that are considered non-bike friendly such as motorways and highways, roads
designed for cars. Nevertheless this has not affected the algorithm significantly and the
route was still able to push routes that were primarily in non-congested road categories.
CHAPTER V
CONCLUSION
generator with a filtered dataset, with data sourced from geofabrik and tomtom, to output
routes that made bikers safer. Django was used to build a UI interface that allowed users
to search for POIs within Quezon City. The inputs were fed into the A-star algorithm self-
hosted by the researcher to traverse a pre-weighted map that prioritizes conditions such as
the slope, road surface and road category of the path taken. Finally, the algorithm itself
was tested for its performance, and the “safety” it provides to the routes by ensuring the
route goes through a relatively flat plane, a hard and smooth road surface and a non-
increased dramatically by 252%, due to the computing taken from a personal computer
instead of the servers APIs were typically using. However, since the weighted map was
needed to make bike routes safer, and they were a feature only available if self-hosted, the
recommended to search for alternatives APIs that allow customly weighted maps while
Alongside this, more data could be inputted to fill in the gaps presented by the
results such as more complete data on road surfaces for a more accurate route that ensures
a smoother ride for bikers, especially if this should get expanded into a nationwide
application. More data can be collected on bike architecture, the surfaces on current
REFERENCES
[2] J. Cruz, “Dotr to build expanded protected bike lanes in 2023,” Interaksyon,
https://interaksyon.philstar.com/trends-spotlights/2023/03/08/245143/dotr-to-build-
expanded-protected-bike-lanes-in-2023/ (accessed Oct. 23, 2023).
[3] Manila bulletin“Bikers, Bike Lanes, and safe roads: It should not be a test to survive a
journey,” Manila Bulletin,
https://mb.com.ph/2023/5/5/bikers-bike-lanes-and-safe-roads-it-should-not-be-a-test-to-
survive-a-journey
[4] I. Gozum, “More bike owners than car owners in ph – SWS,” RAPPLER,
https://www.rappler.com/nation/bike-car-owners-sws-survey-april-2022/ (accessed Oct.
23, 2023).
[5] M. L. Still, “Expert cyclist route planning: Hazards, preferences, and ... - springer,”
Springerlink, https://link.springer.com/content/pdf/10.1007/978-3-030-59987-4_16.pdf
(accessed Oct. 31, 2023).
[7] Huang, J. Xu, and J. Weng, “Multi-task travel route planning with a flexible deep
learning framework,” IEEE Transactions on Intelligent Transportation Systems, vol. 22,
no. 7, pp. 3907–3918, 2021. doi:10.1109/tits.2020.2987645
[8] T. Wang and S. Yamaguchi, “A travel route recommendation system based on route
clustering algorithm considering spatial similarity of routes,” 2023 11th International
Conference on Information and Education Technology (ICIET), 2023.
doi:10.1109/iciet56899.2023.10111109
[9] S. Huber, “Synthetization of bicycle route data from aggregate GPS-based cycling
data and its utility for Bicycle Route Choice Analysis,” 2021 7th International
Conference on Models and Technologies for Intelligent
[10] D. Castells-Graells, C. Salahub, and E. Pournaras, “On cycling risk and discomfort:
Urban safety mapping and Bike Route Recommendations,” Computing, vol. 102, no. 5,
pp. 1259–1274, 2019. doi:10.1007/s00607-019-00771-y
[11] H. Mehta, P. Kanani, and P. Lande, “Google Maps - Researchgate,” Google Maps,
https://github.com/graphhopper/graphhopper?tab=readme-ov-file
urlpatterns = [
path('', views.home, name='home'), # Home page
path('get_route/', views.get_route, name='get_route'), # Endpoint for fetching the route
path('search_location/', views.search_location, name='search_location'), # Endpoint for
location search
]
def get_route(request):
start = request.GET.get('start', '')
end = request.GET.get('end', '')
if start and end:
# Prepares the request to GraphHopper API
params = {
'point': [start, end], # Start and end points
'profile': 'bike_safe', # What custom profile to use
'locale': 'en', # Language for the response
'points_encoded': False, # Ensure coordinates are not encoded for easier parsing
#'details': 'surface'
#'details': 'average_slope'
'details': 'road_class' # Include road class in the response
}
response = requests.get(GRAPHHOPPER_API_URL, params=params)
if response.status_code == 200: # Check if the request was successful
return JsonResponse(response.json())
else:
return JsonResponse({'error': 'Failed to fetch route from GraphHopper'},
status=response.status_code)
return JsonResponse({'error': 'Start or end location missing'}, status=400)
def search_location(request):
query = request.GET.get('query', '')
country_set = request.GET.get('countrySet', 'PH') # Default to the Philippines
lat = request.GET.get('lat', '14.6091') # Default latitude for Metro Manila
lon = request.GET.get('lon', '121.0223') # Default longitude for Metro Manila
if query:
# Call TomTom API to search for locations
url = f'https://api.tomtom.com/search/2/search/{query}.json?
key={TOMTOM_API_KEY}'
params = {
'key': TOMTOM_API_KEY,
'countrySet': country_set,
'lat': lat,
'lon': lon,
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Search Locations</title>
<link rel="stylesheet" href="https://unpkg.com/leaflet/dist/leaflet.css"> <!--Adds
leaflet map-->
<script src="https://unpkg.com/leaflet/dist/leaflet.js"></script> <!--Installs Leaflet
dependency-->
<script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script> <!--Installs
axios dependency-->
<style>
#route-details h2 {
margin-top: 0;
}
#route-instructions {
list-style-type: none;
padding: 0;
}
#route-instructions li {
margin-bottom: 5px;
}
</style>
</head>
<body>
// main page of the web application, where users can search for locations and view
routes on a map.
// sets up basic user interface
<h1>Search Locations</h1>
<form id="location-form">
<label for="start">Start Location:</label>
<input type="text" id="start" name="start" autocomplete="off">
<button type="button" id="use-current-location">Use Current Location</button>
<ul id="start-suggestions" class="autocomplete-suggestions"></ul>
<div id="map"></div>
<div id="route-details">
<h2>Route Details</h2>
<ul id="route-instructions"></ul>
<p id="route-eta"></p>
</div>
<script>
// calls the Leaflet library to create a map and display it on the page.
const map = L.map('map').setView([14.6091, 121.0223], 12); // Set initial view to
Metro Manila
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
maxZoom: 19,
}).addTo(map);
//main function to fetch suggestions from the TomTom API based on user input.
function fetchSuggestions(input, suggestionsList) {
input.addEventListener('input', () => {
const query = input.value;
if (query.length > 2) {
console.log(`Fetching suggestions for: ${query}`); // Debugging
url = `https://api.tomtom.com/search/2/typeahead/${query}.json`
axios.get(`/search_location?query=${query}&countrySet=$
{countrySet}&lat=${lat}&lon=${lon}`) //axios call to the TomTom API
.then(response => {
console.log('Suggestions response:', response.data); // Debugging
suggestionsList.innerHTML = '';
response.data.results.forEach(result => {
const li = document.createElement('li');
li.textContent = result.poi ? result.poi.name :
result.address.freeformAddress; // Display POI name or freeform address
li.addEventListener('click', () => { // Add click event to select
suggestion
input.value = result.poi ? result.poi.name :
result.address.freeformAddress;
input.dataset.lat = result.position.lat;
input.dataset.lon = result.position.lon;
suggestionsList.innerHTML = '';
});
suggestionsList.appendChild(li);
});
})
.catch(error => {
console.error('Error fetching suggestions:', error);
});
} else {
suggestionsList.innerHTML = ''; // Clear suggestions if input is less than 3
characters
}
});
}
fetchSuggestions(document.getElementById('start'),
document.getElementById('start-suggestions')); //views function "fetchSuggestions" for
start and end locations
fetchSuggestions(document.getElementById('end'), document.getElementById('end-
suggestions'));
document.getElementById('use-current-location').addEventListener('click', () => {
if (navigator.geolocation) { //uses native geolocation to get user's current location
navigator.geolocation.getCurrentPosition(
(position) => {
const { latitude, longitude } = position.coords;
// Get the start and end locations from the input fields
const startLat = document.getElementById('start').dataset.lat;
const startLon = document.getElementById('start').dataset.lon;
const endLat = document.getElementById('end').dataset.lat;
const endLon = document.getElementById('end').dataset.lon;
axios.get(`/get_route?start=${start}&end=${end}`)
.then(response => {
const route = response.data.paths[0];
const coordinates = route.points.coordinates.map(coord => [coord[1],
coord[0]]); // Reverse [lon, lat] to [lat, lon]
/*
// Display slope details
const slopeDetails = route.details.average_slope; // Average slope details
from the API
const slopeList = document.createElement('ul');
slopeList.id = 'slope-details';
slopeDetails.forEach(([startIndex, endIndex, slope]) => {
const li = document.createElement('li');
li.textContent = `From point ${startIndex} to ${endIndex}: Average slope
is ${slope.toFixed(2)}%`;
slopeList.appendChild(li);
});
instructionsList.parentElement.appendChild(slopeList);
*/
graphhopper:
datareader.file: philippines-latest.osm.pbf
graph.location: graph-cache
import.osm.ignored_highways: motorway,trunk
graph.elevation.provider: srtm
graph.elevation.cache_dir: ./elevation-cache
graph.elevation.include_ele_tags: true
vehicle_profiles:
- name: bike
profile: bike
custom_models.directory: .
profiles:
- name: bike_safe
vehicle_profile: bike
weighting: custom
custom_model_files: [bike_safe.json]
server:
application_connectors:
- type: http
port: 8989
bind_host: localhost
admin_connectors:
- type: http
port: 8990
bind_host: localhost
{
"priority": [
{ "if": "road_class == CYCLEWAY", "multiply_by": 2.0 },
{ "else_if": "road_class == LIVING_STREET", "multiply_by": 1.7 },
{ "else_if": "road_class == RESIDENTIAL", "multiply_by": 1.6 },
{ "else_if": "road_class == FOOTWAY", "multiply_by": 1.2 },
{ "else_if": "road_class == PRIMARY", "multiply_by": 0.4 },
{ "else_if": "road_class == SECONDARY", "multiply_by": 0.5 },
{ "else_if": "road_class == STEPS", "multiply_by": 0.1 },
{ "else_if": "road_class == MOTORWAY || road_class == TRUNK", "multiply_by":
0.1 },
{
"else": "",
"multiply_by": 1.0
}
],
"speed": [
{ "if": "true", "limit_to": "bike_average_speed" }
],
"distance_influence": 50.0
}
AUTHOR IN ACTION