Skip to content

Commit

Permalink
Telraam rounding working
Browse files Browse the repository at this point in the history
  • Loading branch information
DarraghRogan committed Jan 14, 2021
1 parent 0502d1e commit 2e2901d
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 30 deletions.
8 changes: 4 additions & 4 deletions Miasma.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -973,7 +973,7 @@
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 23;
CURRENT_PROJECT_VERSION = 24;
DEVELOPMENT_TEAM = VDLCQ62KZH;
ENABLE_HARDENED_RUNTIME = YES;
EXCLUDED_ARCHS = "";
Expand All @@ -983,7 +983,7 @@
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 10.12;
MARKETING_VERSION = 1.15;
MARKETING_VERSION = 1.16;
PRODUCT_BUNDLE_IDENTIFIER = "Darragh-Rogan.Miasma";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 5.0;
Expand All @@ -999,7 +999,7 @@
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 23;
CURRENT_PROJECT_VERSION = 24;
DEVELOPMENT_TEAM = VDLCQ62KZH;
ENABLE_HARDENED_RUNTIME = YES;
EXCLUDED_ARCHS = "";
Expand All @@ -1009,7 +1009,7 @@
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 10.12;
MARKETING_VERSION = 1.15;
MARKETING_VERSION = 1.16;
PRODUCT_BUNDLE_IDENTIFIER = "Darragh-Rogan.Miasma";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 5.0;
Expand Down
49 changes: 24 additions & 25 deletions Miasma/DataLoaderTelraam.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,38 +24,37 @@ struct TelraamDataStructure: Codable {
// MARK: - Feature
struct Feature: Codable {
var type: String?
var geometry: Geometry?
// var geometry: Geometry?
var properties: Properties?
}

// MARK: - Geometry
struct Geometry: Codable {
var type: String?
var coordinates: [[[Double]]]?
}
//struct Geometry: Codable {
// var type: String?
// var coordinates: [[[Double]]]?
//}

// MARK: - Properties
struct Properties: Codable {
var oidn: Int? = 0
var oidn: Int?
var firstDataPackage, lastDataPackage: String?
var speed: Int?
var oneway: Bool?
var roadType, roadSpeed: String?
var pedestrian, bike, car: Double?
var lorry: Int?
var speedHistogram: [Double]?
var speedBuckets: [Int]?
// var speed: Int?
// var oneway: Bool?
// var roadType, roadSpeed: String?
var pedestrian, bike, car, lorry: Double?
// var speedHistogram: [Double]?
// var speedBuckets: [Int]?

enum CodingKeys: String, CodingKey {
case oidn
case firstDataPackage = "first_data_package"
case lastDataPackage = "last_data_package"
case speed, oneway
case roadType = "road_type"
case roadSpeed = "road_speed"
// case speed, oneway
// case roadType = "road_type"
// case roadSpeed = "road_speed"
case pedestrian, bike, car, lorry
case speedHistogram = "speed_histogram"
case speedBuckets = "speed_buckets"
// case speedHistogram = "speed_histogram"
// case speedBuckets = "speed_buckets"
}
}

Expand Down Expand Up @@ -90,13 +89,13 @@ var telraamData = TelraamDataStructure()
print(error)
} else {
let httpResponse = response as? HTTPURLResponse
print("Received from the Telraam API")
if let data = data,
let urlContent = NSString(data: data, encoding: String.Encoding.ascii.rawValue) {
print(urlContent)
} else {
print("error with printing string encoded data")
}
// print("Received from the Telraam API")
// if let data = data,
// let urlContent = NSString(data: data, encoding: String.Encoding.ascii.rawValue) {
// print(urlContent)
// } else {
// print("error with printing string encoded data")
// }
//Parse JSON
let decoder = JSONDecoder()
do {
Expand Down
4 changes: 3 additions & 1 deletion Miasma/Menu.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1490,10 +1490,12 @@ class menuFunctions: NSObject {

if telraamData.features?.count ?? 0 > 0 {

self.telraamRoadUsers.title = "📊: 🚶: \(String(format: "%U", locale: Locale.current, telraamData.features?[0].properties?.pedestrian ?? 0)), 🚲: \(String(format: "%U", locale: Locale.current, telraamData.features?[0].properties?.bike ?? 0)), 🚗: \(String(format: "%U", locale: Locale.current, telraamData.features?[0].properties?.car ?? 0)), 🚚: \(String(format: "%U", locale: Locale.current, telraamData.features?[0].properties?.lorry ?? 0))"
self.telraamRoadUsers.title = "📊: 🚶: \(String(Int(round(telraamData.features?[0].properties?.pedestrian ?? 0)))), 🚲: \(String(Int(round(telraamData.features?[0].properties?.bike ?? 0)))), 🚗: \(String(Int(round(telraamData.features?[0].properties?.car ?? 0)))), 🚚: \(String(Int(round(telraamData.features?[0].properties?.lorry ?? 0))))"

self.telraamDataTime.title = "📅: Data Recorded: \(telraamData.features?[0].properties?.lastDataPackage ?? "")"

// print(telraamData.features?[0].properties?.car)

} else {
self.telraamRoadUsers.title = "Error. Check Telraam Connectivity"
self.telraamDataTime.title = "Error. Check Telraam Connectivity"
Expand Down

0 comments on commit 2e2901d

Please sign in to comment.