All Projects → socrata → soda-swift

socrata / soda-swift

Licence: Apache-2.0 license
SODA SDK for Apple's Swift programming language

Programming Languages

swift
15916 projects
ruby
36898 projects - #4 most used programming language
objective c
16641 projects - #2 most used programming language

Projects that are alternatives of or similar to soda-swift

dsfp
Dark Souls save file parser
Stars: ✭ 30 (-28.57%)
Mutual labels:  engineering
pendfetch
Double Pendulum visualised with fetching system information in Python.
Stars: ✭ 62 (+47.62%)
Mutual labels:  engineering
CutAndDisplace
Boundary Element MATLAB code. Modelling faults and deformation
Stars: ✭ 40 (-4.76%)
Mutual labels:  engineering
mathinmse.github.io
Applied Matematical Methods in Materials Engineering
Stars: ✭ 24 (-42.86%)
Mutual labels:  engineering
pymae
Materials for the book "Python for Mechanical and Aerospace Engineering"
Stars: ✭ 56 (+33.33%)
Mutual labels:  engineering
range3
Range Software - Finite Element Analysis
Stars: ✭ 31 (-26.19%)
Mutual labels:  engineering
vibration toolbox
Educational Vibration programs. Intended for undergraduate and early graduate students.
Stars: ✭ 89 (+111.9%)
Mutual labels:  engineering
kiva
Ground heat transfer calculation tool
Stars: ✭ 23 (-45.24%)
Mutual labels:  engineering
Marconi.jl
A Julia Library for DC to Daylight
Stars: ✭ 15 (-64.29%)
Mutual labels:  engineering
soda-java
This is the Java API for the SODA 2.0 API
Stars: ✭ 65 (+54.76%)
Mutual labels:  engineering
trifolia
Trifolia template/profile editor and publication tool
Stars: ✭ 24 (-42.86%)
Mutual labels:  engineering
OutSystemsNow-Android
Create mobile applications and enhance them with native capabilities using the OutSystems native components.
Stars: ✭ 20 (-52.38%)
Mutual labels:  engineering
trifolia-on-fhir
Sister product to Trifolia Workbench that has native support for FHIR resources
Stars: ✭ 23 (-45.24%)
Mutual labels:  engineering
engineering-leader
Beginning knowledge for leading and managing engineers
Stars: ✭ 22 (-47.62%)
Mutual labels:  engineering
welleng
A collection of Wells/Drilling Engineering tools, focused on well trajectory planning for the time being.
Stars: ✭ 79 (+88.1%)
Mutual labels:  engineering
bichon
Robust Coarse Curved TetMesh Generation
Stars: ✭ 29 (-30.95%)
Mutual labels:  engineering
sim8085
Online 8085 simulator
Stars: ✭ 83 (+97.62%)
Mutual labels:  engineering
career-ladders
A sample of career ladders I use for my organization, open sourced for anyone.
Stars: ✭ 676 (+1509.52%)
Mutual labels:  engineering
CodeWars
Daily Coding Exercises to sharpen problem solving skills
Stars: ✭ 67 (+59.52%)
Mutual labels:  engineering
Harris-Hawks-Optimization-Algorithm-and-Applications
Source codes for HHO paper: Harris hawks optimization: Algorithm and applications: https://www.sciencedirect.com/science/article/pii/S0167739X18313530. In this paper, a novel population-based, nature-inspired optimization paradigm is proposed, which is called Harris Hawks Optimizer (HHO).
Stars: ✭ 31 (-26.19%)
Mutual labels:  engineering

soda-swift

soda-swift is a native Swift library to access Socrata OpenData servers. It is compatible with iOS 8 and OS X 10.10.

Getting Started

1. Get an access token for your app

2. Reference SODAKit/SODAClient.swift in Xcode

3. Initialize a SODAClient

let client = SODAClient(domain: "(Domain name of the server)", token: "(Your app's access token)")

For example,

let client = SODAClient(domain: "data.cityofchicago.org", token: "Uo25eXiX14zEd2K6EKAkeMIDW")

(that token won't work)

4. Query for data

Here is a simple filter query to find compressed natural gas stations in Chicago:

let fuelLocations = client.queryDataset("alternative-fuel-locations")

fuelLocations.filterColumn ("fuel_type_code", "CNG").get { res in
    switch res {
    case .Dataset (let data):

        // Display the data

    case .Error (let error):

    	// Show the error

    }
}

Note the use of filterColumn to get only compressed natural gas stations.

Also note that the final get function is asynchronous and that the last argument is a completion handler. For your convenience, soda-swift automatically schedules the handler on the main operation queue.

That completion handler is given an enumeration SODADatasetResult with two possible values:

  • Dataset with an array of rows if the query succeeded.
  • Error with the NSError if the query failed.

Query Options

There are many more query options than just filterColumn. We could have also written:

fuelLocations.filter("fuel_type_code = 'CNG'")

We can also order the results:

fuelLocations.orderAscending("station_name")

We can then limit the results and control the offset to perform paging:

fuelLocations.limit(10).offset(0)

Chaining Queries

Queries can be easily composed and stored in variables. This allows you to keep your code clean and easily construct derivative queries.

For example, we may have an app that has a base query called fuelLocations:

let fuelLocations = client.queryDataset("alternative-fuel-locations")

The app allows the user to choose two types of stations: natural gas and electric. This decision is encapsulated in the query stations.

let userWantsNaturalGas = true // Get this from the UI

let stations = fuelLocations.filterColumn("fuel_type_code", userWantsNaturalGas ? "CNG" : "ELEC")

The app can also display the data sorted in two different directions and stores this in orderedStations:

let userWantsAscending = true // Get this from the UI

let orderedStations = userWantsAscending ?
    stations.orderAscending("station_name") :
    stations.orderDescending("station_name")

Now the app can easily query the results:

orderedStations.get { result in

    // Display the data or the error

}

API Reference

The full API Reference can be found in Reference.md.

Sample App

A sample app that shows recent police incidents in Seattle is included.

  1. Open soda-swift.xcodeproj
  2. Modify SODASample/AppDelegate.swift to insert your access token
  3. Ensure that the target SODA iOS Sample is selected
  4. Run
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].