Browse Source

Completed several shit

-Ev3 Done
-Main page done
-Transit debugged
-Uploaded transit source
old
Yiğit Çolakoğlu 6 years ago
parent
commit
bc648f89e9
32 changed files with 272299 additions and 84 deletions
  1. +196
    -51
      MyCity/app/src/main/java/gq/yigit/mycity/MainFragment.java
  2. +13
    -8
      MyCity/app/src/main/java/gq/yigit/mycity/navigation/TransitFragment.java
  3. +1
    -1
      MyCity/app/src/main/java/gq/yigit/mycity/votesFragment/MyVotesRecyclerViewAdapter.java
  4. +36
    -0
      MyCity/app/src/main/res/drawable-v21/megaphone.xml
  5. +1
    -1
      MyCity/app/src/main/res/drawable/circle_shape.xml
  6. +54
    -9
      MyCity/app/src/main/res/layout/fragment_main.xml
  7. +1
    -1
      MyCity/app/src/main/res/layout/fragment_votes_list.xml
  8. +3
    -4
      MyCity/app/src/main/res/layout/rate_spinner_layout.xml
  9. +2
    -1
      MyCity/app/src/main/res/layout/transit_item.xml
  10. +3
    -2
      MyCity/app/src/main/res/layout/votes_list_item.xml
  11. +1
    -1
      MyCity/app/src/main/res/values/strings.xml
  12. +9
    -0
      bus_stop/bus_stop.iml
  13. +173
    -0
      bus_stop/main.py
  14. +4
    -0
      bus_stop/main.py.err.log
  15. +338
    -0
      bus_stop/times.json
  16. +1
    -0
      server_side/.gitignore
  17. +5
    -1
      server_side/api/app.py
  18. BIN
      server_side/api/modules/__pycache__/announcements.cpython-37.pyc
  19. BIN
      server_side/api/modules/__pycache__/bus_stops.cpython-37.pyc
  20. BIN
      server_side/api/modules/__pycache__/navigation.cpython-37.pyc
  21. BIN
      server_side/api/modules/__pycache__/user_info.cpython-37.pyc
  22. +196
    -0
      server_side/api/modules/alternateSolution1.py
  23. +17
    -0
      server_side/api/modules/announcements.py
  24. +17
    -0
      server_side/api/modules/bus_stops.py
  25. +208390
    -0
      server_side/api/modules/data.json
  26. +10
    -0
      server_side/api/modules/databases/announcements.json
  27. +108
    -0
      server_side/api/modules/databases/bus.json
  28. +4
    -2
      server_side/api/modules/databases/votings.json
  29. +119
    -0
      server_side/api/modules/detectSpot.py
  30. +1
    -2
      server_side/api/modules/navigation.py
  31. +28
    -0
      server_side/api/modules/smart_parking.py
  32. +62568
    -0
      server_side/api/modules/timely.json

+ 196
- 51
MyCity/app/src/main/java/gq/yigit/mycity/MainFragment.java View File

@ -1,73 +1,85 @@
package gq.yigit.mycity;
import android.content.Context;
import android.graphics.Bitmap;
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.TextView;
import gq.yigit.mycity.tools.FileActions;
import gq.yigit.mycity.tools.ImageDownload;
import gq.yigit.mycity.tools.WebRequest;
import gq.yigit.mycity.votesFragment.MyVotesRecyclerViewAdapter;
import gq.yigit.mycity.votesFragment.VotesContent;
import gq.yigit.mycity.votesFragment.VotesFragment;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* A simple {@link Fragment} subclass.
* Activities that contain this fragment must implement the
* {@link MainFragment.OnFragmentInteractionListener} interface
* to handle interaction events.
* Use the {@link MainFragment#newInstance} factory method to
* create an instance of this fragment.
*/
public class MainFragment extends Fragment {
// TODO: Rename parameter arguments, choose names that match
// the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
private static final String ARG_PARAM1 = "param1";
private static final String ARG_PARAM2 = "param2";
// TODO: Rename and change types of parameters
private String mParam1;
private String mParam2;
private OnFragmentInteractionListener mListener;
public class MainFragment extends Fragment implements WebRequest.responseListener, ImageDownload.imageListener {
private TextView temp_text;
private TextView humi_text;
private TextView pres_text;
private ImageView weather_img;
private RecyclerView recyclerView;
private String key = "d6907927a2b9224a0b60d0565c207377";
private String url;
private OnFragmentInteractionListener mListener;
private OnRecyclerViewInteractionListener recyclerViewInteractionListener;
public MainFragment() {
// Required empty public constructor
}
/**
* Use this factory method to create a new instance of
* this fragment using the provided parameters.
*
* @param param1 Parameter 1.
* @param param2 Parameter 2.
* @return A new instance of fragment MainFragment.
*/
// TODO: Rename and change types and number of parameters
}
public static MainFragment newInstance(String param1, String param2) {
MainFragment fragment = new MainFragment();
Bundle args = new Bundle();
args.putString(ARG_PARAM1, param1);
args.putString(ARG_PARAM2, param2);
fragment.setArguments(args);
return fragment;
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (getArguments() != null) {
mParam1 = getArguments().getString(ARG_PARAM1);
mParam2 = getArguments().getString(ARG_PARAM2);
}
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
return inflater.inflate(R.layout.fragment_main, container, false);
View rootView = inflater.inflate(R.layout.fragment_main, container, false);
temp_text = rootView.findViewById(R.id.temp_text);
humi_text = rootView.findViewById(R.id.humidity);
pres_text = rootView.findViewById(R.id.pressure);
weather_img = rootView.findViewById(R.id.forecast_img);
recyclerView = rootView.findViewById(R.id.anouncements);
HashMap<String,String> params = new HashMap<>();
params.put("q","Ankara,tr");
params.put("appid",key);
FileActions file_manager = new FileActions();
url = file_manager.readFromFile(getContext(),"server.config").trim();
WebRequest request = new WebRequest("https://api.openweathermap.org/data/2.5/weather",true,params,0);
request.addListener(this);
request.execute();
return rootView;
}
// TODO: Rename method, update argument and hook method into UI event
public void onButtonPressed(Uri uri) {
if (mListener != null) {
mListener.onFragmentInteraction(uri);
@ -91,18 +103,151 @@ public class MainFragment extends Fragment {
mListener = null;
}
/**
* This interface must be implemented by activities that contain this
* fragment to allow an interaction in this fragment to be communicated
* to the activity and potentially other fragments contained in that
* activity.
* <p>
* See the Android Training lesson <a href=
* "http://developer.android.com/training/basics/fragments/communicating.html"
* >Communicating with Other Fragments</a> for more information.
*/
public interface OnFragmentInteractionListener {
// TODO: Update argument type and name
void onFragmentInteraction(Uri uri);
}
@Override
public void receivedResponse(boolean success, String response,int id){
if(id == 0) {
try {
JSONObject weatherdata = new JSONObject(response).getJSONArray("weather").getJSONObject(0);
JSONObject temp = new JSONObject(response).getJSONObject("main");
temp_text.setText((int)(Float.parseFloat(temp.getString("temp")) - 272.15) + " °C");
humi_text.setText("Humidity: %" + temp.getString("humidity"));
pres_text.setText("Pressure: " + temp.getString("pressure") + "hpa");
ImageDownload imageDownload = new ImageDownload();
imageDownload.addListener(this);
imageDownload.execute(String.format("http://openweathermap.org/img/w/%s.png", weatherdata.getString("icon")));
} catch (JSONException e) {
Log.e("[ERROR]", "Cannot process weather data");
}
}if(id == 1) {
try {
JSONArray announcements = new JSONArray(response);
for(int i = 0; i< announcements.length();i++){
JSONObject obj = announcements.getJSONObject(i);
AnnounceContent.addItem(new AnnounceContent.AnnounceItem(
String.valueOf(i),
obj.getString("text1"),
obj.getString("text2")
));
}
recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
recyclerView.setAdapter(new AnnouncementAdapter(AnnounceContent.ITEMS, recyclerViewInteractionListener));
} catch (JSONException e) {
Log.e("[ERROR]", "Cannot process weather data");
}
}
}
@Override
public void imageDownloaded(Bitmap img) {
weather_img.setImageBitmap(Bitmap.createScaledBitmap(img,100,100,true));
WebRequest request = new WebRequest(url + "/announcements",true,new HashMap<String, String>(),1);
request.addListener(this);
request.execute();
}
public interface OnRecyclerViewInteractionListener {
void OnRecyclerViewInteraction(AnnounceContent.AnnounceItem item);
}
}
class AnnounceContent {
public static final List<AnnounceItem> ITEMS = new ArrayList<>();
public static final Map<String, AnnounceItem> ITEM_MAP = new HashMap<>();
public static void addItem(AnnounceItem item) {
ITEMS.add(item);
ITEM_MAP.put(item.id, item);
}
public static class AnnounceItem {
public final String id;
public final String name;
public final String details;
public AnnounceItem(String id, String name, String details) {
this.id = id;
this.name = name;
this.details = details;
}
@Override
public String toString() {
return name;
}
}
}
class AnnouncementAdapter extends RecyclerView.Adapter<AnnouncementAdapter.ViewHolder> {
private final List<AnnounceContent.AnnounceItem> mValues;
private final MainFragment.OnRecyclerViewInteractionListener mListener;
public AnnouncementAdapter(List<AnnounceContent.AnnounceItem> items, MainFragment.OnRecyclerViewInteractionListener listener) {
mValues = items;
mListener = listener;
}
@Override
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View view = LayoutInflater.from(parent.getContext())
.inflate(R.layout.votes_list_item, parent, false);
return new AnnouncementAdapter.ViewHolder(view);
}
@Override
public void onBindViewHolder(final AnnouncementAdapter.ViewHolder holder, int position) {
holder.mItem = mValues.get(position);
holder.mIdView.setText(mValues.get(position).name);
holder.mContentView.setText(mValues.get(position).details);
holder.mView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (null != mListener) {
mListener.OnRecyclerViewInteraction(holder.mItem);
}
}
});
}
@Override
public int getItemCount() {
return mValues.size();
}
public class ViewHolder extends RecyclerView.ViewHolder {
public final View mView;
public final TextView mIdView;
public final TextView mContentView;
public AnnounceContent.AnnounceItem mItem;
public ViewHolder(View view) {
super(view);
mView = view;
mIdView = (TextView) view.findViewById(R.id.item_number);
mContentView = (TextView) view.findViewById(R.id.content);
}
@Override
public String toString() {
return super.toString() + " '" + mContentView.getText() + "'";
}
}
}

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

@ -3,6 +3,7 @@ package gq.yigit.mycity.navigation;
import android.content.Context;
import android.content.Intent;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.net.Uri;
import android.os.Bundle;
@ -17,6 +18,7 @@ import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;
import com.google.android.gms.common.api.Status;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.libraries.places.api.Places;
@ -100,17 +102,14 @@ public class TransitFragment extends Fragment implements WebRequest.responseList
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());
latitude = "39.9127897";
longitude = "32.8073577";
}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);
@ -181,8 +180,8 @@ public class TransitFragment extends Fragment implements WebRequest.responseList
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("names")).getString(0)),
(new JSONArray(route.getString("names")).getString(1)),
(new JSONArray(route.getString("time")).getString(0)),
(new JSONArray(route.getString("time")).getString(1)),
"bus"
@ -209,6 +208,12 @@ class TransitContent {
ITEMS.add(item);
ITEM_MAP.put(item.endTime, item);
}
public static void resetItems(){
final List<TransitItem> ITEMS = new ArrayList<TransitItem>();
final Map<String, TransitItem> ITEM_MAP = new HashMap<String, TransitItem>();
}
public static class TransitItem {


+ 1
- 1
MyCity/app/src/main/java/gq/yigit/mycity/votesFragment/MyVotesRecyclerViewAdapter.java View File

@ -26,7 +26,7 @@ public class MyVotesRecyclerViewAdapter extends RecyclerView.Adapter<MyVotesRecy
@Override
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View view = LayoutInflater.from(parent.getContext())
.inflate(R.layout.fragment_votes, parent, false);
.inflate(R.layout.votes_list_item, parent, false);
return new ViewHolder(view);
}


