Browse Source

Merge remote-tracking branch 'origin/yigit' into efe

old
Efe Aydın 6 years ago
parent
commit
ea49d6e5f6
53 changed files with 98506 additions and 205713 deletions
  1. +1
    -0
      MyCity/app/build.gradle
  2. +3
    -3
      MyCity/app/src/main/java/gq/yigit/mycity/DenunciationFragment.java
  3. +15
    -3
      MyCity/app/src/main/java/gq/yigit/mycity/MainActivity.java
  4. +4
    -4
      MyCity/app/src/main/java/gq/yigit/mycity/RateFragment.java
  5. +306
    -0
      MyCity/app/src/main/java/gq/yigit/mycity/navigation/TransitFragment.java
  6. +5
    -4
      MyCity/app/src/main/java/gq/yigit/mycity/tools/WebRequest.java
  7. +2
    -2
      MyCity/app/src/main/java/gq/yigit/mycity/utility/UtilityElectricity.java
  8. +3
    -3
      MyCity/app/src/main/java/gq/yigit/mycity/votesFragment/VoteFragment.java
  9. +2
    -2
      MyCity/app/src/main/java/gq/yigit/mycity/votesFragment/VotesFragment.java
  10. +1
    -1
      MyCity/app/src/main/res/drawable-v24/magnifier.xml
  11. +12
    -0
      MyCity/app/src/main/res/drawable/circle_shape.xml
  12. +11
    -0
      MyCity/app/src/main/res/drawable/line_shape.xml
  13. +10
    -0
      MyCity/app/src/main/res/drawable/search_shape.xml
  14. +0
    -1
      MyCity/app/src/main/res/layout/fragment_main.xml
  15. +37
    -0
      MyCity/app/src/main/res/layout/fragment_transit.xml
  16. +1
    -1
      MyCity/app/src/main/res/layout/fragment_utility.xml
  17. +20
    -8
      MyCity/app/src/main/res/layout/popup_confirmation.xml
  18. +72
    -0
      MyCity/app/src/main/res/layout/transit_item.xml
  19. +1
    -0
      MyCity/app/src/main/res/values/dimens.xml
  20. +9
    -0
      client_side/client_side.iml
  21. +31
    -0
      client_side/interface/UserData/index.html
  22. +4
    -0
      client_side/interface/UserData/index.js
  23. +333
    -0
      client_side/interface/UserData/package-lock.json
  24. +1
    -0
      client_side/interface/UserData/socket.io
  25. +16
    -0
      client_side/interface/UserData/style.css
  26. +0
    -0
      client_side/modules/__init__.py
  27. BIN
      client_side/modules/__pycache__/__init__.cpython-37.pyc
  28. +0
    -0
      client_side/modules/qr/__init__.py
  29. BIN
      client_side/modules/qr/__pycache__/__init__.cpython-37.pyc
  30. BIN
      client_side/modules/qr/__pycache__/reader.cpython-37.pyc
  31. BIN
      client_side/modules/qr/__pycache__/user_data.cpython-37.pyc
  32. +37
    -0
      client_side/modules/qr/reader.py
  33. +30
    -0
      client_side/modules/qr/user_data.py
  34. +1
    -0
      client_side/requirements.txt
  35. +1
    -2
      server_side/api/app.py
  36. BIN
      server_side/api/modules/__pycache__/denunciation.cpython-37.pyc
  37. BIN
      server_side/api/modules/__pycache__/navigation.cpython-37.pyc
  38. BIN
      server_side/api/modules/__pycache__/user_info.cpython-37.pyc
  39. BIN
      server_side/api/modules/__pycache__/voting_system.cpython-37.pyc
  40. +97188
    -57179
      server_side/api/modules/databases/bus.json
  41. +0
    -148267
      server_side/api/modules/databases/json
  42. +3
    -0
      server_side/api/modules/databases/users.json
  43. +345
    -41
      server_side/api/modules/navigation.py
  44. +1
    -31
      server_side/api/modules/user_info.py
  45. +0
    -1
      server_side/api/requirements.txt
  46. +0
    -60
      smart_home/.gitignore
  47. BIN
      smart_home/Output-Keypoints.jpg
  48. BIN
      smart_home/Output-Skeleton.jpg
  49. +0
    -85
      smart_home/pose_detector.py
  50. BIN
      smart_home/single.jpeg
  51. BIN
      smart_home/single.jpg
  52. BIN
      smart_home/single.png
  53. +0
    -15
      smart_home/smart_home.iml

+ 1
- 0
MyCity/app/build.gradle View File

@ -32,4 +32,5 @@ dependencies {
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation 'com.google.android.libraries.places:places:1.1.0'
}

+ 3
- 3
MyCity/app/src/main/java/gq/yigit/mycity/DenunciationFragment.java View File

@ -112,7 +112,7 @@ public class DenunciationFragment extends Fragment implements WebRequest.respons
args.put("photo", "null");
}
WebRequest request = new WebRequest(url+"/denunciation",false,args);
WebRequest request = new WebRequest(url+"/denunciation",false,args,0);
request.addListener(activity);
request.execute();
}
@ -177,7 +177,7 @@ public class DenunciationFragment extends Fragment implements WebRequest.respons
void onFragmentInteraction(Uri uri);
}
public void receivedResponse(boolean success, String response) {
public void receivedResponse(boolean success, String response,int id) {
try {
JSONObject received = new JSONObject(response);
if (reps % 2 == 0) {
@ -213,7 +213,7 @@ public class DenunciationFragment extends Fragment implements WebRequest.respons
}
args.put("accepted","true");
WebRequest requestConfirm = new WebRequest(url+"/denunciation",false,args);
WebRequest requestConfirm = new WebRequest(url+"/denunciation",false,args,0);
requestConfirm.addListener(activity);
requestConfirm.execute();
}


+ 15
- 3
MyCity/app/src/main/java/gq/yigit/mycity/MainActivity.java View File

@ -1,14 +1,18 @@
package gq.yigit.mycity;
import android.Manifest;
import android.app.Activity;
import android.content.Context;
import android.content.DialogInterface;
import android.content.pm.PackageManager;
import android.graphics.Bitmap;
import android.net.Uri;
import android.os.Bundle;
import android.support.design.widget.NavigationView.OnNavigationItemSelectedListener;
import android.support.v4.app.ActivityCompat;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.support.v4.content.ContextCompat;
import android.support.v7.app.AlertDialog;
import android.util.Log;
import android.view.*;
@ -23,6 +27,7 @@ import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;
import gq.yigit.mycity.navigation.MapsFragment;
import gq.yigit.mycity.navigation.TransitFragment;
import gq.yigit.mycity.tools.*;
import gq.yigit.mycity.tools.WebRequest.responseListener;
import gq.yigit.mycity.utility.UtilityMain;
@ -46,6 +51,7 @@ public class MainActivity extends AppCompatActivity
RateFragment.OnFragmentInteractionListener,
MapsFragment.OnFragmentInteractionListener,
UtilityMain.OnFragmentInteractionListener,
TransitFragment.OnFragmentInteractionListener,
OnFragmentInteractionListener,
responseListener,
imageListener {
@ -57,10 +63,13 @@ public class MainActivity extends AppCompatActivity
private ImageView avatarView;
private TextView userName;
public static Activity mainActivity;
public static String apikey = "AIzaSyBuOC03IHPA_6TPnfk18b0SAgD1uge4-dk";
@Override
protected void onCreate(Bundle savedInstanceState) {
Log.d("[BOOKMARK]","Started creating activity");
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
@ -77,7 +86,7 @@ public class MainActivity extends AppCompatActivity
HashMap<String,String> request = new HashMap<>();
request.put("username","efe");
request.put("password","12345");
WebRequest login_manager = new WebRequest(url + "/login/",false,request);
WebRequest login_manager = new WebRequest(url + "/login/",false,request,0);
login_manager.addListener(this);
Log.d("[BOOKMARK]","Before executing login");
login_manager.execute();
@ -163,7 +172,10 @@ public class MainActivity extends AppCompatActivity
} else if (id == R.id.parking) {
} else if (id == R.id.transit) {
TransitFragment fragment = new TransitFragment();
fragmentTransaction.replace(R.id.app_bar_main, fragment);
fragmentTransaction.commit();
fragmentTransaction.addToBackStack(null);
} else if (id == R.id.navigation) {
MapsFragment fragment = new MapsFragment();
fragmentTransaction.replace(R.id.app_bar_main, fragment);
@ -205,7 +217,7 @@ public class MainActivity extends AppCompatActivity
}
public void receivedResponse(boolean success,String response){
public void receivedResponse(boolean success,String response,int reqid){
if(success) {
try {
JSONArray receivedData = new JSONArray(response);


+ 4
- 4
MyCity/app/src/main/java/gq/yigit/mycity/RateFragment.java View File

@ -115,7 +115,7 @@ public class RateFragment extends Fragment implements WebRequest.responseListene
Log.e("[ERROR]","An error occured with json!");
}
request.put("note",comment);
WebRequest rate_sender = new WebRequest(url + "/rate", false, request);
WebRequest rate_sender = new WebRequest(url + "/rate", false, request,0);
rate_sender.execute();
}
}
@ -139,7 +139,7 @@ public class RateFragment extends Fragment implements WebRequest.responseListene
HashMap<String,String> request = new HashMap<>();
request.put("longitude",longitude);
request.put("latitude",latitude);
WebRequest web_manager = new WebRequest(url + "/ratings",false,request);
WebRequest web_manager = new WebRequest(url + "/ratings",false,request,0);
web_manager.addListener(this);
web_manager.execute();
return rootView;
@ -175,7 +175,7 @@ public class RateFragment extends Fragment implements WebRequest.responseListene
@Override
public void receivedResponse(boolean success, String response) {
public void receivedResponse(boolean success, String response,int id) {
if(success){
try {
ratings = new JSONArray(response);
@ -223,7 +223,7 @@ public class RateFragment extends Fragment implements WebRequest.responseListene
private void downloadImg(int i) throws JSONException {
ImageDownload downloader = new ImageDownload();
downloader.addListener(this);
downloader.execute(url + ((JSONObject) ratings.get(i)).get("img"));
downloader.execute(url + ((JSONObject) ratings.get(i)).get("type"));
}


+ 306
- 0
MyCity/app/src/main/java/gq/yigit/mycity/navigation/TransitFragment.java View File

@ -0,0 +1,306 @@
package gq.yigit.mycity.navigation;
import android.content.Context;
import android.content.Intent;
import android.location.Location;
import android.location.LocationManager;
import android.net.Uri;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.google.android.gms.common.api.Status;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.libraries.places.api.Places;
import com.google.android.libraries.places.api.model.Place;
import com.google.android.libraries.places.api.model.RectangularBounds;
import com.google.android.libraries.places.api.net.PlacesClient;
import com.google.android.libraries.places.widget.Autocomplete;
import com.google.android.libraries.places.widget.AutocompleteActivity;
import com.google.android.libraries.places.widget.model.AutocompleteActivityMode;
import gq.yigit.mycity.R;
import gq.yigit.mycity.tools.FileActions;
import gq.yigit.mycity.tools.WebRequest;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import java.util.*;
import static android.app.Activity.RESULT_CANCELED;
import static android.app.Activity.RESULT_OK;
import static gq.yigit.mycity.MainActivity.apikey;
import static gq.yigit.mycity.MainActivity.cntxt;
public class TransitFragment extends Fragment implements WebRequest.responseListener {
private OnFragmentInteractionListener mListener;
private OnRecyclerViewInteractionListener recyclerViewInteractionListener;
private TextView place_name;
private String[] place_data = {"","","",""};
private PlacesClient placesClient;
private String url;
private String longitude;
private String latitude;
private RecyclerView recyclerView;
public TransitFragment() {
// Required empty public constructor
}
public static TransitFragment newInstance(String param1, String param2) {
TransitFragment fragment = new TransitFragment();
return fragment;
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_transit, container, false);
LinearLayout search_button = rootView.findViewById(R.id.search_layout);
search_button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Places.initialize(getContext(), apikey);
placesClient = Places.createClient(getContext());
int AUTOCOMPLETE_REQUEST_CODE = 1;
List<Place.Field> fields = Arrays.asList(Place.Field.ID, Place.Field.NAME,Place.Field.LAT_LNG);
Intent intent = new Autocomplete.IntentBuilder(
AutocompleteActivityMode.FULLSCREEN, fields).
setLocationRestriction(RectangularBounds.newInstance(new LatLng(39.7281252,32.4848006),new LatLng(40.061707,32.9889204)))
.build(getContext());
startActivityForResult(intent, AUTOCOMPLETE_REQUEST_CODE);
}
});
place_name = rootView.findViewById(R.id.place_name);
recyclerView = rootView.findViewById(R.id.route_view);
try {
LocationManager locationManager = (LocationManager)
getContext().getSystemService(cntxt.LOCATION_SERVICE);
Location loc = locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER);
longitude = String.valueOf((double)loc.getLongitude());
latitude = String.valueOf(loc.getLatitude());
}catch (SecurityException e){
Log.e("[ERROR]","An error occured with location permissions");
}
return rootView;
}
public void onButtonPressed(Uri uri) {
if (mListener != null) {
mListener.onFragmentInteraction(uri);
}
}
@Override
public void onAttach(Context context) {
super.onAttach(context);
if (context instanceof OnFragmentInteractionListener) {
mListener = (OnFragmentInteractionListener) context;
} else {
throw new RuntimeException(context.toString()
+ " must implement OnFragmentInteractionListener");
}
}
@Override
public void onDetach() {
super.onDetach();
mListener = null;
}
public interface OnFragmentInteractionListener {
// TODO: Update argument type and name
void onFragmentInteraction(Uri uri);
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == 1) {
if (resultCode == RESULT_OK) {
Place place = Autocomplete.getPlaceFromIntent(data);
place_data[0] = place.getName();
place_data[1] = place.getId();
Log.i("[INFO]", "Place: " + place.getName() + ", " + place.getId());
place_name.setText(place_data[0]);
place_data[2] = String.valueOf(place.getLatLng().latitude);
place_data[3] = String.valueOf(place.getLatLng().longitude);
FileActions file_manager = new FileActions();
url = file_manager.readFromFile(cntxt,"server.config").trim();
HashMap<String,String> args = new HashMap<>();
args.put("lat_usr",latitude);
args.put("lng_usr",longitude);
args.put("lat_dest",place_data[2]);
args.put("lng_dest",place_data[3]);
WebRequest request = new WebRequest(url + "/transit",false, args,0);
request.addListener(this);
request.execute();
} else if (resultCode == AutocompleteActivity.RESULT_ERROR) {
Status status = Autocomplete.getStatusFromIntent(data);
Log.i("[INFO]", status.getStatusMessage());
} else if (resultCode == RESULT_CANCELED) {
}
}
}
@Override
public void receivedResponse(boolean success,String response, int reqid){
Log.i("[INFO]",response);
try{
JSONObject travel = new JSONObject(response);
JSONArray routes = new JSONArray(travel.getString("routes"));
for(int i = 0; i< routes.length();i++){
JSONObject route = new JSONObject(routes.getString(i));
TransitContent.addItem(new TransitContent.TransitItem(
route.getString("name"),
(new JSONArray(route.getString("stops")).getString(0)),
(new JSONArray(route.getString("stops")).getString(1)),
(new JSONArray(route.getString("time")).getString(0)),
(new JSONArray(route.getString("time")).getString(1)),
"bus"
));
}
recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
recyclerView.setAdapter(new TransitAdapter(TransitContent.ITEMS, recyclerViewInteractionListener));
}catch (JSONException e){
Log.e("[ERROR]", "Received invalid response from public transport service!");
}
}
public interface OnRecyclerViewInteractionListener {
void OnRecyclerViewInteractionListener(TransitContent.TransitItem item);
}
}
class TransitContent {
public static final List<TransitItem> ITEMS = new ArrayList<TransitItem>();
public static final Map<String, TransitItem> ITEM_MAP = new HashMap<String, TransitItem>();
public static void addItem(TransitItem item) {
ITEMS.add(item);
ITEM_MAP.put(item.endTime, item);
}
public static class TransitItem {
public final String lineNo;
public final String startName;
public final String endName;
public final String startTime;
public final String endTime;
public final String type;
public TransitItem(String lineNo, String startName, String endName, String startTime, String endTime, String type) {
this.lineNo = lineNo;
this.startName = startName;
this.endName = endName;
this.startTime = startTime;
this.endTime = endTime;
this.type = type;
}
}
}
class TransitAdapter extends RecyclerView.Adapter<TransitAdapter.ViewHolder>{
private final List<TransitContent.TransitItem> mValues;
private final TransitFragment.OnRecyclerViewInteractionListener mListener;
public TransitAdapter(List<TransitContent.TransitItem> items, TransitFragment.OnRecyclerViewInteractionListener listener) {
mValues = items;
mListener = listener;
}
@Override
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View view = LayoutInflater.from(parent.getContext())
.inflate(R.layout.transit_item, parent, false);
return new ViewHolder(view);
}
@Override
public void onBindViewHolder(final ViewHolder holder, int position) {
holder.mItem = mValues.get(position);
holder.stop1.setText(mValues.get(position).startName);
holder.stop2.setText(mValues.get(position).endName);
holder.time1.setText(mValues.get(position).startTime);
holder.time2.setText(mValues.get(position).endTime);
holder.line.setText(mValues.get(position).lineNo);
String type = mValues.get(position).type;
if(type.equals("bus")){
}else if(type.equals("subway") || type.equals("ankaray")){
}else if(type.equals("walk")){}
holder.mView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (null != mListener) {
mListener.OnRecyclerViewInteractionListener(holder.mItem);
}
}
});
}
@Override
public int getItemCount() {
return mValues.size();
}
public class ViewHolder extends RecyclerView.ViewHolder {
private final View mView;
private final TextView stop1;
private final TextView stop2;
private final ImageView type;
private final TextView line;
private final TextView time1;
private final TextView time2;
private TransitContent.TransitItem mItem;
private ViewHolder(View view) {
super(view);
mView = view;
stop1 = view.findViewById(R.id.stop1_addr);
stop2 = view.findViewById(R.id.stop2_addr);
time1 = view.findViewById(R.id.stop1_time);
time2 = view.findViewById(R.id.stop2_time);
line = view.findViewById(R.id.line_no);
type = view.findViewById(R.id.type_img);
}
}
}

