Successfully reported this slideshow.
USING OPEN DATA IN!MOBILE APPLICATIONS
Using Open Data inMobile Applications   •  Allan Lykke Christensen"                       •  14 years experience"         ...
Using Open Data inMobile Applications                       •    Introduction to Open Data"                       •    Ope...
Using Open Data inMobile Applications   1.   Access"                       2.   Redistribution"                       3.  ...
Using Open Data inMobile Applications   •    Government"                             –  Kenya Government 
                ...
Using Open Data inMobile Applications                       •    CDFMonitor"                       •    Msema Kweli"      ...
Using Open Data inMobile Applications   •  Protocols / Query"                           –  SOAP"                          ...
Using Open Data inMobile Applications                       •    Flat rates"                       •    Smart phones"SUCCE...
Using Open Data inMobile Applications                       •  Find a service"                       •  Explore the datase...
Using Open Data in     h"p://opendata.go.ke	  Mobile ApplicationsGETTINGSTARTED                                          h...
Using Open Data inMobile Applications                       h"p://opendata.go.ke/browse	  GETTINGSTARTED        EXPLORE   ...
Using Open Data inMobile Applications   h"p://dev.socrata.com/	  GETTINGSTARTED     DETERMINE    PROTOCOL &        FORMAT!
Using Open Data inMobile Applications                       •  For opendata.go.ke we need a                          REST ...
Using Open Data inMobile Applications   All queries below should be prefixed http://opendata.go.ke "                       ...
Using Open Data inMobile Applications                       J2ME"                       "                       String url...
Using Open Data inMobile Applications   J2ME"                       "                       // Read the (JSON) response in...
Using Open Data inMobile Applications   J2ME"                       "                       // Turn response into JSONObje...
Using Open Data inMobile Applications                       •    Open data"                       •    Mobile apps"       ...
THANKS FOR LISTENING!   ALLAN@I2M.DK
Upcoming SlideShare
Loading in …5
×

Using open data in mobile applications

1,504 views

Published on

Brief introduction on using Open Data in Mobile Applications for AITEC Africa 2011 in Nairobi, Kenya.

Published in: Technology, Education
  • Be the first to comment