+ 36
- 0
MyCity/app/src/main/res/drawable-v21/megaphone.xml View File

@ -0,0 +1,36 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android" xmlns:aapt="http://schemas.android.com/aapt"
android:viewportWidth="512"
android:viewportHeight="512"
android:width="512dp"
android:height="512dp">
<path
android:pathData="M134.05 319.086l128.178 41.525c14.158 4.587 21.917 19.782 17.331 33.94l0 0c-4.587 14.158 -19.782 21.917 -33.94 17.331L117.44 370.357c-14.158 -4.587 -21.917 -19.782 -17.331 -33.94l0 0C104.696 322.258 119.891 314.499 134.05 319.086z"
android:fillColor="#A4C2F7" />
<path
android:pathData="M35.93 179.649c-4.758 0.03 -9.421 1.335 -13.503 3.781c-1.386 -0.82 -2.842 -1.517 -4.35 -2.081c0.694 1.315 1.107 2.76 1.212 4.243c-3.504 2.738 -6.28 6.296 -8.081 10.362c-0.364 0.07 -0.732 0.12 -1.101 0.149c-0.379 -0.052 -0.754 -0.128 -1.123 -0.228v126.208c0.901 -0.333 1.847 -0.526 2.807 -0.572c1.078 0.011 2.146 0.203 3.161 0.566c1.503 1.91 3.256 3.609 5.211 5.053c0.324 0.742 0.567 1.517 0.722 2.311c0.526 -0.263 1.008 -0.594 1.514 -0.888c4.088 2.458 8.762 3.77 13.532 3.798c14.864 -0.044 26.904 -12.083 26.947 -26.947v-98.807C62.833 191.732 50.794 179.693 35.93 179.649z"
android:fillColor="#A4C2F7" />
<path
android:pathData="M467.088 35.93L467.088 35.93c19.844 0 35.93 16.086 35.93 35.93V440.14c0 19.844 -16.086 35.93 -35.93 35.93l0 0c-19.844 0 -35.93 -16.086 -35.93 -35.93V71.86C431.158 52.016 447.244 35.93 467.088 35.93z"
android:fillColor="#7FACFA" />
<path
android:pathData="M452.597 38.298c-0.498 4.606 -4.458 8.052 -9.088 7.91c-1.155 -0.024 -2.296 -0.256 -3.368 -0.684v421.504c0.207 -0.011 0.348 -0.114 0.561 -0.114c4.541 -0.15 8.456 3.169 9.052 7.673c15.487 -4.307 26.233 -18.372 26.317 -34.447V71.86C476.001 56.875 466.649 43.503 452.597 38.298z"
android:fillColor="#A4C2F7" />
<path
android:pathData="M431.158 413.193L242.526 296.421 242.526 215.579 431.158 98.807Z"
android:fillColor="#A4C2F7" />
<path
android:pathData="M404.211 404.211L62.877 296.421 62.877 215.579 404.211 107.789Z"
android:fillColor="#E3E7F2" />
<path
android:pathData="M467.088 485.053c-24.792 -0.029 -44.883 -20.12 -44.912 -44.912V71.86c0 -24.804 20.108 -44.912 44.912 -44.912C491.892 26.947 512 47.055 512 71.86V440.14C511.971 464.933 491.88 485.024 467.088 485.053zM467.088 44.912c-14.876 0.016 -26.931 12.071 -26.947 26.947V440.14c0 14.883 12.065 26.947 26.947 26.947c14.883 0 26.947 -12.065 26.947 -26.947V71.86C494.019 56.984 481.964 44.929 467.088 44.912z"
android:fillColor="#428DFF" />
<path
android:pathData="M431.158 422.175c-0.92 0 -1.834 -0.142 -2.711 -0.421L60.167 304.982c-3.733 -1.182 -6.271 -4.646 -6.272 -8.561v-80.842c0.001 -3.916 2.539 -7.38 6.272 -8.561L428.447 90.246c2.729 -0.864 5.707 -0.376 8.017 1.316c2.31 1.691 3.675 4.383 3.676 7.246v314.386C440.139 418.153 436.118 422.174 431.158 422.175L431.158 422.175zM71.86 289.842l350.316 111.079V111.079L71.86 222.158V289.842z"
android:fillColor="#428DFF" />
<path
android:pathData="M253.903 422.184c-3.753 -0.002 -7.483 -0.594 -11.053 -1.754l-128.175 -41.526c-18.848 -6.15 -29.177 -26.381 -23.105 -45.254c6.146 -18.847 26.374 -29.177 45.246 -23.105l128.193 41.526c16.781 5.489 27.091 22.352 24.329 39.79C286.576 409.299 271.559 422.15 253.903 422.184zM125.772 326.763c-7.794 0.002 -14.702 5.019 -17.114 12.43c-3.003 9.433 2.15 19.525 11.553 22.623l128.184 41.526l0 0c9.436 3.046 19.557 -2.128 22.612 -11.562c3.055 -9.434 -2.111 -19.559 -11.542 -22.622l-128.184 -41.526C129.501 327.057 127.643 326.764 125.772 326.763L125.772 326.763z"
android:fillColor="#428DFF" />
<path
android:pathData="M35.93 341.333c-19.835 -0.02 -35.91 -16.095 -35.93 -35.93v-98.807c0 -19.843 16.086 -35.93 35.93 -35.93s35.93 16.086 35.93 35.93v98.807C71.84 325.239 55.765 341.314 35.93 341.333zM35.93 188.632c-9.916 0.013 -17.952 8.049 -17.965 17.965v98.807c0 9.922 8.043 17.965 17.965 17.965s17.965 -8.043 17.965 -17.965v-98.807C53.882 196.68 45.846 188.644 35.93 188.632z"
android:fillColor="#428DFF" />
</vector>

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

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:innerRadius="0dp"
android:innerRadius="5dp"
android:shape="ring"
android:thicknessRatio="1.9"
android:useLevel="false" >


