Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
2
2022-020
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
O.V.B Sewmina
2022-020
Commits
ff5a18c3
Commit
ff5a18c3
authored
Nov 12, 2022
by
A.P.R.C. Abeyrathna
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Final Stage V1
parent
693d76c3
Changes
25
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
25 changed files
with
1016 additions
and
17 deletions
+1016
-17
app/build.gradle
app/build.gradle
+36
-0
app/src/main/AndroidManifest.xml
app/src/main/AndroidManifest.xml
+13
-2
app/src/main/java/com/app/travelle/DataParser.java
app/src/main/java/com/app/travelle/DataParser.java
+97
-0
app/src/main/java/com/app/travelle/FetchURL.java
app/src/main/java/com/app/travelle/FetchURL.java
+79
-0
app/src/main/java/com/app/travelle/InitialMap.java
app/src/main/java/com/app/travelle/InitialMap.java
+2
-2
app/src/main/java/com/app/travelle/Login.java
app/src/main/java/com/app/travelle/Login.java
+2
-0
app/src/main/java/com/app/travelle/MainActivity.java
app/src/main/java/com/app/travelle/MainActivity.java
+14
-0
app/src/main/java/com/app/travelle/PointsParser.java
app/src/main/java/com/app/travelle/PointsParser.java
+95
-0
app/src/main/java/com/app/travelle/RetrieveBusMap.java
app/src/main/java/com/app/travelle/RetrieveBusMap.java
+2
-2
app/src/main/java/com/app/travelle/RouteActivity.java
app/src/main/java/com/app/travelle/RouteActivity.java
+84
-0
app/src/main/java/com/app/travelle/TaskLoadedCallback.java
app/src/main/java/com/app/travelle/TaskLoadedCallback.java
+9
-0
app/src/main/python/AL.py
app/src/main/python/AL.py
+362
-0
app/src/main/python/helpers.py
app/src/main/python/helpers.py
+133
-0
app/src/main/python/script.py
app/src/main/python/script.py
+5
-0
app/src/main/res/layout/activity_initial_map.xml
app/src/main/res/layout/activity_initial_map.xml
+17
-0
app/src/main/res/layout/activity_retrieve_bus_map.xml
app/src/main/res/layout/activity_retrieve_bus_map.xml
+1
-1
app/src/main/res/layout/route_activity.xml
app/src/main/res/layout/route_activity.xml
+20
-0
app/src/main/res/navigation/nav_graph2.xml
app/src/main/res/navigation/nav_graph2.xml
+28
-0
app/src/main/res/values-land/dimens.xml
app/src/main/res/values-land/dimens.xml
+2
-2
app/src/main/res/values-w1240dp/dimens.xml
app/src/main/res/values-w1240dp/dimens.xml
+2
-2
app/src/main/res/values-w600dp/dimens.xml
app/src/main/res/values-w600dp/dimens.xml
+2
-2
app/src/main/res/values/dimens.xml
app/src/main/res/values/dimens.xml
+2
-2
app/src/main/res/values/strings.xml
app/src/main/res/values/strings.xml
+2
-0
app/src/main/res/values/themes.xml
app/src/main/res/values/themes.xml
+3
-0
build.gradle
build.gradle
+4
-2
No files found.
app/build.gradle
View file @
ff5a18c3
plugins
{
id
'com.android.application'
id
'com.chaquo.python'
id
'com.google.android.libraries.mapsplatform.secrets-gradle-plugin'
id
'com.google.gms.google-services'
}
apply
plugin:
'com.android.application'
apply
plugin:
'com.chaquo.python'
android
{
namespace
'com.app.travelle'
compileSdk
32
...
...
@@ -15,7 +23,35 @@ android {
versionCode
1
versionName
"1.0"
python
{
pip
{
install
"networkx"
install
"asyncio"
}
}
ndk
{
abiFilters
"armeabi-v7a"
,
"arm64-v8a"
,
"x86"
,
"x86_64"
}
testInstrumentationRunner
"androidx.test.runner.AndroidJUnitRunner"
python
{
buildPython
"C:/Users/Chamod Abeyrathna/AppData/Local/Programs/Python/Python39/python.exe"
}
python
{
version
"3.9"
}
sourceSets
{
main
{
setRoot
"src/main/"
python
.
srcDir
"src/main/python"
}
}
}
buildTypes
{
...
...
app/src/main/AndroidManifest.xml
View file @
ff5a18c3
...
...
@@ -18,7 +18,6 @@
android:supportsRtl=
"true"
android:theme=
"@style/Theme.Travelle"
tools:targetApi=
"31"
>
<!--
TODO: Before you run your application, you need a Google Maps API key.
...
...
@@ -30,9 +29,13 @@
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}".
-->
<meta-data
android:name=
"com.google.android.gms.version"
android:value=
"@integer/google_play_services_version"
/>
<meta-data
android:name=
"com.google.android.geo.API_KEY"
android:value=
"
YOUR_API_KEY
"
/>
android:value=
"
@string/google_maps_key
"
/>
<activity
android:name=
".RetrieveBusMap"
...
...
@@ -73,11 +76,19 @@
<activity
android:name=
".MainActivity"
android:exported=
"true"
>
<intent-filter>
<action
android:name=
"android.intent.action.MAIN"
/>
<category
android:name=
"android.intent.category.LAUNCHER"
/>
</intent-filter>
<meta-data
android:name=
"android.app.lib_name"
android:value=
""
/>
</activity>
<activity
android:name=
".RouteActivity"
android:exported=
"false"
>
<meta-data
android:name=
"android.app.lib_name"
...
...
app/src/main/java/com/app/travelle/DataParser.java
0 → 100644
View file @
ff5a18c3
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
/
1
E5
)),
(((
double
)
lng
/
1
E5
)));
poly
.
add
(
p
);
}
return
poly
;
}
}
\ No newline at end of file
app/src/main/java/com/app/travelle/FetchURL.java
0 → 100644
View file @
ff5a18c3
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
;
}
}
app/src/main/java/com/app/travelle/InitialMap.java
View file @
ff5a18c3
...
...
@@ -43,7 +43,7 @@ public class InitialMap extends AppCompatActivity {
"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
//Initialize variable
SupportMapFragment
supportMapFragment
;
FusedLocationProviderClient
client
;
GoogleMap
map
;
...
...
@@ -166,4 +166,4 @@ public class InitialMap extends AppCompatActivity {
}
}
}
}
\ No newline at end of file
}
app/src/main/java/com/app/travelle/Login.java
View file @
ff5a18c3
...
...
@@ -7,6 +7,7 @@ import android.os.Bundle;
import
android.view.View
;
import
android.view.WindowManager
;
import
android.widget.Button
;
import
android.widget.Toast
;
public
class
Login
extends
AppCompatActivity
{
private
Button
login_btn
;
...
...
@@ -37,6 +38,7 @@ public class Login extends AppCompatActivity {
});
}
public
void
openWelcome
(){
Toast
.
makeText
(
this
,
"This is from login"
,
Toast
.
LENGTH_SHORT
).
show
();
Intent
intent
=
new
Intent
(
this
,
InitialMap
.
class
);
startActivity
(
intent
);
}
...
...
app/src/main/java/com/app/travelle/MainActivity.java
View file @
ff5a18c3
...
...
@@ -11,6 +11,10 @@ import android.view.Window;
import
android.view.WindowManager
;
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
{
private
Button
button
;
...
...
@@ -31,6 +35,16 @@ public class MainActivity extends AppCompatActivity {
openLogin
();
}
});
if
(!
Python
.
isStarted
())
{
Python
.
start
(
new
AndroidPlatform
(
this
));
}
Python
py
=
Python
.
getInstance
();
PyObject
pyobj
=
py
.
getModule
(
"AL"
);
//PyObject obj = pyobj.callAttr("get_nearest_station",6.902641300889514, 79.89708871696563);
PyObject
obj
=
pyobj
.
callAttr
(
"main"
,
1
,
2
,
6
);
System
.
out
.
println
(
obj
.
toString
());
}
public
void
openLogin
(){
Intent
intent
=
new
Intent
(
this
,
Login
.
class
);
...
...
app/src/main/java/com/app/travelle/PointsParser.java
0 → 100644
View file @
ff5a18c3
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"
);
}
}
}
app/src/main/java/com/app/travelle/RetrieveBusMap.java
View file @
ff5a18c3
...
...
@@ -116,7 +116,7 @@ public class RetrieveBusMap extends FragmentActivity implements OnMapReadyCallba
}
@Override
public
void
onCancelled
(
@NonNull
DatabaseError
databaseError
)
{
...
...
@@ -125,4 +125,4 @@ public class RetrieveBusMap extends FragmentActivity implements OnMapReadyCallba
}
}
\ No newline at end of file
}
app/src/main/java/com/app/travelle/RouteActivity.java
0 → 100644
View file @
ff5a18c3
//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.content.Intent;
//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 com.chaquo.python.PyObject;
//import com.chaquo.python.Python;
//import com.chaquo.python.android.AndroidPlatform;
//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.LatLng;
//import com.google.android.gms.maps.model.MarkerOptions;
//import com.google.android.gms.maps.model.Polyline;
//import com.google.android.gms.maps.model.PolylineOptions;
//
//public class RouteActivity extends AppCompatActivity implements OnMapReadyCallback, TaskLoadedCallback {
//
// private GoogleMap mMap;
// private MarkerOptions place1, place2;
// Button getDirection;
// private Polyline currentPolyline;
//
// @Override
// protected void onCreate(@Nullable Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// setContentView(R.layout.route_activity);
// getDirection = findViewById(R.id.btnGetDirection);
//
// MapFragment mapFragment = (MapFragment) getFragmentManager().findFragmentById(R.id.mapsFrag);
// mapFragment.getMapAsync(this);
//
// //27.658143,85.3199503
// //27.667491,85.3208583
// place1 = new MarkerOptions().position(new LatLng(6.911025392217044, 79.84855826417153)).title("Location 1");
// place2 = new MarkerOptions().position(new LatLng(6.903962700873259, 79.95430199947661)).title("Location 2");
// String url = getUrl(place1.getPosition(), place2.getPosition(), "driving");
// new FetchURL(RouteActivity.this).execute(getUrl(place1.getPosition(), place2.getPosition(), "driving"), "driving");
//
// }
//
//
// @Override
// public void onMapReady(@NonNull GoogleMap googleMap) {
// mMap = googleMap;
// Log.d("mylog", "Added Markers");
// mMap.addMarker(place1);
// mMap.addMarker(place2);
// }
// 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]);
// }
//}
\ No newline at end of file
app/src/main/java/com/app/travelle/TaskLoadedCallback.java
0 → 100644
View file @
ff5a18c3
package
com.app.travelle
;
/**
* Created by Vishal on 10/20/2018.
*/
public
interface
TaskLoadedCallback
{
void
onTaskDone
(
Object
...
values
);
}
app/src/main/python/AL.py
0 → 100644
View file @
ff5a18c3
This diff is collapsed.
Click to expand it.
app/src/main/python/helpers.py
0 → 100644
View file @
ff5a18c3
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'
:
'Parliament 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
)
app/src/main/python/script.py
0 → 100644
View file @
ff5a18c3
def
main
(
paka
,
paka2
):
return
paka
+
12
\ No newline at end of file
app/src/main/res/layout/activity_initial_map.xml
View file @
ff5a18c3
...
...
@@ -72,6 +72,7 @@
<ImageView
android:id=
"@+id/imageView7"
android:layout_width=
"539dp"
...
...
@@ -95,6 +96,22 @@
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toTopOf=
"parent"
/>
<AutoCompleteTextView
android:id=
"@+id/current_location"
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/where_to"
app:layout_constraintStart_toStartOf=
"parent"
/>
<AutoCompleteTextView
android:id=
"@+id/where_to"
android:layout_width=
"340dp"
...
...
app/src/main/res/layout/activity_retrieve_bus_map.xml
View file @
ff5a18c3
...
...
@@ -6,4 +6,4 @@
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
tools:context=
".RetrieveBusMap"
/>
app/src/main/res/layout/route_activity.xml
0 → 100644
View file @
ff5a18c3
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:orientation=
"vertical"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
>
<!-- <fragment-->
<!-- android:id="@+id/mapsFrag"-->
<!-- android:name="com.google.android.gms.maps.MapFragment"-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="0dp"-->
<!-- android:layout_below="@+id/rvToolbar"-->
<!-- android:layout_weight="1" />-->
<!-- <Button-->
<!-- android:id="@+id/btnGetDirection"-->
<!-- android:text="Get Direction"-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:background="?attr/selectableItemBackground" />-->
</LinearLayout>
\ No newline at end of file
app/src/main/res/navigation/nav_graph2.xml
0 → 100644
View file @
ff5a18c3
<?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
app/src/main/res/values-land/dimens.xml
View file @
ff5a18c3
<resources>
<dimen
name=
"fab_margin"
>
48dp
</dimen>
</resources>
\ No newline at end of file
<dimen
name=
"fab_margin"
>
48dp
</dimen>
</resources>
\ No newline at end of file
app/src/main/res/values-w1240dp/dimens.xml
View file @
ff5a18c3
<resources>
<dimen
name=
"fab_margin"
>
200dp
</dimen>
</resources>
\ No newline at end of file
<dimen
name=
"fab_margin"
>
200dp
</dimen>
</resources>
\ No newline at end of file
app/src/main/res/values-w600dp/dimens.xml
View file @
ff5a18c3
<resources>
<dimen
name=
"fab_margin"
>
48dp
</dimen>
</resources>
\ No newline at end of file
<dimen
name=
"fab_margin"
>
48dp
</dimen>
</resources>
\ No newline at end of file
app/src/main/res/values/dimens.xml
View file @
ff5a18c3
<resources>
<dimen
name=
"fab_margin"
>
16dp
</dimen>
<dimen
name=
"fab_margin"
>
16dp
</dimen>
<dimen
name=
"activity_horizontal_margin"
>
0dp
</dimen>
<dimen
name=
"activity_vertical_margin"
>
0dp
</dimen>
</resources>
\ No newline at end of file
</resources>
\ No newline at end of file
app/src/main/res/values/strings.xml
View file @
ff5a18c3
...
...
@@ -12,4 +12,6 @@
<string
name=
"title_activity_homemap"
>
homemap
</string>
<string
name=
"title_activity_home_map"
>
HomeMap
</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>
\ No newline at end of file
app/src/main/res/values/themes.xml
View file @
ff5a18c3
...
...
@@ -13,10 +13,13 @@
<item
name=
"android:statusBarColor"
>
?attr/colorPrimaryVariant
</item>
<!-- Customize your theme here. -->
</style>
<style
name=
"Theme.Travelle.NoActionBar"
>
<item
name=
"windowActionBar"
>
false
</item>
<item
name=
"windowNoTitle"
>
true
</item>
</style>
<style
name=
"Theme.Travelle.AppBarOverlay"
parent=
"ThemeOverlay.AppCompat.Dark.ActionBar"
/>
<style
name=
"Theme.Travelle.PopupOverlay"
parent=
"ThemeOverlay.AppCompat.Light"
/>
</resources>
\ No newline at end of file
build.gradle
View file @
ff5a18c3
buildscript
{
repositories
{
// Make sure that you have the following two repositories
maven
{
url
"https://chaquo.com/maven"
}
}
dependencies
{
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 {
id
'com.android.application'
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.chaquo.python'
version
'13.0.0'
apply
false
}
allprojects
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment