The Comparison of Distance Methods on The On-Demand Ambulance Application

The on-demand ambulance is an application service that can be used to connect hospital ambulances or NGOs with people who need ambulance services. In this application, there is a geolocation feature service that is implemented with the distance calculation method, so that the feature gets the optimal distance with high accuracy. There are 3 distance search methods used in testing the distance search method, namely the haversine method, the Euclidean method, and the spherical triangle law of the cosine method. This study was conducted by utilizing data collected from the Google Maps API and obtained an accuracy of 100% for the haversine and spherical triangle law of cosine methods, while the accuracy was 89.95% for the Euclidean method.


INTRODUCTION
Medically, everyone has the potential to experience an emer gency condition, be it due to illness, accident, being attacked by wild animals, or other causes. An emergency condition is a clinical condition that requires immediate medical action to save lives and prevent the risk of disability. The ambulance is a means of transportation that provides transportation services from or to the hospital, both for patients experiencing emer gency conditions. Ambulance services are often specifically accessed by patients with medical emergencies.
The ambulance is part of the health care system provided by various institutions, especially hospitals. The ambulance is integrated with hospital services and systems to improve public health and safety. The most common mode of transportation used as an ambulance is a car. Based on its purpose, there are two types of ambulances, namely patient transport vehicles and emergency rescue vehicles. As a vehicle for transporting patients, ambulances can carry patients who are in a life threatening medical conditions or not. Meanwhile, as an emergency rescue vehicle, an ambulance serves to transport patients who are in an emergency condition.
The on-demand ambulance application is one of the new services that aims to connect the available ambulances to hospitals or NGOs (Non-Governmental Organizations) and people in need. This on-demand ambulance service uses the Geo-location feature of Google Maps API to find out the position of the ambulance driver and the position of the user who needs an ambulance. Determination of the fastest route is determined by implementing various distance search methods. There are several methods for measuring the distance are often used.
In paper [1], the authors implement the euclidean and haversine method to calculate the distances by utilizing latitude and longitude coordinates and compare both of the methods to find out the level of accuracy, the results obtained in this study have the same accuracy within 0.01 kilometers. Meanwhile, the spherical law of cosines is one of the basic equations of the spherical triangle method, by calculating the distance between two points on the surface of the earth. In the current era, the spherical triangle has been applied to various sectors such as the Global Positioning System (GPS) [2]. Based on these problems, the goal of this study is to compare the performance of the distance method to find out the best method to be applied in the development of on-demand ambulance services. In this study, we will compare the performance

Related Work
Distance calculation is a common element in data science, there are many machine learning algorithms based on distance measures. The Euclidean distance is one of the most com monly used methods. This method is a calculation of the length of a line between two points, if the Cartesian coordinates of two points are known, the distance can be calculated using the Pythagorean theorem. This method was created with the aim of solving problems by calculating the relationship between angles and distances. Euclidean is usually applied to a two dimensional or three-dimensional calculation. The process for calculating the Euclidean distance is by taking an approach to compare the existing closeness between the distance values of the two variables with the test image and the reference image to get the closest distance. As in [3] designing a recommen dation system for clothes that can show 3-dimensional virtual clothes by applying the Euclidean distance method. The testing results of this clothing recommendation system are able to present the suitability of the size recommendation compared to the original size of the prospective buyer by 70%. Likewise in [4], applying the Euclidean distance algorithm for the selection of internet packages that are in accordance with the location of residence and the criteria of the farmers, the results of testing the accuracy of the recommendation system obtain an F-1 score of 0.760. In addition, the euclidean distance algorithm can also perform pattern matching against a number of objects and a number of templates [5].
Furthermore, the haversine method known as the Haversine formula is one of the methods used to calculate the distance with the aim of knowing how much distance there is between the two points. This method was first used by Josef de Mendoza to solve the astronomical problem of determining the distance between stars. This method performs a distance search by measuring the length of the straight line that exists between the two points on the longitude and latitude. Several studies applied the haversine formula, such as building an android-based gallon depot water delivery application with im plement the haversine formula method to determine the closest distance, the percentage of test results achieved is 90.5% [6]. Meanwhile, in [1] the author built an online presence application using a smartphone and using the GPS feature, to limit the area of the attendance process the haversine formula was used. With the application of the haversine formula, the results of this study are the system is able to detect the location and calculate the distance as a limiting presence tolerance.
Moreover, the Spherical Law of Cosines is one of the basic equations of the spherical triangle method. The Spherical Law of Cosines calculates the distance between two points on the earth's surface. In calculating the spherical triangle, three points abc are determined. These three points have curved sides which are denoted by a, b and c [7]. With the development of the current era, the spherical triangle has been applied to various sectors such as the Global Positioning System (GPS) [2].

RESEARCH METHOD
The modeling design of the application workflow built in this study will use a flowchart. In the flowchart design, it can be seen that there are 3 processes in this application, namely: distance calculation using the Haversine method, dis tance calculation using the Spherical Triangle Law of Cosines method, and distance calculation using the Euclidean method. The following is the architectural design of the application which can be seen in Figure  1.
The use of the Google Maps API is to help get latitude and longitude values from each location. After getting the latitude and longitude values, the distance calculation from the three search methods will then be carried out using the following equations. Equations 1 and 2 are for for the Euclidean method. Where r is the radius of the earth, ∆lat is the amount of change in latitude (lat2-lat1) and ∆long is the amount of change in longitude (long2-long1). While d represents distance, x1 symbol for latitude1 coordinates, and x2 is latitude2 coordinates, while y1 is longitude1 coordinates and y2 is longitude2 coordinates. As for the Spherical Triangle Law of Cosine method, it can be calculated using the formula: d = αcos(sin(latitude1))×(sin(latitude2))+(cos(latitude1))× (cos(latitude2)) × (cos(latitude2) − longitude1)) × r. Online ISSN: 2655-3058

Implementation
In this section, we will discuss the implementation of the applications built into this study. Figure 2 shows the interface from the start page of the application that was built, on this page the user can see the maps or geolocation in this application. In addition, the results of calculations from the distance search methods will be in the form of numbers and can also be displayed in graphical form. While Figure 3 shows the appearance of the geolocation or maps feature that is implemented into the application. In this feature, users can enter location point A and location point B. In addition, there are also markers that act as markers for each location. Furthermore, Figure 4 shows the implementation of the calculation feature of the method. This feature can display the results of distance calculations from the three search methods, namely the Haversine method, Euclidean method, and Spherical Law of Cosines. The calculation of this search method will be based on the equation of each method. While Figure 5 shows the result values of the three calculation methods of the search in the form of a bar graph.  This application can run and work well on Google Chrome, Microsoft Edge, Mozilla Firefox, Opera, and Comodo Dragon browsers. Based on the tests that have been carried out, the results show that the Euclidean distance search method is a method that can perform a more optimal distance search. This application has been tested 5 times using different location points and the results of each test as shown in Table I. Meanwhile, the accuracy of each method used is shown in Table II, which is obtained from the error rate on each method's results. By the tests that have been carried out, it can be seen that although the Euclidean method produces the shortest distance calculation compared to the other two methods, the Euclidean method only has an accuracy of 89.95% compared to the other two methods.

CONCLUSION AND SUGGESTION
Based on the results of the tests carried out in this study to compare the distance calculation methods in the on-demand ambulance application, it can be concluded that the application has been successfully built using geolocation by applying the Haversine, Euclidean and Spherical Triangle Law of Cosines methods. Further, a comparison of the three methods is carried