-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathapplication.py
34 lines (24 loc) · 1.34 KB
/
application.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
from flask import Flask
from flask import request
from flask import render_template
import calculation as Distance
app = Flask(__name__)
@app.route('/')
def my_form():
return render_template("basic-view.html")
@app.route('/', methods=['POST'])
def my_form_post():
point_A_text = request.form['point-A']
point_B_text = request.form['point-B']
point_A_lat, point_A_lon = float(point_A_text.split(',')[0]), float(point_A_text.split(',')[1])
point_B_lat, point_B_lon = float(point_B_text.split(',')[0]), float(point_B_text.split(',')[1])
euclid_distance = Distance.euclidean_distance(point_A_lat, point_A_lon, point_B_lat, point_B_lon)
greatcircle_distance = Distance.great_circle_distance(point_A_lat, point_A_lon, point_B_lat, point_B_lon)
vincenty_distance = Distance.vincenty_distance(point_A_lat, point_A_lon, point_B_lat, point_B_lon)
print (euclid_distance)
print (greatcircle_distance)
print (vincenty_distance)
euclid_error, greatcircle_error = Distance.compute_percentage_error(euclid_distance, greatcircle_distance, vincenty_distance)
return render_template('results.html', euclid_distance = euclid_distance, euclid_error = euclid_error, greatcircle_distance = greatcircle_distance, greatcircle_error = greatcircle_error, vincenty_distance = vincenty_distance)
if __name__ == '__main__':
app.run()