+ 54
- 9
MyCity/app/src/main/res/layout/fragment_main.xml View File

@ -1,13 +1,58 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainFragment">
<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=".MainFragment"
android:orientation="vertical"
android:layout_marginTop="@dimen/fragment_margin">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="20dp"
android:layout_marginLeft="25dp">
<TextView
android:text="Ankara,Çankaya"
android:layout_width="match_parent"
android:layout_height="wrap_content" android:id="@+id/city_name" android:textSize="20sp"
android:layout_marginBottom="14dp" android:textColor="@android:color/black"/>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:layout_width="150dp"
android:layout_height="50dp" app:srcCompat="@mipmap/ic_launcher" android:id="@+id/forecast_img"
android:layout_weight="1"/>
<TextView
android:text="20 °C"
android:layout_width="200dp"
android:layout_height="wrap_content" android:id="@+id/temp_text" android:layout_weight="1"
android:textSize="35sp" android:textColor="#000000" android:layout_marginLeft="5dp"/>
<LinearLayout
android:orientation="vertical"
android:layout_width="310dp"
android:layout_height="match_parent" android:layout_weight="1"
android:layout_marginLeft="12dp">
<TextView
android:text="TextView"
android:layout_width="match_parent"
android:layout_height="wrap_content" android:id="@+id/humidity" android:textColor="#000000"/>
<TextView
android:text="TextView"
android:layout_width="match_parent"
android:layout_height="wrap_content" android:id="@+id/pressure" android:textColor="#000000"/>
</LinearLayout>
</LinearLayout>
</LinearLayout>
<TextView
android:text="Announcements:"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="@string/hello_blank_fragment"/>
</FrameLayout>
android:layout_height="wrap_content" android:id="@+id/announcement_title" android:textSize="24sp"
android:textColor="#000000" android:layout_marginBottom="15dp" android:layout_marginLeft="7dp"/>
<android.support.v7.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="match_parent" android:id="@+id/anouncements" android:layout_marginLeft="14dp"/>
</LinearLayout>

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

@ -12,7 +12,7 @@
android:layout_marginRight="16dp"
app:layoutManager="LinearLayoutManager"
tools:context=".votesFragment.VotesFragment"
tools:listitem="@layout/fragment_votes"
tools:listitem="@layout/votes_list_item"
android:divider="@android:color/transparent"
android:dividerHeight="100.0sp"
android:clipChildren="false" android:clipToPadding="false" android:scrollbars="vertical"/>

+ 3
- 4
MyCity/app/src/main/res/layout/rate_spinner_layout.xml View File

@ -4,10 +4,9 @@
android:layout_height="wrap_content">
<ImageView
android:layout_width="115dp"
android:layout_height="wrap_content" app:srcCompat="@mipmap/ic_launcher" android:id="@+id/rate_item_img"
android:layout_weight="1"
android:layout_marginRight="5dp"/>
android:layout_width="150dp"
android:layout_height="50dp" app:srcCompat="@mipmap/ic_launcher" android:id="@+id/rate_item_img"
android:layout_weight="1"/>
<TextView
android:text="TextView"
android:layout_width="match_parent"


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

@ -3,7 +3,8 @@
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">
android:orientation="horizontal"
android:layout_marginBottom="5dp">
<LinearLayout
android:orientation="vertical"


MyCity/app/src/main/res/layout/fragment_votes.xml → MyCity/app/src/main/res/layout/votes_list_item.xml View File


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

@ -1,5 +1,5 @@
<resources>
<string name="app_name">MyCity</string>
<string name="app_name">CitizenView</string>
<string name="navigation_drawer_open">Open navigation drawer</string>
<string name="navigation_drawer_close">Close navigation drawer</string>
<string name="nav_header_title">Android Studio</string>


+ 9
- 0
bus_stop/bus_stop.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="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

+ 173
- 0
bus_stop/main.py View File

