Skip to content
Snippets Groups Projects
Commit 62a35ac9 authored by theilen's avatar theilen
Browse files

Add /adressmatching endpoint

parent 607b0823
No related branches found
No related tags found
1 merge request!6final project merge into main
...@@ -114,10 +114,33 @@ class _MyHomePageState extends State<MyHomePage> { ...@@ -114,10 +114,33 @@ class _MyHomePageState extends State<MyHomePage> {
); );
if (result != null) { if (result != null) {
List<Location> originLoc = await locationFromAddress(result); List<Location> originLoc = await locationFromAddress(result);
//Match adress with Backend
final response = await http.post(
Uri.parse('http://10.0.2.2:8080/addressmatching'),
body: jsonEncode({"address": result}),
headers: <String, String>{"Content-Type": "application/json"});
_data = jsonDecode(response.body);
var coordinate = _data["coordinate"];
print(response.body);
if (_data.containsKey('error_code') && _data['error_code'] != 0) {
switch (_data['error_code']) {
case 1:
_showMessage(
'The address is outside the solution space. Please enter an address within Berlin-Brandenburg.',
context);
return;
case 2:
_showMessage('The address could not be found.', context);
return;
}
}
setState(() { setState(() {
originText = result; originText = result;
_originCoordinates = _originCoordinates =
latlng.LatLng(originLoc[0].latitude, originLoc[0].longitude); latlng.LatLng(coordinate["lat"], coordinate["lon"]);
}); });
} }
// Toggle keyboard // Toggle keyboard
...@@ -259,12 +282,7 @@ class _MyHomePageState extends State<MyHomePage> { ...@@ -259,12 +282,7 @@ class _MyHomePageState extends State<MyHomePage> {
if (_data.containsKey('error_code') && _data['error_code'] != 0) { if (_data.containsKey('error_code') && _data['error_code'] != 0) {
switch (_data['error_code']) { switch (_data['error_code']) {
case 1: case 1:
_showMessage( _showMessage('No route was found.', context);
'The address is outside the solution space. Please enter an address within Berlin-Brandenburg.',
context);
return;
case 2:
_showMessage('The address could not be found.', context);
return; return;
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment