-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
indoors #370
base: master
Are you sure you want to change the base?
indoors #370
Changes from all commits
4f65b30
de0bae9
769580a
3e9ffc7
771f6a7
530f82f
d8983ef
f315495
bcba999
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -288,6 +288,9 @@ typedef void (^_Nonnull RadarRouteMatrixCompletionHandler)(RadarStatus status, R | |||||
*/ | ||||||
typedef void (^_Nonnull RadarLogConversionCompletionHandler)(RadarStatus status, RadarEvent *_Nullable event); | ||||||
|
||||||
// define RadarIndoorsSurveyCompletionHandler -- which is called with no arguments | ||||||
typedef void (^_Nonnull RadarIndoorsSurveyCompletionHandler)(NSString *_Nullable result); | ||||||
|
||||||
/** | ||||||
The main class used to interact with the Radar SDK. | ||||||
|
||||||
|
@@ -1086,6 +1089,12 @@ logConversionWithNotification | |||||
units:(RadarRouteUnits)units | ||||||
completionHandler:(RadarRouteMatrixCompletionHandler)completionHandler NS_SWIFT_NAME(getMatrix(origins:destinations:mode:units:completionHandler:)); | ||||||
|
||||||
#pragma mark - Indoors | ||||||
|
||||||
+ (void)doIndoorSurvey:(NSString *)placeLabel | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
or something of the like is more in-line with our naming conventions. |
||||||
forLength:(int)surveyLengthSeconds | ||||||
completionHandler:(RadarIndoorsSurveyCompletionHandler)completionHandler; | ||||||
|
||||||
#pragma mark - Logging | ||||||
|
||||||
/** | ||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -71,7 +71,9 @@ typedef NS_ENUM(NSInteger, RadarEventType) { | |
/// 'user.arrived_at_wrong_trip_destination` | ||
RadarEventTypeUserArrivedAtWrongTripDestination NS_SWIFT_NAME(userArrivedAtWrongTripDestination), | ||
/// `user.failed_fraud` | ||
RadarEventTypeUserFailedFraud NS_SWIFT_NAME(userFailedFraud) | ||
RadarEventTypeUserFailedFraud NS_SWIFT_NAME(userFailedFraud), | ||
/// `user.indoor_location` | ||
RadarEventTypeIndoorLocation NS_SWIFT_NAME(indoorLocation) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we want a new event type here? I think instead we're likely to prefer something like an optional |
||
}; | ||
|
||
/** | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -154,6 +154,8 @@ typedef NS_ENUM(NSInteger, RadarTrackingOptionsSyncLocations) { | |
*/ | ||
@property (nonatomic, assign) BOOL beacons; | ||
|
||
@property (nonatomic, assign) BOOL indoors; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Bigger philosophical naming question: we might want to use the techniques here in contexts that aren't actually indoors (e.g. open air malls, around the covered perimeter of buildings, etc) — would we potentially want to name this something like |
||
|
||
/** | ||
Updates about every 30 seconds while moving or stopped. Moderate battery usage. Shows the flashing blue status bar during tracking. | ||
@see https://developer.apple.com/documentation/corelocation/cllocationmanager/2923541-showsbackgroundlocationindicator | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// | ||
// GZIP.h | ||
// | ||
// Version 1.3.2 | ||
// | ||
// Created by Nick Lockwood on 03/06/2012. | ||
// Copyright (C) 2012 Charcoal Design | ||
// | ||
// Distributed under the permissive MIT license | ||
// Get the latest version from here: | ||
// | ||
// https://github.com/nicklockwood/GZIP | ||
// | ||
// Permission is hereby granted, free of charge, to any person obtaining a copy | ||
// of this software and associated documentation files (the "Software"), to deal | ||
// in the Software without restriction, including without limitation the rights | ||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
// copies of the Software, and to permit persons to whom the Software is | ||
// furnished to do so, subject to the following conditions: | ||
// | ||
// The above copyright notice and this permission notice shall be included in all | ||
// copies or substantial portions of the Software. | ||
// | ||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
// SOFTWARE. | ||
// | ||
|
||
#import <Foundation/Foundation.h> | ||
|
||
|
||
@interface NSData (GZIP) | ||
|
||
- (nullable NSData *)gzippedDataWithCompressionLevel:(float)level; | ||
- (nullable NSData *)gzippedData; | ||
- (nullable NSData *)gunzippedData; | ||
- (BOOL)isGzippedData; | ||
|
||
@end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,135 @@ | ||
// | ||
// GZIP.m | ||
// | ||
// Version 1.3.2 | ||
// | ||
// Created by Nick Lockwood on 03/06/2012. | ||
// Copyright (C) 2012 Charcoal Design | ||
// | ||
// Distributed under the permissive MIT license | ||
// Get the latest version from here: | ||
// | ||
// https://github.com/nicklockwood/GZIP | ||
// | ||
// Permission is hereby granted, free of charge, to any person obtaining a copy | ||
// of this software and associated documentation files (the "Software"), to deal | ||
// in the Software without restriction, including without limitation the rights | ||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
// copies of the Software, and to permit persons to whom the Software is | ||
// furnished to do so, subject to the following conditions: | ||
// | ||
// The above copyright notice and this permission notice shall be included in all | ||
// copies or substantial portions of the Software. | ||
// | ||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
// SOFTWARE. | ||
// | ||
|
||
#import "NSData+GZIP.h" | ||
#import <zlib.h> | ||
|
||
|
||
#pragma clang diagnostic ignored "-Wcast-qual" | ||
|
||
|
||
@implementation NSData (GZIP) | ||
|
||
- (NSData *)gzippedDataWithCompressionLevel:(float)level | ||
{ | ||
if (self.length == 0 || [self isGzippedData]) | ||
{ | ||
return self; | ||
} | ||
|
||
z_stream stream; | ||
stream.zalloc = Z_NULL; | ||
stream.zfree = Z_NULL; | ||
stream.opaque = Z_NULL; | ||
stream.avail_in = (uint)self.length; | ||
stream.next_in = (Bytef *)(void *)self.bytes; | ||
stream.total_out = 0; | ||
stream.avail_out = 0; | ||
|
||
static const NSUInteger ChunkSize = 16384; | ||
|
||
NSMutableData *output = nil; | ||
int compression = (level < 0.0f)? Z_DEFAULT_COMPRESSION: (int)(roundf(level * 9)); | ||
if (deflateInit2(&stream, compression, Z_DEFLATED, 31, 8, Z_DEFAULT_STRATEGY) == Z_OK) | ||
{ | ||
output = [NSMutableData dataWithLength:ChunkSize]; | ||
while (stream.avail_out == 0) | ||
{ | ||
if (stream.total_out >= output.length) | ||
{ | ||
output.length += ChunkSize; | ||
} | ||
stream.next_out = (uint8_t *)output.mutableBytes + stream.total_out; | ||
stream.avail_out = (uInt)(output.length - stream.total_out); | ||
deflate(&stream, Z_FINISH); | ||
} | ||
deflateEnd(&stream); | ||
output.length = stream.total_out; | ||
} | ||
|
||
return output; | ||
} | ||
|
||
- (NSData *)gzippedData | ||
{ | ||
return [self gzippedDataWithCompressionLevel:-1.0f]; | ||
} | ||
|
||
- (NSData *)gunzippedData | ||
{ | ||
if (self.length == 0 || ![self isGzippedData]) | ||
{ | ||
return self; | ||
} | ||
|
||
z_stream stream; | ||
stream.zalloc = Z_NULL; | ||
stream.zfree = Z_NULL; | ||
stream.avail_in = (uint)self.length; | ||
stream.next_in = (Bytef *)self.bytes; | ||
stream.total_out = 0; | ||
stream.avail_out = 0; | ||
|
||
NSMutableData *output = nil; | ||
if (inflateInit2(&stream, 47) == Z_OK) | ||
{ | ||
int status = Z_OK; | ||
output = [NSMutableData dataWithCapacity:self.length * 2]; | ||
while (status == Z_OK) | ||
{ | ||
if (stream.total_out >= output.length) | ||
{ | ||
output.length += self.length / 2; | ||
} | ||
stream.next_out = (uint8_t *)output.mutableBytes + stream.total_out; | ||
stream.avail_out = (uInt)(output.length - stream.total_out); | ||
status = inflate (&stream, Z_SYNC_FLUSH); | ||
} | ||
if (inflateEnd(&stream) == Z_OK) | ||
{ | ||
if (status == Z_STREAM_END) | ||
{ | ||
output.length = stream.total_out; | ||
} | ||
} | ||
} | ||
|
||
return output; | ||
} | ||
|
||
- (BOOL)isGzippedData | ||
{ | ||
const UInt8 *bytes = (const UInt8 *)self.bytes; | ||
return (self.length >= 2 && bytes[0] == 0x1f && bytes[1] == 0x8b); | ||
} | ||
|
||
@end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
note: @KennyHuRadar's
Info.plist
will obviate the need for this