Skip to content

Commit

Permalink
Beta location based on core 3.1
Browse files Browse the repository at this point in the history
  • Loading branch information
ryang-phunware committed Jun 27, 2017
1 parent 9ee447e commit 0b860b1
Show file tree
Hide file tree
Showing 25 changed files with 1,138 additions and 2 deletions.
1 change: 1 addition & 0 deletions Framework/PWLocation.framework/Headers
6 changes: 6 additions & 0 deletions Framework/PWLocation.framework/Modules/module.modulemap
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
framework module PWLocation {
umbrella header "PWLocation.h"

export *
module * { export * }
}
1 change: 1 addition & 0 deletions Framework/PWLocation.framework/PWLocation
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
//
// PWBeaconLocationManager.h
// PWLocation
//
// Copyright (c) 2015 Phunware Inc. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <PWLocation/PWIndoorLocation.h>
#import <PWLocation/PWLocationManager.h>

typedef NS_ENUM(NSUInteger, PWBLMError) {
PWBLMErrorRangingUnavailable,
PWBLMErrorRangingFailure,
PWBLMErrorDenied
};

extern NSUInteger const PWBeaconLocationManagerMaximumRegionsToMonitorLimit;
extern NSUInteger const PWBeaconLocationManagerDefaultMaximumRegionsToMonitor;

@protocol PWBeaconProximityManagerDelegate;

/**
The `PWBeaconProximityManager` class defines the interface for configuring the delivery of beacon proximity-related events to your application. You use an instance of this class to establish the parameters that determine when beacon proximity events should be delivered and to start and stop the actual delivery of those events.
The beacon proximity provider receives location data from multiple beacons and selected the closest beacon over a given time period to promote as the current location. While beacon proximity will update fairly frequently (1-2 times/second) the accuracy is suspect and should not be relied on for fine-grained location updates.
*/
@interface PWBeaconProximityManager : NSObject <PWLocationManager>

/**
The `CLLocationManager` used to deliver beacon location updates.
@discussion You are responsible for requesting permission to use location services. The `CLLocationManagerDelegate` of this instance is owned by the `PWGPSLocationManager` instance. Modifying this location manager directly may have adverse affects on beacon location updates.
*/
@property (nonatomic, readonly) CLLocationManager *internalLocationManager;
@property (nonatomic, readonly) NSArray *beaconRegions;

@property (nonatomic, readwrite) NSUInteger maximumBeaconRegionsToMonitor;

/**
The floor ID mapping dictionary used to define the mapping between the location provider floor ID and the Phunware floor ID. The dictionary format must adhere to the following format: `@{CUSTOMER_FLOORID : PHUNWARE_FLOOR_ID}`.
*/
@property (nonatomic, strong) NSDictionary *floorIDMapping;

/**
The most recently retrieved indoor location.
@discussion The value of this property is nil if no location data has ever been retrieved.
*/
@property (nonatomic, readonly) PWIndoorLocation *location;

- (instancetype)initWithCLLocationManager:(CLLocationManager *)locationManager beaconRegions:(NSArray * /* PWBeaconProximityRegion */)beaconRegions NS_DESIGNATED_INITIALIZER;
- (instancetype)init NS_UNAVAILABLE;

///-------------------------------------------
/// @name Determining Availability of Services
///-------------------------------------------

/**
Returns a Boolean value indicating whether location services are enabled on the device.
@discussion In order to fetch the user's location, the manager must be within proximity of the venue and have retrieved specific device information from Phunware's servers.
*/
- (BOOL)locationServicesAvailable;

///----------------------------------
/// @name Initiating Location Updates
///----------------------------------

/**
Starts the generation of updates that report the user’s current location.
@discussion This method returns immediately. Calling this method causes the location manager to obtain an initial location fix (which may take several seconds) and notify your delegate by calling its `locationManager:didUpdateToLocation:` method.
*/
- (void)startUpdatingLocation;

/**
Stops the generation of location updates.
@discussion Call this method whenever your code no longer needs to receive location-related events. Disabling event delivery gives the receiver the option of disabling the appropriate hardware (and thereby saving power) when no clients need location data. You can always restart the generation of location updates by calling the `startUpdatingLocation` method again.
*/
- (void)stopUpdatingLocation;