+ 5
- 4
MyCity/app/src/main/java/gq/yigit/mycity/tools/WebRequest.java View File

@ -37,9 +37,9 @@ public class WebRequest extends AsyncTask<Void,Void,String> {
private HttpPost post_request;
private HttpResponse response;
private List<responseListener> listeners = new ArrayList<>();
private int reqid = 0;
public WebRequest(String url, boolean request_type, HashMap<String,String> request_content){
public WebRequest(String url, boolean request_type, HashMap<String,String> request_content,int reqid){
client = AcceptAllSSLSocketFactory.getNewHttpClient();
@ -61,6 +61,7 @@ public class WebRequest extends AsyncTask<Void,Void,String> {
}else{
post_request = new HttpPost(this.url);
}
this.reqid = reqid;
}
protected String doInBackground(Void... params){
@ -109,14 +110,14 @@ public class WebRequest extends AsyncTask<Void,Void,String> {
}
protected void onPostExecute(String result){
for (responseListener hl : listeners)
hl.receivedResponse(!result.equals("Error"),result);
hl.receivedResponse(!result.equals("Error"),result,reqid);
}
public void addListener(responseListener toAdd) {
listeners.add(toAdd);
}
public interface responseListener {
void receivedResponse(boolean success, String response);
void receivedResponse(boolean success, String response,int id);
}
}


+ 2
- 2
MyCity/app/src/main/java/gq/yigit/mycity/utility/UtilityElectricity.java View File

@ -69,7 +69,7 @@ public class UtilityElectricity extends Fragment implements WebRequest.responseL
Log.e("[ERROR]","User data not correct");
}
request.put("type","electricity");
WebRequest login_manager = new WebRequest(url + "/resources/",false,request);
WebRequest login_manager = new WebRequest(url + "/resources/",false,request,0);
login_manager.addListener(this);
login_manager.execute();
@ -106,7 +106,7 @@ public class UtilityElectricity extends Fragment implements WebRequest.responseL
void onFragmentInteraction(Uri uri);
}
public void receivedResponse(boolean success, String result){
public void receivedResponse(boolean success, String result,int reqid){
if(success){
try{
electricityUsage = new JSONObject(result);


+ 3
- 3
MyCity/app/src/main/java/gq/yigit/mycity/votesFragment/VoteFragment.java View File

@ -75,7 +75,7 @@ public class VoteFragment extends Fragment implements responseListener, imageLis
FileActions file_manager = new FileActions();
url = file_manager.readFromFile(getContext(),"server.config").trim();
String url_vote = url + "/votings/" + vote_id;
WebRequest data_request = new WebRequest(url_vote,true,new HashMap<String, String>());
WebRequest data_request = new WebRequest(url_vote,true,new HashMap<String, String>(),0);
data_request.addListener(this);
data_request.execute();
cntxt = getContext();
@ -110,7 +110,7 @@ public class VoteFragment extends Fragment implements responseListener, imageLis
void onFragmentInteraction(Uri uri);
}
public void receivedResponse(boolean success,String response){
public void receivedResponse(boolean success,String response, int reqid){
Log.i("[INFO]",response);
if(success){
try{
@ -170,7 +170,7 @@ public class VoteFragment extends Fragment implements responseListener, imageLis
}catch (JSONException e){
Log.e("[ERROR]","Cannot get user data");
}
WebRequest vote_request = new WebRequest(url+"/vote",false, params);
WebRequest vote_request = new WebRequest(url+"/vote",false, params,0);
vote_request.execute();
}else{
Toast.makeText(cntxt,"Please selet a vote!",Toast.LENGTH_SHORT).show();


+ 2
- 2
MyCity/app/src/main/java/gq/yigit/mycity/votesFragment/VotesFragment.java View File

@ -69,7 +69,7 @@ public class VotesFragment extends Fragment implements responseListener, imageLi
}
FileActions file_manager = new FileActions();
url = (file_manager.readFromFile(context,"server.config")).trim();
WebRequest web_manager = new WebRequest(url + "/votings/",true,new HashMap<String,String>());
WebRequest web_manager = new WebRequest(url + "/votings/",true,new HashMap<String,String>(),0);
web_manager.addListener(this);
web_manager.execute();
}
@ -98,7 +98,7 @@ public class VotesFragment extends Fragment implements responseListener, imageLi
void onListFragmentInteraction(VoteItem item);
}
public void receivedResponse(boolean success, String response){
public void receivedResponse(boolean success, String response,int id){
if(success) {
try {


+ 1
- 1
MyCity/app/src/main/res/drawable-v24/magnifier.xml View File

@ -6,5 +6,5 @@
<path
android:pathData="M244.186 214.604l-54.379 -54.378c-0.289 -0.289 -0.628 -0.491 -0.93 -0.76c10.7 -16.231 16.945 -35.66 16.945 -56.554C205.822 46.075 159.747 0 102.911 0S0 46.075 0 102.911c0 56.835 46.074 102.911 102.91 102.911c20.895 0 40.323 -6.245 56.554 -16.945c0.269 0.301 0.47 0.64 0.759 0.929l54.38 54.38c8.169 8.168 21.413 8.168 29.583 0C252.354 236.017 252.354 222.773 244.186 214.604zM102.911 170.146c-37.134 0 -67.236 -30.102 -67.236 -67.235c0 -37.134 30.103 -67.236 67.236 -67.236c37.132 0 67.235 30.103 67.235 67.236C170.146 140.044 140.043 170.146 102.911 170.146z"
android:fillType="evenOdd"
android:fillColor="#000000" />
android:fillColor="#717171" />
</vector>

+ 12
- 0
MyCity/app/src/main/res/drawable/circle_shape.xml View File

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:innerRadius="0dp"
android:shape="ring"
android:thicknessRatio="1.9"
android:useLevel="false" >
<solid android:color="@android:color/transparent" />
<stroke
android:width="10dp"
android:color="@android:color/white" />
</shape>

+ 11
- 0
MyCity/app/src/main/res/drawable/line_shape.xml View File

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners
android:radius="6dp"/>
<stroke
android:width="0dp"
android:color="#c9c9c9" />
<solid android:color="#0019B9" />
</shape>

+ 10
- 0
MyCity/app/src/main/res/drawable/search_shape.xml View File

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners
android:radius="20dp"/>
<stroke
android:width="2dp"
android:color="#c9c9c9" />
<solid android:color="#e9e9e9" />
</shape>

+ 0
- 1
MyCity/app/src/main/res/layout/fragment_main.xml View File

@ -5,7 +5,6 @@
android:layout_height="match_parent"
tools:context=".MainFragment">
<!-- TODO: Update blank fragment layout -->
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"


+ 37
- 0
MyCity/app/src/main/res/layout/fragment_transit.xml View File

@ -0,0 +1,37 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".navigation.TransitFragment"
android:layout_marginTop="@dimen/fragment_margin"
android:orientation="vertical">
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content" android:id="@+id/search_layout"
android:background="@drawable/search_shape"
android:layout_marginHorizontal="10dp"
android:paddingHorizontal="5dp"
android:layout_marginBottom="30dp">
<ImageView
android:layout_width="70dp"
android:layout_height="40dp" android:id="@+id/rate_item_img"
android:layout_weight="1"
android:layout_marginRight="5dp" app:srcCompat="@drawable/magnifier"
android:layout_marginVertical="5dp"
android:layout_marginLeft="10dp"/>
<TextView
android:text="Please select a place"
android:layout_width="match_parent"
android:layout_height="match_parent" android:id="@+id/place_name" android:layout_weight="1"
android:gravity="center_vertical" android:textColor="#FF616161" android:textSize="16sp"
android:layout_marginLeft="7dp"/>
</LinearLayout>
<android.support.v7.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="match_parent" android:id="@+id/route_view"
android:layout_marginLeft="8dp"/>
</LinearLayout>

+ 1
- 1
MyCity/app/src/main/res/layout/fragment_utility.xml View File

@ -6,7 +6,7 @@
android:layout_width="match_parent"
android:layout_height="match_parent" xmlns:app="http://schemas.android.com/apk/res-auto"
tools:context=".utility.UtilityMain" android:orientation="vertical"
android:layout_marginTop="55dp">
android:layout_marginTop="@dimen/fragment_margin">


+ 20
- 8
MyCity/app/src/main/res/layout/popup_confirmation.xml View File

@ -1,9 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
<android.support.constraint.ConstraintLayout 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:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
android:orientation="vertical" android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingBottom="15dp">
<TextView
android:text="If this alert is wrong, you will receive a penalty of "
@ -13,7 +14,11 @@
android:textStyle="normal|bold"
android:textSize="18sp"
android:layout_alignParentTop="true"
android:layout_marginTop="193dp" android:layout_centerHorizontal="true" android:textColor="#000000"/>
android:layout_centerHorizontal="true" android:textColor="#000000"
android:layout_marginTop="20dp"
app:layout_constraintTop_toBottomOf="@+id/imageView" app:layout_constraintStart_toStartOf="parent"
android:layout_marginStart="8dp" android:layout_marginEnd="8dp" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"/>
<Button
android:id="@+id/confirm_button"
@ -24,12 +29,19 @@
android:textSize="18sp"
style="@android:style/Widget.Button"
tools:ignore="RtlHardcoded,RtlSymmetry"
android:layout_centerHorizontal="true" android:layout_alignParentBottom="true"
android:layout_marginBottom="211dp" android:background="@android:color/holo_red_dark"/>
android:layout_alignParentBottom="true"
android:background="@android:color/holo_red_dark"
android:layout_alignStart="@+id/imageView"
android:layout_marginTop="36dp"
app:layout_constraintTop_toBottomOf="@+id/confirm_text" app:layout_constraintStart_toStartOf="parent"
android:layout_marginStart="8dp" app:layout_constraintEnd_toEndOf="parent" android:layout_marginEnd="8dp"/>
<ImageView
android:layout_width="191dp"
android:layout_height="181dp" app:srcCompat="@drawable/warning"
android:layout_centerHorizontal="true" android:id="@+id/imageView"
android:layout_alignParentTop="true"/>
android:layout_alignParentTop="true"
app:layout_constraintTop_toTopOf="parent"
android:layout_marginTop="8dp" app:layout_constraintEnd_toEndOf="parent" android:layout_marginEnd="8dp"
app:layout_constraintStart_toStartOf="parent" android:layout_marginStart="8dp"/>
</RelativeLayout>
</android.support.constraint.ConstraintLayout>

+ 72
- 0
MyCity/app/src/main/res/layout/transit_item.xml View File

@ -0,0 +1,72 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<LinearLayout
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="150dp"
android:gravity="center"
android:background="@drawable/line_shape"
android:padding="2dp"
android:layout_marginRight="7dp">
<ImageView
android:layout_width="30dp"
android:layout_height="30dp" app:srcCompat="@drawable/bus" android:id="@+id/type_img"
android:background="@drawable/circle_shape"
android:padding="2dp"/>
</LinearLayout>
<android.support.constraint.ConstraintLayout
android:layout_width="wrap_content"
android:layout_height="match_parent" android:id="@+id/linearLayout">
<TextView
android:text="TextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content" android:id="@+id/stop1_addr"
android:textColor="#000000"
android:textSize="15sp"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toStartOf="parent"
android:layout_marginStart="8dp" android:layout_marginTop="8dp"/>
<TextView
android:text="TextView"
android:layout_width="64dp"
android:layout_height="wrap_content" android:id="@+id/stop1_time"
android:textColor="#000000" android:textSize="15sp"
app:layout_constraintTop_toTopOf="@+id/stop1_addr"
app:layout_constraintStart_toEndOf="@+id/stop1_addr" android:layout_marginStart="4dp"/>
<TextView
android:text="TextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content" android:id="@+id/line_no"
android:textColor="#000000"
android:layout_marginTop="64dp" app:layout_constraintTop_toTopOf="parent"
android:textSize="16sp" android:layout_marginStart="8dp"
app:layout_constraintStart_toStartOf="@+id/stop2_addr"/>
<TextView
android:text="TextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content" android:id="@+id/stop2_addr"
android:textColor="#000000" android:textSize="15sp"
android:layout_marginBottom="8dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="@+id/stop1_addr"/>
<TextView
android:text="TextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content" android:id="@+id/stop2_time"
android:textColor="#000000"
android:textSize="15sp"
app:layout_constraintBottom_toBottomOf="@+id/stop2_addr"
app:layout_constraintStart_toStartOf="@+id/stop1_time"/>
</android.support.constraint.ConstraintLayout>
</LinearLayout>

+ 1
- 0
MyCity/app/src/main/res/values/dimens.xml View File

@ -6,4 +6,5 @@
<dimen name="nav_header_height">176dp</dimen>
<dimen name="fab_margin">16dp</dimen>
<dimen name="text_margin">16dp</dimen>
<dimen name="fragment_margin">65dp</dimen>
</resources>

+ 9
- 0
client_side/client_side.iml View File

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="PYTHON_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$" />
<orderEntry type="jdk" jdkName="Python 3.7" jdkType="Python SDK" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

+ 31
- 0
client_side/interface/UserData/index.html View File

@ -0,0 +1,31 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>UserInterface</title>
<link rel="stylesheet" href="style.css">
<script src="socket.io/dist/socket.io.js"></script>
<script src = "index.js"></script>
</head>
<body>
<div id = "basics">
<span class="inline"><img src="https://proxy.duckduckgo.com/iu/?u=https%3A%2F%2Ftse4.mm.bing.net%2Fth%3Fid%3DOIP.ELnJq_JhiyfewhCMKOkNfwHaHa%26pid%3DApi&f=1" id="userpic" alt=""></span>
<span class="inline">
<table>
<tr>
<td class="table-header"><solid>Name:</solid></td>
<td id = "name"></td>
<td class="table-header"><solid>TC:</solid></td>
<td id = "tc"></td>
<td class="table-header"><solid>Status:</solid></td>
<td id = "status"></td>
</tr>
<tr>
<td class="table-header"><solid>Health info:</solid></td>
<td id = "health"></td>
</tr>
</table>
</span>
</div>
</body>
</html>

+ 4
- 0
client_side/interface/UserData/index.js View File

@ -0,0 +1,4 @@
var exampleSocket = new WebSocket("ws://localhost:3000", "protocolOne");
exampleSocket.onmessage = function (event) {
console.log(event.data);
}

+ 333
- 0
client_side/interface/UserData/package-lock.json View File

@ -0,0 +1,333 @@
{
"requires": true,
"lockfileVersion": 1,
"dependencies": {
"accepts": {
"version": "1.3.5",
"resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.5.tgz",
"integrity": "sha1-63d99gEXI6OxTopywIBcjoZ0a9I=",
"requires": {
"mime-types": "2.1.23",
"negotiator": "0.6.1"
}
},
"after": {
"version": "0.8.2",
"resolved": "https://registry.npmjs.org/after/-/after-0.8.2.tgz",
"integrity": "sha1-/ts5T58OAqqXaOcCvaI7UF+ufh8="
},
"arraybuffer.slice": {
"version": "0.0.7",
"resolved": "https://registry.npmjs.org/arraybuffer.slice/-/arraybuffer.slice-0.0.7.tgz",
"integrity": "sha512-wGUIVQXuehL5TCqQun8OW81jGzAWycqzFF8lFp+GOM5BXLYj3bKNsYC4daB7n6XjCqxQA/qgTJ+8ANR3acjrog=="
},
"async-limiter": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/async-limiter/-/async-limiter-1.0.0.tgz",
"integrity": "sha512-jp/uFnooOiO+L211eZOoSyzpOITMXx1rBITauYykG3BRYPu8h0UcxsPNB04RR5vo4Tyz3+ay17tR6JVf9qzYWg=="
},
"backo2": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/backo2/-/backo2-1.0.2.tgz",
"integrity": "sha1-MasayLEpNjRj41s+u2n038+6eUc="
},
"base64-arraybuffer": {
"version": "0.1.5",
"resolved": "https://registry.npmjs.org/base64-arraybuffer/-/base64-arraybuffer-0.1.5.tgz",
"integrity": "sha1-c5JncZI7Whl0etZmqlzUv5xunOg="
},
"base64id": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/base64id/-/base64id-1.0.0.tgz",
"integrity": "sha1-R2iMuZu2gE8OBtPnY7HDLlfY5rY="
},
"better-assert": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/better-assert/-/better-assert-1.0.2.tgz",
"integrity": "sha1-QIZrnhueC1W0gYlDEeaPr/rrxSI=",
"requires": {
"callsite": "1.0.0"
}
},
"blob": {
"version": "0.0.5",
"resolved": "https://registry.npmjs.org/blob/-/blob-0.0.5.tgz",
"integrity": "sha512-gaqbzQPqOoamawKg0LGVd7SzLgXS+JH61oWprSLH+P+abTczqJbhTR8CmJ2u9/bUYNmHTGJx/UEmn6doAvvuig=="
},
"callsite": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/callsite/-/callsite-1.0.0.tgz",
"integrity": "sha1-KAOY5dZkvXQDi28JBRU+borxvCA="
},
"component-bind": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/component-bind/-/component-bind-1.0.0.tgz",
"integrity": "sha1-AMYIq33Nk4l8AAllGx06jh5zu9E="
},
"component-emitter": {
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/component-emitter/-/component-emitter-1.2.1.tgz",
"integrity": "sha1-E3kY1teCg/ffemt8WmPhQOaUJeY="
},
"component-inherit": {
"version": "0.0.3",
"resolved": "https://registry.npmjs.org/component-inherit/-/component-inherit-0.0.3.tgz",
"integrity": "sha1-ZF/ErfWLcrZJ1crmUTVhnbJv8UM="
},
"cookie": {
"version": "0.3.1",
"resolved": "https://registry.npmjs.org/cookie/-/cookie-0.3.1.tgz",
"integrity": "sha1-5+Ch+e9DtMi6klxcWpboBtFoc7s="
},
"debug": {
"version": "4.1.1",
"resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz",
"integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==",
"requires": {
"ms": "2.1.1"
}
},
"engine.io": {
"version": "3.3.2",
"resolved": "https://registry.npmjs.org/engine.io/-/engine.io-3.3.2.tgz",
"integrity": "sha512-AsaA9KG7cWPXWHp5FvHdDWY3AMWeZ8x+2pUVLcn71qE5AtAzgGbxuclOytygskw8XGmiQafTmnI9Bix3uihu2w==",
"requires": {
"accepts": "1.3.5",
"base64id": "1.0.0",
"cookie": "0.3.1",
"debug": "3.1.0",
"engine.io-parser": "2.1.3",
"ws": "6.1.4"
},
"dependencies": {
"debug": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz",
"integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==",
"requires": {
"ms": "2.0.0"
}
},
"ms": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
"integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g="
}
}
},
"engine.io-client": {
"version": "3.3.2",
"resolved": "https://registry.npmjs.org/engine.io-client/-/engine.io-client-3.3.2.tgz",
"integrity": "sha512-y0CPINnhMvPuwtqXfsGuWE8BB66+B6wTtCofQDRecMQPYX3MYUZXFNKDhdrSe3EVjgOu4V3rxdeqN/Tr91IgbQ==",
"requires": {
"component-emitter": "1.2.1",
"component-inherit": "0.0.3",
"debug": "3.1.0",
"engine.io-parser": "2.1.3",
"has-cors": "1.1.0",
"indexof": "0.0.1",
"parseqs": "0.0.5",
"parseuri": "0.0.5",
"ws": "6.1.4",
"xmlhttprequest-ssl": "1.5.5",
"yeast": "0.1.2"
},
"dependencies": {
"debug": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz",
"integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==",
"requires": {
"ms": "2.0.0"
}
},
"ms": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
"integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g="
}
}
},
"engine.io-parser": {
"version": "2.1.3",
"resolved": "https://registry.npmjs.org/engine.io-parser/-/engine.io-parser-2.1.3.tgz",
"integrity": "sha512-6HXPre2O4Houl7c4g7Ic/XzPnHBvaEmN90vtRO9uLmwtRqQmTOw0QMevL1TOfL2Cpu1VzsaTmMotQgMdkzGkVA==",
"requires": {
"after": "0.8.2",
"arraybuffer.slice": "0.0.7",
"base64-arraybuffer": "0.1.5",
"blob": "0.0.5",
"has-binary2": "1.0.3"
}
},
"has-binary2": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/has-binary2/-/has-binary2-1.0.3.tgz",
"integrity": "sha512-G1LWKhDSvhGeAQ8mPVQlqNcOB2sJdwATtZKl2pDKKHfpf/rYj24lkinxf69blJbnsvtqqNU+L3SL50vzZhXOnw==",
"requires": {
"isarray": "2.0.1"
}
},
"has-cors": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/has-cors/-/has-cors-1.1.0.tgz",
"integrity": "sha1-XkdHk/fqmEPRu5nCPu9J/xJv/zk="
},
"indexof": {
"version": "0.0.1",
"resolved": "https://registry.npmjs.org/indexof/-/indexof-0.0.1.tgz",
"integrity": "sha1-gtwzbSMrkGIXnQWrMpOmYFn9Q10="
},
"isarray": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/isarray/-/isarray-2.0.1.tgz",
"integrity": "sha1-o32U7ZzaLVmGXJ92/llu4fM4dB4="
},
"mime-db": {
"version": "1.39.0",
"resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.39.0.tgz",
"integrity": "sha512-DTsrw/iWVvwHH+9Otxccdyy0Tgiil6TWK/xhfARJZF/QFhwOgZgOIvA2/VIGpM8U7Q8z5nDmdDWC6tuVMJNibw=="
},
"mime-types": {
"version": "2.1.23",
"resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.23.tgz",
"integrity": "sha512-ROk/m+gMVSrRxTkMlaQOvFmFmYDc7sZgrjjM76abqmd2Cc5fCV7jAMA5XUccEtJ3cYiYdgixUVI+fApc2LkXlw==",
"requires": {
"mime-db": "1.39.0"
}
},
"ms": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.1.tgz",
"integrity": "sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg=="
},
"negotiator": {
"version": "0.6.1",
"resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.1.tgz",
"integrity": "sha1-KzJxhOiZIQEXeyhWP7XnECrNDKk="
},
"object-component": {
"version": "0.0.3",
"resolved": "https://registry.npmjs.org/object-component/-/object-component-0.0.3.tgz",
"integrity": "sha1-8MaapQ78lbhmwYb0AKM3acsvEpE="
},
"parseqs": {
"version": "0.0.5",
"resolved": "https://registry.npmjs.org/parseqs/-/parseqs-0.0.5.tgz",
"integrity": "sha1-1SCKNzjkZ2bikbouoXNoSSGouJ0=",
"requires": {
"better-assert": "1.0.2"
}
},
"parseuri": {
"version": "0.0.5",
"resolved": "https://registry.npmjs.org/parseuri/-/parseuri-0.0.5.tgz",
"integrity": "sha1-gCBKUNTbt3m/3G6+J3jZDkvOMgo=",
"requires": {
"better-assert": "1.0.2"
}
},
"socket.io": {
"version": "2.2.0",
"resolved": "https://registry.npmjs.org/socket.io/-/socket.io-2.2.0.tgz",
"integrity": "sha512-wxXrIuZ8AILcn+f1B4ez4hJTPG24iNgxBBDaJfT6MsyOhVYiTXWexGoPkd87ktJG8kQEcL/NBvRi64+9k4Kc0w==",
"requires": {
"debug": "4.1.1",
"engine.io": "3.3.2",
"has-binary2": "1.0.3",
"socket.io-adapter": "1.1.1",
"socket.io-client": "2.2.0",
"socket.io-parser": "3.3.0"
}
},
"socket.io-adapter": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/socket.io-adapter/-/socket.io-adapter-1.1.1.tgz",
"integrity": "sha1-KoBeihTWNyEk3ZFZrUUC+MsH8Gs="
},
"socket.io-client": {
"version": "2.2.0",
"resolved": "https://registry.npmjs.org/socket.io-client/-/socket.io-client-2.2.0.tgz",
"integrity": "sha512-56ZrkTDbdTLmBIyfFYesgOxsjcLnwAKoN4CiPyTVkMQj3zTUh0QAx3GbvIvLpFEOvQWu92yyWICxB0u7wkVbYA==",
"requires": {
"backo2": "1.0.2",
"base64-arraybuffer": "0.1.5",
"component-bind": "1.0.0",
"component-emitter": "1.2.1",
"debug": "3.1.0",
"engine.io-client": "3.3.2",
"has-binary2": "1.0.3",
"has-cors": "1.1.0",
"indexof": "0.0.1",
"object-component": "0.0.3",
"parseqs": "0.0.5",
"parseuri": "0.0.5",
"socket.io-parser": "3.3.0",
"to-array": "0.1.4"
},
"dependencies": {
"debug": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz",
"integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==",
"requires": {
"ms": "2.0.0"
}
},
"ms": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
"integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g="
}
}
},
"socket.io-parser": {
"version": "3.3.0",
"resolved": "https://registry.npmjs.org/socket.io-parser/-/socket.io-parser-3.3.0.tgz",
"integrity": "sha512-hczmV6bDgdaEbVqhAeVMM/jfUfzuEZHsQg6eOmLgJht6G3mPKMxYm75w2+qhAQZ+4X+1+ATZ+QFKeOZD5riHng==",
"requires": {
"component-emitter": "1.2.1",
"debug": "3.1.0",
"isarray": "2.0.1"
},
"dependencies": {
"debug": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz",
"integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==",
"requires": {
"ms": "2.0.0"
}
},
"ms": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
"integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g="
}
}
},
"to-array": {
"version": "0.1.4",
"resolved": "https://registry.npmjs.org/to-array/-/to-array-0.1.4.tgz",
"integrity": "sha1-F+bBH3PdTz10zaek/zI46a2b+JA="
},
"ws": {
"version": "6.1.4",
"resolved": "https://registry.npmjs.org/ws/-/ws-6.1.4.tgz",
"integrity": "sha512-eqZfL+NE/YQc1/ZynhojeV8q+H050oR8AZ2uIev7RU10svA9ZnJUddHcOUZTJLinZ9yEfdA2kSATS2qZK5fhJA==",
"requires": {
"async-limiter": "1.0.0"
}
},
"xmlhttprequest-ssl": {
"version": "1.5.5",
"resolved": "https://registry.npmjs.org/xmlhttprequest-ssl/-/xmlhttprequest-ssl-1.5.5.tgz",
"integrity": "sha1-wodrBhaKrcQOV9l+gRkayPQ5iz4="
},
"yeast": {
"version": "0.1.2",
"resolved": "https://registry.npmjs.org/yeast/-/yeast-0.1.2.tgz",
"integrity": "sha1-AI4G2AlDIMNy28L47XagymyKxBk="
}
}
}

