Commit 973e414a authored by Nirman M.A.H.L's avatar Nirman M.A.H.L

Merge branch 'master' into 'IT19177342'

Master

See merge request 2022-020/2022-020!33
parents 8be416f6 3d3a5278
Travelle
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="RemoteRepositoriesConfiguration">
<remote-repository>
<option name="id" value="central" />
<option name="name" value="Maven Central repository" />
<option name="url" value="https://repo1.maven.org/maven2" />
</remote-repository>
<remote-repository>
<option name="id" value="jboss.community" />
<option name="name" value="JBoss Community repository" />
<option name="url" value="https://repository.jboss.org/nexus/content/repositories/public/" />
</remote-repository>
<remote-repository>
<option name="id" value="MavenRepo" />
<option name="name" value="MavenRepo" />
<option name="url" value="https://repo.maven.apache.org/maven2/" />
</remote-repository>
<remote-repository>
<option name="id" value="Google" />
<option name="name" value="Google" />
<option name="url" value="https://dl.google.com/dl/android/maven2/" />
</remote-repository>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="" vcs="Git" />
</component>
</project>
\ No newline at end of file
{
"python.analysis.extraPaths": [
"./TravelTimePrediction/TrainData",
"./TravelTimePrediction"
]
}
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
This diff is collapsed.
# %%
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
...@@ -1668,7 +1668,7 @@ ...@@ -1668,7 +1668,7 @@
"orig_nbformat": 4, "orig_nbformat": 4,
"vscode": { "vscode": {
"interpreter": { "interpreter": {
"hash": "26de051ba29f2982a8de78e945f0abaf191376122a1563185a90213a26c5da77" "hash": "5cf8c3d3e58a91b903f819a9c98dd2220f70e367ec47969cb612bf546ce9e823"
} }
} }
}, },
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
import pandas as pd import pandas as pd
# %% # %%
data = pd.read_csv('BusTravelData.csv') data = pd.read_csv('TravelTimePrediction\BusTravelData.csv')
# %% # %%
...@@ -180,6 +180,8 @@ def GetDateCode(date): ...@@ -180,6 +180,8 @@ def GetDateCode(date):
import testingWeather import testingWeather
city = "malabe" city = "malabe"
city = city+" weather" city = city+" weather"
...@@ -187,16 +189,37 @@ time= 6 #this time come from semins data/member of route planning ...@@ -187,16 +189,37 @@ time= 6 #this time come from semins data/member of route planning
day ='Friday' #date come from UI day ='Friday' #date come from UI
date = GetDateCode(day) date = GetDateCode(day)
special = 0 # Special Day or Not 1/0 special = 0 # Special Day or Not 1/0
Congestion= 8 # This is depend on the depature time---- heavy traffic =9 / No Traffic = 0 Congestion= 8 # This is come from TomTOm API / APK app
drivingspeedAVG = 40 #this is come from GPS data drivingspeedAVG = 40 #this is come from GPS data
stops =14 #total Bus stops/holts between the travel --- data come from the Seminas data/member of route planning stops =14 #total Bus stops/holts between the travel --- data come from the Seminas data/member of route planning
weather =testingWeather.weather(city) #Get weather in travel area weather =testingWeather.weather(city) #Get weather in travel area
Distance =14.7 #Distance data come from seminas ----- data come from the Seminas data/member of route planning Distance =14.7 #Distance data come from seminas ----- data come from the Seminas data/member of route planning
GetPrediction(time,date,special,Congestion,drivingspeedAVG,stops,weather,Distance) #- ToDO
# callTimePrediction arguments should be dis, stops, hour, day
# Get Prediction USing this Method after Seminas Calling
def CallTimePrediction(distance,BuStops,TodayDate):
FnewDate = GetDateCode(TodayDate)
GetPrediction(time,FnewDate,special,Congestion,drivingspeedAVG,BuStops,weather,distance)
# Get Train Data
# import sys
# adding Folder_2/subfolder to the system path
# sys.path.insert(0, 'TravelTimePrediction\TrainData')
# importing the hello
# from TrainTimePrediction import GetPrediction
# GetPrediction('Dehiwala','Fort')
plugins { plugins {
id 'com.android.application' id 'com.android.application'
id 'com.google.android.libraries.mapsplatform.secrets-gradle-plugin' id 'com.google.android.libraries.mapsplatform.secrets-gradle-plugin'
id 'com.google.gms.google-services'
} }
android { android {
...@@ -42,7 +43,23 @@ dependencies { ...@@ -42,7 +43,23 @@ dependencies {
implementation 'com.google.android.gms:play-services-maps:18.1.0' implementation 'com.google.android.gms:play-services-maps:18.1.0'
implementation 'com.google.android.gms:play-services-maps:18.1.0' implementation 'com.google.android.gms:play-services-maps:18.1.0'
implementation 'com.google.android.gms:play-services-location:20.0.0' implementation 'com.google.android.gms:play-services-location:20.0.0'
implementation 'com.google.firebase:firebase-database:20.0.6'
testImplementation 'junit:junit:4.13.2' testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3' androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0' androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
} // Import the BoM for the Firebase platform
\ No newline at end of file implementation platform('com.google.firebase:firebase-bom:30.5.0')
// Add the dependency for the Realtime Database library
// When using the BoM, you don't specify versions in Firebase library dependencies
implementation 'com.google.firebase:firebase-database'
// Import the BoM for the Firebase platform
implementation platform('com.google.firebase:firebase-bom:30.5.0')
// Declare the dependencies for the desired Firebase products without specifying versions
// For example, declare the dependencies for Firebase Authentication and Cloud Firestore
implementation 'com.google.firebase:firebase-auth'
implementation 'com.google.firebase:firebase-firestore'
}
{
"project_info": {
"project_number": "764544025792",
"firebase_url": "https://gps-b123c-default-rtdb.firebaseio.com",
"project_id": "gps-b123c",
"storage_bucket": "gps-b123c.appspot.com"
},
"client": [
{
"client_info": {
"mobilesdk_app_id": "1:764544025792:android:af682706740c3b93dd1925",
"android_client_info": {
"package_name": "com.app.travelle"
}
},
"oauth_client": [
{
"client_id": "764544025792-4d40sjiq3sj6rdag8v3gdobdf1ee2kb7.apps.googleusercontent.com",
"client_type": 3
}
],
"api_key": [
{
"current_key": "AIzaSyAQdPBb4ktGFcpFqC9Fi1oDUiA0DaeIgaU"
}
],
"services": {
"appinvite_service": {
"other_platform_oauth_client": [
{
"client_id": "764544025792-4d40sjiq3sj6rdag8v3gdobdf1ee2kb7.apps.googleusercontent.com",
"client_type": 3
}
]
}
}
}
],
"configuration_version": "1"
}
\ No newline at end of file
...@@ -14,17 +14,11 @@ ...@@ -14,17 +14,11 @@
android:icon="@mipmap/ic_launcher" android:icon="@mipmap/ic_launcher"
android:label="@string/app_name" android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round" android:roundIcon="@mipmap/ic_launcher_round"
android:screenOrientation="sensorPortrait"
android:supportsRtl="true" android:supportsRtl="true"
android:theme="@style/Theme.Travelle" android:theme="@style/Theme.Travelle"
android:screenOrientation="sensorPortrait"
tools:targetApi="31"> tools:targetApi="31">
<activity
android:name=".InitialMap"
android:exported="false">
<meta-data
android:name="android.app.lib_name"
android:value="" />
</activity>
<!-- <!--
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.
...@@ -38,8 +32,19 @@ ...@@ -38,8 +32,19 @@
--> -->
<meta-data <meta-data
android:name="com.google.android.geo.API_KEY" android:name="com.google.android.geo.API_KEY"
android:value="AIzaSyD7LBGU3enFRU4u2is65UDT5jRGeIcx4_Q" /> android:value="YOUR_API_KEY" />
<activity
android:name=".RetrieveBusMap"
android:exported="false"
android:label="@string/title_activity_retrieve_bus_map" />
<activity
android:name=".InitialMap"
android:exported="false">
<meta-data
android:name="android.app.lib_name"
android:value="" />
</activity>
<activity <activity
android:name=".HomeMap" android:name=".HomeMap"
android:exported="false" android:exported="false"
......
...@@ -6,13 +6,17 @@ import androidx.core.app.ActivityCompat; ...@@ -6,13 +6,17 @@ import androidx.core.app.ActivityCompat;
import android.Manifest; import android.Manifest;
import android.annotation.SuppressLint; import android.annotation.SuppressLint;
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.util.Log; import android.util.Log;
import android.view.View;
import android.view.WindowManager; import android.view.WindowManager;
import android.widget.ArrayAdapter;
import android.widget.AutoCompleteTextView;
import com.google.android.gms.location.FusedLocationProviderClient; import com.google.android.gms.location.FusedLocationProviderClient;
import com.google.android.gms.location.LocationServices; import com.google.android.gms.location.LocationServices;
...@@ -28,10 +32,18 @@ import com.google.android.gms.maps.model.Polyline; ...@@ -28,10 +32,18 @@ import com.google.android.gms.maps.model.Polyline;
import com.google.android.gms.maps.model.PolylineOptions; 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 java.util.HashMap;
import java.util.Map;
public class InitialMap extends AppCompatActivity { public class InitialMap extends AppCompatActivity {
//Initialize variable 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"
,"Thalahena Junction","Malabe","Fort_TR","Kompannavidiya_TR","Kollupitiya_TR","Bambalapitiya_TR","Wellawatte_TR","Dehiwala_TR"
};
//Initialize variable
SupportMapFragment supportMapFragment; SupportMapFragment supportMapFragment;
FusedLocationProviderClient client; FusedLocationProviderClient client;
GoogleMap map; GoogleMap map;
...@@ -44,6 +56,12 @@ public class InitialMap extends AppCompatActivity { ...@@ -44,6 +56,12 @@ public class InitialMap extends AppCompatActivity {
getSupportActionBar().hide(); getSupportActionBar().hide();
setContentView(R.layout.activity_initial_map); setContentView(R.layout.activity_initial_map);
//Where to declaration
AutoCompleteTextView editText = findViewById(R.id.where_to);
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this , android.R.layout.simple_list_item_1, CITIES);
editText.setAdapter(adapter);
//Assign variable //Assign variable
...@@ -67,6 +85,12 @@ public class InitialMap extends AppCompatActivity { ...@@ -67,6 +85,12 @@ public class InitialMap extends AppCompatActivity {
} }
} }
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) {
......
package com.app.travelle;
import androidx.annotation.NonNull;
import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;
import androidx.fragment.app.FragmentActivity;
import android.Manifest;
import android.content.pm.PackageManager;
import android.content.res.Resources;
import android.os.Bundle;
import android.util.Log;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Toast;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.OnMapReadyCallback;
import com.google.android.gms.maps.SupportMapFragment;
import com.google.android.gms.maps.model.BitmapDescriptorFactory;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.MapStyleOptions;
import com.google.android.gms.maps.model.Marker;
import com.google.android.gms.maps.model.MarkerOptions;
import com.app.travelle.databinding.ActivityRetrieveBusMapBinding;
import com.google.android.gms.maps.model.PolylineOptions;
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;
public class RetrieveBusMap extends FragmentActivity implements OnMapReadyCallback {
private GoogleMap mMap;
private ActivityRetrieveBusMapBinding binding;
Marker mm;
@Override
protected void onCreate(Bundle savedInstanceState) {
System.out.println("Started");
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
binding = ActivityRetrieveBusMapBinding.inflate(getLayoutInflater());
setContentView(binding.getRoot());
// Obtain the SupportMapFragment and get notified when the map is ready to be used.
SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager()
.findFragmentById(R.id.map);
mapFragment.getMapAsync(this);
}
/**
* Manipulates the map once available.
* This callback is triggered when the map is ready to be used.
* This is where we can add markers or lines, add listeners or move the camera. In this case,
* we just add a marker near Sydney, Australia.
* If Google Play services is not installed on the device, the user will be prompted to install
* it inside the SupportMapFragment. This method will only be triggered once the user has
* installed Google Play services and returned to the app.
*/
@Override
public void onMapReady(GoogleMap googleMap) {
mMap = googleMap;
DatabaseReference databaseReference = FirebaseDatabase.getInstance().getReference("/");
System.out.println("================================================") ;
System.out.println(databaseReference);
//Styling
try {
// Customise the styling of the base map using a JSON object defined
// in a raw resource file.
boolean success = googleMap.setMapStyle(
MapStyleOptions.loadRawResourceStyle(
this, R.raw.map_style));
if (!success) {
Log.e("HomeMap", "Style parsing failed.");
}
} catch (Resources.NotFoundException e) {
Log.e("HomeMap", "Can't find style. Error: ", e);
}
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));
if(mm != null){
mm.remove();
}
mm = mMap.addMarker(new MarkerOptions()
.position(location)
.title("117")
.icon(BitmapDescriptorFactory.fromResource(R.drawable.bus_icon))
);
mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(location,17));
mMap.getUiSettings().setMapToolbarEnabled(false);
}
@Override
public void onCancelled(@NonNull DatabaseError databaseError) {
}
});
}
}
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners android:radius="60dp" />
<!-- This is the border color -->
<stroke android:width="2dp" android:color="#FFFFFF" />
<!--- This is the background color -->
<solid android:color="#FFFFFF" />
</shape>
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_focused="true" android:color="@android:color/transparent" />
<item android:color="#6A6A6A" />
</selector>
\ No newline at end of file
...@@ -17,13 +17,13 @@ ...@@ -17,13 +17,13 @@
android:id="@+id/imageView10" android:id="@+id/imageView10"
android:layout_width="508dp" android:layout_width="508dp"
android:layout_height="297dp" android:layout_height="297dp"
android:layout_marginStart="-67dp" android:layout_marginStart="-60dp"
android:layout_marginBottom="-40dp" android:layout_marginTop="572dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/rectangle_16" /> 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"
android:layout_width="340dp" android:layout_width="340dp"
...@@ -54,15 +54,16 @@ ...@@ -54,15 +54,16 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:fontFamily="@font/sans_bold" android:fontFamily="@font/sans_bold"
android:hint="Where to?" /> android:hint="Where to?" />
</com.google.android.material.textfield.TextInputLayout> </com.google.android.material.textfield.TextInputLayout> -->
<Button <Button
android:id="@+id/button2" android:id="@+id/findbus"
android:layout_width="124dp" android:layout_width="124dp"
android:layout_height="58dp" android:layout_height="58dp"
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"
...@@ -94,4 +95,22 @@ ...@@ -94,4 +95,22 @@
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" /> app:layout_constraintTop_toTopOf="parent" />
<AutoCompleteTextView
android:id="@+id/where_to"
android:layout_width="340dp"
android:layout_height="59dp"
android:layout_marginStart="32dp"
android:layout_marginBottom="30dp"
android:hint="Where to"
android:fontFamily="@font/sans_bold"
android:textColorHint="@drawable/selector"
android:textAlignment="center"
android:completionThreshold="1"
android:completionHint="Select a city"
android:background="@drawable/rounded_corner"
app:layout_constraintBottom_toTopOf="@+id/findbus"
app:layout_constraintStart_toStartOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:map="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/map"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".RetrieveBusMap" />
\ No newline at end of file
...@@ -6,16 +6,7 @@ ...@@ -6,16 +6,7 @@
android:layout_height="match_parent" android:layout_height="match_parent"
tools:context=".Welcome"> tools:context=".Welcome">
<ImageView <!--
android:id="@+id/imageView10"
android:layout_width="508dp"
android:layout_height="297dp"
android:layout_marginStart="-60dp"
android:layout_marginBottom="-40dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="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"
...@@ -47,16 +38,27 @@ ...@@ -47,16 +38,27 @@
</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="572dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/rectangle_16" />
<Button <Button
android:id="@+id/button2" android:id="@+id/button2"
android:layout_width="124dp" android:layout_width="165dp"
android:layout_height="58dp" android:layout_height="70dp"
android:layout_marginStart="140dp" android:layout_marginStart="120dp"
android:layout_marginBottom="16dp" android:layout_marginBottom="16dp"
android:backgroundTint="#262730" android:backgroundTint="#262730"
android:text="FIND " android:text="FIND "
app:cornerRadius="60px"
android:textSize="60px" android:textSize="60px"
app:cornerRadius="60px"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent" /> app:layout_constraintStart_toStartOf="parent" />
...@@ -75,12 +77,12 @@ ...@@ -75,12 +77,12 @@
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="156dp" android:layout_marginBottom="12dp"
android:background="#FFFFFF"
android:completionThreshold="3"
android:text="Where to" android:text="Where to"
android:textAlignment="center" android:textAlignment="center"
android:completionThreshold="3"
android:popupTheme="#FFFFFF"
android:background="#FFFFFF"
app:layout_constraintBottom_toTopOf="@+id/button2" app:layout_constraintBottom_toTopOf="@+id/button2"
app:layout_constraintStart_toStartOf="parent" /> app:layout_constraintStart_toStartOf="parent" />
......
[
{
"elementType": "geometry",
"stylers": [
{
"color": "#1d2c4d"
}
]
},
{
"elementType": "labels.text.fill",
"stylers": [
{
"color": "#8ec3b9"
}
]
},
{
"elementType": "labels.text.stroke",
"stylers": [
{
"color": "#1a3646"
}
]
},
{
"featureType": "administrative.country",
"elementType": "geometry.stroke",
"stylers": [
{
"color": "#4b6878"
}
]
},
{
"featureType": "administrative.land_parcel",
"elementType": "labels.text.fill",
"stylers": [
{
"color": "#64779e"
}
]
},
{
"featureType": "administrative.province",
"elementType": "geometry.stroke",
"stylers": [
{
"color": "#4b6878"
}
]
},
{
"featureType": "landscape.man_made",
"elementType": "geometry.stroke",
"stylers": [
{
"color": "#334e87"
}
]
},
{
"featureType": "landscape.natural",
"elementType": "geometry",
"stylers": [
{
"color": "#023e58"
}
]
},
{
"featureType": "poi",
"elementType": "geometry",
"stylers": [
{
"color": "#283d6a"
}
]
},
{
"featureType": "poi",
"elementType": "labels.text.fill",
"stylers": [
{
"color": "#6f9ba5"
}
]
},
{
"featureType": "poi",
"elementType": "labels.text.stroke",
"stylers": [
{
"color": "#1d2c4d"
}
]
},
{
"featureType": "poi.park",
"elementType": "geometry.fill",
"stylers": [
{
"color": "#023e58"
}
]
},
{
"featureType": "poi.park",
"elementType": "labels.text.fill",
"stylers": [
{
"color": "#3C7680"
}
]
},
{
"featureType": "road",
"elementType": "geometry",
"stylers": [
{
"color": "#304a7d"
}
]
},
{
"featureType": "road",
"elementType": "labels.text.fill",
"stylers": [
{
"color": "#98a5be"
}
]
},
{
"featureType": "road",
"elementType": "labels.text.stroke",
"stylers": [
{
"color": "#1d2c4d"
}
]
},
{
"featureType": "road.arterial",
"elementType": "geometry.fill",
"stylers": [
{
"color": "#545454"
}
]
},
{
"featureType": "road.highway",
"elementType": "geometry",
"stylers": [
{
"color": "#2c6675"
}
]
},
{
"featureType": "road.highway",
"elementType": "geometry.stroke",
"stylers": [
{
"color": "#255763"
}
]
},
{
"featureType": "road.highway",
"elementType": "labels.text.fill",
"stylers": [
{
"color": "#b0d5ce"
}
]
},
{
"featureType": "road.highway",
"elementType": "labels.text.stroke",
"stylers": [
{
"color": "#023e58"
}
]
},
{
"featureType": "road.local",
"elementType": "geometry.fill",
"stylers": [
{
"color": "#878787"
}
]
},
{
"featureType": "transit",
"elementType": "labels.text.fill",
"stylers": [
{
"color": "#98a5be"
}
]
},
{
"featureType": "transit",
"elementType": "labels.text.stroke",
"stylers": [
{
"color": "#1d2c4d"
}
]
},
{
"featureType": "transit.line",
"elementType": "geometry.fill",
"stylers": [
{
"color": "#283d6a"
}
]
},
{
"featureType": "transit.station",
"elementType": "geometry",
"stylers": [
{
"color": "#3a4762"
}
]
},
{
"featureType": "water",
"elementType": "geometry",
"stylers": [
{
"color": "#0e1626"
}
]
},
{
"featureType": "water",
"elementType": "labels.text.fill",
"stylers": [
{
"color": "#4e6d70"
}
]
}
]
\ No newline at end of file
...@@ -11,4 +11,5 @@ ...@@ -11,4 +11,5 @@
<string name="hello_second_fragment">Hello second fragment. Arg: %1$s</string> <string name="hello_second_fragment">Hello second fragment. Arg: %1$s</string>
<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>
</resources> </resources>
\ No newline at end of file
// Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript {
repositories {
// Make sure that you have the following two repositories
}
dependencies {
classpath 'com.google.gms:google-services:4.3.14'
}
}// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins { 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
} }
\ No newline at end of file allprojects {
repositories {
// Make sure that you have the following two repositories
}}
\ No newline at end of file
from asyncio.windows_events import NULL
from tokenize import ContStr from tokenize import ContStr
from turtle import distance from turtle import distance
from helpers import load_map_test, load_map_bus, load_map_train,route_177,route_176,route_8717 from helpers import load_map_test, load_map_bus, load_map_train,route_177,route_176,route_8717
...@@ -14,6 +15,7 @@ class PathPlanner(): ...@@ -14,6 +15,7 @@ class PathPlanner():
self.type = type self.type = type
self.range = 0 self.range = 0
self.cost = 0 self.cost = 0
self.allRoutes = [177,176,8717]
self.closedSet = self.create_closedSet() if goal != None and start != None else None self.closedSet = self.create_closedSet() if goal != None and start != None else None
self.openSet = self.create_openSet() if goal != None and start != None else None self.openSet = self.create_openSet() if goal != None and start != None else None
self.cameFrom = self.create_cameFrom() if goal != None and start != None else None self.cameFrom = self.create_cameFrom() if goal != None and start != None else None
...@@ -78,7 +80,6 @@ class PathPlanner(): ...@@ -78,7 +80,6 @@ class PathPlanner():
self.record_best_path_to(current, neighbor) self.record_best_path_to(current, neighbor)
#self.range += self.dis #self.range += self.dis
print("No Path Found")
self.path = None self.path = None
return False return False
...@@ -216,34 +217,25 @@ class PathPlanner(): ...@@ -216,34 +217,25 @@ class PathPlanner():
#traveled_distance #traveled_distance
lastNode = self.start lastNode = self.start
for n in self.path[1:]: for n in self.path[1:]:
self.range = self.range+ distance(lastNode, n ) self.range += distance(lastNode, n )
lastNode = n lastNode = n
return self.range return self.range
def get_fare(self,path): def get_fare(self,path):
currentRouteNo = self.map.routeNo[self.start] routeNumbers = []
for each in path:
temp = 0 routeNumbers.append(self.map.routeNo[each])
for x in path: #routeNumbers
if self.map.routeNo[x] == currentRouteNo:
#print('path is(x) =' + str(x)+ ' ,temp =' + str(temp)) for n in self.allRoutes:
temp+=1 val = routeNumbers.count(n)
currentRouteNo = self.map.routeNo[x] if val >= 0:
else : self.funcc(n, val)
print("eeeeeeeeeeeeeeeeeeee")
self.func(currentRouteNo, temp)
currentRouteNo = self.map.routeNo[x]
temp = 0
print('cost = ', self.cost)
#cost = cost + route_177.get(temp)
return self.cost return self.cost
def func(self, no, nodes): def funcc(self, no, nodes):
print('fuction')
if(no == 177): if(no == 177):
self.cost = self.cost + route_177.get(nodes) self.cost = self.cost + route_177.get(nodes)
elif(no == 176): elif(no == 176):
...@@ -254,35 +246,49 @@ class PathPlanner(): ...@@ -254,35 +246,49 @@ class PathPlanner():
pass pass
# Get route # Get route
def main( a, start, destination): def main( val, start, destination):
if a == 3: if val == 3:
map = load_map_train() map = load_map_train()
elif a == 2: elif val == 2:
map = load_map_bus() map = load_map_bus()
else: else:
map = load_map_test() map = load_map_test()
planner = PathPlanner(map,start,destination) planner = PathPlanner(map,start,destination)
print(map.roads) #print(map.roads)
path = planner.path path = planner.path
print("Genarated path")
if path == False: if path == False:
print("No path Found", path) print("No path Found ")
return return False
else: else:
print(path) print('path = ' ,path)
print('distance =' , planner.get_traveled_distance()) dist = planner.get_traveled_distance()/10
print(planner.get_fare(path)) print('distance = ' , dist)
fare = planner.get_fare(path)
print('trip RS.' , fare)
####--------------- calling functions of travelTimePredictions (Shiwantha) ---------------
from datetime import datetime
# get current datetime
dateTime = datetime.now()
import sys
#adding Folder_2/subfolder to the system path
sys.path.insert(0, 'TravelTimePrediction')
#importing the hello
from TravelTimePredictionNN import CallTimePrediction
#dis, stops, hour, day
CallTimePrediction(dist,len(path),(dateTime.hour),(dateTime.strftime('%A')))
main( 1, 8, 18)
main( 1, 0, 3) # from test import test
\ No newline at end of file # test(map)
\ No newline at end of file
import networkx as nx import networkx as nx
import pickle
from chart_studio import plotly as py from chart_studio import plotly as py
import random import random
from plotly.graph_objs import *
#init_notebook_mode(connected=True) #init_notebook_mode(connected=True)
route_177 = { route_177 = {
0:0,
1: 34, 1: 34,
2: 42, 2: 42,
3: 54, 3: 54,
...@@ -26,12 +26,16 @@ route_177 = { ...@@ -26,12 +26,16 @@ route_177 = {
} }
route_176 = { route_176 = {
0:0,
1: 34, 1: 34,
2: 42, 2: 42,
3: 54, 3: 54,
} }
route_8717 = { route_8717 = {
0:0,
1: 20, 1: 20,
2: 20, 2: 20,
3: 20, 3: 20,
...@@ -40,7 +44,7 @@ route_8717 = { ...@@ -40,7 +44,7 @@ route_8717 = {
} }
map_test = { map_test = {
0: {'pos': (6.911034627182109, 79.84918916006576), 'connections': [1], 'name' : 'Kollupitiya','type': 0,'routeNo': 177, 'hValue': 1}, 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}, 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}, 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}, 3: {'pos': (6.911031363415147, 79.88498429384545), 'connections': [2,4], 'name' : 'Castle Street', 'type': 0, 'routeNo': 177, 'hValue': 1},
...@@ -69,18 +73,13 @@ class Map: ...@@ -69,18 +73,13 @@ class Map:
self.intersections = nx.get_node_attributes(G, "pos") self.intersections = nx.get_node_attributes(G, "pos")
self.routeNo = nx.get_node_attributes(G, "routeNo") self.routeNo = nx.get_node_attributes(G, "routeNo")
self.type = nx.get_node_attributes(G, "type") 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()] self.roads = [list(G[node]) for node in G.nodes()]
def save(self, filename):
with open(filename, 'wb') as f:
pickle.dump(self._graph, f)
def load_map_graph(map_dict): def load_map_graph(map_dict):
G = nx.Graph() G = nx.Graph()
for node in map_dict.keys(): 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']) 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 node in map_dict.keys():
for con_node in map_dict[node]['connections']: for con_node in map_dict[node]['connections']:
G.add_edge(node, con_node) G.add_edge(node, con_node)
...@@ -89,22 +88,11 @@ def load_map_graph(map_dict): ...@@ -89,22 +88,11 @@ def load_map_graph(map_dict):
def load_map_b(map_dict): def load_map_b(map_dict):
# G = nx.Graph()
# for node in map_dict.keys():
# #nodeValue =
# if map_dict[node]['type'] != 1:
# continue
# else:
# G.add_node(node, pos=map_dict[node]['pos'], type=map_dict[node]['type'],routeNo=map_dict[node]['routeNo'])
G = nx.Graph() G = nx.Graph()
for node in map_dict.keys(): 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']) 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[con_node]['type'] != 1:
# continue
# else:
# G.add_edge(node, con_node)
for node in map_dict.keys(): for node in map_dict.keys():
for con_node in map_dict[node]['connections']: for con_node in map_dict[node]['connections']:
if map_dict[node]['type'] != 1: if map_dict[node]['type'] != 1:
......
from helpers import load_map_test
MAP_ANSWERS = [ ANSWERS = [
(5, 34, [5, 16, 37, 12, 34]), (1,5, 34, [5, 16, 37, 12, 34]),
(5, 5, [5]), (1,5, 5, [5]),
(8, 24, [8, 14, 16, 37, 12, 17, 10, 24]) (1,8, 24, [8, 14, 16, 37, 12, 17, 10, 24])
] ]
def test(shortest_path_function): def test(shortest_path_function):
map = load_map_test() print('test started ---------------')
correct = 0 correct = 0
for start, goal, answer_path in MAP_ANSWERS: for map, start, goal, answer_path in ANSWERS:
path = shortest_path_function(map, start, goal).path path = shortest_path_function(map, start, goal).path
if path == answer_path: if path == answer_path:
correct += 1 correct += 1
...@@ -19,8 +18,8 @@ def test(shortest_path_function): ...@@ -19,8 +18,8 @@ def test(shortest_path_function):
"Correct: ", answer_path) "Correct: ", answer_path)
else: else:
print("Error Testing faild !!!" ) print("Error Testing faild !!!" )
if correct == len(MAP_ANSWERS): if correct == len(ANSWERS):
print("All tests pass ") print("All tests pass ")
else: else:
print("Only passed", correct, "/", len(MAP_ANSWERS), "test cases") print("Only passed", correct, "/", len(ANSWERS), "test cases")
\ No newline at end of file
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