@end


@protocol PWBeaconProximityManagerDelegate <PWLocationManagerDelegate>

- (void)locationManager:(PWBeaconProximityManager *)manager didUpdateToLocation:(PWIndoorLocation *)location;
- (void)locationManager:(PWBeaconProximityManager *)manager failedWithError:(NSError *)error;

@end
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
//
// PWBeaconRegion.h
// PWLocation
//
// Created by Illya Busigin on 5/28/15.
// Copyright (c) 2015 Phunware Inc. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <CoreLocation/CoreLocation.h>

@interface PWBeaconProximityRegion : NSObject <NSSecureCoding, NSCopying>

@property (nonatomic, readonly) CLBeaconRegion *region;
@property (nonatomic, readonly) CLLocationCoordinate2D coordinate;
@property (nonatomic, readonly) NSUInteger floorIdentifier;

- (instancetype)initWithBeaconRegion:(CLBeaconRegion *)region coordinate:(CLLocationCoordinate2D)coordinate floorIdentifier:(NSUInteger)floorIdentifier NS_DESIGNATED_INITIALIZER;

@end
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
//
// PWFusedLocationManager.h
// PWLocation
//
// Copyright (c) 2014 Phunware Inc. All rights reserved.
//

#import <MapKit/MapKit.h>

#import <PWLocation/PWIndoorLocation.h>
#import <PWLocation/PWLocationManager.h>

@class PWFusedLocationManagerZone;
@class PWFusedLocationManagerZoneConfiguration;

extern NSString *const PWFusedLocationManagerDidChangeNotification;

/**
The `PWFusedLocationManager` class defines the interface for configuring the delivery of fused location-related events to your application. The fused provider accepts an indoor location manager that conforms to the `PWLocationManager` protocol. Internally, it manages a `CLLocationManager` which it will fall back on if no indoor location updates are available. This class conforms to the `PWLocationManager` protocol.
*/
@interface PWFusedLocationManager : NSObject <PWLocationManager>

/**
An array of `PWFusedLocationManagerZoneConfiguration` objects associated with the fused location manager.
*/
@property (nonatomic, readonly) NSArray *zoneConfigurations;

/**
The floorIDMapping normally provides a mapping from between indoor floor identifiers and Phunware floor identifiers. This mapping is not used in the `PWFusedLocationManager` implementation. You should ensure this property is populated on the `PWLocationManager` that is passed in during initialization.
*/
@property (nonatomic, strong) NSDictionary *floorIDMapping;

/**
The latest location received by the fused provider.
@discussion If the latest location received is a GPS-based location the floorID property will always be `kPWUnknownFloorID`.
*/
@property (nonatomic, readonly) PWIndoorLocation *location;

/**
Initializes the fused location manager with the specified `PWLocationManager`.
@param locationManager - Obtained from Phunware.
*/
- (instancetype)initWithDefaultLocationManager:(id<PWLocationManager>)locationManager;

/**
Adds a configuration object that will define a new location manager and the set of zones where that location manager should be used.
@param zoneConfiguration The zone configuration for a new location manager
*/
- (void)addLocationManagerZoneConfiguration:(PWFusedLocationManagerZoneConfiguration *)zoneConfiguration;

/**
Returns a Boolean value indicating whether location services are enabled on the device.
@discussion In order for this value to return `YES` both the internal `CLLocationManager` and the `PWLocationManager` object must return `YES`.
*/
- (BOOL)locationServicesAvailable;

/**
Starts the generation of updates that report the user’s current location.
@discussion This method will fail if GPS and indoor location services are not available.
*/
- (void)startUpdatingLocation;

/**
Stops updating user’s current location.
@discussion All the internal location managers are stopped after this method is involked.
*/
- (void)stopUpdatingLocation;

/**
Check if the specified coordinate is inside of polygon area.
@param coordinate The coordinate to be tested.
@param polygon The polygon to test the coordinate against.
@return YES if it is, or else NO.
*/
- (BOOL)coordinate:(CLLocationCoordinate2D)coordinate isInsidePolygon:(MKPolygon*)polygon;

