Web-services for sensor-based and
location-aware products
Kaj Grønbæk
with contributions from Raghid Kawash and Allan Hansen Department of Computer Science,
University of Aarhus, Denmark
itPDP12 Kaj Grønbæk
AARHUS UNIVERSITET
Plan
› About the project requirements (in Danish) › About integration of sensor data in Web apps
› Web feeds › Sensor Web › SensorML
› About location based Web apps
› Inspiration Endomondo/Garmin › KML
Project Requirements for Web-services
itPDP12 Kaj Grønbæk
AARHUS UNIVERSITET
Mål og afgrænsning for it-produktet
› It-produktet skal placeres klart i et af de tre temaer
› Udvise forståelse og respekt for målgruppens behov.
› Løsningen skal positionere sig som relevant i forhold til de forventede brugere af teknologien.
› Der skal tages højde for målgruppen og typen af lidelse/støtte, der adresseres
› Løsningen skal omfatte flere klienter og servere (evt. peers),
der benytter web-standarder
› Kontakt til professionelle støttepersoner, social kontakt i målgruppe, automatisk indsendelse af sensordata.
› It-produktet må gerne involvere en mobiltelefon som en del af løsningen, men der skal være et samspil med andre fysisk designede elementer i omgivelserne
› Der skal argumenteres for det forretningsmæssige potentiale og behov for produkter
Webservices – fra opgaven
› Programkoden for gruppens web-service skal installeres på server der gør det muligt at afprøve systemet, endvidere afleveres koden som en separat ZIP-fil med en README-tekst-fil, der beskriver brugen af jeres Web-services. Endelig vedlægges en kort tekst, der beskriver funktionaliteten og argumenterer for jeres implementation. Denne vil blive bedømt på følgende kriterier:
› Hvor avanceret funktionalitet stiller web-servicen til rådighed? Diskuteres valg blandt alternative teknologier, til at løse opgaven?
› Er der kendte mangler i implementationen eller andre ændringer i forhold til jeres plan (delafleveringen)? Eller nye ideer til forbedringer?
› Er den overordnede struktur af programkoden beskrevet?
› Er interfacet til Flash- (Web- eller Mobil-) delen klart beskrevet (så denne i princippet kunne implementeres uafhængigt af web-servicen)?’’
AARHUS UNIVERSITET
Airstrip example:
Cardiology measuring via cell phone
itPDP12 Kaj Grønbæk
AARHUS UNIVERSITET
HealthBarometer – Caretech Innovation
› Daily health coaching
› In context of everyday work and life situations
› e.g.via Mobile device › “What if…” simulations…
Internet of Things - Stream feeds
Internet
A hierarchy of stream feeds (fusion trees) A fusion feed, which is a composition of two other stream feeds
› Like web feeds
› Extend web feeds with the notion of
real-time streaming of sensor data › Fusion trees
› Conditional subscription over temporal scopes:
All time Historical Real-time Internet
Your System (subscribes to)
• Example of a Stream-feed URL: http://www.somedomain.com/streams/radiator/real-time feedback Publish Future Past itPDP12 Kaj Grønbæk AARHUS UNIVERSITET
How Do Stream
Feeds work?
These aspects can be implemented – using open source toolkits
Client Apache/Tomcat
Web Server
A stream feed
Subscribe to feed Feed + listen to port
Connect Data Data Data Pull feed Data (feed) React Your System Server pushes updates Clients pull updates Clients wait for updates Your System Maybe a Stream feed Servlet? Pull
What are web feed?
› A web feed is an XML document + DTD - frequently used to publish content by content providers
› A DTD defines the building blocks for the web feed › Content providers have web sites with frequent updates
› They provide these updates by means of web feeds
› Other may read web sites and and provide web feeds for these sites (3rd party web feeders)
› Users want to be constantly updated with new information from the web
› They use feed readers - aka aggregators
› These tools help them organize frequently updated
information on the web
Client-side based Aggregators Server-side based Aggregators itPDP12 Kaj Grønbæk AARHUS UNIVERSITET
How do
web feeds
work?
The Web Desktop computer Server Web browsing Laptop Enterprise Network LAN
Some other Server
iPhone
XML/HTTP/TCP
VPN/Router
• Hyper Text Transfer Protocol (HTTP)
• Identify feeds using DNS + URLs Content providers
How does it really work?
• Web feeds e.g. RSS and Atom are XML based documents transmitted on the web
• HTTP Primitives are used to Create, Update, Read and Delete Atom web feed POST GET DELETE
HTTP primitives: PUT
Web Server Client
- Create feed using POST
- Consume feed using GET
- Update feed using PUT
- Delete feed using DELETE
Resources (feeds) identified using URLs
Web servers understands these types
of requests XML XML XML XML Your System Atom Publishing Protocol: itPDP12 Kaj Grønbæk AARHUS UNIVERSITET
Example of an Atom
web feed
<?xml version="1.0" encoding="utf-8"?> <feed xmlns="http://www.w3.org/2005/Atom"> <title>Example Feed</title>
<link href="http://example.org/"/>
<updated>2003-12-13T18:30:02Z</updated> <author>
<name>John Doe</name> </author>
<id>urn:uuid:60a76c80-d399-11d9-b93C-0003939e0af6</id> <entry>
<title type=“text” >Atom-Powered Robots Run Amok</title> <link href="http://example.org/2003/12/13/atom03"/> <id>urn:uuid:1225c695-cfb8-4ebb-aaaa-80da344efa6a</id> <updated>2003-12-13T18:30:02Z</updated>
<text>…</text>
<summary>Some text.</summary> </entry> </feed> Uniquely identifies the entry Who published this feed Uniquely identifies the feed
There are many more elements and attributes We can also use mime-media types We can add our own attributes
Feeds in
PHP
› Feedwriter itPDP12 Kaj Grønbæk AARHUS UNIVERSITETProgramming Web Feeds
Java based e.g.
› http://www.vogella.com/articles/RSSFeed/article.html
› http://sourceforge.net/projects/jrss/ PhP based, e.g.
Some historical Info
› Many formats
› Rich Site Summary (RSS 0.91) › RDF Site Summary (RSS 1.0, RSS 0.9)
› Really Simple Syndication (RSS 2.0) – used by many › ATOM 1.0 – Alternative to RSS
› Most of which are to some extent incompatible
itPDP12 Kaj Grønbæk
AARHUS UNIVERSITET
Designing Your Database
› The simplest is to use the existing Atom mode
Entry * Feed 1 EntryState - Historical - Latest - Title - Id - Author - Id - etc.. - etc… - etc…
MySql and Web scripts on CS servers
› You have to run the following script in a termnal window on a CS horse
› /users/mysql/linux/daimi/muser
› It will return a database with login info for you. › Following that you can admin your database via
phpmyadmin on mysql.cs.au.dk.
› You should place your Web scripts under public_html on your own account.
AARHUS UNIVERSITET
Sensor Web
Sensor web papers and standard
› http://dx.doi.org/10.1145/1621890.1621898
› http://www.cloudbus.org/papers/ICISIP2006-SensorWeb.pdf
› http://www.opengeospatial.org/
› http://opengeo.org/publications/opengeo-swe/
Sensor network projects related to healthcare › http://fiji.eecs.harvard.edu/CodeBlue › http://static.usenix.org/event/mobisys05/eesr05/tech/ full_papers/hashmi/hashmi.pdf itPDP12 Kaj Grønbæk AARHUS UNIVERSITET
SensorML Elements
!Example of SensorML
<response id=ysi_wss_0001><GeneralPropertyModel> <dynamicRange>
<minimum>
<Quantity observable type=#windSpeedunitOfMeasure=#mph>0</Quantity> </minimum>
<maximum>
<Quantity observable type=#windSpeedunitOfMeasure=#mph>134</Quantity> </maximum> </dynamicRange> <threshold> <Quantity observableType=#windSpeedunitOfMeasure=#mph>2.2</Quantity> </threshold> <survivableRange> <maximum> <Quantity observableType=#windSpeedunitOfMeasure=#mph>220</Quantity> </maximum> </survivableRange> <operationalRange> <minimum> <Quantity observableType=#airTemeratureunitOfMeasure=#celsius>-40 </minimum> <maximum> <Quantity observableType=#airTemeratureunitOfMeasure=#celsius>40 </maximum> </operationalRange> </GeneralPropertyModel> </response> itPDP12 Kaj Grønbæk AARHUS UNIVERSITET
Sensor Readings and Visualization
itPDP12 Kaj Grønbæk
AARHUS UNIVERSITET
Sketch your scenarios…
Home1 Person2 Person1 Home2 Pharmacy Hospital Welfare Services Physician Stationary Sensors Mobile Sensors SensorML SensorML XML XHTML XHTML SmartPhone AppsQUESTIONS?
AARHUS UNIVERSITET
Web-services for location-aware
products
Endomondo.com
itPDP12 Kaj Grønbæk AARHUS UNIVERSITETGarmin
Hasle Running Coach
- Prevention
›
KML based data format
› KML / KMZ
› Running routes + coach › Logdata
›
Existing players
› Google Earth › Google Maps › ... itPDP12 Kaj Grønbæk AARHUS UNIVERSITETHow to represent the data?
› Database approach
› Data is managed by a geographic information system (GIS)
› A GIS supports user created searches (interactive queries), data editing, analyzes of spatial information, and visual presentation of these results on maps.
› Document approach
› Data is distributed in files or documents. › Files are read by geo-browsers (Earth Viewers).
› Functions in much the same way that Web-browsers read distributed HTML files on the Web.
› The two approaches can be combined e.g. documents can be generated from a GIS database system, and/or the documents can have “live” links to the GIS database.
KML is becoming the de facto standard
for location based mark up of maps
KML = Keyhole Markup Language (an XML based language)
itPDP12 Kaj Grønbæk
AARHUS UNIVERSITET
KML: a geographic document format
› Keyhole Markup Language (KML) is an XML-based language for
geographic documents.
› Originally created in 2001 by Keyhole Inc. for use in the “Keyhole Earth
Viewer” geo-browser.
› “Keyhole” refers to the nickname of the American KH-11 spy satellites launched in the 1970s.
› Keyhole Inc. was acquired by Google in 2004. › Google Earth (re-)launched in 2005.
› KML 2.2 was ratified as an open standard for geo-browser by the Open
Geospatial Consortium in 2008.
› Used as document format by many geo-browsers,
both 2D, 3D and mobile:
› Google Earth, Google Maps, Google Mobile Maps, › Microsoft Virtual Earth, Live Search Maps, › Yahoo Pipes, …
KML: Spatial Objects
› KML defines a lot of useful objects for presenting spatial data
› E.g. place marks, tours, images, lines, polygons, 3D models, textual descriptions, annotations, time based data, etc.
› Each object has a spatial placement and style information that specifies how the object should be presented.
› KML also supports specifications of how the camera should look at objects
› This is harder to implement correctly, since 2D and 3D browsers may not support the same views, e.g. tilt and rotation.
itPDP12 Kaj Grønbæk
AARHUS UNIVERSITET
Hello World! (Google Earth)
› Simple PlaceMark
Hello World! (KML)
› Line 1: XML declaration (must be valid xml)
› Line 2-12: KML element. Defines the kml namespace. › Line 4-10: A Placemark object. The placemark includes:
› A name that is used as the label
› A description that appears in the "balloon" attached to the Placemark
› A Point that specifies the position of the Placemark (longitude, latitude, and altitude)
itPDP12 Kaj Grønbæk
AARHUS UNIVERSITET
How to to look at objects
(The <Lookat> element)
Paths
itPDP12 Kaj Grønbæk AARHUS UNIVERSITETPaths
Styles: Shared styles for objects
› Styles can be applied to Geometry, Placemarks, and Overlays defined in the Document.
› A Style is defined with an ID.
› A Style is defined once, and can be reference multiple times, using the <styleUrl> element.
› Styles can be embedded and used within the same file.
› <styleUrl>#transBluePoly</styleUrl>
› Or it can be loaded from an external file.
› <styleUrl>http://www.example.com/file.kml#transBluePoly</styleUrl>
› This is much like CSS style declaration in HTML (but not cascading).
itPDP12 Kaj Grønbæk
AARHUS UNIVERSITET
Network Links
› Network links support loading external data
› KML files, images, or models
› Loading can be time based or view based
› E.g. an external kml file, can be reloaded with a certain interval
› Network links are defined by the <NetworkLink>, <Link>, and <href> elements.
itPDP12 Kaj Grønbæk
AARHUS UNIVERSITET
Working with KML documents
› KML files are simple XML files and can be created and edited in any text editor.
› Google Earth has some editing facilities as well
› It is possible to export a folder from Google Earth to KML/KMZ › It is possible to copy objects in Google Earth
› When pasted, you get the KML representation
› But KML can also be generated by programs or Web services on the fly from other data…
Working with KML documents
(Web services)
› KML Generator:
› A simple PHP Web service that generates:
› Network linked › A number of place marks
› Static Map Generator:
› A simple service that uses the above generated KML and creates a google static image with the place marks on top
itPDP12 Kaj Grønbæk AARHUS UNIVERSITET
KML References
› Googles KML documentation › http://code.google.com/intl/da/apis/kml/ › Tutorial › http://code.google.com/intl/da/apis/kml/documentation/kml_tut.html › Developer's Guide › http://code.google.com/intl/da/apis/kml/documentation/topicsinkml.html › KML Reference › http://code.google.com/intl/da/apis/kml/documentation/kmlreference.html › Books› KML Handbook, The: Geographic Visualization for the Web
› http://www.informit.com/articles/article.aspx?p=1276353
› Blogs and discussions
› http://googlegeodevelopers.blogspot.com/ › http://groups.google.com/group/kml-support › http://www.gearthblog.com/