+ 1
- 0
client_side/interface/UserData/socket.io

@ -0,0 +1 @@
Subproject commit 3020e455ab9a81341722e6c1e6cd8ef6b4b0ea28

+ 16
- 0
client_side/interface/UserData/style.css View File

@ -0,0 +1,16 @@
#userpic{
height: 150px;
width: auto;
border: black 1px solid;
}
.inline{
display: inline-block;
}
td{
padding: 0px 5px;
}
table, td {
border: 1px solid black;
}

+ 0
- 0
client_side/modules/__init__.py View File


BIN
client_side/modules/__pycache__/__init__.cpython-37.pyc View File


+ 0
- 0
client_side/modules/qr/__init__.py View File


BIN
client_side/modules/qr/__pycache__/__init__.cpython-37.pyc View File


BIN
client_side/modules/qr/__pycache__/reader.cpython-37.pyc View File


BIN
client_side/modules/qr/__pycache__/user_data.cpython-37.pyc View File


+ 37
- 0
client_side/modules/qr/reader.py View File

@ -0,0 +1,37 @@
import cv2
from pyzbar import pyzbar
class Read():
instance = 0
sid = 0
def __init__(self,inst):
self.instance = inst
def detect(self):
cam = cv2.VideoCapture(0)
barcodeData_prev = 0
while 1:
ret , img = cam.read()
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
barcode = pyzbar.decode(gray)
if len(barcode) > 0:
barcode = barcode[0]
(x, y, w, h) = barcode.rect
barcodeData = barcode.data.decode("utf-8")
barcodeType = barcode.type
if barcodeData_prev == 0 or barcodeData_prev != barcodeData:
barcodeData_prev = barcodeData
self.instance.received(barcodeData)
continue
text = "{} ({})".format(barcodeData, barcodeType)
cv2.putText(img, text, (x, y - 10), cv2.FONT_HERSHEY_SIMPLEX,
0.5, (255, 0, 0), 2)
cv2.rectangle(img, (x, y), (x + w, y + h), (255, 0, 0), 2)
cv2.imshow("a", img)
if cv2.waitKey(1) & 0xFF == ord('q'):
break
cam.release()
cv2.destroyAllWindows()