@ -0,0 +1,173 @@
#!/usr/bin/env python3
'''Hello to the world from ev3dev.org'''
import os
import sys
import time
import json
import datetime
import urllib3
import requests
from ev3dev2.motor import LargeMotor, OUTPUT_A, OUTPUT_B, SpeedPercent, MoveTank
from ev3dev2.sensor import INPUT_1,INPUT_2
from ev3dev2.sensor.lego import TouchSensor
from ev3dev2.sensor.lego import UltrasonicSensor
from ev3dev2.sound import Sound
from ev3dev2.button import Button
ON = True
OFF = False
def debug_print(*args, **kwargs):
print(*args, **kwargs, file=sys.stderr)
def reset_console():
print('\x1Bc', end='')
def set_cursor(state):
if state:
print('\x1B[?25h', end='')
else:
print('\x1B[?25l', end='')
def set_font(name):
'''Sets the console font
A full list of fonts can be found with `ls /usr/share/consolefonts`
'''
os.system('setfont ' + name)
def raise_ramp():
print("Raising ramp")
def get_closest_time(times, time):
closest = 0
times = [datetime.datetime.strptime(i,"%H:%M") for i in times]
time = datetime.datetime.strptime(time,"%H:%M")
for i in times:
if i.hour < time.hour or (i.hour == time.hour and i.minute < time.minute):
continue
else:
if closest == 0:
closest = i
continue
if abs(i.hour - time.hour) < abs(closest.hour - time.hour):
closest = i
continue
elif abs(i.hour - time.hour) == abs(closest.hour - time.hour):
if i.minute - time.minute < closest.minute - time.minute:
closest = i
return closest.strftime("%H:%M")
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 raise_ramp(motor1):
motor1.on_for_rotations(SpeedPercent(75), 5)
def main():
start = time.time()
file = open("times.json","r")
time_data = json.loads(file.read())
stop_data = [i for i in time_data.keys()]
debug_print(stop_data)
file.close()
time_start = "10:02"
debug_print('Started Code')
reset_console()
set_cursor(OFF)
set_font('Lat15-Terminus24x12')
alarms = [0,0,0]
stop = "11222"
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
print('AKILLI DURAK')
sound = Sound()
us = UltrasonicSensor(INPUT_2)
us.MODE_US_DIST_CM
btn = Button()
m1 = LargeMotor(OUTPUT_A)
ts = TouchSensor(INPUT_1)
while 1:
if us.distance_centimeters < 15:
sound.speak("Please select a stop")
i = 0
reset_console()
print(stop_data[i%len(stop_data)])
while not btn.enter:
if btn.up:
i += 1
reset_console()
print(stop_data[i%len(stop_data)])
time.sleep(0.1)
if btn.down:
i -= 1
reset_console()
print(stop_data[i%len(stop_data)])
time.sleep(0.1)
closest = datetime.datetime.strptime(time_diff(time_start,get_closest_time(time_data[stop_data[i%len(stop_data)]]["weekday"][:],time_start)),"%H:%M")
difference = datetime.timedelta(hours=closest.hour,minutes=closest.minute).total_seconds()+start
if not difference in alarms:
alarms[i%len(stop_data)] = difference
r = requests.get("https://192.168.44.50:5000/bus?line={}&stop={}".format(stop_data[i%len(stop_data)],stop), verify=False)
print(difference-time.time())
time.sleep(1)
reset_console()
print("AKILLI DURAK")
for i in range(len(alarms)):
if alarms[i] == 0:
continue
else:
if alarms[i]-time.time()<0:
reset_console()
print("Bus no {} has arrived".format(stop_data[i%len(stop_data)]))
sound.speak("Bus no {} has arrived".format(stop_data[i%len(stop_data)]))
sound.speak("Would you like a ramp?")
waiter = time.time()
pressed = True
while time.time()-waiter < 10 and pressed:
if ts.is_pressed:
pressed = False
raise_ramp(m1)
reset_console()
print("AKILLI DURAK")
alarms[i] = 0
if __name__ == '__main__':
main()

+ 4
- 0
bus_stop/main.py.err.log View File

@ -0,0 +1,4 @@
Traceback (most recent call last):
File "/home/robot/bus_stop/main.py", line 9, in <module>
import urllib3
ImportError: No module named 'urllib3'

+ 338
- 0
bus_stop/times.json View File

@ -0,0 +1,338 @@
{
"188-5": {
"saturday": [],
"weekday": [
"06:20",
"06:35",
"06:35",
"06:50",
"06:50",
"07:05",
"07:17",
"07:20",
"07:29",
"07:35",
"07:41",
"07:50",
"07:53",
"08:05",
"08:05",
"08:20",
"08:20",
"08:35",
"08:35",
"08:50",
"08:50",
"09:05",
"09:05",
"09:25",
"09:25",
"09:45",
"09:45",
"10:05",
"10:05",
"10:25",
"10:25",
"10:45",
"10:45",
"11:05",
"11:05",
"11:25",
"11:25",
"11:45",
"11:45",
"12:05",
"12:05",
"12:25",
"12:25",
"12:45",
"12:45",
"13:05",
"13:05",
"13:25",
"13:25",
"13:45",
"13:45",
"14:05",
"14:05",
"14:25",
"14:25",
"14:45",
"14:45",
"15:05",
"15:05",
"15:25",
"15:25",
"15:45",
"15:45",
"16:05",
"16:05",
"16:25",
"16:25",
"16:45",
"16:45",
"17:05",
"17:05",
"17:25",
"17:25",
"17:45",
"17:45",
"18:05",
"18:05",
"18:25",
"18:25",
"18:45",
"18:45",
"19:05",
"19:05",
"19:35",
"19:35",
"20:05",
"20:05",
"20:35",
"20:35",
"21:05",
"21:05",
"21:35",
"21:35",
"22:05",
"22:05"
]
},
"173-1": {
"saturday": [
"06:49",
"07:19",
"07:49",
"08:20",
"08:50",
"09:19",
"10:19",
"11:20",
"12:19",
"13:18",
"14:18",
"15:19",
"15:49",
"16:19",
"16:49",
"17:19",
"17:49",
"18:24",
"19:03",
"20:03",
"21:05",
"22:05"
],
"weekday": [
"06:29",
"06:49",
"07:09",
"07:29",
"07:49",
"08:10",
"08:35",
"09:14",
"09:54",
"10:34",
"11:15",
"11:55",
"12:35",
"13:14",
"13:54",
"14:34",
"14:54",
"15:14",
"15:34",
"15:54",
"16:14",
"16:34",
"16:54",
"17:15",
"17:35",
"17:55",
"18:15",
"18:35",
"19:03",
"19:33",
"20:03",
"21:05",
"22:05"
]
},
"185-3": {
"saturday": [
"05:55",
"06:04",
"06:13",
"06:22",
"06:31",
"06:39",
"06:47",
"06:55",
"06:56",
"07:03",
"07:05",
"07:11",
"07:14",
"07:19",
"07:23",
"07:27",
"07:33",
"07:36",
"07:43",
"07:53",
"08:03",
"08:13",
"08:23",
"08:33",
"08:43",
"08:53",
"09:02",
"09:11",
"09:20",
"09:29",
"09:38",
"09:47",
"09:56",
"10:05",
"10:14",
"10:23",
"10:32",
"10:41",
"10:50",
"10:59",
"11:08",
"11:17",
"11:26",
"11:35",
"11:45",
"11:55",
"12:05",
"12:15",
"12:25",
"12:35",
"12:45",
"12:55",
"13:05",
"13:15",
"13:25",
"13:35",
"13:45",
"13:55",
"14:05",
"14:15",
"14:25",
"14:35",
"14:45",
"14:55",
"15:05",
"15:15",
"15:25",
"15:35",
"15:45",
"15:55",
"16:05",
"16:15",
"16:25",
"16:35",
"16:45",
"16:55",
"17:05",
"17:15",
"17:25",
"17:35",
"17:45",
"17:55",
"18:05",
"18:15",
"18:25",
"18:35",
"18:45",
"18:55",
"19:05",
"19:15",
"19:25",
"19:35",
"19:45",
"19:55",
"20:01",
"20:06",
"20:11",
"20:17",
"20:21",
"20:28",
"20:31",
"20:39",
"20:46",
"20:51",
"21:03",
"21:15",
"21:16",
"21:29",
"21:44",
"22:03",
"22:26"
],
"weekday": [
"05:51",
"06:00",
"06:09",
"06:18",
"06:27",
"06:36",
"06:44",
"06:50",
"06:52",
"06:59",
"07:00",
"07:07",
"07:08",
"07:14",
"07:17",
"07:21",
"07:26",
"07:28",
"07:36",
"07:46",
"07:56",
"08:06",
"08:16",
"08:26",
"08:36",
"08:46",
"08:55",
"09:05",
"09:15",
"09:25",
"09:35",
"09:44",
"09:53",
"10:03",
"10:12",
"10:21",
"10:30",
"10:39",
"10:48",
"10:57",
"11:06",
"11:15",
"11:24",
"11:34",
"11:43",
"11:52",
"12:01",
"12:10",
"12:19",
"12:28",
"12:37",
"12:46",
"12:55",
"13:05",
"13:15",
"13:25",
"13:35",
"13:45",
"13:55",
"14:05"
]}}

