Commit 303595d3 authored by A.P.R.C. Abeyrathna's avatar A.P.R.C. Abeyrathna

Research Completed

parent 046d6cd9
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
{
"cells": [
{
"cell_type": "code",
"execution_count": 62,
"metadata": {},
"outputs": [],
"source": [
"import pandas as pd"
]
},
{
"cell_type": "code",
"execution_count": 63,
"metadata": {},
"outputs": [],
"source": [
"data = pd.read_csv('TrainData.csv')"
]
},
{
"cell_type": "code",
"execution_count": 64,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>Dipature</th>\n",
" <th>Arrival</th>\n",
" <th>Time</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>Dehiwala</td>\n",
" <td>Fort</td>\n",
" <td>25min</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>Dehiwala</td>\n",
" <td>wellawatte</td>\n",
" <td>5min</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>Dehiwala</td>\n",
" <td>bambalapitiya</td>\n",
" <td>9min</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>Dehiwala</td>\n",
" <td>kollupitiya</td>\n",
" <td>13min</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>Dehiwala</td>\n",
" <td>kompannavidiya</td>\n",
" <td>16min</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" Dipature Arrival Time\n",
"0 Dehiwala Fort 25min\n",
"1 Dehiwala wellawatte 5min\n",
"2 Dehiwala bambalapitiya 9min\n",
"3 Dehiwala kollupitiya 13min\n",
"4 Dehiwala kompannavidiya 16min"
]
},
"execution_count": 64,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"data.head()"
]
},
{
"cell_type": "code",
"execution_count": 65,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"<class 'pandas.core.frame.DataFrame'>\n",
"RangeIndex: 150 entries, 0 to 149\n",
"Data columns (total 3 columns):\n",
" # Column Non-Null Count Dtype \n",
"--- ------ -------------- ----- \n",
" 0 Dipature 150 non-null object\n",
" 1 Arrival 150 non-null object\n",
" 2 Time 150 non-null object\n",
"dtypes: object(3)\n",
"memory usage: 3.6+ KB\n"
]
}
],
"source": [
"data.info()"
]
},
{
"cell_type": "code",
"execution_count": 66,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"array(['Dehiwala', 'wellawatte', 'bambalapitiya', 'kollupitiya',\n",
" 'kompannavidiya'], dtype=object)"
]
},
"execution_count": 66,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"data['Dipature'].unique()"
]
},
{
"cell_type": "code",
"execution_count": 67,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"0 1\n",
"1 1\n",
"2 1\n",
"3 1\n",
"4 1\n",
" ..\n",
"145 3\n",
"146 3\n",
"147 4\n",
"148 4\n",
"149 5\n",
"Name: Dipature, Length: 150, dtype: int64"
]
},
"execution_count": 67,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"data['Dipature'].map({'Dehiwala':1,'wellawatte':2,'bambalapitiya':3,'kollupitiya':4,'kompannavidiya':5})"
]
},
{
"cell_type": "code",
"execution_count": 68,
"metadata": {},
"outputs": [],
"source": [
"data['Dipature'] = data['Dipature'].map({'Dehiwala':1,'wellawatte':2,'bambalapitiya':3,'kollupitiya':4,'kompannavidiya':5})"
]
},
{
"cell_type": "code",
"execution_count": 69,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"array(['Fort ', 'wellawatte', 'bambalapitiya', 'kollupitiya',\n",
" 'kompannavidiya'], dtype=object)"
]
},
"execution_count": 69,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"data['Arrival'].unique()"
]
},
{
"cell_type": "code",
"execution_count": 70,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"0 6\n",
"1 2\n",
"2 3\n",
"3 4\n",
"4 5\n",
" ..\n",
"145 5\n",
"146 6\n",
"147 5\n",
"148 6\n",
"149 6\n",
"Name: Arrival, Length: 150, dtype: int64"
]
},
"execution_count": 70,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"data['Arrival'].map({'Fort ':6,'wellawatte':2,'bambalapitiya':3,'kollupitiya':4,'kompannavidiya':5})"
]
},
{
"cell_type": "code",
"execution_count": 71,
"metadata": {},
"outputs": [],
"source": [
"data['Arrival'] = data['Arrival'].map({'Fort ':6,'wellawatte':2,'bambalapitiya':3,'kollupitiya':4,'kompannavidiya':5})"
]
},
{
"cell_type": "code",
"execution_count": 72,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>Dipature</th>\n",
" <th>Arrival</th>\n",
" <th>Time</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>1</td>\n",
" <td>6</td>\n",
" <td>25min</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>1</td>\n",
" <td>2</td>\n",
" <td>5min</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>1</td>\n",
" <td>3</td>\n",
" <td>9min</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>1</td>\n",
" <td>4</td>\n",
" <td>13min</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>1</td>\n",
" <td>5</td>\n",
" <td>16min</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" Dipature Arrival Time\n",
"0 1 6 25min\n",
"1 1 2 5min\n",
"2 1 3 9min\n",
"3 1 4 13min\n",
"4 1 5 16min"
]
},
"execution_count": 72,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"data.head()"
]
},
{
"cell_type": "code",
"execution_count": 73,
"metadata": {},
"outputs": [],
"source": [
"X = data.drop(['Time'],axis=1)"
]
},
{
"cell_type": "code",
"execution_count": 74,
"metadata": {},
"outputs": [],
"source": [
"y = data['Time']"
]
},
{
"cell_type": "code",
"execution_count": 75,
"metadata": {},
"outputs": [],
"source": [
"from sklearn.model_selection import train_test_split"
]
},
{
"cell_type": "code",
"execution_count": 76,
"metadata": {},
"outputs": [],
"source": [
"X_train,X_test,y_train,y_test = train_test_split(X,y,test_size=0.2,random_state=42)"
]
},
{
"cell_type": "code",
"execution_count": 77,
"metadata": {},
"outputs": [],
"source": [
"from sklearn.neural_network import MLPClassifier"
]
},
{
"cell_type": "code",
"execution_count": 78,
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"c:\\Users\\Shiv\\AppData\\Local\\Programs\\Python\\Python310\\lib\\site-packages\\sklearn\\neural_network\\_multilayer_perceptron.py:702: ConvergenceWarning: Stochastic Optimizer: Maximum iterations (200) reached and the optimization hasn't converged yet.\n",
" warnings.warn(\n"
]
},
{
"data": {
"text/html": [
"<style>#sk-container-id-18 {color: black;background-color: white;}#sk-container-id-18 pre{padding: 0;}#sk-container-id-18 div.sk-toggleable {background-color: white;}#sk-container-id-18 label.sk-toggleable__label {cursor: pointer;display: block;width: 100%;margin-bottom: 0;padding: 0.3em;box-sizing: border-box;text-align: center;}#sk-container-id-18 label.sk-toggleable__label-arrow:before {content: \"▸\";float: left;margin-right: 0.25em;color: #696969;}#sk-container-id-18 label.sk-toggleable__label-arrow:hover:before {color: black;}#sk-container-id-18 div.sk-estimator:hover label.sk-toggleable__label-arrow:before {color: black;}#sk-container-id-18 div.sk-toggleable__content {max-height: 0;max-width: 0;overflow: hidden;text-align: left;background-color: #f0f8ff;}#sk-container-id-18 div.sk-toggleable__content pre {margin: 0.2em;color: black;border-radius: 0.25em;background-color: #f0f8ff;}#sk-container-id-18 input.sk-toggleable__control:checked~div.sk-toggleable__content {max-height: 200px;max-width: 100%;overflow: auto;}#sk-container-id-18 input.sk-toggleable__control:checked~label.sk-toggleable__label-arrow:before {content: \"▾\";}#sk-container-id-18 div.sk-estimator input.sk-toggleable__control:checked~label.sk-toggleable__label {background-color: #d4ebff;}#sk-container-id-18 div.sk-label input.sk-toggleable__control:checked~label.sk-toggleable__label {background-color: #d4ebff;}#sk-container-id-18 input.sk-hidden--visually {border: 0;clip: rect(1px 1px 1px 1px);clip: rect(1px, 1px, 1px, 1px);height: 1px;margin: -1px;overflow: hidden;padding: 0;position: absolute;width: 1px;}#sk-container-id-18 div.sk-estimator {font-family: monospace;background-color: #f0f8ff;border: 1px dotted black;border-radius: 0.25em;box-sizing: border-box;margin-bottom: 0.5em;}#sk-container-id-18 div.sk-estimator:hover {background-color: #d4ebff;}#sk-container-id-18 div.sk-parallel-item::after {content: \"\";width: 100%;border-bottom: 1px solid gray;flex-grow: 1;}#sk-container-id-18 div.sk-label:hover label.sk-toggleable__label {background-color: #d4ebff;}#sk-container-id-18 div.sk-serial::before {content: \"\";position: absolute;border-left: 1px solid gray;box-sizing: border-box;top: 0;bottom: 0;left: 50%;z-index: 0;}#sk-container-id-18 div.sk-serial {display: flex;flex-direction: column;align-items: center;background-color: white;padding-right: 0.2em;padding-left: 0.2em;position: relative;}#sk-container-id-18 div.sk-item {position: relative;z-index: 1;}#sk-container-id-18 div.sk-parallel {display: flex;align-items: stretch;justify-content: center;background-color: white;position: relative;}#sk-container-id-18 div.sk-item::before, #sk-container-id-18 div.sk-parallel-item::before {content: \"\";position: absolute;border-left: 1px solid gray;box-sizing: border-box;top: 0;bottom: 0;left: 50%;z-index: -1;}#sk-container-id-18 div.sk-parallel-item {display: flex;flex-direction: column;z-index: 1;position: relative;background-color: white;}#sk-container-id-18 div.sk-parallel-item:first-child::after {align-self: flex-end;width: 50%;}#sk-container-id-18 div.sk-parallel-item:last-child::after {align-self: flex-start;width: 50%;}#sk-container-id-18 div.sk-parallel-item:only-child::after {width: 0;}#sk-container-id-18 div.sk-dashed-wrapped {border: 1px dashed gray;margin: 0 0.4em 0.5em 0.4em;box-sizing: border-box;padding-bottom: 0.4em;background-color: white;}#sk-container-id-18 div.sk-label label {font-family: monospace;font-weight: bold;display: inline-block;line-height: 1.2em;}#sk-container-id-18 div.sk-label-container {text-align: center;}#sk-container-id-18 div.sk-container {/* jupyter's `normalize.less` sets `[hidden] { display: none; }` but bootstrap.min.css set `[hidden] { display: none !important; }` so we also need the `!important` here to be able to override the default hidden behavior on the sphinx rendered scikit-learn.org. See: https://github.com/scikit-learn/scikit-learn/issues/21755 */display: inline-block !important;position: relative;}#sk-container-id-18 div.sk-text-repr-fallback {display: none;}</style><div id=\"sk-container-id-18\" class=\"sk-top-container\"><div class=\"sk-text-repr-fallback\"><pre>MLPClassifier()</pre><b>In a Jupyter environment, please rerun this cell to show the HTML representation or trust the notebook. <br />On GitHub, the HTML representation is unable to render, please try loading this page with nbviewer.org.</b></div><div class=\"sk-container\" hidden><div class=\"sk-item\"><div class=\"sk-estimator sk-toggleable\"><input class=\"sk-toggleable__control sk-hidden--visually\" id=\"sk-estimator-id-18\" type=\"checkbox\" checked><label for=\"sk-estimator-id-18\" class=\"sk-toggleable__label sk-toggleable__label-arrow\">MLPClassifier</label><div class=\"sk-toggleable__content\"><pre>MLPClassifier()</pre></div></div></div></div></div>"
],
"text/plain": [
"MLPClassifier()"
]
},
"execution_count": 78,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"NN = MLPClassifier()\n",
"NN.fit(X_train,y_train)"
]
},
{
"cell_type": "code",
"execution_count": 79,
"metadata": {},
"outputs": [],
"source": [
"y_pred1 = NN.predict(X_test)"
]
},
{
"cell_type": "code",
"execution_count": 80,
"metadata": {},
"outputs": [],
"source": [
"df1 = pd.DataFrame({'Actual':y_test, 'NN Results':y_pred1})"
]
},
{
"cell_type": "code",
"execution_count": 81,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>Dipature</th>\n",
" <th>Arrival</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>1</td>\n",
" <td>2</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" Dipature Arrival\n",
"0 1 2"
]
},
"execution_count": 81,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"data = {'Dipature':1,\n",
" 'Arrival':2,\n",
" }\n",
"df = pd.DataFrame(data,index=[0])\n",
"df"
]
},
{
"cell_type": "code",
"execution_count": 82,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Train Travel Time Prediction :- 5min \n"
]
}
],
"source": [
"predit = NN.predict(df)\n",
"print('Train Travel Time Prediction :- ',*predit,' ')"
]
},
{
"cell_type": "code",
"execution_count": 83,
"metadata": {},
"outputs": [],
"source": [
"def GetTrainPrediction(Dipature,Arrival):\n",
" data = {'Dipature':Dipature,\n",
" 'Arrival':Arrival,\n",
" }\n",
" df = pd.DataFrame(data,index=[0])\n",
" predit = NN.predict(df)\n",
" print('Train Travel Time Prediction :- ',*predit,' ')"
]
},
{
"cell_type": "code",
"execution_count": 84,
"metadata": {},
"outputs": [],
"source": [
"def GetDipatureCode(data):\n",
" if('Dehiwala' == data):\n",
" return 1\n",
" elif('wellawatte' == data):\n",
" return 2\n",
" elif('bambalapitiya' == data):\n",
" return 3\n",
" elif('kollupitiya' == data):\n",
" return 4\n",
" elif('kompannavidiya' == data):\n",
" return 5"
]
},
{
"cell_type": "code",
"execution_count": 85,
"metadata": {},
"outputs": [],
"source": [
"def GetArrivalCode(data):\n",
" if('Fort' == data):\n",
" return 6\n",
" elif('wellawatte' == data):\n",
" return 2\n",
" elif('bambalapitiya' == data):\n",
" return 3\n",
" elif('kollupitiya' == data):\n",
" return 4\n",
" elif('kompannavidiya' == data):\n",
" return 5"
]
},
{
"cell_type": "code",
"execution_count": 86,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Train Travel Time Prediction :- 25min \n"
]
}
],
"source": [
"Dipature = GetDipatureCode('Dehiwala')\n",
"Arrival = GetArrivalCode('Fort')\n",
"\n",
"GetTrainPrediction(Dipature,Arrival)"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3.10.7 64-bit",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.7"
},
"orig_nbformat": 4,
"vscode": {
"interpreter": {
"hash": "5cf8c3d3e58a91b903f819a9c98dd2220f70e367ec47969cb612bf546ce9e823"
}
}
},
"nbformat": 4,
"nbformat_minor": 2
}
# %%
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
...@@ -25,11 +25,18 @@ android { ...@@ -25,11 +25,18 @@ android {
python{ python{
pip{ pip{
install "numpy"
install "pandas"
install "matplotlib"
install "sklearn"
install "matplotlib"
install "scikit-learn"
install "networkx" install "networkx"
install "asyncio" install "asyncio"
} }
} }
...@@ -44,7 +51,7 @@ android { ...@@ -44,7 +51,7 @@ android {
buildPython "C:/Users/Chamod Abeyrathna/AppData/Local/Programs/Python/Python39/python.exe" buildPython "C:/Users/Chamod Abeyrathna/AppData/Local/Programs/Python/Python39/python.exe"
} }
python { python {
version "3.9" version "3.8"
} }
sourceSets { sourceSets {
main { main {
......
...@@ -76,7 +76,6 @@ ...@@ -76,7 +76,6 @@
<activity <activity
android:name=".MainActivity" android:name=".MainActivity"
android:exported="true"> android:exported="true">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.MAIN" /> <action android:name="android.intent.action.MAIN" />
...@@ -90,6 +89,8 @@ ...@@ -90,6 +89,8 @@
android:name=".RouteActivity" android:name=".RouteActivity"
android:exported="false"> android:exported="false">
<meta-data <meta-data
android:name="android.app.lib_name" android:name="android.app.lib_name"
android:value="" /> android:value="" />
......
...@@ -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);
} }
}
public void btnRetrieveLocation(View view) {
startActivity(new Intent(getApplicationContext(),RetrieveBusMap.class)); 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)
);
}
});
} }
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,6 +2,7 @@ package com.app.travelle; ...@@ -2,6 +2,7 @@ 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;
...@@ -13,6 +14,7 @@ public class Login extends AppCompatActivity { ...@@ -13,6 +14,7 @@ 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);
...@@ -21,6 +23,8 @@ public class Login extends AppCompatActivity { ...@@ -21,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);
...@@ -38,7 +42,6 @@ public class Login extends AppCompatActivity { ...@@ -38,7 +42,6 @@ public class Login extends AppCompatActivity {
}); });
} }
public void openWelcome(){ public void openWelcome(){
Toast.makeText(this, "This is from login", Toast.LENGTH_SHORT).show();
Intent intent = new Intent(this, InitialMap.class); Intent intent = new Intent(this, InitialMap.class);
startActivity(intent); startActivity(intent);
} }
......
...@@ -38,13 +38,7 @@ public class MainActivity extends AppCompatActivity { ...@@ -38,13 +38,7 @@ public class MainActivity extends AppCompatActivity {
if (! Python.isStarted()) { if (! Python.isStarted()) {
Python.start(new AndroidPlatform(this)); 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(){ public void openLogin(){
Intent intent = new Intent(this, Login.class); Intent intent = new Intent(this, Login.class);
......
//package com.app.travelle; package com.app.travelle;
//
//import androidx.annotation.NonNull; import androidx.annotation.NonNull;
//import androidx.annotation.Nullable; import androidx.annotation.Nullable;
//import androidx.appcompat.app.ActionBar; import androidx.appcompat.app.ActionBar;
//import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.app.AppCompatActivity;
//
//import android.annotation.SuppressLint; import android.annotation.SuppressLint;
//import android.content.Intent; import android.app.ProgressDialog;
//import android.os.Bundle; import android.content.Intent;
//import android.util.Log; import android.graphics.Color;
//import android.view.View; import android.os.Bundle;
//import android.view.Window; import android.util.Log;
//import android.view.WindowManager; import android.view.View;
//import android.widget.Button; import android.view.Window;
// import android.view.WindowManager;
//import com.chaquo.python.PyObject; import android.widget.Button;
//import com.chaquo.python.Python; import android.widget.TextView;
//import com.chaquo.python.android.AndroidPlatform; import android.widget.Toast;
//import com.google.android.gms.maps.GoogleMap;
//import com.google.android.gms.maps.MapFragment; import com.chaquo.python.PyObject;
//import com.google.android.gms.maps.OnMapReadyCallback; import com.chaquo.python.Python;
//import com.google.android.gms.maps.model.LatLng; import com.chaquo.python.android.AndroidPlatform;
//import com.google.android.gms.maps.model.MarkerOptions; import com.google.android.gms.maps.CameraUpdateFactory;
//import com.google.android.gms.maps.model.Polyline; import com.google.android.gms.maps.GoogleMap;
//import com.google.android.gms.maps.model.PolylineOptions; import com.google.android.gms.maps.MapFragment;
// import com.google.android.gms.maps.OnMapReadyCallback;
//public class RouteActivity extends AppCompatActivity implements OnMapReadyCallback, TaskLoadedCallback { import com.google.android.gms.maps.model.BitmapDescriptorFactory;
// import com.google.android.gms.maps.model.LatLng;
// private GoogleMap mMap; import com.google.android.gms.maps.model.LatLngBounds;
// private MarkerOptions place1, place2; import com.google.android.gms.maps.model.Marker;
// Button getDirection; import com.google.android.gms.maps.model.MarkerOptions;
// private Polyline currentPolyline; import com.google.android.gms.maps.model.Polyline;
// import com.google.android.gms.maps.model.PolylineOptions;
// @Override import com.google.common.base.CharMatcher;
// protected void onCreate(@Nullable Bundle savedInstanceState) { import com.google.firebase.database.DataSnapshot;
// super.onCreate(savedInstanceState); import com.google.firebase.database.DatabaseError;
// setContentView(R.layout.route_activity); import com.google.firebase.database.DatabaseReference;
// getDirection = findViewById(R.id.btnGetDirection); import com.google.firebase.database.FirebaseDatabase;
// import com.google.firebase.database.ValueEventListener;
// MapFragment mapFragment = (MapFragment) getFragmentManager().findFragmentById(R.id.mapsFrag);
// mapFragment.getMapAsync(this); import org.json.JSONArray;
// import org.json.JSONException;
// //27.658143,85.3199503 import org.json.JSONObject;
// //27.667491,85.3208583 import org.json.JSONTokener;
// 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"); import java.io.FileReader;
// String url = getUrl(place1.getPosition(), place2.getPosition(), "driving"); import java.io.FileWriter;
// new FetchURL(RouteActivity.this).execute(getUrl(place1.getPosition(), place2.getPosition(), "driving"), "driving"); import java.io.IOException;
// import java.sql.SQLOutput;
// } import java.util.ArrayList;
// import org.json.JSONException;
// import org.json.JSONObject;
// @Override
// public void onMapReady(@NonNull GoogleMap googleMap) { import io.grpc.internal.JsonParser;
// mMap = googleMap;
// Log.d("mylog", "Added Markers"); public class RouteActivity extends AppCompatActivity implements OnMapReadyCallback, TaskLoadedCallback {
// mMap.addMarker(place1);
// mMap.addMarker(place2); private GoogleMap mMap;
// } private MarkerOptions place1, place2;
// private String getUrl(LatLng origin, LatLng dest, String directionMode) { Button getDirection;
// // Origin of route private Polyline currentPolyline;
// String str_origin = "origin=" + origin.latitude + "," + origin.longitude; Marker mm;
// // Destination of route Bundle bundle;
// String str_dest = "destination=" + dest.latitude + "," + dest.longitude; TextView timeDisplay,fireDisply,TrackerLoca;
// // Mode String[] Route;
// String mode = "mode=" + directionMode; ProgressDialog pd;
// // Building the parameters to the web service
// String parameters = str_origin + "&" + str_dest + "&" + mode; @SuppressLint("MissingInflatedId")
// // Output format @Override
// String output = "json"; protected void onCreate(@Nullable Bundle savedInstanceState) {
// // Building the url to the web service super.onCreate(savedInstanceState);
// String url = "https://maps.googleapis.com/maps/api/directions/" + output + "?" + parameters + "&key=" + getString(R.string.google_maps_key); setContentView(R.layout.route_activity);
// return url; //requestWindowFeature(getWindow().FEATURE_NO_TITLE);
// } this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
// getSupportActionBar().hide();
// pd = new ProgressDialog(this);
// @Override
// public void onTaskDone(Object... values) { timeDisplay = findViewById(R.id.time_pred);
// if (currentPolyline != null) fireDisply = findViewById(R.id.fair_calc);
// currentPolyline.remove(); TrackerLoca = findViewById(R.id.TrackerL);
// currentPolyline = mMap.addPolyline((PolylineOptions) values[0]);
// } MapFragment mapFragment = (MapFragment) getFragmentManager().findFragmentById(R.id.mapsFrag);
//} mapFragment.getMapAsync(this);
\ No newline at end of file
//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
#from asyncio.windows_events import NULL #from asyncio.windows_events import NULL
from cmath import inf from cmath import inf
from tokenize import ContStr from tokenize import ContStr
#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
from math import radians, cos, sin, asin, sqrt from math import radians, cos, sin, asin, sqrt
import json
class PathPlanner(): class PathPlanner():
...@@ -212,14 +212,14 @@ class PathPlanner(): ...@@ -212,14 +212,14 @@ class PathPlanner():
#self.dis = dist #self.dis = dist
return dist return dist
def get_traveled_distance(self): # def get_traveled_distance(self):
#traveled_distance # #traveled_distance
lastNode = self.start # lastNode = self.start
for n in self.path[1:]: # for n in self.path[1:]:
self.range += distance(lastNode, n ) # self.range = range + distance(self,lastNode, n)
lastNode = n # lastNode = n
return self.range # return self.range
def get_fare(self,path): def get_fare(self,path):
...@@ -247,7 +247,7 @@ class PathPlanner(): ...@@ -247,7 +247,7 @@ class PathPlanner():
# Get route # Get route
def main( val, start, destination): def get_route( val, start, destination):
if val == 3: if val == 3:
map = load_map_train() map = load_map_train()
elif val == 2: elif val == 2:
...@@ -258,11 +258,43 @@ def main( val, start, destination): ...@@ -258,11 +258,43 @@ def main( val, start, destination):
planner = PathPlanner(map,start,destination) planner = PathPlanner(map,start,destination)
#print(map.roads) #print(map.roads)
path = planner.path path = planner.path
print(type(path))
if path == False: if path == False:
print("No path Found ")
return False return False
else: else:
# print('path = ' ,path)
#dist = planner.get_traveled_distance()/10
dist =10
# print('distance = ' , dist)
fare = planner.get_fare(path)
# print('trip RS.' , fare)
# return path
#data = dict()
data = []
data.append(fare)
for each in path:
data.append(map.intersections[each])
#print(type(data))
return data
# for each in path:
# data[each] = list()
#raw = {map.intersections[each],map.name[each],map.routeNo[each],map.type[each]}
# jsonData=json.dumps(data)
#
# data[each].extend(raw)
#
# route = json.dumps(data)
#
#
# return route,dist,fare
return path
#>>>>>>>>>>>>>>>>>>>>> #>>>>>>>>>>>>>>>>>>>>>
...@@ -297,7 +329,7 @@ def test1(typ,start,stop1,stop2,stop3): ...@@ -297,7 +329,7 @@ def test1(typ,start,stop1,stop2,stop3):
raise ValueError("No path found for planner") raise ValueError("No path found for planner")
path1.extend(path2) path1.extend(path2)
print(path1)
else: else:
planner2 = PathPlanner(map,stop1,stop2) planner2 = PathPlanner(map,stop1,stop2)
path2 = planner2.path path2 = planner2.path
...@@ -311,33 +343,33 @@ def test1(typ,start,stop1,stop2,stop3): ...@@ -311,33 +343,33 @@ def test1(typ,start,stop1,stop2,stop3):
path1.extend(path2 + path3) path1.extend(path2 + path3)
print (path1)
def get_nearest_station(lon,lat): def get_nearest_station(lon,lat):
map = load_map_test() map = load_map_test()
tempDist = float(inf) tempDist = float('inf')
nearestStation = None nearestStation = None
lon1 = radians(lon) lon1 = radians(lon)
lat1 = radians(lat) lat1 = radians(lat)
for node in map.intersections.keys(): for node in map.intersections.keys():
lon2 = radians(map.intersections [node][0]) lon2 = radians(map.intersections [node][0])
lat2 = radians(map.intersections [node][1]) lat2 = radians(map.intersections [node][1])
# Haversine formula # Haversine formula
dlon = lon2 - lon1 dlon = lon2 - lon1
dlat = lat2 - lat1 dlat = lat2 - lat1
a = sin(dlat / 2)**2 + cos(lat1) * cos(lat2) * sin(dlon / 2)**2 a = sin(dlat / 2)**2 + cos(lat1) * cos(lat2) * sin(dlon / 2)**2
c = 2 * asin(sqrt(a)) c = 2 * asin(sqrt(a))
# Radius of earth in kilometers # Radius of earth in kilometers
r = 6371 r = 6371
# calculate the result # calculate the result
dist = (c * r) dist = (c * r)
...@@ -345,11 +377,10 @@ def get_nearest_station(lon,lat): ...@@ -345,11 +377,10 @@ def get_nearest_station(lon,lat):
tempDist = dist tempDist = dist
nearestStation = map.name[node] nearestStation = map.name[node]
return nearestStation return nearestStation
#<<<<<<<<<<<<<<<<< #<<<<<<<<<<<<<<<<<
#main( 1, 14, 15) #print(get_route( 1, 14, 15) )
#>>>>>>>>>>>>>> #>>>>>>>>>>>>>>
#test1(1,2,3,14,18) #test1(1,2,3,14,18)
......
...@@ -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
......
...@@ -51,7 +51,7 @@ map_test = { ...@@ -51,7 +51,7 @@ map_test = {
4: {'pos': (6.908462881966912, 79.89338919261249), 'connections': [3,5], 'name' : 'Rajagiriya', '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}, 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}, 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}, 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}, 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}, 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}, 10: {'pos': (6.906173952520986, 79.92862087153598), 'connections': [9,11], 'name' : 'Koswatta', 'type': 0, 'routeNo': 177, 'hValue': 1},
......
...@@ -13,49 +13,49 @@ ...@@ -13,49 +13,49 @@
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"/>
<!-- <com.google.android.material.textfield.TextInputLayout
android:id="@+id/search_destination"
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
android:layout_width="340dp"
android:layout_height="70dp"
android:layout_marginStart="30dp"
android:layout_marginTop="260dp"
app:boxBackgroundColor="#FFFFFF"
app:boxCornerRadiusBottomEnd="60px"
app:boxCornerRadiusBottomStart="60px"
app:boxCornerRadiusTopEnd="60px"
app:boxCornerRadiusTopStart="60px"
app:boxStrokeColor="#FFFFFF"
app:endIconMode="clear_text"
app:startIconTint="@color/white"
app:endIconTint="#FFFFFF"
android:shadowColor="#000000"
android:shadowDx="1.2"
android:shadowDy="1.2"
android:shadowRadius="1.5"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<com.google.android.material.textfield.TextInputEditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fontFamily="@font/sans_bold"
android:hint="Where to?" />
</com.google.android.material.textfield.TextInputLayout> -->
<ImageView <ImageView
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="-60dp" android:layout_marginStart="-60dp"
android:layout_marginTop="572dp" android:layout_marginTop="520dp"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/rectangle_16" /> app:srcCompat="@drawable/rectangle_16" />
<!-- <com.google.android.material.textfield.TextInputLayout
android:id="@+id/search_destination"
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
android:layout_width="340dp"
android:layout_height="70dp"
android:layout_marginStart="30dp"
android:layout_marginTop="260dp"
app:boxBackgroundColor="#FFFFFF"
app:boxCornerRadiusBottomEnd="60px"
app:boxCornerRadiusBottomStart="60px"
app:boxCornerRadiusTopEnd="60px"
app:boxCornerRadiusTopStart="60px"
app:boxStrokeColor="#FFFFFF"
app:endIconMode="clear_text"
app:startIconTint="@color/white"
app:endIconTint="#FFFFFF"
android:shadowColor="#000000"
android:shadowDx="1.2"
android:shadowDy="1.2"
android:shadowRadius="1.5"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<com.google.android.material.textfield.TextInputEditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fontFamily="@font/sans_bold"
android:hint="Where to?" />
</com.google.android.material.textfield.TextInputLayout> -->
<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"
...@@ -96,18 +95,17 @@ ...@@ -96,18 +95,17 @@
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" /> app:layout_constraintTop_toTopOf="parent" />
<AutoCompleteTextView <TextView
android:id="@+id/current_location" android:id="@+id/current_location"
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="10dp"
android:hint="Where to" android:fontFamily="@font/sans_italic"
android:fontFamily="@font/sans_bold" android:textSize="19dp"
android:gravity="center"
android:textColorHint="@drawable/selector" android:textColorHint="@drawable/selector"
android:textAlignment="center" android:textAlignment="center"
android:completionThreshold="1"
android:completionHint="Select a city"
android:background="@drawable/rounded_corner" android:background="@drawable/rounded_corner"
app:layout_constraintBottom_toTopOf="@+id/where_to" app:layout_constraintBottom_toTopOf="@+id/where_to"
app:layout_constraintStart_toStartOf="parent" /> app:layout_constraintStart_toStartOf="parent" />
...@@ -117,7 +115,7 @@ ...@@ -117,7 +115,7 @@
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"
...@@ -125,9 +123,9 @@ ...@@ -125,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
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical" android:orientation="vertical"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="match_parent">
<!-- <fragment--> <androidx.cardview.widget.CardView
<!-- android:id="@+id/mapsFrag"--> android:id="@+id/bus_card"
<!-- android:name="com.google.android.gms.maps.MapFragment"--> android:layout_width="match_parent"
<!-- android:layout_width="match_parent"--> android:layout_height="wrap_content"
<!-- android:layout_height="0dp"--> android:layout_marginLeft="8dp"
<!-- android:layout_below="@+id/rvToolbar"--> android:layout_marginTop="5dp"
<!-- android:layout_weight="1" />--> android:layout_marginRight="8dp"
<!-- <Button--> android:clickable="false"
<!-- android:id="@+id/btnGetDirection"--> android:focusable="true"
<!-- android:text="Get Direction"--> android:foreground="?android:attr/selectableItemBackground"
<!-- android:layout_width="match_parent"--> app:cardCornerRadius="4dp"
<!-- android:layout_height="wrap_content"--> app:cardUseCompatPadding="true"
<!-- android:background="?attr/selectableItemBackground" />--> app:contentPadding="10dp">
</LinearLayout>
\ No newline at end of file <LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="100">
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="60"
android:orientation="vertical">
<!-- <TextView-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:fontFamily="@font/calibri"-->
<!-- android:text="1st"-->
<!-- android:textColor="#000000"-->
<!-- android:textStyle="bold" />-->
<ImageView
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_marginTop="4dp"
android:layout_marginBottom="4dp"
android:paddingLeft="-130dp"
android:src="@drawable/bus_icon" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="22dp"
android:fontFamily="@font/sans_bold"
android:text="117"
android:textAlignment="textStart"
android:textSize="20sp"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:layout_width="20dp"
android:layout_height="match_parent"
android:layout_weight="40"
android:gravity="center"
android:paddingRight="10dp"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fontFamily="@font/calibri"
android:text="Bus is near"
android:textAlignment="textEnd"
android:textColor="#8a8a8a" />
<TextView
android:id="@+id/TrackerL"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="4dp"
android:fontFamily="@font/sans_bold"
android:text="Tracker Location"
android:textSize="18sp"
android:textStyle="bold"
android:textAlignment="textEnd"
/>
</LinearLayout>
</LinearLayout>
</androidx.cardview.widget.CardView>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="57dp"
android:layout_below="@+id/mapsFrag"
android:layout_marginTop="504dp"
android:layout_weight="1">
<TextView
android:id="@+id/time_pred"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:fontFamily="@font/nunito_bold"
android:text="Time"
android:textAlignment="center"
android:gravity="center"
android:textColor="#191C22"
android:textSize="28sp"
android:textStyle="bold" />
<TextView
android:id="@+id/fair_calc"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:fontFamily="@font/calibri"
android:text="Fare"
android:gravity="center"
android:textAlignment="center"
android:textColor="#f5a622"
android:textSize="24sp"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="27dp"
android:layout_below="@+id/mapsFrag"
android:layout_marginTop="566dp"
android:layout_weight="1">
<TextView
android:id="@+id/textView3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Bus Stops"
android:textAlignment="center"
android:textColor="#191C22"
android:drawableLeft="@drawable/bus_stop__5_"
android:gravity="center"
android:drawablePadding="20dp"
android:paddingHorizontal="120dp"
android:textSize="18sp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fontFamily="@font/tw"
android:layout_below="@+id/mapsFrag"
android:layout_marginTop="594dp"
android:layout_weight="1">
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
</RelativeLayout>
<androidx.cardview.widget.CardView
android:id="@+id/cardView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
android:layout_marginTop="2dp"
android:layout_marginRight="8dp"
android:clickable="true"
android:focusable="true"
android:foreground="?android:attr/selectableItemBackground"
app:cardCornerRadius="4dp"
app:cardUseCompatPadding="true"
app:contentPadding="16dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="100">
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="60"
android:orientation="vertical">
<!-- <TextView-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:fontFamily="@font/calibri"-->
<!-- android:text="1st"-->
<!-- android:textColor="#000000"-->
<!-- android:textStyle="bold" />-->
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
android:layout_marginBottom="4dp"
android:fontFamily="@font/calibri"
android:text="Kaduwela"
android:textColor="#4b4b4b"
android:textStyle="bold" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fontFamily="@font/calibri"
android:text="2.5 KM"
android:textColor="#8a8a8a" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="40"
android:gravity="center"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
android:layout_marginBottom="4dp"
android:fontFamily="@font/calibri"
android:text="4mins"
android:textAlignment="textEnd"
android:textColor="#b3b3b3" />
</LinearLayout>
</LinearLayout>
</androidx.cardview.widget.CardView>
<androidx.cardview.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:clickable="true"
android:focusable="true"
android:foreground="?android:attr/selectableItemBackground"
app:cardCornerRadius="4dp"
app:cardUseCompatPadding="true"
app:contentPadding="16dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="100">
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="60"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
android:layout_marginBottom="4dp"
android:fontFamily="@font/calibri"
android:text="Kothalawala"
android:textColor="#4b4b4b"
android:textStyle="bold" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fontFamily="@font/calibri"
android:text="3.4 KM"
android:textColor="#8a8a8a" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="40"
android:gravity="center"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
android:layout_marginBottom="4dp"
android:fontFamily="@font/calibri"
android:text="12mins"
android:textAlignment="textEnd"
android:textColor="#b3b3b3" />
</LinearLayout>
</LinearLayout>
</androidx.cardview.widget.CardView>
<androidx.cardview.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:clickable="true"
android:focusable="true"
android:foreground="?android:attr/selectableItemBackground"
app:cardCornerRadius="4dp"
app:cardUseCompatPadding="true"
app:contentPadding="16dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="100">
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="60"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
android:layout_marginBottom="4dp"
android:fontFamily="@font/calibri"
android:text="SLIIT"
android:textColor="#4b4b4b"
android:textStyle="bold" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fontFamily="@font/calibri"
android:text="7.9 KM"
android:textColor="#8a8a8a" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="40"
android:gravity="center"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
android:layout_marginBottom="4dp"
android:fontFamily="@font/calibri"
android:text="21mins"
android:textAlignment="textEnd"
android:textColor="#b3b3b3" />
</LinearLayout>
</LinearLayout>
</androidx.cardview.widget.CardView>
<androidx.cardview.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:clickable="true"
android:focusable="true"
android:foreground="?android:attr/selectableItemBackground"
app:cardCornerRadius="4dp"
app:cardUseCompatPadding="true"
app:contentPadding="16dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="100">
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="60"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
android:layout_marginBottom="4dp"
android:fontFamily="@font/calibri"
android:text="Pittugala"
android:textColor="#4b4b4b"
android:textStyle="bold" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fontFamily="@font/calibri"
android:text="11.3 KM"
android:textColor="#8a8a8a" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="40"
android:gravity="center"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
android:layout_marginBottom="4dp"
android:fontFamily="@font/calibri"
android:text="24mins"
android:textAlignment="textEnd"
android:textColor="#b3b3b3" />
</LinearLayout>
</LinearLayout>
</androidx.cardview.widget.CardView>
<androidx.cardview.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:clickable="true"
android:focusable="true"
android:foreground="?android:attr/selectableItemBackground"
app:cardCornerRadius="4dp"
app:cardUseCompatPadding="true"
app:contentPadding="16dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="100">
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="60"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
android:layout_marginBottom="4dp"
android:fontFamily="@font/calibri"
android:text="Malabe"
android:textColor="#4b4b4b"
android:textStyle="bold" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fontFamily="@font/calibri"
android:text="12.2 KM"
android:textColor="#8a8a8a" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="40"
android:gravity="center"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
android:layout_marginBottom="4dp"
android:fontFamily="@font/calibri"
android:text="27mins"
android:textAlignment="textEnd"
android:textColor="#b3b3b3" />
</LinearLayout>
</LinearLayout>
</androidx.cardview.widget.CardView>
</LinearLayout>
</ScrollView>
</LinearLayout>
<fragment
android:id="@+id/mapsFrag"
android:name="com.google.android.gms.maps.MapFragment"
android:layout_width="match_parent"
android:layout_height="504dp"
android:layout_below="@+id/rvToolbar"
android:layout_weight="1" />
</FrameLayout>
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