

Fix: z축 전달
@2b19a37e9c7d8e1e4e1c4f9aa0f7fe8f0d50e594
--- pothole_client/src/context/MapContext.js
+++ pothole_client/src/context/MapContext.js
... | ... | @@ -45,7 +45,7 @@ |
45 | 45 |
//id임의값 |
46 | 46 |
let id = 1; |
47 | 47 |
|
48 |
- const potholeReport = () => { |
|
48 |
+ const potholeReport = z => { |
|
49 | 49 |
fetch(`${url}/action/pothole_report`, { |
50 | 50 |
method: 'POST', |
51 | 51 |
headers: { |
... | ... | @@ -56,6 +56,7 @@ |
56 | 56 |
pothole_id: id, |
57 | 57 |
pothole_x: location.latitude, |
58 | 58 |
pothole_y: location.longitude, |
59 |
+ z: z, |
|
59 | 60 |
}), |
60 | 61 |
}) |
61 | 62 |
.then(response => response.json()) |
... | ... | @@ -76,10 +77,10 @@ |
76 | 77 |
setUpdateIntervalForType(SensorTypes.accelerometer, 1000); //임의 1초에 1번으로 변경 |
77 | 78 |
|
78 | 79 |
const subscription = accelerometer.subscribe(({z}) => { |
79 |
- if (z >= 15) { |
|
80 |
- console.log(z, ' z 축이 15g 이상입니다. Bump'); //임의 15, 원래30 테스트용 |
|
80 |
+ if (z >= 20) { |
|
81 |
+ console.log(z, ' z 축이 20g 이상입니다. Bump'); //임의 15, 원래30 테스트용 |
|
81 | 82 |
Alert.alert('알림', 'bump 발생'); |
82 |
- potholeReport(); |
|
83 |
+ potholeReport(z); |
|
83 | 84 |
} |
84 | 85 |
}); |
85 | 86 |
|
... | ... | @@ -115,14 +116,14 @@ |
115 | 116 |
if (location) { |
116 | 117 |
const speed = location.speed * 3.6; // km/hour로 계산 |
117 | 118 |
|
118 |
- console.log('Current speed:' + speed + ' km/hour'); |
|
119 |
- setIsAccelerometerActive(true); //현재 움직일 수 없으니 임의주석처리 |
|
120 |
- // if (speed >= 8) { |
|
121 |
- // console.log('8이상:' + speed + ' km/hour'); |
|
122 |
- // setIsAccelerometerActive(true); // 속도가 8 이상일 때 가속도 센서 활성화 |
|
123 |
- // } else { |
|
124 |
- // setIsAccelerometerActive(false); // 속도가 8 미만일 때 가속도 센서 비활성화 |
|
125 |
- // } |
|
119 |
+ // console.log('Current speed:' + speed + ' km/hour'); |
|
120 |
+ // setIsAccelerometerActive(true); //현재 움직일 수 없으니 임의주석처리 |
|
121 |
+ if (speed >= 8) { |
|
122 |
+ console.log('8이상:' + speed + ' km/hour'); |
|
123 |
+ setIsAccelerometerActive(true); // 속도가 8 이상일 때 가속도 센서 활성화 |
|
124 |
+ } else { |
|
125 |
+ setIsAccelerometerActive(false); // 속도가 8 미만일 때 가속도 센서 비활성화 |
|
126 |
+ } |
|
126 | 127 |
} else { |
127 | 128 |
console.log('Location is not available yet.'); |
128 | 129 |
} |
--- pothole_server/action.py
+++ pothole_server/action.py
... | ... | @@ -112,7 +112,8 @@ |
112 | 112 |
pothole_id = request.json['pothole_id'] |
113 | 113 |
pothole_x = float(request.json['pothole_x']) |
114 | 114 |
pothole_y = float(request.json['pothole_y']) |
115 |
- pc.report(report_id,pothole_id,pothole_x,pothole_y) |
|
115 |
+ z = float(request.json['z']) |
|
116 |
+ pc.report(report_id,pothole_id,pothole_x,pothole_y,z) |
|
116 | 117 |
return { |
117 | 118 |
'report': 'done' # str으로 반환하여 return |
118 | 119 |
}, 200 |
--- pothole_server/database/database.py
+++ pothole_server/database/database.py
... | ... | @@ -121,13 +121,13 @@ |
121 | 121 |
|
122 | 122 |
return (float(result[2]),float(result[3])) |
123 | 123 |
|
124 |
- def db_add_report(self,report_id,report_x,report_y) : |
|
124 |
+ def db_add_report(self,report_id,report_x,report_y,z) : |
|
125 | 125 |
cur = self.conn.cursor() # 커서를 생성한다 |
126 | 126 |
now=time.localtime() |
127 | 127 |
d=time.strftime('%Y-%m-%d %X', now) |
128 | 128 |
cur.execute(f''' |
129 |
- insert into "TRAFFICAGENCY".report (report_id,report_x,report_y,timestamp) |
|
130 |
- values ('{report_id}','{report_x}','{report_y}','{d}') |
|
129 |
+ insert into "TRAFFICAGENCY".report (report_id,report_x,report_y,timestamp,z) |
|
130 |
+ values ('{report_id}','{report_x}','{report_y}','{d}','{z}') |
|
131 | 131 |
''') |
132 | 132 |
|
133 | 133 |
def db_get_near_point(self,dest_x,dest_y): |
--- pothole_server/pothole_model/pothole.py
+++ pothole_server/pothole_model/pothole.py
... | ... | @@ -9,9 +9,9 @@ |
9 | 9 |
start_time=time.time() |
10 | 10 |
self.db=DB() |
11 | 11 |
|
12 |
- def report(self,report_id,pothole_id,pothole_x,pothole_y): |
|
12 |
+ def report(self,report_id,pothole_id,pothole_x,pothole_y,z): |
|
13 | 13 |
self.db = DB() |
14 |
- self.db.db_add_report(report_id,pothole_x,pothole_y) |
|
14 |
+ self.db.db_add_report(report_id,pothole_x,pothole_y,z) |
|
15 | 15 |
result=self.db.db_get_near_point(pothole_x,pothole_y) |
16 | 16 |
if len(result) >3 : |
17 | 17 |
value = 0 |
Add a comment
Delete comment
Once you delete this comment, you won't be able to recover it. Are you sure you want to delete this comment?