@end


Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
//
// PWFusedLocationManagerZone.h
// PWLocation
//
// Copyright (c) 2015 Phunware Inc. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <MapKit/MapKit.h>

/**
The 'PWFusedLocationManagerZone' class defines a zone where a particular location manager should be used. The zone will be considered valid for use only if the location given by the location manager has a coordinate inside the polygon region and if the floorID of the location is contained in the floorIDs array.
*/
@interface PWFusedLocationManagerZone : NSObject

/** The polygon that encompasses the zone where the location manager should be used */
@property (readonly) MKPolygon *polygon;
/** The identifiers of the floors where the polygon for this zone is be valid */
@property (readonly) NSArray /* NSNumber */ *floorIdentifiers;

/**
Initializes a zone where a location manager should be used.
@param polygon A polygon that encompasses the zone where the location manager should be used
@param floorIdentifiers An array of integers that indicate the floors where the polygon for this zone is be valid
@return An initialized zone object.
*/
- (instancetype)initWithPolygon:(MKPolygon *)polygon floorIdentifiers:(NSArray /* NSNumber */ *)floorIdentifiers NS_DESIGNATED_INITIALIZER;

@end
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
//
// PWFusedLocationManagerZoneConfiguration.h
// PWLocation
//
// Copyright (c) 2015 Phunware Inc. All rights reserved.
//

#import <Foundation/Foundation.h>
@protocol PWLocationManager;

/**
The 'PWFusedLocationManagerZoneConfiguration' class relates a location manager to the zones where the location manager should be used.
*/
@interface PWFusedLocationManagerZoneConfiguration : NSObject

/** The location manager object */
@property (readonly) id<PWLocationManager> locationManager;
/** An array of zones where the location manager should be used */
@property (readonly) NSArray /* PWFusedLocationManagerZone */ *zones;

/**
Initializes a 'PWFusedLocationManagerZoneConfiguration' object with a location manager along with the zones where the location manager will be valid
@param locationManager A location manager object
@param zones The zones where the location manager will be valid
@return An initialized 'PWFusedLocationManagerZoneConfiguration' object.
*/
- (instancetype)initWithLocationManager:(id<PWLocationManager>)locationManager zones:(NSArray /* PWFusedLocationManagerZone */ *)zones NS_DESIGNATED_INITIALIZER;

@end
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
//
// PWGPSLocationManager.h
// PWLocation
//
// Created by Illya Busigin on 1/7/15.
// Copyright (c) 2015 Phunware Inc. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <CoreLocation/CoreLocation.h>

#import <PWLocation/PWIndoorLocation.h>
#import <PWLocation/PWLocationManager.h>

@protocol PWGPSLocationManagerDelegate;

/**
The `PWGPSLocationManager` class defines the interface for configuring the delivery of GPS location-related events to your application. You use an instance of this class to establish the parameters that determine when location events should be delivered and to start and stop the actual delivery of those events. This class conforms to the `PWLocationManager` protocol.
@discussion You are still responsible for requesting permission to use location services. In addition the `CLLocationManager` associated with this class is exposed so that it can be configured as desired.
*/

@interface PWGPSLocationManager : NSObject <PWLocationManager>

/**
The `CLLocationManager` used to deliver indoor GPS location updates.
@discussion You are still responsible for requesting permission to use location services. The `CLLocationManagerDelegate` of this instance is owned by the `PWGPSLocationManager` instance.
*/
@property (nonatomic, readonly) CLLocationManager *internalLocationManager;

/**
The floor ID mapping dictionary used to define the mapping between the location provider floor ID and the Phunware floor ID. The dictionary format must adhere to the following format: `@{CUSTOMER_FLOORID : PHUNWARE_FLOOR_ID}`.
*/
@property (nonatomic, strong) NSDictionary *floorIDMapping;

/**
The latest indoor location received from the Phunware location service.
*/
@property (nonatomic, readonly) PWIndoorLocation *location;

/**
Initializes the location manager with the specified `CLLocationManager` instance.
@param locationManager The location manager to use for GPS positioning. There parameter cannot be `nil`.
@return A `PWGPSLocationManager` instance.
*/
- (instancetype)initWithCLLocationManager:(CLLocationManager *)locationManager NS_DESIGNATED_INITIALIZER;