+ 1
- 0
server_side/.gitignore View File

@ -68,4 +68,5 @@ fabric.properties
# Editor-based Rest Client
.idea/httpRequests
Ambulans/*

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

@ -1,7 +1,7 @@
from flask import Flask, send_from_directory
from flask_restful import Api
from api.modules import user_info, voting_system, rating_system, utility, denunciation, navigation
from api.modules import user_info, voting_system, rating_system, utility, denunciation, navigation, bus_stops, announcements
app = Flask(__name__)
api = Api(app)
@ -34,4 +34,8 @@ if __name__ == '__main__':
api.add_resource(navigation.Transit, '/transit', '/transit/')
api.add_resource(bus_stops.Bus, '/bus', '/bus/')
api.add_resource(announcements.Announcement, '/announcements', '/announcements/')
app.run(host='0.0.0.0', port=5000, ssl_context=context)

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


BIN
server_side/api/modules/__pycache__/bus_stops.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


+ 196
- 0
server_side/api/modules/alternateSolution1.py View File

@ -0,0 +1,196 @@
import xml.etree.ElementTree as ET
import cv2
import numpy as np
import os
import json
from pysolar.solar import *
from datetime import datetime
def timeAverage():
data_file = open("data.json","r")
time_file = open("timely.json","w")
averages = json.loads(data_file.read())
timely = {}
altitudes = {}
for key in averages:
date = key[37:-13]
time = key[49:-4].replace("_",":")
averages[key]["time"]=time
averages[key]["date"]=date
data_file.close()
data_file = open("data.json","w")
data_file.write(json.dumps(averages))
for key in averages:
time = datetime.strptime(averages[key]["date"] + " " + averages[key]["time"] + " -0300","%Y-%m-%d %H:%M:%S %z")
altitude = int(get_altitude(-25.4269081,-49.3318036,time))
altitudes[averages[key]["date"] + " " + averages[key]["time"] ] = altitude
if not (altitude in timely):
timely[altitude] = {}
for spot in averages[key]:
if(spot == "time" or spot == "date"):
continue
if not spot in timely[altitude]:
timely[altitude][spot]=[]
timely[altitude][spot].append({"r":averages[key][spot]["r"],"b":averages[key][spot]["b"],"g":averages[key][spot]["g"]})
print(altitudes)
for key in timely:
for id in timely[key]:
total = {"r":0,"g":0,"b":0}
for i in range(len(timely[key][id])):
for color in total:
total[color] += timely[key][id][i][color]
for color in total:
total[color] = total[color] / len(timely[key][id])
timely[key][id] = total
print(timely)
timely_json = json.dumps(timely)
time_file.write(timely_json)
data_file.close()
time_file.close()
def generateData(locations,image,show,averages):
loc_images = {}
average_values = {}
average_total=[0,0,0]
for col in range(len(image)):
for pix in range(len(image[col])):
if (image[col][pix] == [255,255,255]).all():
image[col][pix] == [255,255,254]
for i in locations:
temp = locations[i]
pts = np.array([[int(temp[0]['x']),int(temp[0]['y'])],
[int(temp[1]['x']),int(temp[1]['y'])],
[int(temp[2]['x']),int(temp[2]['y'])],
[int(temp[3]['x']),int(temp[3]['y'])]])
rect = cv2.boundingRect(pts)
x,y,w,h = rect
croped = image[y:y+h, x:x+w].copy()
pts = pts - pts.min(axis=0)
mask = np.zeros(croped.shape[:2], np.uint8)
cv2.drawContours(mask, [pts], -1, (255, 255, 255), -1, cv2.LINE_AA)
dst = cv2.bitwise_and(croped, croped, mask=mask)
bg = np.ones_like(croped, np.uint8)*255
cv2.bitwise_not(bg,bg, mask=mask)
dst2 = bg+ dst
split_len = len(dst2)//3
splitted = [dst2[:split_len,:],dst2[split_len:split_len*2,:],dst2[split_len*2:,:]]
loc_images[i]=[dst2]
for lot in loc_images:
average_values[lot] = []
for i in range(1):
diff_pix = 0
reps = 0
avg_rgb = [0,0,0]
rgb = ["b","g","r"]
for col in loc_images[lot][i]:
for pix in col:
if (pix == [255,255,255]).all():
continue
different = False
print("[",end="")
for j in range(3):
print(abs(int(averages[lot][rgb[i]]-pix[i])) , end=",")
if abs(averages[lot][rgb[i]]-pix[i]) > 59:
different = True
reps += 1
diff_pix += different
print("]",end=" ")
print("")
print("\n\n")
average_values[lot] = (diff_pix/reps)*100
if lot in show:
cv2.imshow("a" , loc_images[lot][0])
cv2.waitKey(0)
return average_values
def findSpot(img_loc,locations):
empty = []
timely_values = time_file = open("timely.json","r")
timely_averages = json.loads(timely_values.read())
img = cv2.imread(img_loc)
date = img_loc[37:-13]
time = img_loc[49:-4]
time = time.replace("_",":")
time = datetime.strptime(date + " " + time + " -0300","%Y-%m-%d %H:%M:%S %z")
altitude = int(get_altitude(-25.4269081,-49.3318036,time))
base_value = timely_averages[str(altitude)]
print(altitude)
averages = generateData(locations,img,[],base_value)
for i in averages:
print(i + " " + str(averages[i]))
for i in locations:
if(averages[i] > 32):
color=[0,0,255]
empty.append(i)
else:
color=[0,255,0]
corners = [[],[]]
for j in range(0,4):
val2 = j+1
if(val2 == 4):
val2 = 0
pt1 = (int(locations[i][j]["x"]),int(locations[i][j]["y"]))
pt2 = (int(locations[i][val2]["x"]),int(locations[i][val2]["y"]))
cv2.line(img,pt1,pt2,color)
corners[0].append(int(locations[i][j]["x"]))
corners[1].append(int(locations[i][j]["y"]))
x1=min(corners[0][0],corners[0][1],corners[0][2],corners[0][3]);
x2=max(corners[0][0],corners[0][1],corners[0][2],corners[0][3]);
y1=min(corners[1][0],corners[1][1],corners[1][2],corners[1][3]);
y2=max(corners[1][0],corners[1][1],corners[1][2],corners[1][3]);
pt = (int((x1+x2)/2),int((y1+y2)/2))
cv2.putText(img,str(i), pt, cv2.FONT_HERSHEY_SIMPLEX, 0.5, 255)
cv2.imshow("Parking Lot",img)
cv2.waitKey(0)
return empty
location_file = open("locations.json","r")
location_json = json.loads(location_file.read())
empty_locs = findSpot('./PKLot/PKLot/PUCPR/Sunny/2012-09-11/2012-09-11_18_08_41.jpg',location_json)
closest = 1000
for i in empty_locs:
print (location_json[i][4])
if location_json[i][4] < closest:
closest = int(i)
print("The closest spot is " + str(closest))
print("done")

+ 17
- 0
server_side/api/modules/announcements.py View File

@ -0,0 +1,17 @@
from flask import Flask, request
from flask_restful import Resource, Api
import json
app = Flask(__name__)
api = Api(app)
buses = {}
with open("modules/databases/announcements.json","r") as f:
announcements = json.loads(f.read())
class Announcement(Resource):
def get(self):
return announcements

+ 17
- 0
server_side/api/modules/bus_stops.py View File

@ -0,0 +1,17 @@
from flask import Flask, request
from flask_restful import Resource, Api, abort
app = Flask(__name__)
api = Api(app)
buses = {}
class Bus(Resource):
def get(self):
args = request.args
if not args["line"] in buses:
buses[args["line"]] = []
if not args["stop"] in buses[args["line"]]:
buses[args["line"]].append(args["stop"])
return "OK"

+ 208390
- 0
server_side/api/modules/data.json
File diff suppressed because it is too large
View File


+ 10
- 0
server_side/api/modules/databases/announcements.json View File

@ -0,0 +1,10 @@
[
{
"text1": "Yeni park",
"text2": "Çankaya 100.Yıl mahallesinde yeni park"
},
{
"text1": "Muhtarlık Seçimleri",
"text2": "Muhtarlı seçimleri 11.05.2019 tarihinde yapılacak"
}
]

+ 108
- 0
server_side/api/modules/databases/bus.json View File

@ -6,12 +6,24 @@
"location": "\u00dd\u00fe\u00e7i Bloklar\u00fd Mh.1516.Cd.\u00c7ankaya",
"name": "MUHTARLIK"
},
"10871": {
"lat": "39.910909",
"lng": "32.8145",
"location": "K\u00fdz\u00fdl\u00fdrmak Mh.Mevlana Blv.\u00c7ankaya",
"name": "UFUK \u00dcN\u00ddVERS\u00ddTES\u00dd HASTANES\u00dd"
},
"11222": {
"lat": "39.846263",
"lng": "32.828952",
"location": "Oran Mh.Z\u00fclf\u00fc Ti\u00f0rel Cd.\u00c7ankaya",
"name": "PANORA AVM"
},
"13250": {
"lat": "39.824533",
"lng": "32.775541",
"location": "Ta\u00fep\u00fdnar Mh.Mh.Ankara TED Koleji G\u00f6lba\u00fe\u00fd",
"name": "OPTOWN KONUTLARI"
},
"40064": {
"lat": "39.9835",
"lng": "32.875418",
@ -58834,6 +58846,32 @@
]
},
"10871": {
"saturday": [
{
"dakika": "10",
"detay": "",
"saat": "08",
"tur": "CUMARTES\u00dd"
},
{
"dakika": "07",
"detay": "",
"saat": "11",
"tur": "CUMARTES\u00dd"
},
{
"dakika": "51",
"detay": "",
"saat": "15",
"tur": "CUMARTES\u00dd"
},
{
"dakika": "53",
"detay": "",
"saat": "17",
"tur": "CUMARTES\u00dd"
}
],
"weekday": [
{
"dakika": "11",
@ -58916,6 +58954,34 @@
"tur": "HAFTA \u00dd\u00c7\u00dd"
}
]
},
"13250": {
"saturday": [
{
"dakika": "47",
"detay": "",
"saat": "08",
"tur": "CUMARTES\u00dd"
},
{
"dakika": "34",
"detay": "",
"saat": "11",
"tur": "CUMARTES\u00dd"
},
{
"dakika": "22",
"detay": "",
"saat": "16",
"tur": "CUMARTES\u00dd"
},
{
"dakika": "23",
"detay": "",
"saat": "18",
"tur": "CUMARTES\u00dd"
}
]
}
},
"197": {
@ -58942,6 +59008,26 @@
]
},
"10871": {
"saturday": [
{
"dakika": "37",
"detay": "",
"saat": "20",
"tur": "CUMARTES\u00dd"
},
{
"dakika": "37",
"detay": "",
"saat": "21",
"tur": "CUMARTES\u00dd"
},
{
"dakika": "36",
"detay": "",
"saat": "22",
"tur": "CUMARTES\u00dd"
}
],
"weekday": [
{
"dakika": "37",
@ -59006,6 +59092,28 @@
"tur": "HAFTA \u00dd\u00c7\u00dd"
}
]
},
"13250": {
"saturday": [
{
"dakika": "52",
"detay": "",
"saat": "20",
"tur": "CUMARTES\u00dd"
},
{
"dakika": "54",
"detay": "",
"saat": "21",
"tur": "CUMARTES\u00dd"
},
{
"dakika": "52",
"detay": "",
"saat": "22",
"tur": "CUMARTES\u00dd"
}
]
}
},
"411-3": {


+ 4
- 2
server_side/api/modules/databases/votings.json View File

@ -25,12 +25,14 @@
"name": "Park Ad\u0131 Oylamas\u0131",
"desc": "Mahallemizin yeni park\u0131n\u0131n ad\u0131",
"img": "/img/park.jpg",
"voters": [],
"voters": [
"9vard12ty0ad2yvwp3q53rsf3h43r2vq"
],
"votes": {
"1": {
"name": "Mutlu Park",
"desc": "Mutlu park, mutlu isimlerle olur.",
"votes": 3
"votes": 4
},
"2": {
"name": "Yi\u011fit \u00c7olako\u011flu Park\u0131",


+ 119
- 0
server_side/api/modules/detectSpot.py View File

@ -0,0 +1,119 @@
import cv2
import numpy as np
import json
from matplotlib import pyplot as plt
import cv2
import numpy as np
import json
import os
from matplotlib import pyplot as plt
import xml.etree.ElementTree as ET
import cv2
import numpy as np
import os
import json
from pysolar.solar import *
from datetime import datetime
def calcAvg(img,locations_xml):
locations_extracted = []
loc_images = {}
average_values = {}
for i in range( len( locations_xml ) ):
try:
locations_extracted.append([])
for j in range(4):
locations_extracted[i].append(locations_xml[i][1][j].attrib)
locations_extracted[i].append(locations_xml[i].attrib['occupied'])
locations_extracted[i].append(locations_xml[i].attrib['id'])
except Exception:
print("xml corrupt!")
return {}
for col in range(len(img)):
for pix in range(len(img[col])):
if (img[col][pix] == [255,255,255]).all():
img[col][pix] == [255,255,254]
for i in range(len(locations_extracted)):
temp = locations_extracted[i]
pts = np.array([[int(temp[0]['x']),int(temp[0]['y'])],
[int(temp[1]['x']),int(temp[1]['y'])],
[int(temp[2]['x']),int(temp[2]['y'])],
[int(temp[3]['x']),int(temp[3]['y'])]])
rect = cv2.boundingRect(pts)
x,y,w,h = rect
croped = img[y:y+h, x:x+w].copy()
pts = pts - pts.min(axis=0)
mask = np.zeros(croped.shape[:2], np.uint8)
cv2.drawContours(mask, [pts], -1, (255, 255, 255), -1, cv2.LINE_AA)
dst = cv2.bitwise_and(croped, croped, mask=mask)
bg = np.ones_like(croped, np.uint8)*255
cv2.bitwise_not(bg,bg, mask=mask)
dst2 = bg+ dst
blurred = cv2.GaussianBlur(dst2,(5,5),3)
edges = cv2.Canny(blurred,100,100)
if not temp[4] in loc_images:
loc_images[temp[4]] = {}
loc_images[temp[4]][temp[5]] = edges
for state in loc_images:
average_values[state] = {}
for lot in loc_images[state]:
reps = 0
for col in loc_images[state][lot]:
for pix in col:
if(pix == 255):
reps += 1
average_values[state][lot] = reps
print (average_values)
return average_values
def generateAvg():
dates = os.listdir('./PKLot/PKLot/PUCPR/Sunny')
imgs = []
averages={}
back_file = open("backup.json","w")
back_file.write("{")
for i in range(len(dates)):
imgs.append(os.listdir(os.path.join('./PKLot/PKLot/PUCPR/Sunny',dates[i])))
for i in range(len(imgs)):
for j in range(len(imgs[i])):
if(imgs[i][j][-4:] == ".jpg"):
try:
img_location = os.path.join('./PKLot/PKLot/PUCPR/Sunny',dates[i],imgs[i][j])
locs = ET.parse(img_location[:-4] + ".xml").getroot()
print(img_location,end=" ")
average = calcAvg(cv2.imread(img_location),locs)
if not(average == {}):
averages[img_location] = average
back_file.write("'"+img_location + "':" + str(average))
except Exception:
continue
back_file.write("}")
js = json.dumps(averages)
print(js)
fp = open('data.json', 'w')
fp.write(js)
fp.close()
generateAvg()

+ 1
- 2
server_side/api/modules/navigation.py View File

@ -159,8 +159,7 @@ class Transit(Resource):
& 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")
time_cur = datetime.datetime.today().time()
if len(one_bus) > 0:
for i in one_bus:


+ 28
- 0
server_side/api/modules/smart_parking.py View File

@ -0,0 +1,28 @@
import os
import copy
import json
from flask import Flask, request
from flask_restful import Resource, Api, abort
app = Flask(__name__)
api = Api(app)
class Empty(Resource):
def get(self):
try:
rating = copy.deepcopy(ratings[rating_id - 1])
del rating['rates']
return rating
except:
abort(404, error="Rating {} doesn't exist".format(rating_id))

+ 62568
- 0
server_side/api/modules/timely.json
File diff suppressed because it is too large
View File


Loading…
Cancel
Save