Using open data in mobile applications
-
Upload
allan-lykke-christensen -
Category
Technology
-
view
1.167 -
download
5
description
Transcript of Using open data in mobile applications
![Page 1: Using open data in mobile applications](https://reader034.fdocuments.in/reader034/viewer/2022042814/555a4615d8b42a83368b53ad/html5/thumbnails/1.jpg)
USING OPEN DATA IN!MOBILE APPLICATIONS
![Page 2: Using open data in mobile applications](https://reader034.fdocuments.in/reader034/viewer/2022042814/555a4615d8b42a83368b53ad/html5/thumbnails/2.jpg)
ABOUT ME
• Allan Lykke Christensen"• 14 years experience"• B.S.c. 1. Class Honours Computer
Science & E-Business"• Career"– Director
Interactive Media Management"– Vice President
Danish ICT Management"– Business Analyst
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"
Using Open Data in Mobile Applications
![Page 3: Using open data in mobile applications](https://reader034.fdocuments.in/reader034/viewer/2022042814/555a4615d8b42a83368b53ad/html5/thumbnails/3.jpg)
PURPOSE OPEN DATA &
MOBILE APPS!
• Introduction to Open Data"• Open Data Services"• Open Data in Mobile Apps"• Success Factors"• Getting Started!"
Using Open Data in Mobile Applications
![Page 4: Using open data in mobile applications](https://reader034.fdocuments.in/reader034/viewer/2022042814/555a4615d8b42a83368b53ad/html5/thumbnails/4.jpg)
WHAT IS OPEN
DATA? FROM OPEN
DEFINITION.ORG!
1. Access"2. Redistribution"3. Reuse"4. Absence of Technological
Restriction"5. Attribution"6. Integrity"7. No Discrimination against Persons
or Groups"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"
Using Open Data in Mobile Applications
![Page 5: Using open data in mobile applications](https://reader034.fdocuments.in/reader034/viewer/2022042814/555a4615d8b42a83368b53ad/html5/thumbnails/5.jpg)
OPEN DATA
SERVICES NOT ALL
SERVICES ARE FREE!
• Government"– Kenya Government
http://opendata.go.ke"– World Bank
http://data.worldbank.org"– United Nations
http://undata-api.org/"– Data.gov
http://www.data.gov"– Data.gov.uk
http://www.data.gov.uk""
• Non-government"– OpenStreetMap
http://openstreetmap.org"– Wikipedia
http://www.dbpedia.org"
• Portals and Providers"– Infochimps
http://www.infochimps.com"– Socrata
http://opendata.socrata.com"– Freebase
http://www.freebase.com"– DataMasher
http://www.datamasher.com"
Using Open Data in Mobile Applications
![Page 6: Using open data in mobile applications](https://reader034.fdocuments.in/reader034/viewer/2022042814/555a4615d8b42a83368b53ad/html5/thumbnails/6.jpg)
MOBILE APPS
EXAMPLES!
• CDFMonitor"• Msema Kweli"• Huduma (SMS)"• K-Traffic"• mHealth (Ethiopia)"• PHSRP (India)"
Using Open Data in Mobile Applications
![Page 7: Using open data in mobile applications](https://reader034.fdocuments.in/reader034/viewer/2022042814/555a4615d8b42a83368b53ad/html5/thumbnails/7.jpg)
DATA EXCHANGE
COMMON PROTOCOLS AND
FORMATS!
• Protocols / Query"– SOAP"– REST"– XML-RPC"– X over HTTP"– SPARQL"– YQL"– OData"
• Formats"– JSON"– XML"– RDF"– XLS"– CSV"– TXT"– HTML"– PDF"
Using Open Data in Mobile Applications
![Page 8: Using open data in mobile applications](https://reader034.fdocuments.in/reader034/viewer/2022042814/555a4615d8b42a83368b53ad/html5/thumbnails/8.jpg)
SUCCESS FACTORS
CONSTRAINTS!
• Flat rates"• Smart phones"• Marketing of solutions"• Partnerships"• More open data!"
Using Open Data in Mobile Applications
![Page 9: Using open data in mobile applications](https://reader034.fdocuments.in/reader034/viewer/2022042814/555a4615d8b42a83368b53ad/html5/thumbnails/9.jpg)
GETTING STARTED
DEVELOPERS!
• Find a service"• Explore the datasets"– Register API key"
• Determine protocol"• Determine format"• Identify client API libraries"• Design queries"
Don’t just consume, PRODUCE!"
Using Open Data in Mobile Applications
![Page 10: Using open data in mobile applications](https://reader034.fdocuments.in/reader034/viewer/2022042814/555a4615d8b42a83368b53ad/html5/thumbnails/10.jpg)
GETTING STARTED FIND A SERVICE!
Using Open Data in Mobile Applications
h"p://opendata.go.ke
h"p://www.infochimps.com
![Page 11: Using open data in mobile applications](https://reader034.fdocuments.in/reader034/viewer/2022042814/555a4615d8b42a83368b53ad/html5/thumbnails/11.jpg)
GETTING STARTED
EXPLORE DATASETS!
Using Open Data in Mobile Applications
h"p://opendata.go.ke/browse
![Page 12: Using open data in mobile applications](https://reader034.fdocuments.in/reader034/viewer/2022042814/555a4615d8b42a83368b53ad/html5/thumbnails/12.jpg)
GETTING STARTED
DETERMINE PROTOCOL &
FORMAT!
Using Open Data in Mobile Applications h"p://dev.socrata.com/
![Page 13: Using open data in mobile applications](https://reader034.fdocuments.in/reader034/viewer/2022042814/555a4615d8b42a83368b53ad/html5/thumbnails/13.jpg)
GETTING STARTED
CLIENT API LIBRARY!
Using Open Data in Mobile Applications
• For opendata.go.ke we need a REST client that supports JSON"
• Devices:"– J2ME"• org.json Java Library
– Android"• org.json Java Library • Open Data Kit
– iOS"• json-‐framework (Google Code)
![Page 14: Using open data in mobile applications](https://reader034.fdocuments.in/reader034/viewer/2022042814/555a4615d8b42a83368b53ad/html5/thumbnails/14.jpg)
GETTING STARTED
DESIGN QUERIES!
Using Open Data in Mobile Applications All queries below should be prefixed http://opendata.go.ke "
• http://opendata.go.ke/api/views.jsonList of available datasets. Datasets have unique identifiers."
• /api/views/rsim-nh7f.json Get dataset with unique identifier rsim-nh7f (CDF Projects)"
• /api/views/rsim-nh7f/rows.json Gets all the data in the data set"
• /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-datasetsFilter queries use the HTTP POST method or by predefining queries"
![Page 15: Using open data in mobile applications](https://reader034.fdocuments.in/reader034/viewer/2022042814/555a4615d8b42a83368b53ad/html5/thumbnails/15.jpg)
GETTING STARTED
WRITING THE CODE!
Using Open Data in Mobile Applications
J2ME""String url = "http://opendata.go.ke/api/views/rsim-nh7f/rows.json?max_rows=100";
// Prepare a RESTful connection
HttpConnection hc = (HttpConnection) Connector.open(url);
hc.setRequestMethod(hc.GET);
hc.setRequestProperty("Accept-Type", "application/json");
// Execute connection
int responseCode = hc.getResponseCode();
![Page 16: Using open data in mobile applications](https://reader034.fdocuments.in/reader034/viewer/2022042814/555a4615d8b42a83368b53ad/html5/thumbnails/16.jpg)
GETTING STARTED
WRITING THE CODE!
Using Open Data in Mobile 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; if (len != -1) { for (int i = 0; i < len; i++) { if ((ch = is.read()) != -1) { b.append((char) ch); } } } else { // 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();
}
![Page 17: Using open data in mobile applications](https://reader034.fdocuments.in/reader034/viewer/2022042814/555a4615d8b42a83368b53ad/html5/thumbnails/17.jpg)
GETTING STARTED
WRITING THE CODE!
Using Open Data in Mobile 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; int COLUMN_CONSTITUENCY = 11; int COLUMN_PROJECT = 12; int COLUMN_SECTOR = 14; int COLUMN_EXPECTED_OUTPUT = 17; int COLUMN_STATUS = 19; int COLUMN_ESTIMATED_COSTS = 21; int COLUMN_TOTAL_COSTS = 28; // 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); } }
![Page 18: Using open data in mobile applications](https://reader034.fdocuments.in/reader034/viewer/2022042814/555a4615d8b42a83368b53ad/html5/thumbnails/18.jpg)
SUMMARY
• Open data"• Mobile apps"• Data exchange"• Success factors"• Getting started"
Using Open Data in Mobile Applications
![Page 19: Using open data in mobile applications](https://reader034.fdocuments.in/reader034/viewer/2022042814/555a4615d8b42a83368b53ad/html5/thumbnails/19.jpg)
THANKS FOR [email protected]