Using open data in mobile applications

  1. 1. USING OPEN DATA IN!MOBILE APPLICATIONS
  2. 2. Using Open Data inMobile Applications •  Allan Lykke Christensen" •  14 years experience" •  B.S.c. 1. Class Honours Computer Science & E-Business" •  Career" –  Director
 Interactive Media Management" ABOUT –  Vice President
 Danish ICT Management" ME –  Business Analyst
 ALLAN@I2M.DK! PRO€INVEST (EU)" –  Software Engineer
 Siemens Communications" –  Technical Consultant
 Metrocomia" –  Independent Consultant" •  Open source and open data solutions" •  LinkedIn
 http://dk.linkedin.com/in/allanlykkechristensen"
  3. 3. Using Open Data inMobile Applications •  Introduction to Open Data" •  Open Data Services"PURPOSE •  Open Data in Mobile Apps" OPEN DATA & MOBILE APPS! •  Success Factors" •  Getting Started!"
  4. 4. Using Open Data inMobile Applications 1.  Access" 2.  Redistribution" 3.  Reuse" 4.  Absence of Technological Restriction" WHAT IS 5.  Attribution" OPEN 6.  Integrity" 7.  No Discrimination against Persons DATA? or Groups" FROM OPENDEFINITION.ORG! 8.  No Discrimination against Fields of Endeavour" 9.  Distribution of License" 10. License must not be specific to a package" 11.  License must not restrict the distribution of other works"
  5. 5. Using Open Data inMobile Applications •  Government" –  Kenya Government 
 http://opendata.go.ke" –  World Bank
 http://data.worldbank.org" –  United Nations
 http://undata-api.org/" –  Data.gov
 OPEN http://www.data.gov" –  Data.gov.uk
 http://www.data.gov.uk" DATA •  " Non-government"SERVICES –  OpenStreetMap
 http://openstreetmap.org" –  Wikipedia
 NOT ALL http://www.dbpedia.org
 " SERVICES ARE •  Portals and Providers" FREE! –  Infochimps
 http://www.infochimps.com" –  Socrata
 http://opendata.socrata.com" –  Freebase
 http://www.freebase.com" –  DataMasher
 http://www.datamasher.com"
  6. 6. Using Open Data inMobile Applications •  CDFMonitor" •  Msema Kweli" •  Huduma (SMS)" •  K-Traffic" •  mHealth (Ethiopia)" MOBILE •  PHSRP (India)" APPS EXAMPLES!
  7. 7. Using Open Data inMobile Applications •  Protocols / Query" –  SOAP" –  REST" –  XML-RPC" –  X over HTTP" –  SPARQL" DATA –  YQL" –  OData"EXCHANGE •  Formats" COMMON –  JSON"PROTOCOLS AND FORMATS! –  XML" –  RDF" –  XLS" –  CSV" –  TXT" –  HTML" –  PDF"
  8. 8. Using Open Data inMobile Applications •  Flat rates" •  Smart phones"SUCCESS •  Marketing of solutions"FACTORS •  Partnerships" CONSTRAINTS! •  More open data!"
  9. 9. Using Open Data inMobile Applications •  Find a service" •  Explore the datasets" –  Register API key" •  Determine protocol"GETTING •  Determine format"STARTED •  Identify client API libraries" DEVELOPERS! •  Design queries" Don’t just consume, PRODUCE!"
  10. 10. Using Open Data in h"p://opendata.go.ke  Mobile ApplicationsGETTINGSTARTED h"p://www.infochimps.com   FIND A SERVICE!
  11. 11. Using Open Data inMobile Applications h"p://opendata.go.ke/browse  GETTINGSTARTED EXPLORE DATASETS!
  12. 12. Using Open Data inMobile Applications h"p://dev.socrata.com/  GETTINGSTARTED DETERMINE PROTOCOL & FORMAT!
  13. 13. Using Open Data inMobile Applications •  For opendata.go.ke we need a REST client that supports JSON" •  Devices:"GETTING –  J2ME"STARTED •  org.json  Java  Library   CLIENT API –  Android" LIBRARY! •  org.json  Java  Library   •  Open  Data  Kit   –  iOS" •  json-­‐framework  (Google  Code)  
  14. 14. Using Open Data inMobile Applications All queries below should be prefixed http://opendata.go.ke " •  http://opendata.go.ke/api/views.json
 List of available datasets. Datasets have unique identifiers." •  /api/views/rsim-nh7f.json
 Get dataset with unique identifier rsim-nh7f (CDFGETTING Projects)"STARTED •  /api/views/rsim-nh7f/rows.json
 Gets all the data in the data set"DESIGN QUERIES! •  /api/views/89zb-g69r/rows.json?max_rows=20
 Gets the first 20 data entries in the data set" •  /api/views/89zb-g69r/rows/2.json
 Extract record number 2 from the data set" •  http://dev.socrata.com/querying-datasets
 Filter queries use the HTTP POST method or by predefining queries"
  15. 15. Using Open Data inMobile Applications J2ME" " String url = "http://opendata.go.ke/api/ views/rsim-nh7f/rows.json?max_rows=100";GETTING // Prepare a RESTful connection HttpConnection hc = (HttpConnection)STARTED Connector.open(url); WRITING THE hc.setRequestMethod(hc.GET); CODE! hc.setRequestProperty("Accept-Type", "application/json"); // Execute connection int responseCode = hc.getResponseCode();
  16. 16. Using Open Data inMobile Applications J2ME" " // Read the (JSON) response into a String InputStream is = null; StringBuffer b = new StringBuffer(); try { is = hc.openInputStream(); long len = hc.getLength(); int ch = 0;GETTING if (len != -1) { for (int i = 0; i < len; i++) { if ((ch = is.read()) != -1) {STARTED } } b.append((char) ch); WRITING THE } else { CODE! // Read till the connection is closed. while ((ch = is.read()) != -1) { len = is.available(); b.append((char) ch); } } } finally { if (is != null) { is.close(); } hc.close(); }
  17. 17. Using Open Data inMobile Applications J2ME" " // Turn response into JSONObject JSONObject json = new JSONObject(b.toString()); JSONArray results = json.optJSONArray("data"); // Store result in internal data structure Vector projects = new Vector(); // Column indexes int COLUMN_ID = 1; int COLUMN_COUNTY = 9; int COLUMN_DISTRICT = 10;GETTING int COLUMN_CONSTITUENCY = 11; int COLUMN_PROJECT = 12; int COLUMN_SECTOR = 14;STARTED int COLUMN_EXPECTED_OUTPUT = 17; int COLUMN_STATUS = 19; int COLUMN_ESTIMATED_COSTS = 21; int COLUMN_TOTAL_COSTS = 28; WRITING THE CODE! // Iterate through resutls if (results != null) { for (int i = 0; i < results.length(); i++) { JSONArray item = results.getJSONArray(i); CdfProject project = new CdfProject(); project.setId(item.get(COLUMN_ID)); project.setTitle(item.get(COLUMN_PROJECT)); project.setConstituency(item.get(COLUMN_CONSTITUENCY)); projects.addElement(project); } }
  18. 18. Using Open Data inMobile Applications •  Open data" •  Mobile apps" •  Data exchange"SUMMARY •  Success factors" •  Getting started"
  19. 19. THANKS FOR LISTENING! ALLAN@I2M.DK

×