Web-services for sensor-based and location-aware products with contributions from Raghid Kawash and Allan Hansen Department of Computer Science, University of Aarhus, Denmark 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 1
Project Requirements for Web-services 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 2
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 READMEtekst-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)? Web-services for sensor-based products 3
Airstrip example: Cardiology measuring via cell phone HealthBarometer Caretech Innovation Daily health coaching In context of everyday work and life situations e.g.via Mobile device What if simulations 4
16/04/12 Internet of Things - Stream feeds Your System (subscribes to) feedback Internet Internet A hierarchy of stream feeds (fusion trees) Like web feeds Extend web feeds with the notion of real-time streaming of sensor data A fusion feed, which Fusion trees is a composition Conditional subscription over of two other temporal scopes: Publish stream feeds All time Historical Real-time Past Future Example of a Stream-feed URL: http://www.somedomain.com/streams/radiator/real-time How Do Stream Feeds work? Clients pull updates Your System Client Pull feed Pull Apache/Tomcat Web Server A stream feed Data (feed) Subscribe to feed Feed + listen to port Maybe a Stream feed Servlet? Connect Clients wait for updates Your System Data React Server pushes updates Data Data These aspects can be implemented using open source toolkits 5
16/04/12 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 Server-side based Aggregators Client-side based Aggregators How do web feeds work? Some other Server Server Laptop LAN The Web Content providers VPN/Router Enterprise Network iphone XML/HTTP/TCP Desktop computer Web browsing RSS, ATOM standardized protocols Identify feeds using DNS + URLs Hyper Text Transfer Protocol (HTTP) 6
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 HTTP primitives: POST PUT GET DELETE Atom Publishing Protocol: Resources (feeds) identified using URLs - Create feed using POST XML - Consume feed using GET XML - Update feed using PUT Web servers understands these types of requests XML Your System Client - Delete feed using DELETE XML Web Server Example of an <?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> Atom web feed <author> Who published <name>john Doe</name> this feed </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> There are many more elements and attributes We can also use mimemedia types We can add our own attributes Uniquely identifies the feed Uniquely identifies the entry Read more here 7
Feeds in PHP Feedwriter Programming Web Feeds Java based e.g. http://www.vogella.com/articles/rssfeed/article.html http://sourceforge.net/projects/jrss/ PhP based, e.g. http://abdera.apache.org/ 8
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 Designing Your Database The simplest is to use the existing Atom mode Feed * Entry 1 EntryState - Id - Author - etc - Id - Title - etc - Latest - Historical - etc.. 9
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. Sensor Web 10
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 SensorML Elements! 11
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> Example Sensor Web Architecture 12
Sensor Readings and Visualization Sketch your scenarios Hospital Home1 Home2 Stationary Sensors XML SensorML Physician XHTML Person1 SensorML Mobile Sensors XHTML Person2 SmartPhone Apps Welfare Services Pharmacy 13
QUESTIONS? Web-services for location-aware products 14
Endomondo.com Garmin 15
Hasle Running Coach - Prevention KML based data format KML / KMZ Running routes + coach Logdata Existing players Google Earth Google Maps... How 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. 16
KML is becoming the de facto standard for location based mark up of maps KML = Keyhole Markup Language (an XML based language) 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, 17
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. Hello World! (Google Earth) Simple PlaceMark 18
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) How to to look at objects (The <Lookat> element) 19
16/04/12 Paths Paths Line 15-70: Paths are created with the <LineString> element 20
16/04/12 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). Styles 21
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. 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 22
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 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/ http://www.ogleearth.com/ 23
QUESTIONS? 24