+ 30
- 0
client_side/modules/qr/user_data.py View File

@ -0,0 +1,30 @@
from multiprocessing import Process
import reader
class Reader():
def __init__(self):
read = reader.Read(self)
p1 = Process(target=read.detect)
p1.start()
def received(self,data):
print(data)
qr_reader = Reader()
while 1:
continue

+ 1
- 0
client_side/requirements.txt View File

@ -0,0 +1 @@
pyzbar==0.1.8

+ 1
- 2
server_side/api/app.py View File

@ -24,8 +24,7 @@ if __name__ == '__main__':
api.add_resource( user_info.Users, '/users', '/users/' )
api.add_resource( user_info.User, '/users/<path:user_id>', '/users/<path:user_id>/' )
api.add_resource( user_info.Login, '/login', '/login/' )
api.add_resource(user_info.QRCode, '/qr', '/qr/')
api.add_resource(user_info.QRRead, '/qr_data', '/qr_data/')
api.add_resource(utility.Resources, '/resources', '/resources/')


BIN
server_side/api/modules/__pycache__/denunciation.cpython-37.pyc View File


BIN
server_side/api/modules/__pycache__/navigation.cpython-37.pyc View File


BIN
server_side/api/modules/__pycache__/user_info.cpython-37.pyc View File


