Giter Club home page Giter Club logo

yours's Introduction

YOURS

Objective-C class for accessing Yet another OpenStreetMap Route Service that provides routing API based on OSM.

The result of requests is a parsed to NSDictionary GeoJSON LineString object with properties (which is wrong by the standard).

Installation

Just drag&drop the YoursAPI.h and YoursAPI.m file in your XCode Project.

Or with Cocoapods

pod 'YOURS', :git => "https://github.com/MrZoidberg/YOURS.git"

Dependencies

YOURS depends on CoreLocation and AFNetworking 2.x

ARC

YOURS is ARC only and works on iOS >= 6.0

Changelog

  • Master branch

API limitations

YOURS fair use policy prohibits more then 1 request per second for sustained periods of time. API users (IP addresses or applications) that violate this FUP will be blocked. To support this policy this library puts all requests for one for YoursAPI class in a serial queue, however you can override this behavious by setting [[YoursAPI sharedInstance] setEnforceFairUsePolicy:NO];

Usage

//Set response language and client info

[[YoursAPI sharedInstance] setResponseLanguage:@"en"];
[[YoursAPI sharedInstance] setClientInfo:@"YOUR_APP_WEBSITE"];

//Make a request. The result is parsed GeoJSON LineString with properties

[[YoursAPI sharedInstance] calcRouteFromLocation:userLocation toLocation:targetLocation success:^(NSDictionary *response) {
            
    NSDictionary *routeProps = [response objectForKey:@"properties"];
    NSString *distanceInKm = [routeProps objectForKey:@"distance"];
    NSString *traveltimeInSeconds = [routeProps objectForKey:@"traveltime"];
            
} failure:^(NSError *error){
    NSLog(@"Cannot calculate route: %@", [error localizedDescription]);
}];

Results example

{
   "type":"LineString",
   "crs":{
      "type":"name",
      "properties":{
         "name":"urn:ogc:def:crs:OGC:1.3:CRS84"
      }
   },
   "coordinates":[
      [
         36.230035,
         50.006553
      ],
      [
         36.230212,
         50.006483
      ],
      [
         36.230524,
         50.006310
      ],
      [
         36.230870,
         50.005996
      ],
      [
         36.231468,
         50.005533
      ],
      [
         36.231844,
         50.005242
      ],
      [
         36.233600,
         50.006721
      ],
      [
         36.234662,
         50.006347
      ],
      [
         36.234619,
         50.006283
      ],
      [
         36.234256,
         50.005804
      ]
   ],
   "properties":{
      "distance":"0.620647",
      "description":"To enable simple instructions add: 'instructions=1' as parameter to the URL",
      "traveltime":"108"
   }
}

yours's People

Contributors

mrzoidberg avatar

Stargazers

Kyle Howells avatar Alexey Aleshkov avatar

Watchers

 avatar

yours's Issues

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.