Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions GeoFire.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,9 @@ Pod::Spec.new do |s|
s.frameworks = 'CoreLocation', 'FirebaseDatabase'
s.requires_arc = true
s.static_framework = true

s.subspec 'Utils' do |utils|
utils.source_files = "GeoFire/Utils/**/*.{h,m}"
utils.framework = "CoreLocation"
end
end
55 changes: 55 additions & 0 deletions GeoFire/Utils/API/GeoFireUtils.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/*
* Firebase GeoFire iOS Library
*
* Copyright © 2020 Firebase - All Rights Reserved
* https://firebase.google.com
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* 2. Redistributions in binaryform must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY FIREBASE AS IS AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL FIREBASE BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

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

NS_ASSUME_NONNULL_BEGIN

/**
* Utility methods for storing locations.
*/
@interface GeoFireUtils : NSObject

/** @name Utility methods */

- (NSString *)getGeoHashForLocation:(CLLocation *)location;

- (NSString *)getGeoHashForLocation:(CLLocation *)location
withPrecision:(int)precision;

// TODO: We probably don't need this one because CLLocation has it built in
- (double)getDistanceBetween:(CLLocation *)locationA
andLocation:(CLLocation *)locationB;

- (NSArray<GFGeoHashQuery *>)getQueryBounds:(CLLocation *)location
forRadius:(double)radius;

@end

NS_ASSUME_NONNULL_END
38 changes: 38 additions & 0 deletions GeoFire/Utils/Implementation/GeoFireUtils.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
//
// GeoFireUtils.m
// GeoFire
//
// Copyright (c) 2020 Firebase. All rights reserved.
//

#import "GeoFireUtils.h"

@implementation GeoFireUtils

+ (NSString *)getGeoHashForLocation:(CLLocation *)location
{
// TODO: What about precision?
return NSString *geoHash = [GFGeoHash newWithLocation:location.coordinate].geoHashValue;;
}

+ (NSString *)getGeoHashForLocation:(CLLocation *)location
withPrecision:(int)precision
{
// TODO: Implement
return "";
}

// TODO: Probably delete this method
+ (double)getDistanceBetween:(CLLocation *)locationA
andLocation:(CLLocation *)locationB
{
return [locationA distanceFromLocation:locationB];
}

- (NSArray<GFGeoHashQuery *>)getQueryBounds:(CLLocation *)location
forRadius:(double)radius {
// TODO: Implement
return nil;
}

@end