BIN
server_side/api/modules/__pycache__/voting_system.cpython-37.pyc View File


+ 97188
- 57179
server_side/api/modules/databases/bus.json
File diff suppressed because it is too large
View File


+ 0
- 148267
server_side/api/modules/databases/json
File diff suppressed because it is too large
View File


+ 3
- 0
server_side/api/modules/databases/users.json View File

@ -5,6 +5,9 @@
"avatar": "/img/user1.png",
"password": "827ccb0eea8a706c4c34a16891f84e7b",
"email": "efeaydin@mycity.com",
"TC": "11111111111",
"tel": "0555 555 55 55",
"health": ["antibiotic allergy", "peanut allergy", "asthma"],
"stats": {
"bus_usage_week": 1,
"bus_usage_month": 5,


+ 345
- 41
server_side/api/modules/navigation.py View File

@ -1,63 +1,367 @@
from flask import Flask, request
from flask_restful import Resource, Api, abort
import datetime
import json
import requests
import json
from flask import Flask, request
from flask_restful import Api, Resource
app = Flask( __name__ )
api = Api( app )
app = Flask(__name__)
api = Api(app)
bus_data = open("databases/bus.json","a")
def sendRequest( url, raw ):
def send_request(url, raw):
headers = {
"User-Agent": "EGO Genel Mudurlugu-EGO Cepte-3.1.0 GT-I9500 7.1.2",
"Content-Type": "application/x-www-form-urlencoded",
"Content-Length": "0" }
headers[ "Content-Length" ] = str( len( raw ) )
r = requests.post( url, headers=headers, data=raw )
content = r.content.decode( "cp1252" )
content = content.replace( "Ý", "I" )
content = content.replace( "ý", "i" )
content = content.replace( "ð", "g" )
content = content.replace( "þ", "s" )
content = content.replace( "Þ", "S" )
"User-Agent": "EGO Genel Mudurlugu-EGO Cepte-3.1.0 GT-I9500 7.1.2",
"Content-Type":"application/x-www-form-urlencoded", "Content-Length":str(len(raw))
}
r = requests.post(url, headers=headers, data=raw)
content = r.content.decode("cp1252")
replace_chars = {"Ý":"I", "ý":"i", "ð":"g", "þ":"s", "Þ":"S"}
for key in replace_chars:
content.replace(key, replace_chars[key])
content = content.replace("'", '"')
content = json.loads(content)
return content
conn1 = sendRequest(
'http://88.255.141.70/mbl/android/connect.asp?SID=0.9672804113380772&VER=3.1.0&LAN=tr&UID=%7BACB78701' \
'-2727-4E9A-AE62-28491D671A7D%7D-130570234&FNC=Connect',
"UID=%7BACB78701-2727-4E9A-AE62-28491D671A7D%7D-130570234&UPS=TRUE" )
conn2 = sendRequest(
'http://88.255.141.66/mbl/android/connect.asp?SID=0.6654049014198404&VER=3.1.0&LAN=tr&UID=%7BACB78701' \
'-2727-4E9A-AE62-28491D671A7D%7D-130570234&FNC=Start', "" )
hatlar = sendRequest( 'http://88.255.141.66/mbl/android/action.asp?SID=0.8328642811845514&VER=3.1.0&LAN=tr&UID'
'=%7BACB78701-2727-4E9A-AE62-28491D671A7D%7D-130570234&FNC=Hatlar', "QUERY=" )
hatlar = hatlar.replace( "'", '"' )
hatlar = json.loads( hatlar )
conn1 = send_request(
'http://88.255.141.70/mbl/android/connect.asp?SID=0.392509188312098&VER=3.1.0&LAN=tr&UID=%7BACB78701'
'-2727-4E9A-AE62-28491D671A7D%7D-130570234&FNC=Connect',
"UID=%7BACB78701-2727-4E9A-AE62-28491D671A7D%7D-130570234&UPS=TRUE")
conn2 = send_request(
'http://88.255.141.66/mbl/android/connect.asp?SID=0.392509188312098&VER=3.1.0&LAN=tr&UID=%7BACB78701'
'-2727-4E9A-AE62-28491D671A7D%7D-130570234&FNC=Start', "")
bus_data = open("modules/databases/bus.json", "r")
bus_json = json.loads(bus_data.read())
routes = bus_json["stops"]
bus_data.close()
print('\n', conn1, '\n\n', conn2, '\n')
def time_small(t1, t2):
time1 = datetime.datetime.strptime(t1, "%H:%M")
time2 = datetime.datetime.strptime(t2, "%H:%M")
if time1 < time2:
return False
else:
return True
def time_diff(t1, t2):
time1 = datetime.datetime.strptime(t1, "%H:%M")
time2 = datetime.datetime.strptime(t2, "%H:%M")
response = ""
if abs(time2.hour - time1.hour) < 10:
response += "0"
if time2.minute - time1.minute >= 0:
response += str(abs(time2.hour - time1.hour))
else:
response += str(abs(time2.hour - time1.hour) - 1)
response += ":"
if abs(time2.minute - time1.minute) < 10:
response += "0"
response += str(abs(time2.minute - time1.minute))
return response
def time_sum(t1, t2):
time1 = datetime.datetime.strptime(t1, "%H:%M")
time2 = datetime.datetime.strptime(t2, "%H:%M")
response = ""
if time2.hour + time1.hour < 10:
response += "0"
if time2.minute + time1.minute > 60:
response += str(time2.hour + time1.hour + 1)
else:
response += str(time2.hour + time1.hour)
response += ":"
if time2.minute + time1.minute % 60 < 10:
response += "0"
response += str((time2.minute + time1.minute) % 60)
return response
def get_closest_time(times, time):
closest = [0, 0]
for i in times[0]:
if i.hour < time.hour or (i.hour == time.hour and i.minute - 6 < time.minute):
continue
else:
if closest[0] == 0:
closest[0] = i
continue
if abs(i.hour - time.hour) < abs(closest[0].hour - time.hour):
closest[0] = i
continue
elif abs(i.hour - time.hour) == abs(closest[0].hour - time.hour):
if i.minute - time.minute < closest[0].minute - time.minute:
closest[0] = i
if closest[0] == 0:
return []
class Transit( Resource ):
for i in times[1]:
if i.hour < closest[0].hour or (i.hour == closest[0].hour and i.minute - 6 < closest[0].minute):
continue
else:
if closest[1] == 0:
closest[1] = i
continue
if abs(i.hour - time.hour) < abs(closest[1].hour - time.hour):
closest[1] = i
continue
elif abs(i.hour - time.hour) == abs(closest[1].hour - time.hour):
if i.minute - time.minute < closest[1].minute - time.minute:
closest[1] = i
if closest[1] == 0:
return []
return [closest[0].strftime("%H:%M"), closest[1].strftime("%H:%M")]
def post( self ):
class Transit(Resource):
def post(self):
change = False
args = request.form
stops_raw = {"user":{}, "dest":{}}
stops_arr = {"user":{}, "dest":{}}
url_closestops = "http://88.255.141.66/mbl/android/action.asp?SID=0.392509188312098&VER=3.1.0&LAN=tr&UID"\
"=%7BACB78701"\
"-2727-4E9A-AE62-28491D671A7D%7D-130570234&FNC=YakinDuraklar"
closestops = send_request(url_closestops, "LAT={0}&LNG={1}&MSF=500".format(args["lat_usr"], args["lng_usr"]))
for stop in closestops["data"][0]["table"]:
stops_arr["user"][stop["kod"]] = stop["hatlar"].split(",")
closestops = send_request(url_closestops, "LAT={0}&LNG={1}&MSF=500".format(args["lat_dest"], args["lng_dest"]))
for stop in closestops["data"][0]["table"]:
stops_arr["dest"][stop["kod"]] = stop["hatlar"].split(",")
one_bus = {k.strip():
[dict({x:n for n in stops_arr["user"] for x in stops_arr["user"][n]})[k],
dict({x:n for n in stops_arr["dest"] for x in stops_arr["dest"][n]})[k]]
for k in (list(set([x for n in stops_arr["user"] for x in stops_arr["user"][n]])
& set([x for n in stops_arr["dest"] for x in stops_arr["dest"][n]])))}
travel = {"routes":[], "total":[]}
# time_cur = datetime.datetime.today().time()
time_cur = datetime.datetime.strptime("13:00", "%H:%M")
if len(one_bus) > 0:
for i in one_bus:
travel["routes"].append([{"name":i, "stops":[one_bus[i][0], one_bus[i][1]]}])
else:
routes_arr = {"user":{}, "dest":{}}
stopno = {}
for i in stops_arr["user"]:
for j in stops_arr["user"][i]:
try:
routes_arr["user"][j.strip()] = bus_json["stops"][j.strip()]
except KeyError:
stops = send_request(
"http://88.255.141.66/mbl/android/action.asp?SID=0.8737969480190279&VER=3.1.0&LAN=tr"
"&UID"
"=%7BACB78701-2727-4E9A-AE62-28491D671A7D%7D-130570234&FNC=HatBilgileri",
"KOD={}".format(routes_arr["user"][j.strip()]))["data"][0]["table_durak"]
bus_json["stops"][j.strip()] = [x["kod"] for x in stops]
routes_arr["user"][j.strip()] = bus_json["stops"][j.strip()]
for x in stops:
bus_json["stop_info"][x["kod"]] = {
"name": x["ad"],
"location":x["konum"],
"lat": x["lat"],
"lng": x["lng"]
}
change = True
stopno[j.strip()] = i
for i in stops_arr["dest"]:
for j in stops_arr["dest"][i]:
try:
routes_arr["dest"][j.strip()] = bus_json["stops"][j.strip()]
except KeyError:
stops = send_request(
"http://88.255.141.66/mbl/android/action.asp?SID=0.8737969480190279&VER=3.1.0&LAN=tr"
"&UID"
"=%7BACB78701-2727-4E9A-AE62-28491D671A7D%7D-130570234&FNC=HatBilgileri",
"KOD={}".format(routes_arr["dest"][j.strip()]))["data"][0]["table_durak"]
bus_json["stops"][j.strip()] = [x["kod"] for x in stops]
routes_arr["dest"][j.strip()] = bus_json["stops"][j.strip()]
for x in stops:
bus_json["stop_info"][x["kod"]] = {
"name": x["ad"],
"location":x["konum"],
"lat": x["lat"],
"lng": x["lng"]
}
change = True
stopno[j.strip()] = i
for i in routes_arr["user"]:
for j in routes_arr["user"][i]:
for k in routes_arr["dest"]:
for x in routes_arr["dest"][k]:
if j.strip() == x.strip():
travel["routes"].append([
{"name":i.strip(), "stops":[stopno[i.strip()], x.strip()]},
{"name":k.strip(), "stops":[x.strip(), stopno[k.strip()]]}])
for i in range(len(travel["routes"])):
for k in range(len(travel["routes"][i])):
url = "http://88.255.141.66/mbl/android/action.asp?SID=0.4474110208361718&VER=3.1.0&LAN=tr&UID"\
"=%7BACB78701-2727-4E9A-AE62-28491D671A7D%7D-130570234&FNC=DuraktanGecisSaatleri "
weekno = datetime.datetime.today().weekday()
times_anal = [[], []]
for j in range(2):
try:
times_raw = bus_json["times"][travel["routes"][i][k]["name"]]
except Exception:
bus_json["times"][travel["routes"][i][k]["name"]] = {}
try:
times_raw = bus_json["times"][travel["routes"][i][k]["name"]][
travel["routes"][i][k]["stops"][j]]
except Exception:
bus_json["times"][travel["routes"][i][k]["name"]][travel["routes"][i][k]["stops"][j]] = {}
if weekno < 5:
try:
weekday = "HAFTA+%C4%B0%C3%87%C4%B0"
times_raw =\
bus_json["times"][travel["routes"][i][k]["name"]][travel["routes"][i][k]["stops"][j]][
"weekday"]
except KeyError:
bus_json["times"][travel["routes"][i][k]["name"]][travel["routes"][i][k]["stops"][j]][
"weekday"] = send_request(url, "HAT={0}&DURAK={1}&TUR={2}".format(
travel["routes"][i][k]["name"], travel["routes"][i][k]["stops"][j], weekday))[
"data"][0]["table"]
times_raw =\
bus_json["times"][travel["routes"][i][k]["name"]][travel["routes"][i][k]["stops"][j]][
"weekday"]
change = True
elif weekno == 5:
try:
weekday = "CUMARTES%C4%B0"
times_raw =\
bus_json["times"][travel["routes"][i][k]["name"]][travel["routes"][i][k]["stops"][j]][
"saturday"]
except KeyError:
bus_json["times"][travel["routes"][i][k]["name"]][travel["routes"][i][k]["stops"][j]][
"saturday"] = send_request(url, "HAT={0}&DURAK={1}&TUR={2}".format(
travel["routes"][i][k]["name"], travel["routes"][i][k]["stops"][j], weekday))[
"data"][0]["table"]
times_raw =\
bus_json["times"][travel["routes"][i][k]["name"]][travel["routes"][i][k]["stops"][j]][
"saturday"]
change = True
else:
try:
weekday = "PAZAR"
times_raw =\
bus_json["times"][travel["routes"][i][k]["name"]][travel["routes"][i][k]["stops"][j]][
"sunday"]
except KeyError:
bus_json["times"][travel["routes"][i][k]["name"]][travel["routes"][i][k]["stops"][j]][
"sunday"] = send_request(url, "HAT={0}&DURAK={1}&TUR={2}".format(
travel["routes"][i][k]["name"], travel["routes"][i][k]["stops"][j], weekday))[
"data"][0]["table"]
times_raw =\
bus_json["times"][travel["routes"][i][k]["name"]][travel["routes"][i][k]["stops"][j]][
"sunday"]
change = True
for time in times_raw:
times_anal[j].append(
datetime.datetime.strptime("{0}:{1}".format(time["saat"], time["dakika"]), "%H:%M"))
closest_times = get_closest_time([times_anal[0], times_anal[1]], time_cur)
travel["routes"][i][k]["time"] = closest_times
empty = []
for i in range(len(travel["routes"])):
remove = True
for k in range(len(travel["routes"][i])):
if remove:
if len(travel["routes"][i][k]["time"]) == 0:
empty.append(i - len(empty))
remove = False
for i in empty:
travel["routes"].pop(i)
for route in travel["routes"]:
start = route[0]["time"][0]
end = route[-1]["time"][1]
diff = time_diff(start, end)
diff = time_sum(diff, time_diff(time_cur.strftime("%H:%M"), start))
diff = time_sum(diff, "00:05")
travel["total"].append(diff)
shortest = 0
durak = sendRequest(
"http://88.255.141.66/mbl/android/service.asp?SID=0.09912588645045828&VER=3.1.0&LAN=tr&UID=%7BACB78701" \
"-2727-4E9A-AE62-28491D671A7D%7D-130570234&FNC=Otobusler", "DURAK=" + str( args[ "stop" ] ) )
durak = durak.replace( "'", '"' )
durak = json.loads( durak )
for i in range(len(travel["total"])):
if shortest == 0:
shortest = {"routes":travel["routes"][i], "time":travel["total"][i]}
continue
if time_small(shortest["time"], travel["total"][i]):
shortest = {"routes":travel["routes"][i], "time":travel["total"][i]}
if change:
bus_data = open("modules/databases/bus.json", "w")
bus_data.write(json.dumps(bus_json, indent=4, sort_keys=True))
bus_data.close()
for i in range(len(shortest["routes"])):
try:
shortest["routes"][i]["names"] = [bus_json["stop_info"][shortest["routes"][i][0]]["name"],bus_json["stop_info"][shortest["routes"][i][1]]["name"]]
except KeyError:
shortest["routes"][i]["names"] = []
shortest["routes"][i]["locations"] = []
shortest["routes"][i]["coordinates"] = []
for j in range(2):
data = send_request("http://88.255.141.66/mbl/android/action.asp?SID=0.21893997000802157&VER=3.1.0&LAN=tr&UID=%7BACB78701-2727-4E9A-AE62-28491D671A7D%7D-130570234&FNC=Duraklar",
"QUERY={}".format(shortest["routes"][i]["stops"][j]))["data"][0]["table"][0]
bus_json["stop_info"][shortest["routes"][i]["stops"][j]] ={
"name": data["ad"],
"location": data["konum"],
"lat": data["lat"],
"lng": data["lng"]
}
shortest["routes"][i]["names"].append(bus_json["stop_info"][shortest["routes"][i]["stops"][j]]["name"])
shortest["routes"][i]["locations"].append(bus_json["stop_info"][shortest["routes"][i]["stops"][j]]["location"])
shortest["routes"][i]["coordinates"].append({"lat":bus_json["stop_info"][shortest["routes"][i]["stops"][j]]["lat"], "lng":bus_json["stop_info"][shortest["routes"][i]["stops"][j]]["lng"]})
change=True
return [durak,hatlar]
if change:
bus_data = open("modules/databases/bus.json", "w")
bus_data.write(json.dumps(bus_json, indent=4, sort_keys=True))
bus_data.close()
return shortest
if __name__ == '__main__':
api.add_resource( Transit, '/transit', '/transit/' )
api.add_resource(Transit, '/transit', '/transit/')
app.run( host='0.0.0.0', port=5000 )
app.run(host='0.0.0.0', port=5000)

