GithubHelp home page GithubHelp logo

plummer / realmgeoqueries Goto Github PK

View Code? Open in Web Editor NEW

This project forked from mhergon/realmgeoqueries

0.0 1.0 0.0 2.12 MB

Realm GeoQueries made easy

License: Apache License 2.0

Ruby 3.74% Swift 96.26%

realmgeoqueries's Introduction

RealmGeoQueries

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"

Manually installation

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

Requirements

Version Language Minimum iOS Target
1.2 Swift 3.0 iOS 9
1.1 Swift 2.x iOS 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; ```swift 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 2015 Marc Hervera.

realmgeoqueries's People

Contributors

mhergon avatar

Watchers

Andrew Plummer avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.