Latest1.3.1
Homepagehttps://github.com/mhergon/RealmGeoQueries
LicenseApache License, Version 2.0
Platformsios 9.0, requires ARC
DependenciesRealmSwift
Authors

RealmGeoQueries

cocoapods
carthage
issues
stars
license

RealmGeoQueries simplifies spatial queries with Realm Cocoa. In the absence of and official functions, this library provide the possibility to do proximity search.
It’s not necessary to include Geohash or other types of indexes in the model class as it only needs latitude and longitude properties.

How To Get Started

Installation with CocoaPods

platform :ios, '9.0'
pod "RealmGeoQueries"

Installation with Carthage

Add to mhergon/RealmGeoQueries project to your Cartfile

github "mhergon/RealmGeoQueries"

Drag GeoQueries.framework, RealmSwift.framework and Realm.framework from Carthage/Build/ to the “Linked Frameworks and Libraries” section of your Xcode project’s “General” settings.

Only on iOS/tvOS/watchOS: On your application targets "Build Phases" settings tab, click the "+" icon and choose "New Run Script Phase". Create a Run Script with the following contents:

/usr/local/bin/carthage copy-frameworks

and add the paths to the frameworks you want to use under "Input Files", e.g.:

$(SRCROOT)/Carthage/Build/iOS/GeoQueries.framework
$(SRCROOT)/Carthage/Build/iOS/Realm.framework
$(SRCROOT)/Carthage/Build/iOS/RealmSwift.framework

Manually installation

Download (right-click) and add to your project.

Requirements

VersionLanguageMinimum iOS Target
1.3Swift 4.x / Realm 3.xiOS 9
1.2Swift 3.0 / Realm 2.xiOS 9
1.1Swift 2.x / Realm 2.xiOS 8

Usage

First, import module;

import GeoQueries

Model must have a latitude and longitude keys, that have to be named "lat" and "lng" respectively. You can use another property names (use "latitudeKey" and "longitudeKey" parameters).

Search with MapView MKCoordinateRegion;

let results = try! Realm()
    .findInRegion(type: YourModelClass.self, region: mapView.region)

Search around the center with radius in meters;

let results = try! Realm()
    .findNearby(YourModeltype: Class.self, origin: mapView.centerCoordinate, radius: 500, sortAscending: nil)

Filter Realm results with radius in meters;

let results = try! Realm()
    .objects(YourModelClass.self)
    .filter("type", "restaurant")
    .filterGeoRadius(center: mapView.centerCoordinate, radius: 500, sortAscending: nil)

See GeoQueries.swift for more options.

Contact

License

Licensed under Apache License v2.0.

Copyright 2017 Marc Hervera.

Latest podspec

{
    "name": "RealmGeoQueries",
    "platforms": {
        "ios": "9.0"
    },
    "version": "1.3.1",
    "license": {
        "type": "Apache License, Version 2.0"
    },
    "homepage": "https://github.com/mhergon/RealmGeoQueries",
    "authors": {
        "Marc Hervera": "[email protected]"
    },
    "summary": "Realm GeoQueries made easy",
    "source": {
        "git": "https://github.com/mhergon/RealmGeoQueries.git",
        "tag": "v1.3.1"
    },
    "source_files": "GeoQueries.swift",
    "ios": {
        "frameworks": [
            "CoreLocation",
            "MapKit"
        ]
    },
    "dependencies": {
        "RealmSwift": []
    },
    "requires_arc": true,
    "module_name": "GeoQueries",
    "pushed_with_swift_version": "4.0"
}

Pin It on Pinterest

Share This