+ 1
- 31
server_side/api/modules/user_info.py View File

@ -3,15 +3,13 @@ import copy
import json
import base64
import pyDes
import qrcode
from api.modules import utils
from flask import Flask, request
from flask_restful import Resource, Api, abort
enc = pyDes.triple_des(b'Kz\n\x1a\xc1~\x05#\xf9\xad\xc8\xa2\x15\xd5J\x89\xe4RT\x8d\xb3?\x93\x1c')
app = Flask(__name__)
api = Api(app)
db_path = os.path.join(app.root_path, 'databases', 'users.json')
@ -85,34 +83,6 @@ class Login(Resource):
else:
return [False, {}]
class QRCode(Resource):
def post(self):
"""
POST Data:
id=<user_id>
"""
user_id = request.form['id']
if utils.find_by_id(users.values(), user_id):
image_path = os.path.join(app.root_path, '..', 'images', user_id + '_qr' + '.png')
if not os.path.exists(image_path):
encrypted_id = enc.encrypt(user_id, padmode=2)
img = qrcode.make(base64.b64encode(encrypted_id).decode('utf-8'))
img.save(image_path)
return '/img/' + user_id + '_qr' + '.png'
else:
abort(404, error="User {} doesn't exist".format(user_id))
class QRRead(Resource):
def post(self):
"""
POST Data:
qr_data=<qr_data>
"""
qr_data = base64.b64decode(request.form['qr_data'])
user_id = enc.decrypt(qr_data, padmode=2)
return utils.find_by_id(users.values(), user_id.decode())
if __name__ == '__main__':
api.add_resource(Users, '/users', '/users/')