- (BOOL)locationServicesAvailable;
- (void)startUpdatingLocation;
- (void)stopUpdatingLocation;

@end

/**
The `PWMSELocationManagerDelegate` protocol defines the methods used to receive location updates from a `PWMSELocationManager` object. This class conforms to the `PWLocationManagerDelegate` protocol.
The methods of your delegate object are called from the main application thread.
*/

@protocol PWGPSLocationManagerDelegate <PWLocationManagerDelegate>

/**
Tells the delegate that a new location update is available.
@param manager The location manager object that generated the update event.
@param location A location object with the updated location information. This object conforms to the `PWLocation` protocol.
@discussion Implementation of this method is optional but recommended.
*/
- (void)locationManager:(PWGPSLocationManager *)manager didUpdateToLocation:(id<PWLocation>)location;

/**
Tells the delegate that the location manager was unable to retrieve a location value.
@param manager The location manager object that was unable to retrieve the location.
@param error The error object containing the reason the location could not be retrieved.
@discussion Implementation of this method is optional but recommended.
The location manager calls this method when it encounters an error trying to get the location data. If an error is encountered, the location manager will keep attempting to update until `stopUpdatingLocation` is called.
*/
- (void)locationManager:(PWGPSLocationManager *)manager failedWithError:(NSError *)error;

@end
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
//
// PWMSELocation.h
// PWLocation
//
// Copyright (c) 2014 Phunware. All rights reserved.
//

#import <CoreLocation/CoreLocation.h>
#import <PWLocation/PWLocationProtocol.h>

@protocol PWLocation;

/**
A `PWIndoorLocation` object represents the location data generated by a `PWLocationManager` object. This object incorporates the geographical coordinates of the device’s location along with the floor ID, if available. This object conforms to the `PWLocation` protocol.
Typically, an object that adheres to the `PWLocationManager` protocol is used to create instances of this class based on the last known location of the user’s device. You can create instances yourself, however, if you want to cache custom location data or get the distance between two points.
This class is designed to be used as-is and should not be subclassed.
*/

@interface PWIndoorLocation : NSObject <PWLocation>

/**
Initializes and returns a location object with the specified latitude and longitude.
@param latitude The latitude of the coordinate point.
@param longitude The longitude of the coordinate point.
@param timestamp The time at which the location was reported.
@return A location object initialized with the specified coordinate point and timestamp.
@discussion When using this method, the other properties of the object are initialized to appropriate values. In particular, the horizontalAccuracy property is set to -1, the floorID is set to `kPWUnknownFloorID` and the type is set to `PWLocationTypeUnknown`.
*/
- (instancetype)initWithLatitude:(CLLocationDegrees)latitude longitude:(CLLocationDegrees)longitude timestamp:(NSDate*)timestamp;

/**
Initializes and returns a location object with the specified coordinate information.
@param coordinate A coordinate structure containing the latitude and longitude values.
@param floorID The floor ID associated with the location object. If the floor ID is unknown or unspecified, initialize with `kPWUnknownFloorID`.
@param timestamp The time at which the location was reported.
@return A location object initialized with the specified information.
*/
- (instancetype)initWithCoordinate:(CLLocationCoordinate2D)coordinate floorID:(NSUInteger)floorID timestamp:(NSDate*)timestamp;

/**
Initializes and returns a location object with the specified coordinate information.
@param coordinate A coordinate structure containing the latitude and longitude values.
@param floorID The floor ID associated with the location object. If the floor ID is unknown or unspecified, initialize with `kPWUnknownFloorID`.
@param hAccuracy The accuracy of the coordinate value. Specifying a negative number indicates that the horizontal accuracy value is invalid.
@param timestamp The time at which the location was reported.
@return A location object initialized with the specified information.
*/
- (instancetype)initWithCoordinate:(CLLocationCoordinate2D)coordinate floorID:(NSUInteger)floorID horizontalAccuracy:(CLLocationAccuracy)hAccuracy timestamp:(NSDate*)timestamp;

@end
Loading

0 comments on commit 0b860b1

Please sign in to comment.