Toggle navigation
Toggle navigation
This project
Loading...
Sign in
open-source
/
warply_sdk_framework
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Graphs
Network
Create a new issue
Commits
Issue Boards
Authored by
Manos Chorianopoulos
2023-11-06 15:44:27 +0200
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
5b49a6c046d1e20edc3c2d706e72cec56fb49cae
5b49a6c0
1 parent
67904179
fix initial location coords values
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
5 deletions
SwiftWarplyFramework/SwiftWarplyFramework/TelematicsMainViewController.swift
SwiftWarplyFramework/SwiftWarplyFramework/TelematicsViewController.swift
SwiftWarplyFramework/SwiftWarplyFramework/TelematicsMainViewController.swift
View file @
5b49a6c
...
...
@@ -173,6 +173,9 @@ import CoreMotion
orientationCount
=
0
touchCount
=
0
mLatitude
=
0.0
mLongitude
=
0.0
}
private
func
saveAccelerationDataToFile
()
{
...
...
SwiftWarplyFramework/SwiftWarplyFramework/TelematicsViewController.swift
View file @
5b49a6c
...
...
@@ -173,6 +173,9 @@ import CoreMotion
orientationCount
=
0
touchCount
=
0
mLatitude
=
0.0
mLongitude
=
0.0
}
private
func
saveAccelerationDataToFile
()
{
...
...
@@ -247,7 +250,7 @@ import CoreMotion
}
private
func
processAccelerometerData
(
_
accelerationData
:
CMAccelerometerData
)
{
//
print("=== accelerationData: ",accelerationData)
//
print("=== accelerationData: ",accelerationData)
// sensorDataLabel.text = "\(accelerationData.acceleration.x), \(accelerationData.acceleration.y), \(accelerationData.acceleration.z)"
...
...
@@ -273,7 +276,7 @@ import CoreMotion
// TODO: CHECK mayby this is correct
// accelerationLabel.text = String(format: "%.1f m/s^2", acceleration)
//
print("=== acceleration: ",acceleration)
//
print("=== acceleration: ",acceleration)
// If acceleration is below the stop threshold, assume we are in a stop
// if acceleration < STOP_THRESHOLD {
...
...
@@ -283,7 +286,7 @@ import CoreMotion
velocity
=
acceleration
*
time
// }
//
print("=== velocity: ",velocity)
//
print("=== velocity: ",velocity)
// Convert velocity to km/h
mAcceleration
=
velocity
// Convert to km/h
...
...
@@ -335,6 +338,7 @@ import CoreMotion
private
func
calculateSpeed
(
lat1
:
Double
,
lon1
:
Double
,
lat2
:
Double
,
lon2
:
Double
,
timeDifferenceInSeconds
:
Double
)
->
Double
{
let
distance
=
calculateDistance
(
lat1
:
lat1
,
lon1
:
lon1
,
lat2
:
lat2
,
lon2
:
lon2
)
// print("=== distance: ",distance)
return
(
distance
/
timeDifferenceInSeconds
)
*
3.6
// Convert to km/h
}
...
...
@@ -493,12 +497,14 @@ import CoreMotion
public
func
locationManager
(
_
manager
:
CLLocationManager
,
didUpdateLocations
locations
:
[
CLLocation
])
{
if
let
location
=
locations
.
last
{
//
print("=== locationManager didUpdateLocations latitude: ",location.coordinate.latitude)
//
print("=== locationManager didUpdateLocations longitude: ",location.coordinate.longitude)
//
print("=== locationManager didUpdateLocations latitude: ",location.coordinate.latitude)
//
print("=== locationManager didUpdateLocations longitude: ",location.coordinate.longitude)
if
mLatitude
!=
0
&&
mLongitude
!=
0
{
mSpeed
=
calculateSpeed
(
lat1
:
mLatitude
,
lon1
:
mLongitude
,
lat2
:
location
.
coordinate
.
latitude
,
lon2
:
location
.
coordinate
.
longitude
,
timeDifferenceInSeconds
:
LOCATION_UPDATE_INTERVAL
/
1000
)
avgVelocityLabel
.
text
=
String
(
format
:
"%.1f"
,
floor
(
mSpeed
))
+
" km/h"
// print("=== mSpeed: ",String(format: "%.1f", floor(mSpeed)) + " km/h")
}
mLatitude
=
location
.
coordinate
.
latitude
...
...
Please
register
or
login
to post a comment