+ 0
- 1
server_side/api/requirements.txt View File

@ -10,5 +10,4 @@ pytz==2018.9
six==1.12.0
Werkzeug==0.14.1
pyDes==2.0.1
qrcode==6.1
Pillow==6.0.0

+ 0
- 60
smart_home/.gitignore View File

@ -1,60 +0,0 @@
# Created by .ignore support plugin (hsz.mobi)
### JetBrains template
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
# User-specific stuff
.idea/**/workspace.xml
.idea/**/tasks.xml
.idea/**/dictionaries
.idea/**/shelf
# Sensitive or high-churn files
.idea/**/dataSources/
.idea/**/dataSources.ids
.idea/**/dataSources.local.xml
.idea/**/sqlDataSources.xml
.idea/**/dynamic.xml
.idea/**/uiDesigner.xml
.idea/**/dbnavigator.xml
# Gradle
.idea/**/gradle.xml
.idea/**/libraries
# CMake
cmake-build-debug/
cmake-build-release/
# Mongo Explorer plugin
.idea/**/mongoSettings.xml
# File-based project format
*.iws
# IntelliJ
out/
# mpeltonen/sbt-idea plugin
.idea_modules/
# JIRA plugin
atlassian-ide-plugin.xml
# Cursive Clojure plugin
.idea/replstate.xml
# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties
# Editor-based Rest Client
.idea/httpRequests
face/*
hand/*
pose/*
cameraParameters/*
cameraParameters/*/*

BIN
smart_home/Output-Keypoints.jpg View File

Before After
Width: 3000  |  Height: 2000  |  Size: 946 KiB

BIN
smart_home/Output-Skeleton.jpg View File

Before After
Width: 3000  |  Height: 2000  |  Size: 974 KiB

+ 0
- 85
smart_home/pose_detector.py View File

@ -1,85 +0,0 @@
import cv2
import time
import numpy as np
MODE = "MPI"
if MODE is "COCO":
protoFile = "pose/coco/pose_deploy_linevec.prototxt"
weightsFile = "pose/coco/pose_iter_440000.caffemodel"
nPoints = 18
POSE_PAIRS = [ [1,0],[1,2],[1,5],[2,3],[3,4],[5,6],[6,7],[1,8],[8,9],[9,10],[1,11],[11,12],[12,13],[0,14],[0,15],[14,16],[15,17]]
elif MODE is "MPI" :
protoFile = "pose/mpi/pose_deploy_linevec_faster_4_stages.prototxt"
weightsFile = "pose/mpi/pose_iter_160000.caffemodel"
nPoints = 15
POSE_PAIRS = [[0,1], [1,2], [2,3], [3,4], [1,5], [5,6], [6,7], [1,14], [14,8], [8,9], [9,10], [14,11], [11,12], [12,13] ]
frame = cv2.imread("single.jpeg")
frameCopy = np.copy(frame)
frameWidth = frame.shape[1]
frameHeight = frame.shape[0]
threshold = 0.2
net = cv2.dnn.readNetFromCaffe(protoFile, weightsFile)
t = time.time()
# input image dimensions for the network
inWidth = 368
inHeight = 368
inpBlob = cv2.dnn.blobFromImage(frame, 1.0 / 255, (inWidth, inHeight),
(0, 0, 0), swapRB=False, crop=False)
net.setInput(inpBlob)
output = net.forward()
print("time taken by network : {:.3f}".format(time.time() - t))
H = output.shape[2]
W = output.shape[3]
# Empty list to store the detected keypoints
points = []
for i in range(nPoints):
# confidence map of corresponding body's part.
probMap = output[0, i, :, :]
# Find global maxima of the probMap.
minVal, prob, minLoc, point = cv2.minMaxLoc(probMap)
# Scale the point to fit on the original image
x = (frameWidth * point[0]) / W
y = (frameHeight * point[1]) / H
if prob > threshold :
cv2.circle(frameCopy, (int(x), int(y)), 8, (0, 255, 255), thickness=-1, lineType=cv2.FILLED)
cv2.putText(frameCopy, "{}".format(i), (int(x), int(y)), cv2.FONT_HERSHEY_SIMPLEX, 1, (0, 0, 255), 2, lineType=cv2.LINE_AA)
# Add the point to the list if the probability is greater than the threshold
points.append((int(x), int(y)))
else :
points.append(None)
# Draw Skeleton
for pair in POSE_PAIRS:
partA = pair[0]
partB = pair[1]
if points[partA] and points[partB]:
cv2.line(frame, points[partA], points[partB], (0, 255, 255), 2)
cv2.circle(frame, points[partA], 8, (0, 0, 255), thickness=-1, lineType=cv2.FILLED)
cv2.imshow('Output-Keypoints', cv2.resize(frameCopy,(900,900)))
cv2.imshow('Output-Skeleton', cv2.resize(frame,(600,900)))
cv2.imwrite('Output-Keypoints.jpg', frameCopy)
cv2.imwrite('Output-Skeleton.jpg', frame)
print("Total time taken : {:.3f}".format(time.time() - t))
cv2.waitKey(0)

BIN
smart_home/single.jpeg View File

Before After
Width: 3000  |  Height: 2000  |  Size: 548 KiB

BIN
smart_home/single.jpg View File

Before After
Width: 2000  |  Height: 1333  |  Size: 237 KiB

BIN
smart_home/single.png View File

Before After
Width: 946  |  Height: 1248  |  Size: 1018 KiB

+ 0
- 15
smart_home/smart_home.iml View File

@ -1,15 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="WEB_MODULE" version="4">
<component name="FacetManager">
<facet type="Python" name="Python">
<configuration sdkName="Python 3.7" />
</facet>
</component>
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="Python 3.7 interpreter library" level="application" />
</component>
</module>

Loading…
Cancel
Save