Commit 6306c9fd authored by O.V.B Sewmina's avatar O.V.B Sewmina

Merge branch 'IT19179568' into 'master'

final merge

See merge request 2022-020/2022-020!41
parents a63b406d 0e0508f7
Dipature,Arrival,Time
Dehiwala,Fort ,25min
Dehiwala,wellawatte,5min
Dehiwala,bambalapitiya,9min
Dehiwala,kollupitiya,13min
Dehiwala,kompannavidiya,16min
wellawatte,bambalapitiya,4min
wellawatte,kollupitiya,8min
wellawatte,kompannavidiya,11min
wellawatte,Fort ,13min
bambalapitiya,kollupitiya,4min
bambalapitiya,kompannavidiya,7min
bambalapitiya,Fort ,9min
kollupitiya,kompannavidiya,3min
kollupitiya,Fort ,5min
kompannavidiya,Fort ,3min
Dehiwala,Fort ,25min
Dehiwala,wellawatte,5min
Dehiwala,bambalapitiya,9min
Dehiwala,kollupitiya,13min
Dehiwala,kompannavidiya,16min
wellawatte,bambalapitiya,4min
wellawatte,kollupitiya,8min
wellawatte,kompannavidiya,11min
wellawatte,Fort ,13min
bambalapitiya,kollupitiya,4min
bambalapitiya,kompannavidiya,7min
bambalapitiya,Fort ,9min
kollupitiya,kompannavidiya,3min
kollupitiya,Fort ,5min
kompannavidiya,Fort ,3min
Dehiwala,Fort ,25min
Dehiwala,wellawatte,5min
Dehiwala,bambalapitiya,9min
Dehiwala,kollupitiya,13min
Dehiwala,kompannavidiya,16min
wellawatte,bambalapitiya,4min
wellawatte,kollupitiya,8min
wellawatte,kompannavidiya,11min
wellawatte,Fort ,13min
bambalapitiya,kollupitiya,4min
bambalapitiya,kompannavidiya,7min
bambalapitiya,Fort ,9min
kollupitiya,kompannavidiya,3min
kollupitiya,Fort ,5min
kompannavidiya,Fort ,3min
Dehiwala,Fort ,25min
Dehiwala,wellawatte,5min
Dehiwala,bambalapitiya,9min
Dehiwala,kollupitiya,13min
Dehiwala,kompannavidiya,16min
wellawatte,bambalapitiya,4min
wellawatte,kollupitiya,8min
wellawatte,kompannavidiya,11min
wellawatte,Fort ,13min
bambalapitiya,kollupitiya,4min
bambalapitiya,kompannavidiya,7min
bambalapitiya,Fort ,9min
kollupitiya,kompannavidiya,3min
kollupitiya,Fort ,5min
kompannavidiya,Fort ,3min
Dehiwala,Fort ,25min
Dehiwala,wellawatte,5min
Dehiwala,bambalapitiya,9min
Dehiwala,kollupitiya,13min
Dehiwala,kompannavidiya,16min
wellawatte,bambalapitiya,4min
wellawatte,kollupitiya,8min
wellawatte,kompannavidiya,11min
wellawatte,Fort ,13min
bambalapitiya,kollupitiya,4min
bambalapitiya,kompannavidiya,7min
bambalapitiya,Fort ,9min
kollupitiya,kompannavidiya,3min
kollupitiya,Fort ,5min
kompannavidiya,Fort ,3min
Dehiwala,Fort ,25min
Dehiwala,wellawatte,5min
Dehiwala,bambalapitiya,9min
Dehiwala,kollupitiya,13min
Dehiwala,kompannavidiya,16min
wellawatte,bambalapitiya,4min
wellawatte,kollupitiya,8min
wellawatte,kompannavidiya,11min
wellawatte,Fort ,13min
bambalapitiya,kollupitiya,4min
bambalapitiya,kompannavidiya,7min
bambalapitiya,Fort ,9min
kollupitiya,kompannavidiya,3min
kollupitiya,Fort ,5min
kompannavidiya,Fort ,3min
Dehiwala,Fort ,25min
Dehiwala,wellawatte,5min
Dehiwala,bambalapitiya,9min
Dehiwala,kollupitiya,13min
Dehiwala,kompannavidiya,16min
wellawatte,bambalapitiya,4min
wellawatte,kollupitiya,8min
wellawatte,kompannavidiya,11min
wellawatte,Fort ,13min
bambalapitiya,kollupitiya,4min
bambalapitiya,kompannavidiya,7min
bambalapitiya,Fort ,9min
kollupitiya,kompannavidiya,3min
kollupitiya,Fort ,5min
kompannavidiya,Fort ,3min
Dehiwala,Fort ,25min
Dehiwala,wellawatte,5min
Dehiwala,bambalapitiya,9min
Dehiwala,kollupitiya,13min
Dehiwala,kompannavidiya,16min
wellawatte,bambalapitiya,4min
wellawatte,kollupitiya,8min
wellawatte,kompannavidiya,11min
wellawatte,Fort ,13min
bambalapitiya,kollupitiya,4min
bambalapitiya,kompannavidiya,7min
bambalapitiya,Fort ,9min
kollupitiya,kompannavidiya,3min
kollupitiya,Fort ,5min
kompannavidiya,Fort ,3min
Dehiwala,Fort ,25min
Dehiwala,wellawatte,5min
Dehiwala,bambalapitiya,9min
Dehiwala,kollupitiya,13min
Dehiwala,kompannavidiya,16min
wellawatte,bambalapitiya,4min
wellawatte,kollupitiya,8min
wellawatte,kompannavidiya,11min
wellawatte,Fort ,13min
bambalapitiya,kollupitiya,4min
bambalapitiya,kompannavidiya,7min
bambalapitiya,Fort ,9min
kollupitiya,kompannavidiya,3min
kollupitiya,Fort ,5min
kompannavidiya,Fort ,3min
Dehiwala,Fort ,25min
Dehiwala,wellawatte,5min
Dehiwala,bambalapitiya,9min
Dehiwala,kollupitiya,13min
Dehiwala,kompannavidiya,16min
wellawatte,bambalapitiya,4min
wellawatte,kollupitiya,8min
wellawatte,kompannavidiya,11min
wellawatte,Fort ,13min
bambalapitiya,kollupitiya,4min
bambalapitiya,kompannavidiya,7min
bambalapitiya,Fort ,9min
kollupitiya,kompannavidiya,3min
kollupitiya,Fort ,5min
kompannavidiya,Fort ,3min
Dehiwala 1
wellawatte 2
bambalapitiya 3
kollupitiya 4
kompannavidiya 5
Fort 6
# %%
import pandas as pd
# %%
data = pd.read_csv('TravelTimePrediction\TrainData\TrainData.csv')
# %%
# %%
# %%
# %%
data['Dipature'].map({'Dehiwala':1,'wellawatte':2,'bambalapitiya':3,'kollupitiya':4,'kompannavidiya':5})
# %%
data['Dipature'] = data['Dipature'].map({'Dehiwala':1,'wellawatte':2,'bambalapitiya':3,'kollupitiya':4,'kompannavidiya':5})
# %%
# %%
data['Arrival'].map({'Fort ':6,'wellawatte':2,'bambalapitiya':3,'kollupitiya':4,'kompannavidiya':5})
# %%
data['Arrival'] = data['Arrival'].map({'Fort ':6,'wellawatte':2,'bambalapitiya':3,'kollupitiya':4,'kompannavidiya':5})
# %%
# %%
X = data.drop(['Time'],axis=1)
# %%
y = data['Time']
# %%
from sklearn.model_selection import train_test_split
# %%
X_train,X_test,y_train,y_test = train_test_split(X,y,test_size=0.2,random_state=42)
# %%
from sklearn.neural_network import MLPClassifier
# %%
NN = MLPClassifier()
NN.fit(X_train,y_train)
# %%
y_pred1 = NN.predict(X_test)
# %%
df1 = pd.DataFrame({'Actual':y_test, 'NN Results':y_pred1})
# %%
data = {'Dipature':1,
'Arrival':2,
}
df = pd.DataFrame(data,index=[0])
# %%
predit = NN.predict(df)
# %%
def GetTrainPrediction(Dipature,Arrival):
data = {'Dipature':Dipature,
'Arrival':Arrival,
}
df = pd.DataFrame(data,index=[0])
predit = NN.predict(df)
print('Train Travel Time Prediction :- ',*predit,' ')
# %%
def GetDipatureCode(data):
if('Dehiwala' == data):
return 1
elif('wellawatte' == data):
return 2
elif('bambalapitiya' == data):
return 3
elif('kollupitiya' == data):
return 4
elif('kompannavidiya' == data):
return 5
# %%
def GetArrivalCode(data):
if('Fort' == data):
return 6
elif('wellawatte' == data):
return 2
elif('bambalapitiya' == data):
return 3
elif('kollupitiya' == data):
return 4
elif('kompannavidiya' == data):
return 5
# %%
def GetPrediction(Dvalue,Avalue):
Dipature = GetDipatureCode(Dvalue)
Arrival = GetArrivalCode(Avalue)
GetTrainPrediction(Dipature,Arrival)
GetPrediction('Dehiwala','Fort')
\ No newline at end of file
plugins { plugins {
id 'com.android.application' id 'com.android.application'
id 'com.chaquo.python'
id 'com.google.android.libraries.mapsplatform.secrets-gradle-plugin' id 'com.google.android.libraries.mapsplatform.secrets-gradle-plugin'
id 'com.google.gms.google-services' id 'com.google.gms.google-services'
} }
apply plugin: 'com.android.application'
apply plugin: 'com.chaquo.python'
android { android {
namespace 'com.app.travelle' namespace 'com.app.travelle'
compileSdk 32 compileSdk 32
...@@ -15,7 +23,42 @@ android { ...@@ -15,7 +23,42 @@ android {
versionCode 1 versionCode 1
versionName "1.0" versionName "1.0"
python{
pip{
install "numpy"
install "pandas"
install "matplotlib"
install "sklearn"
install "matplotlib"
install "scikit-learn"
install "networkx"
install "asyncio"
}
}
ndk {
abiFilters "armeabi-v7a", "arm64-v8a", "x86", "x86_64"
}
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
python {
buildPython "C:/Users/Chamod Abeyrathna/AppData/Local/Programs/Python/Python39/python.exe"
}
python {
version "3.8"
}
sourceSets {
main {
setRoot "src/main/"
python.srcDir "src/main/python"
}
}
} }
buildTypes { buildTypes {
......
...@@ -18,7 +18,6 @@ ...@@ -18,7 +18,6 @@
android:supportsRtl="true" android:supportsRtl="true"
android:theme="@style/Theme.Travelle" android:theme="@style/Theme.Travelle"
tools:targetApi="31"> tools:targetApi="31">
<!-- <!--
TODO: Before you run your application, you need a Google Maps API key. TODO: Before you run your application, you need a Google Maps API key.
...@@ -30,9 +29,13 @@ ...@@ -30,9 +29,13 @@
project's local.properties file (e.g. MAPS_API_KEY=Aiza...), and replace the project's local.properties file (e.g. MAPS_API_KEY=Aiza...), and replace the
"YOUR_API_KEY" string in this file with "${MAPS_API_KEY}". "YOUR_API_KEY" string in this file with "${MAPS_API_KEY}".
--> -->
<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
<meta-data <meta-data
android:name="com.google.android.geo.API_KEY" android:name="com.google.android.geo.API_KEY"
android:value="YOUR_API_KEY" /> android:value="@string/google_maps_key" />
<activity <activity
android:name=".RetrieveBusMap" android:name=".RetrieveBusMap"
...@@ -78,6 +81,15 @@ ...@@ -78,6 +81,15 @@
<category android:name="android.intent.category.LAUNCHER" /> <category android:name="android.intent.category.LAUNCHER" />
</intent-filter> </intent-filter>
<meta-data
android:name="android.app.lib_name"
android:value="" />
</activity>
<activity
android:name=".RouteActivity"
android:exported="false">
<meta-data <meta-data
android:name="android.app.lib_name" android:name="android.app.lib_name"
......
package com.app.travelle;
import com.google.android.gms.maps.model.LatLng;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
/**
* Created by Vishal on 10/20/2018.
*/
public class DataParser {
public List<List<HashMap<String, String>>> parse(JSONObject jObject) {
List<List<HashMap<String, String>>> routes = new ArrayList<>();
JSONArray jRoutes;
JSONArray jLegs;
JSONArray jSteps;
try {
jRoutes = jObject.getJSONArray("routes");
/** Traversing all routes */
for (int i = 0; i < jRoutes.length(); i++) {
jLegs = ((JSONObject) jRoutes.get(i)).getJSONArray("legs");
List path = new ArrayList<>();
/** Traversing all legs */
for (int j = 0; j < jLegs.length(); j++) {
jSteps = ((JSONObject) jLegs.get(j)).getJSONArray("steps");
/** Traversing all steps */
for (int k = 0; k < jSteps.length(); k++) {
String polyline = "";
polyline = (String) ((JSONObject) ((JSONObject) jSteps.get(k)).get("polyline")).get("points");
List<LatLng> list = decodePoly(polyline);
/** Traversing all points */
for (int l = 0; l < list.size(); l++) {
HashMap<String, String> hm = new HashMap<>();
hm.put("lat", Double.toString((list.get(l)).latitude));
hm.put("lng", Double.toString((list.get(l)).longitude));
path.add(hm);
}
}
routes.add(path);
}
}
} catch (JSONException e) {
e.printStackTrace();
} catch (Exception e) {
}
return routes;
}
/**
* Method to decode polyline points
* Courtesy : https://jeffreysambells.com/2010/05/27/decoding-polylines-from-google-maps-direction-api-with-java
*/
private List<LatLng> decodePoly(String encoded) {
List<LatLng> poly = new ArrayList<>();
int index = 0, len = encoded.length();
int lat = 0, lng = 0;
while (index < len) {
int b, shift = 0, result = 0;
do {
b = encoded.charAt(index++) - 63;
result |= (b & 0x1f) << shift;
shift += 5;
} while (b >= 0x20);
int dlat = ((result & 1) != 0 ? ~(result >> 1) : (result >> 1));
lat += dlat;
shift = 0;
result = 0;
do {
b = encoded.charAt(index++) - 63;
result |= (b & 0x1f) << shift;
shift += 5;
} while (b >= 0x20);
int dlng = ((result & 1) != 0 ? ~(result >> 1) : (result >> 1));
lng += dlng;
LatLng p = new LatLng((((double) lat / 1E5)),
(((double) lng / 1E5)));
poly.add(p);
}
return poly;
}
}
\ No newline at end of file
package com.app.travelle;
import android.content.Context;
import android.os.AsyncTask;
import android.util.Log;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
/**
* Created by Vishal on 10/20/2018.
*/
public class FetchURL extends AsyncTask<String, Void, String> {
Context mContext;
String directionMode = "driving";
public FetchURL(Context mContext) {
this.mContext = mContext;
}
@Override
protected String doInBackground(String... strings) {
// For storing data from web service
String data = "";
directionMode = strings[1];
try {
// Fetching the data from web service
data = downloadUrl(strings[0]);
Log.d("mylog", "Background task data " + data.toString());
} catch (Exception e) {
Log.d("Background Task", e.toString());
}
return data;
}
@Override
protected void onPostExecute(String s) {
super.onPostExecute(s);
PointsParser parserTask = new PointsParser(mContext, directionMode);
// Invokes the thread for parsing the JSON data
parserTask.execute(s);
}
private String downloadUrl(String strUrl) throws IOException {
String data = "";
InputStream iStream = null;
HttpURLConnection urlConnection = null;
try {
URL url = new URL(strUrl);
// Creating an http connection to communicate with url
urlConnection = (HttpURLConnection) url.openConnection();
// Connecting to url
urlConnection.connect();
// Reading data from url
iStream = urlConnection.getInputStream();
BufferedReader br = new BufferedReader(new InputStreamReader(iStream));
StringBuffer sb = new StringBuffer();
String line = "";
while ((line = br.readLine()) != null) {
sb.append(line);
}
data = sb.toString();
Log.d("mylog", "Downloaded URL: " + data.toString());
br.close();
} catch (Exception e) {
Log.d("mylog", "Exception downloading URL: " + e.toString());
} finally {
iStream.close();
urlConnection.disconnect();
}
return data;
}
}
...@@ -6,12 +6,14 @@ import androidx.core.app.ActivityCompat; ...@@ -6,12 +6,14 @@ import androidx.core.app.ActivityCompat;
import android.Manifest; import android.Manifest;
import android.annotation.SuppressLint; import android.annotation.SuppressLint;
import android.app.ProgressDialog;
import android.content.Intent; import android.content.Intent;
import android.content.pm.PackageManager; import android.content.pm.PackageManager;
import android.content.res.Resources; import android.content.res.Resources;
import android.graphics.Color; import android.graphics.Color;
import android.location.Location; import android.location.Location;
import android.os.Bundle; import android.os.Bundle;
import android.text.Editable;
import android.util.Log; import android.util.Log;
import android.view.View; import android.view.View;
import android.view.WindowManager; import android.view.WindowManager;
...@@ -28,17 +30,22 @@ import com.google.android.gms.maps.model.BitmapDescriptorFactory; ...@@ -28,17 +30,22 @@ import com.google.android.gms.maps.model.BitmapDescriptorFactory;
import com.google.android.gms.maps.model.LatLng; import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.MapStyleOptions; import com.google.android.gms.maps.model.MapStyleOptions;
import com.google.android.gms.maps.model.MarkerOptions; import com.google.android.gms.maps.model.MarkerOptions;
import com.google.android.gms.maps.model.Polyline;
import com.google.android.gms.maps.model.PolylineOptions;
import com.google.android.gms.tasks.OnSuccessListener; import com.google.android.gms.tasks.OnSuccessListener;
import com.google.android.gms.tasks.Task; import com.google.android.gms.tasks.Task;
import android.view.View; import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;
import com.chaquo.python.PyObject;
import com.chaquo.python.Python;
import com.chaquo.python.android.AndroidPlatform;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
public class InitialMap extends AppCompatActivity { public class InitialMap extends AppCompatActivity {
private AutoCompleteTextView editText;
private static final String[] CITIES = new String[]{ private static final String[] CITIES = new String[]{
"Viharamahadevi Park","House Of Fashion","Castle Street","Rajagiriya","HSBC Rajagiriya","Ethulkotte New","Parliament Junction","Battaramulla Junction","Ganahena","Koswatta","Kotte-Bope" "Viharamahadevi Park","House Of Fashion","Castle Street","Rajagiriya","HSBC Rajagiriya","Ethulkotte New","Parliament Junction","Battaramulla Junction","Ganahena","Koswatta","Kotte-Bope"
,"Thalahena Junction","Malabe","Fort_TR","Kompannavidiya_TR","Kollupitiya_TR","Bambalapitiya_TR","Wellawatte_TR","Dehiwala_TR" ,"Thalahena Junction","Malabe","Fort_TR","Kompannavidiya_TR","Kollupitiya_TR","Bambalapitiya_TR","Wellawatte_TR","Dehiwala_TR"
...@@ -47,6 +54,11 @@ public class InitialMap extends AppCompatActivity { ...@@ -47,6 +54,11 @@ public class InitialMap extends AppCompatActivity {
SupportMapFragment supportMapFragment; SupportMapFragment supportMapFragment;
FusedLocationProviderClient client; FusedLocationProviderClient client;
GoogleMap map; GoogleMap map;
TextView textView;
Button findBtn;
Double Longi;
Double Lati;
ProgressDialog pd;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
...@@ -55,14 +67,23 @@ public class InitialMap extends AppCompatActivity { ...@@ -55,14 +67,23 @@ public class InitialMap extends AppCompatActivity {
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
getSupportActionBar().hide(); getSupportActionBar().hide();
setContentView(R.layout.activity_initial_map); setContentView(R.layout.activity_initial_map);
pd = new ProgressDialog(this);
//find button function
findBtn = findViewById(R.id.findbus);
//id selecting
textView = findViewById(R.id.current_location);
//Where to declaration //Where to declaration
AutoCompleteTextView editText = findViewById(R.id.where_to); editText = findViewById(R.id.where_to);
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this , android.R.layout.simple_list_item_1, CITIES); ArrayAdapter<String> adapter = new ArrayAdapter<String>(this , android.R.layout.simple_list_item_1, CITIES);
editText.setAdapter(adapter); editText.setAdapter(adapter);
//Assign variable //Assign variable
supportMapFragment = (SupportMapFragment) getSupportFragmentManager() supportMapFragment = (SupportMapFragment) getSupportFragmentManager()
...@@ -77,20 +98,54 @@ public class InitialMap extends AppCompatActivity { ...@@ -77,20 +98,54 @@ public class InitialMap extends AppCompatActivity {
//When granted //When granted
//Call method //Call method
getCurrentLocation(); getCurrentLocation();
} }
else{ else{
//When denied request permission //When denied request permission
ActivityCompat.requestPermissions(InitialMap.this, ActivityCompat.requestPermissions(InitialMap.this,
new String[]{Manifest.permission.ACCESS_FINE_LOCATION},44); new String[]{Manifest.permission.ACCESS_FINE_LOCATION},44);
} }
findBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
//set title of progress dialog
String value = editText.getText().toString();
String valu2 = textView.getText().toString();
String locationOne = textView.getText().toString();//start location
String locationTwo = editText.getText().toString();//end location
int travelTime = GetTravelTime(locationOne,locationTwo);
int ArrivalValue = GetStationID(locationTwo);
startActivity(new Intent(InitialMap.this, RouteActivity.class)
.putExtra("key", 79.95430199947661)
.putExtra("rname", 6.903962700873259)
.putExtra("TimePrediction", travelTime)
.putExtra("EndLocation", ArrivalValue)
);
} }
public void btnRetrieveLocation(View view) { });
startActivity(new Intent(getApplicationContext(),RetrieveBusMap.class));
} }
private void getCurrentLocation() { private void getCurrentLocation() {
//Initialize task location //Initialize task location
if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) { if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
...@@ -101,6 +156,8 @@ public class InitialMap extends AppCompatActivity { ...@@ -101,6 +156,8 @@ public class InitialMap extends AppCompatActivity {
// int[] grantResults) // int[] grantResults)
// to handle the case where the user grants the permission. See the documentation // to handle the case where the user grants the permission. See the documentation
// for ActivityCompat#requestPermissions for more details. // for ActivityCompat#requestPermissions for more details.
return; return;
} }
Task<Location> task = client.getLastLocation(); Task<Location> task = client.getLastLocation();
...@@ -117,6 +174,14 @@ public class InitialMap extends AppCompatActivity { ...@@ -117,6 +174,14 @@ public class InitialMap extends AppCompatActivity {
//Initialize lat lan //Initialize lat lan
LatLng latLng = new LatLng(location.getLatitude(), LatLng latLng = new LatLng(location.getLatitude(),
location.getLongitude()); location.getLongitude());
Longi=location.getLongitude();
Lati=location.getLatitude();
System.out.println("Longi :- "+Longi +" Lat:- "+Lati);
textView.setText(""+GetCurrentLocationName(Longi,Lati));
//Create marker //Create marker
MarkerOptions options = new MarkerOptions() MarkerOptions options = new MarkerOptions()
.position(latLng) .position(latLng)
...@@ -124,10 +189,6 @@ public class InitialMap extends AppCompatActivity { ...@@ -124,10 +189,6 @@ public class InitialMap extends AppCompatActivity {
.title("You are here"); .title("You are here");
//Zoom map //Zoom map
googleMap.animateCamera(CameraUpdateFactory.newLatLngZoom(latLng, 18)); googleMap.animateCamera(CameraUpdateFactory.newLatLngZoom(latLng, 18));
//Add marker //Add marker
...@@ -149,6 +210,7 @@ public class InitialMap extends AppCompatActivity { ...@@ -149,6 +210,7 @@ public class InitialMap extends AppCompatActivity {
} }
}); });
} }
} }
}); });
} }
...@@ -166,4 +228,115 @@ public class InitialMap extends AppCompatActivity { ...@@ -166,4 +228,115 @@ public class InitialMap extends AppCompatActivity {
} }
} }
} }
public String GetCurrentLocationName(Double longi,Double lat){
if (! Python.isStarted()) {
Python.start(new AndroidPlatform(this));
}
Python py = Python.getInstance();
PyObject pyobj = py.getModule("AL");
PyObject obj = pyobj.callAttr("get_nearest_station",lat,longi);
PyObject obj2 = pyobj.callAttr("get_route",1,2,3);
//semina function call and get the current location name
return obj.toString();
}
public int GetStationID(String name){
// Create a HashMap object called capitalCities
HashMap<String, Integer> capitalCities = new HashMap<String, Integer>();
// Add keys and values (name,value)
capitalCities.put("Kollupitiya", 0);
capitalCities.put("Viharamahadevi Park", 1);
capitalCities.put("House Of Fashion", 2);
capitalCities.put("Castle Street", 3);
capitalCities.put("Rajagiriya", 4);
capitalCities.put("HSBC Rajagiriya", 5);
capitalCities.put("Ethulkotte New", 6);
capitalCities.put("Parliament Junction", 7);
capitalCities.put("Battaramulla Junction", 8);
capitalCities.put("Ganahena", 9);
capitalCities.put("Koswatta", 10);
capitalCities.put("Kotte-Bope", 11);
capitalCities.put("Thalahena Junction", 12);
capitalCities.put("Malabe", 13);
capitalCities.put("Fort_TR", 14);
capitalCities.put("Kompannavidiya_TR", 15);
capitalCities.put("Kollupitiya_TR", 16);
capitalCities.put("Bambalapitiya_TR", 17);
capitalCities.put("Wellawatte_TR", 18);
capitalCities.put("Dehiwala_TR", 19);
int val = capitalCities.get(name);
return val;
}
public int GetTravelTime(String StartLocation,String EndLocation){
int time=0;
if(StartLocation.equals("Malabe")){
if(EndLocation.equals("Koswatta")){
time = 20;
}
else if(EndLocation.equals("Kollupitiya")){
time = 58;
}
else if(EndLocation.equals("Viharamahadevi Park")){
time = 56;
}
else if(EndLocation.equals("House Of Fashion")){
time = 44;
}
else if(EndLocation.equals("Castle Street")){
time = 41;
}
else if(EndLocation.equals("Rajagiriya")){
time = 43;
}
else if(EndLocation.equals("HSBC Rajagiriya")){
time = 42;
}
else if(EndLocation.equals("Ethulkotte New")){
time = 34;
}
else if(EndLocation.equals("Parliaent Junction")){
time = 31;
}
else if(EndLocation.equals("Battaramulla Junction")){
time = 28;
}
else if(EndLocation.equals("Ganahena")){
time = 26;
}
else if(EndLocation.equals("Kotte-Bope")){
time = 20;
}
else if(EndLocation.equals("Thalahena Junction")){
time = 15;
}
}else{
}
return time;
}
} }
...@@ -2,16 +2,19 @@ package com.app.travelle; ...@@ -2,16 +2,19 @@ package com.app.travelle;
import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.app.AppCompatActivity;
import android.app.ProgressDialog;
import android.content.Intent; import android.content.Intent;
import android.os.Bundle; import android.os.Bundle;
import android.view.View; import android.view.View;
import android.view.WindowManager; import android.view.WindowManager;
import android.widget.Button; import android.widget.Button;
import android.widget.Toast;
public class Login extends AppCompatActivity { public class Login extends AppCompatActivity {
private Button login_btn; private Button login_btn;
private Button direct_to_signup_btn; private Button direct_to_signup_btn;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
...@@ -20,6 +23,8 @@ public class Login extends AppCompatActivity { ...@@ -20,6 +23,8 @@ public class Login extends AppCompatActivity {
getSupportActionBar().hide(); getSupportActionBar().hide();
setContentView(R.layout.activity_login); setContentView(R.layout.activity_login);
login_btn = (Button) findViewById(R.id.login); login_btn = (Button) findViewById(R.id.login);
direct_to_signup_btn = (Button) findViewById(R.id.signup); direct_to_signup_btn = (Button) findViewById(R.id.signup);
......
...@@ -11,6 +11,10 @@ import android.view.Window; ...@@ -11,6 +11,10 @@ import android.view.Window;
import android.view.WindowManager; import android.view.WindowManager;
import android.widget.Button; import android.widget.Button;
import com.chaquo.python.PyObject;
import com.chaquo.python.Python;
import com.chaquo.python.android.AndroidPlatform;
public class MainActivity extends AppCompatActivity { public class MainActivity extends AppCompatActivity {
private Button button; private Button button;
...@@ -31,6 +35,10 @@ public class MainActivity extends AppCompatActivity { ...@@ -31,6 +35,10 @@ public class MainActivity extends AppCompatActivity {
openLogin(); openLogin();
} }
}); });
if (! Python.isStarted()) {
Python.start(new AndroidPlatform(this));
}
} }
public void openLogin(){ public void openLogin(){
Intent intent = new Intent(this, Login.class); Intent intent = new Intent(this, Login.class);
......
package com.app.travelle;
import android.content.Context;
import android.graphics.Color;
import android.os.AsyncTask;
import android.util.Log;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.PolylineOptions;
import org.json.JSONObject;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
/**
* Created by Vishal on 10/20/2018.
*/
public class PointsParser extends AsyncTask<String, Integer, List<List<HashMap<String, String>>>> {
TaskLoadedCallback taskCallback;
String directionMode = "driving";
public PointsParser(Context mContext, String directionMode) {
this.taskCallback = (TaskLoadedCallback) mContext;
this.directionMode = directionMode;
}
// Parsing the data in non-ui thread
@Override
protected List<List<HashMap<String, String>>> doInBackground(String... jsonData) {
JSONObject jObject;
List<List<HashMap<String, String>>> routes = null;
try {
jObject = new JSONObject(jsonData[0]);
Log.d("mylog", jsonData[0].toString());
DataParser parser = new DataParser();
Log.d("mylog", parser.toString());
// Starts parsing data
routes = parser.parse(jObject);
Log.d("mylog", "Executing routes");
Log.d("mylog", routes.toString());
} catch (Exception e) {
Log.d("mylog", e.toString());
e.printStackTrace();
}
return routes;
}
// Executes in UI thread, after the parsing process
@Override
protected void onPostExecute(List<List<HashMap<String, String>>> result) {
ArrayList<LatLng> points;
PolylineOptions lineOptions = null;
// Traversing through all the routes
for (int i = 0; i < result.size(); i++) {
points = new ArrayList<>();
lineOptions = new PolylineOptions();
// Fetching i-th route
List<HashMap<String, String>> path = result.get(i);
// Fetching all the points in i-th route
for (int j = 0; j < path.size(); j++) {
HashMap<String, String> point = path.get(j);
double lat = Double.parseDouble(point.get("lat"));
double lng = Double.parseDouble(point.get("lng"));
LatLng position = new LatLng(lat, lng);
points.add(position);
}
// Adding all the points in the route to LineOptions
lineOptions.addAll(points);
if (directionMode.equalsIgnoreCase("walking")) {
lineOptions.width(10);
lineOptions.color(Color.MAGENTA);
} else {
lineOptions.width(20);
lineOptions.color(Color.BLUE);
}
Log.d("mylog", "onPostExecute lineoptions decoded");
}
// Drawing polyline in the Google Map for the i-th route
if (lineOptions != null) {
//mMap.addPolyline(lineOptions);
taskCallback.onTaskDone(lineOptions);
} else {
Log.d("mylog", "without Polylines drawn");
}
}
}
package com.app.travelle;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AppCompatActivity;
import android.annotation.SuppressLint;
import android.app.ProgressDialog;
import android.content.Intent;
import android.graphics.Color;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;
import com.chaquo.python.PyObject;
import com.chaquo.python.Python;
import com.chaquo.python.android.AndroidPlatform;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.MapFragment;
import com.google.android.gms.maps.OnMapReadyCallback;
import com.google.android.gms.maps.model.BitmapDescriptorFactory;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.LatLngBounds;
import com.google.android.gms.maps.model.Marker;
import com.google.android.gms.maps.model.MarkerOptions;
import com.google.android.gms.maps.model.Polyline;
import com.google.android.gms.maps.model.PolylineOptions;
import com.google.common.base.CharMatcher;
import com.google.firebase.database.DataSnapshot;
import com.google.firebase.database.DatabaseError;
import com.google.firebase.database.DatabaseReference;
import com.google.firebase.database.FirebaseDatabase;
import com.google.firebase.database.ValueEventListener;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import org.json.JSONTokener;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.sql.SQLOutput;
import java.util.ArrayList;
import org.json.JSONException;
import org.json.JSONObject;
import io.grpc.internal.JsonParser;
public class RouteActivity extends AppCompatActivity implements OnMapReadyCallback, TaskLoadedCallback {
private GoogleMap mMap;
private MarkerOptions place1, place2;
Button getDirection;
private Polyline currentPolyline;
Marker mm;
Bundle bundle;
TextView timeDisplay,fireDisply,TrackerLoca;
String[] Route;
ProgressDialog pd;
@SuppressLint("MissingInflatedId")
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.route_activity);
//requestWindowFeature(getWindow().FEATURE_NO_TITLE);
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
getSupportActionBar().hide();
pd = new ProgressDialog(this);
timeDisplay = findViewById(R.id.time_pred);
fireDisply = findViewById(R.id.fair_calc);
TrackerLoca = findViewById(R.id.TrackerL);
MapFragment mapFragment = (MapFragment) getFragmentManager().findFragmentById(R.id.mapsFrag);
mapFragment.getMapAsync(this);
//27.658143,85.3199503
//27.667491,85.3208583
Intent intent = getIntent();
bundle = intent.getExtras();
int ArrivalID = bundle.getInt("EndLocation");
Route = findRoute(1,13,ArrivalID);
int Routlength = Route.length - 1;
place1 = new MarkerOptions().position(new LatLng(Double.valueOf(Route[1]), Double.valueOf(Route[2]))).title("Location 1");
place2 = new MarkerOptions().position(new LatLng(Double.valueOf(Route[Routlength-2]), Double.valueOf(Route[Routlength-1]))).title("Location 2");
String url = getUrl(place1.getPosition(), place2.getPosition(), "transit");
new FetchURL(RouteActivity.this).execute(getUrl(place1.getPosition(), place2.getPosition(), "driving"), "driving");
pd.setTitle("Travelle Fetching..");
pd.show();
}
@Override
public void onMapReady(@NonNull GoogleMap googleMap) {
mMap = googleMap;
mMap.addMarker(place1);
mMap.addMarker(place2);
// Firebase data come from here
DatabaseReference databaseReference = FirebaseDatabase.getInstance().getReference("/");
System.out.println("================================================") ;
System.out.println(databaseReference);
ValueEventListener listener = databaseReference.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
System.out.println("changing-----------------------------");
String latitude = dataSnapshot.child("latitude").getValue(String.class);
String longitude = dataSnapshot.child("longitude").getValue(String.class);
System.out.println(latitude+longitude);
LatLng location = new LatLng(Double.parseDouble(latitude),Double.parseDouble(longitude));
//Toast.makeText(RouteActivity.this, "This is data :-"+latitude+" Longi :-"+longitude, Toast.LENGTH_SHORT).show();
//Set the location
String NearestValue = GetCurrentLocationName(Double.parseDouble(longitude),Double.parseDouble(latitude));
TrackerLoca.setText(NearestValue);
if(mm != null){
mm.remove();
}
mm = mMap.addMarker(new MarkerOptions()
.position(location)
.title("117")
.icon(BitmapDescriptorFactory.fromResource(R.drawable.bus_icon))
);
//bus stop marker here
LatLng BStopLocation = new LatLng(6.913578717566548,79.99873889604599);
mMap.addMarker(new MarkerOptions()
.position(BStopLocation)
.title("BusStop1")
.icon(BitmapDescriptorFactory.fromResource(R.drawable.transit))
);
//bus stop marker end here
int Routlength = Route.length - 1;
LatLngBounds.Builder builder = new LatLngBounds.Builder();
builder.include(new LatLng(Double.valueOf(Route[1]), Double.valueOf(Route[2])));
builder.include(new LatLng(Double.valueOf(Route[Routlength-2]), Double.valueOf(Route[Routlength-1])));
mMap.moveCamera(CameraUpdateFactory.newLatLngBounds(builder.build(), 190));
pd.dismiss();
mMap.setOnCameraMoveListener(new GoogleMap.OnCameraMoveListener() {
@Override
public void onCameraMove() {
}
});
int TravelTime = bundle.getInt("TimePrediction");
timeDisplay.setText(""+TravelTime+"min");
fireDisply.setText("LKR "+Route[0]+".00");
}
@Override
public void onCancelled(@NonNull DatabaseError databaseError) {
}
});
}
private String getUrl(LatLng origin, LatLng dest, String directionMode) {
// Origin of route
String str_origin = "origin=" + origin.latitude + "," + origin.longitude;
// Destination of route
String str_dest = "destination=" + dest.latitude + "," + dest.longitude;
// Mode
String mode = "mode=" + directionMode;
// Building the parameters to the web service
String parameters = str_origin + "&" + str_dest + "&" + mode;
// Output format
String output = "json";
// Building the url to the web service
String url = "https://maps.googleapis.com/maps/api/directions/" + output + "?" + parameters + "&key=" + getString(R.string.google_maps_key);
return url;
}
@Override
public void onTaskDone(Object... values) {
if (currentPolyline != null)
currentPolyline.remove();
currentPolyline = mMap.addPolyline((PolylineOptions) values[0]);
}
public String[] findRoute(int map,int start, int destination){
if (! Python.isStarted()) {
Python.start(new AndroidPlatform(this));
}
Python py = Python.getInstance();
PyObject pyobj = py.getModule("AL");
PyObject obj = pyobj.callAttr("get_route",map,start,destination);
System.out.println("-----------ssssssssssssssssssssssss-------------------");
String testValue = obj.toString();
String valueRE = testValue.replace("[(","");
String valueRE2 = valueRE.replace(")]","");
String valueRE3 = valueRE2.replace(")","");
String valueRE4 = valueRE3.replace("(","");
String valueRE5 = valueRE4.replace("[","");
int occurance = CharMatcher.is(',').countIn(valueRE5);
String[] arrOfStr = valueRE5.split(",", occurance);
for (String a : arrOfStr)
System.out.println(a);
return arrOfStr;
}
public String GetCurrentLocationName(Double longi,Double lat){
if (! Python.isStarted()) {
Python.start(new AndroidPlatform(this));
}
Python py = Python.getInstance();
PyObject pyobj = py.getModule("AL");
PyObject obj = pyobj.callAttr("get_nearest_station",lat,longi);
PyObject obj2 = pyobj.callAttr("get_route",1,2,3);
//semina function call and get the current location name
return obj.toString();
}
}
\ No newline at end of file
package com.app.travelle;
/**
* Created by Vishal on 10/20/2018.
*/
public interface TaskLoadedCallback {
void onTaskDone(Object... values);
}
This diff is collapsed.
This diff is collapsed.
...@@ -2,8 +2,10 @@ ...@@ -2,8 +2,10 @@
import pandas as pd import pandas as pd
# %% # %%
data = pd.read_csv('TravelTimePrediction\BusTravelData.csv') #data = pd.read_csv('../TravelTimePrediction\BusTravelData.csv')
from os.path import dirname, join
filename = join(dirname(__file__), "BusTravelData.csv")
data = pd.read_csv(filename)
# %% # %%
data['Day'].unique() data['Day'].unique()
...@@ -36,6 +38,8 @@ X = data.drop(['Date','Travel Time'],axis=1) ...@@ -36,6 +38,8 @@ X = data.drop(['Date','Travel Time'],axis=1)
# %% # %%
y = data['Travel Time'] y = data['Travel Time']
print("Python printing")
# %% [markdown] # %% [markdown]
# Train/test split # Train/test split
......
import networkx as nx
#from chart_studio import plotly as py
import random
#init_notebook_mode(connected=True)
route_177 = {
0:0,
1: 34,
2: 42,
3: 54,
4: 67,
5: 80,
6: 92,
7: 105,
8: 109,
9: 117,
10: 126,
11: 134,
12: 140,
13: 149,
14: 157,
15: 163,
}
route_176 = {
0:0,
1: 34,
2: 42,
3: 54,
}
route_8717 = {
0:0,
1: 20,
2: 20,
3: 20,
4: 20,
5: 40
}
map_test = {
0: {'pos': (6.911034627182109, 79.84918916006576), 'connections': [1,16], 'name' : 'Kollupitiya','type': 0,'routeNo': 177, 'hValue': 5},
1: {'pos': (6.911751932322411, 79.86194701315071), 'connections': [0,2], 'name' : 'Viharamahadevi Park', 'type': 0, 'routeNo': 177, 'hValue': 1},
2: {'pos': (6.911385550864001, 79.87682791026592), 'connections': [1,3], 'name' : 'House Of Fashion', 'type': 0, 'routeNo': 177, 'hValue': 1},
3: {'pos': (6.911031363415147, 79.88498429384545), 'connections': [2,4], 'name' : 'Castle Street', 'type': 0, 'routeNo': 177, 'hValue': 1},
4: {'pos': (6.908462881966912, 79.89338919261249), 'connections': [3,5], 'name' : 'Rajagiriya', 'type': 0, 'routeNo': 177, 'hValue': 1},
5: {'pos': (6.906663916178293, 79.90205413217801), 'connections': [4,6], 'name' : 'HSBC Rajagiriya', 'type': 0, 'routeNo': 177, 'hValue': 1},
6: {'pos': (6.90333333857459, 79.90747047529919), 'connections': [5,7], 'name' : 'Ethulkotte New', 'type': 0, 'routeNo': 177, 'hValue': 1},
7: {'pos': (6.903185701293392, 79.91168232658337), 'connections': [6,8], 'name' : 'Parliaent Junction', 'type': 0, 'routeNo': 177, 'hValue': 1},
8: {'pos': (6.902102452411621, 79.91741047710077), 'connections': [7,9], 'name' : 'Battaramulla Junction', 'type': 0, 'routeNo': 177, 'hValue': 1},
9: {'pos': (6.90431022366131, 79.92400480782847), 'connections': [8,10], 'name' : 'Ganahena', 'type': 0, 'routeNo': 177, 'hValue': 1},
10: {'pos': (6.906173952520986, 79.92862087153598), 'connections': [9,11], 'name' : 'Koswatta', 'type': 0, 'routeNo': 177, 'hValue': 1},
11: {'pos': (6.9084657304543455, 79.9383708894408), 'connections': [10,12], 'name' : 'Kotte-Bope', 'type': 0, 'routeNo': 177, 'hValue': 1},
12: {'pos': (6.9085023402918155, 79.94425286198016), 'connections': [11,13], 'name' : 'Thalahena Junction', 'type': 0, 'routeNo': 177, 'hValue': 1},
13: {'pos': (6.903962700873259, 79.95430199947661), 'connections': [12,14], 'name' : 'Malabe', 'type': 0, 'routeNo': 177, 'hValue': 1},
14: {'pos': (6.933539686667202, 79.85005389798111), 'connections': [15], 'name' : 'Fort_TR', 'type': 1, 'routeNo': 8717, 'hValue': 1},
15: {'pos': (6.923619774894732, 79.84965509086771), 'connections': [14,16], 'name' : 'Kompannavidiya_TR', 'type': 1, 'routeNo': 8717, 'hValue': 1},
16: {'pos': (6.911282166657041, 79.84821747831087), 'connections': [15,1,17], 'name' : 'Kollupitiya_TR', 'type': 1, 'routeNo': 8717, 'hValue': 1},
17: {'pos': (6.893710110662125, 79.85300590028642), 'connections': [16,18], 'name' : 'Bambalapitiya_TR', 'type': 1, 'routeNo': 8717, 'hValue': 1},
18: {'pos': (6.875030063532378, 79.85744793142631), 'connections': [17,19], 'name' : 'Wellawatte_TR', 'type': 1, 'routeNo': 8717, 'hValue': 1},
19: {'pos': (6.850915755796403, 79.8620969312958), 'connections': [18], 'name' : 'Dehiwala_TR', 'type': 1, 'routeNo': 8717, 'hValue': 1},
}
class Map:
def __init__(self, G):
self._graph = G
self.intersections = nx.get_node_attributes(G, "pos")
self.routeNo = nx.get_node_attributes(G, "routeNo")
self.type = nx.get_node_attributes(G, "type")
self.name = nx.get_node_attributes(G, "name")
self.roads = [list(G[node]) for node in G.nodes()]
def load_map_graph(map_dict):
G = nx.Graph()
for node in map_dict.keys():
G.add_node(node, pos=map_dict[node]['pos'], type=map_dict[node]['type'],routeNo=map_dict[node]['routeNo'],name=map_dict[node]['name'])
for node in map_dict.keys():
for con_node in map_dict[node]['connections']:
G.add_edge(node, con_node)
return G
def load_map_b(map_dict):
G = nx.Graph()
for node in map_dict.keys():
G.add_node(node, pos=map_dict[node]['pos'], type=map_dict[node]['type'],routeNo=map_dict[node]['routeNo'])
for node in map_dict.keys():
for con_node in map_dict[node]['connections']:
if map_dict[node]['type'] != 1:
continue
elif map_dict[con_node]['type'] != 1:
continue
else:
G.add_edge(node, con_node)
return G
#map for train
def load_map_t(map_dict):
G = nx.Graph()
for node in map_dict.keys():
G.add_node(node, pos=map_dict[node]['pos'], type=map_dict[node]['type'],routeNo=map_dict[node]['routeNo'])
for node in map_dict.keys():
for con_node in map_dict[node]['connections']:
if map_dict[node]['type'] == 1:
continue
elif map_dict[con_node]['type'] == 1:
continue
else:
G.add_edge(node, con_node)
return G
def load_map_test():
G = load_map_graph(map_test)
return Map(G)
def load_map_bus():
G = load_map_b(map_test)
return Map(G)
def load_map_train():
G = load_map_t(map_test)
return Map(G)
def main(paka,paka2):
return paka+12
\ No newline at end of file
from helpers import load_map_train, load_map_test, load_map_bus
ANSWERS = [
(1,5, 10, [5, 6, 7, 8, 9,10]),
(1,5, 5, [5]),
(1,3, 18, [3, 2, 1, 16, 17, 18]),
(1,14, 18, [14, 15, 16, 17, 18]),
(1,15, 2, [15, 16, 1, 2])
]
def test(path_planner_function):
print('testing started ---------------')
correct = 0
for mapval, start, goal, answer_path in ANSWERS:
if mapval == 3:
map = load_map_train()
elif mapval == 2:
map = load_map_bus()
else:
map = load_map_test()
path = path_planner_function(map, start, goal).path
if path == answer_path:
correct += 1
print("For start:", start,
"Goal: ", goal,
"Your path:", path,
"Correct: ", answer_path)
else:
print("Error Testing faild !!!" )
if correct == len(ANSWERS):
print("All tests pass ")
else:
print("Only passed", correct, "/", len(ANSWERS), "test cases")
\ No newline at end of file
...@@ -13,16 +13,6 @@ ...@@ -13,16 +13,6 @@
android:id="@+id/maps_section" android:id="@+id/maps_section"
android:name="com.google.android.gms.maps.SupportMapFragment"/> android:name="com.google.android.gms.maps.SupportMapFragment"/>
<ImageView
android:id="@+id/imageView10"
android:layout_width="508dp"
android:layout_height="297dp"
android:layout_marginStart="-60dp"
android:layout_marginTop="572dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/rectangle_16" />
<!-- <com.google.android.material.textfield.TextInputLayout <!-- <com.google.android.material.textfield.TextInputLayout
android:id="@+id/search_destination" android:id="@+id/search_destination"
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox" style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
...@@ -56,6 +46,16 @@ ...@@ -56,6 +46,16 @@
android:hint="Where to?" /> android:hint="Where to?" />
</com.google.android.material.textfield.TextInputLayout> --> </com.google.android.material.textfield.TextInputLayout> -->
<ImageView
android:id="@+id/imageView10"
android:layout_width="508dp"
android:layout_height="297dp"
android:layout_marginStart="-60dp"
android:layout_marginTop="520dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/rectangle_16" />
<Button <Button
android:id="@+id/findbus" android:id="@+id/findbus"
android:layout_width="124dp" android:layout_width="124dp"
...@@ -63,7 +63,6 @@ ...@@ -63,7 +63,6 @@
android:layout_marginStart="140dp" android:layout_marginStart="140dp"
android:layout_marginBottom="16dp" android:layout_marginBottom="16dp"
android:backgroundTint="#262730" android:backgroundTint="#262730"
android:onClick="btnRetrieveLocation"
android:text="FIND " android:text="FIND "
app:cornerRadius="60px" app:cornerRadius="60px"
android:textSize="60px" android:textSize="60px"
...@@ -72,6 +71,7 @@ ...@@ -72,6 +71,7 @@
<ImageView <ImageView
android:id="@+id/imageView7" android:id="@+id/imageView7"
android:layout_width="539dp" android:layout_width="539dp"
...@@ -95,12 +95,27 @@ ...@@ -95,12 +95,27 @@
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" /> app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/current_location"
android:layout_width="340dp"
android:layout_height="59dp"
android:layout_marginStart="32dp"
android:layout_marginBottom="10dp"
android:fontFamily="@font/sans_italic"
android:textSize="19dp"
android:gravity="center"
android:textColorHint="@drawable/selector"
android:textAlignment="center"
android:background="@drawable/rounded_corner"
app:layout_constraintBottom_toTopOf="@+id/where_to"
app:layout_constraintStart_toStartOf="parent" />
<AutoCompleteTextView <AutoCompleteTextView
android:id="@+id/where_to" android:id="@+id/where_to"
android:layout_width="340dp" android:layout_width="340dp"
android:layout_height="59dp" android:layout_height="59dp"
android:layout_marginStart="32dp" android:layout_marginStart="32dp"
android:layout_marginBottom="30dp" android:layout_marginBottom="20dp"
android:hint="Where to" android:hint="Where to"
android:fontFamily="@font/sans_bold" android:fontFamily="@font/sans_bold"
android:textColorHint="@drawable/selector" android:textColorHint="@drawable/selector"
...@@ -108,9 +123,9 @@ ...@@ -108,9 +123,9 @@
android:completionThreshold="1" android:completionThreshold="1"
android:completionHint="Select a city" android:completionHint="Select a city"
android:background="@drawable/rounded_corner" android:background="@drawable/rounded_corner"
app:layout_constraintBottom_toTopOf="@+id/findbus" app:layout_constraintBottom_toTopOf="@+id/findbus"
app:layout_constraintStart_toStartOf="parent" /> app:layout_constraintStart_toStartOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
This diff is collapsed.
<?xml version="1.0" encoding="utf-8"?>
<navigation xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/nav_graph2"
app:startDestination="@id/First2Fragment">
<fragment
android:id="@+id/First2Fragment"
android:name="com.app.travelle.First2Fragment"
android:label="@string/first_fragment_label"
tools:layout="@layout/fragment_first2">
<action
android:id="@+id/action_First2Fragment_to_Second2Fragment"
app:destination="@id/Second2Fragment" />
</fragment>
<fragment
android:id="@+id/Second2Fragment"
android:name="com.app.travelle.Second2Fragment"
android:label="@string/second_fragment_label"
tools:layout="@layout/fragment_second2">
<action
android:id="@+id/action_Second2Fragment_to_First2Fragment"
app:destination="@id/First2Fragment" />
</fragment>
</navigation>
\ No newline at end of file
<resources> <resources>
<dimen name="fab_margin">48dp</dimen> <dimen name="fab_margin">48dp</dimen>
</resources> </resources>
\ No newline at end of file \ No newline at end of file
<resources> <resources>
<dimen name="fab_margin">200dp</dimen> <dimen name="fab_margin">200dp</dimen>
</resources> </resources>
\ No newline at end of file \ No newline at end of file
<resources> <resources>
<dimen name="fab_margin">48dp</dimen> <dimen name="fab_margin">48dp</dimen>
</resources> </resources>
\ No newline at end of file \ No newline at end of file
...@@ -2,4 +2,4 @@ ...@@ -2,4 +2,4 @@
<dimen name="fab_margin">16dp</dimen> <dimen name="fab_margin">16dp</dimen>
<dimen name="activity_horizontal_margin">0dp</dimen> <dimen name="activity_horizontal_margin">0dp</dimen>
<dimen name="activity_vertical_margin">0dp</dimen> <dimen name="activity_vertical_margin">0dp</dimen>
</resources> </resources>
\ No newline at end of file \ No newline at end of file
...@@ -12,4 +12,6 @@ ...@@ -12,4 +12,6 @@
<string name="title_activity_homemap">homemap</string> <string name="title_activity_homemap">homemap</string>
<string name="title_activity_home_map">HomeMap</string> <string name="title_activity_home_map">HomeMap</string>
<string name="title_activity_retrieve_bus_map">RetrieveBusMap</string> <string name="title_activity_retrieve_bus_map">RetrieveBusMap</string>
<string name="title_activity_route">RouteActivity</string>
<string name="google_maps_key">AIzaSyA6byk50XLU3_WXUpsy7HGfpKbbrjwVlj8</string>
</resources> </resources>
\ No newline at end of file
...@@ -13,10 +13,13 @@ ...@@ -13,10 +13,13 @@
<item name="android:statusBarColor">?attr/colorPrimaryVariant</item> <item name="android:statusBarColor">?attr/colorPrimaryVariant</item>
<!-- Customize your theme here. --> <!-- Customize your theme here. -->
</style> </style>
<style name="Theme.Travelle.NoActionBar"> <style name="Theme.Travelle.NoActionBar">
<item name="windowActionBar">false</item> <item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item> <item name="windowNoTitle">true</item>
</style> </style>
<style name="Theme.Travelle.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" /> <style name="Theme.Travelle.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />
<style name="Theme.Travelle.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" /> <style name="Theme.Travelle.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />
</resources> </resources>
\ No newline at end of file
buildscript { buildscript {
repositories { repositories {
// Make sure that you have the following two repositories // Make sure that you have the following two repositories
maven { url "https://chaquo.com/maven" }
} }
dependencies { dependencies {
classpath 'com.google.gms:google-services:4.3.14' classpath 'com.google.gms:google-services:4.3.14'
classpath "com.chaquo.python:gradle:13.0.0"
classpath "com.chaquo.python:gradle:13.0.0"
} }
...@@ -16,6 +17,7 @@ plugins { ...@@ -16,6 +17,7 @@ plugins {
id 'com.android.application' version '7.3.0' apply false id 'com.android.application' version '7.3.0' apply false
id 'com.android.library' version '7.3.0' apply false id 'com.android.library' version '7.3.0' apply false
id 'com.google.android.libraries.mapsplatform.secrets-gradle-plugin' version '2.0.1' apply false id 'com.google.android.libraries.mapsplatform.secrets-gradle-plugin' version '2.0.1' apply false
id 'com.chaquo.python' version '13.0.0' apply false
} }
allprojects { allprojects {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment