Presentation is loading. Please wait.

Presentation is loading. Please wait.

DSA Week 151 Mashups, Google Earth and Geo-coding.

Similar presentations


Presentation on theme: "DSA Week 151 Mashups, Google Earth and Geo-coding."— Presentation transcript:

1 DSA Week 151 Mashups, Google Earth and Geo-coding

2 DSA Week 152 Agenda XPath continued Mashups Google Earth Keyhole Markup Language Generating kml

3 DSA Week 153 Mashups (1) Mashups are about information reuse. Just as code reuse was the holy grail of object-oriented development, enabled through class (code) libraries, so mashups are about data reuse and recombination. An alternative term is ‘bricolage’, a term used in the IS context by Claudio Ciborra.Claudio Ciborra ProgrammeableWeb documents over 1520 (700 at the beginning of May 2006), nearly half of which use location data associated with photographs (Flickr), house sales (Craig’s List) and news items (RSS) linked to maps( Google Map.)ProgrammeableWeb Google Map

4 DSA Week 154 Mashups (2) Combining information from multiple sources –Application gets data from a source Page-scraping (parsing HTML) Application Programmer Interface (API) –SOAP / REST /JavaScript functions RSS (Real Simple Syndication) –Standard identifiers to link data (e.g. Currency codes) –Combine data on server or client E.g. Using Google Map Javascript API E.g. –Subletr at Waterloo University on CanadaSubletr

5 DSA Week 155 Google Earth Blog entry Google Earth is a client-side mapping application (needs a download) so not used in this list of Mashups –Image based on satellite and aerial imagery (200 terabytes) –Uses can add annotations such as Placemarks, with a position and description –User defined overlays can be saved and distributed as XML Google Maps now can use the same overlays.

6 DSA Week 156 Google Earth Demo StudentsOnline Google Earth operations –Creating Folders –Creating Placemarks –Editing Location and Description –Editing Icons –Saving as kml Partner Organisations map

7 DSA Week 157 Creating a static GE overlay Create a new folder Go to a location Create a new Placemark and add to folder Edit the Placemark Save the Folder as kml (kmz is zipped kml) View the saved file in a text editor. Edit the description of a Placemark in this file Load the modified kml file Place the kml file in your public-html directory Reference this file from a browser (Firefox) This should then start up GE and load the overlay

8 DSA Week 158 Example kml file UWE 1 …. Bower Ashton <![CDATA[The home of the Faculty of Art, Media and Design ]]> - 2.632474205298138,51.44408935082485,0 …. This is very minimal but it is enough Uses default icon Uses default viewpoint

9 DSA Week 159 CDATA Problem – XML has a strict definition of what is allowable, but what if you have to include content which is not allowed e.g. Un-nested tags as pure data. Answer 1 –Replace all characters by their character entities or decimal character i.e. < becomes < Answer 2 –Enclose the messy data in the special tag

10 DSA Week 1510 Understanding kml Experimental: –Use a text editor (Notepad, PFE32) to load the text file, change a description, save and reload (after deleting the original) ? Online documentation– the Google Earth specification Draw a tree diagram to explain the general structure

11 DSA Week 1511 Advanced Google Earth Icons –Style can be designed For each Placemark For a set of placemarks by creating a style with an id Small icons can be selected from the big pallette png’s – each is 32* 32 pixels, arranged in 8 rows of 8, numbered 0- 7 from the bottom-left. Specific icons can be selected with the appropriate x, y, h, w parameters

12 DSA Week 1512 Understanding Latitude and Longitude Lines of equal latitude Lines of equal longitude (0, 0) of the West coast of Africa 0 longitude is the Greenwich Meridian 0 latitude is the Equator +,+ +, - Bristol 51 ° 27’ N 2 ° 36’ W 1 minute of latitude = 1 Nautical Mile = 1.150779 miles 60 seconds in 1 minute 60 minutes in 1 degree 360 degrees in a full circle 1 minute of longitude goes to zero at the poles 50 0 -2 As decimal 51.45 -2.6

13 DSA Week 1513 Geocoding To determine the latitude and longitude of an address or postcode One at a time –Use Google Earth to find a place by name or full postcode and note the latitude and longitude –Hint – select the option to display latitude and longitude in decimal degrees not degrees, minutes and seconds In Bulk UK Postcodes –commercially available in bulk –Use one of the free XML-based services supplied Mikel Maron who resides in the Dominican Republic.Mikel Maron http://brainoff.com/geocoder/rest?post=BS7

14 DSA Week 1514 Examples of location data -2.6, 51.45,0 -2.6 51.45 -2.6 51.45 -2.6

15 DSA Week 1515 Inconsistant Geocoding data Just as we saw with the weather data, there are lots of ways of marking up position data. Nearly all in Latitude and Longitude expressed as decimal degrees but also in OS northing and easting Compare the different markups in –Weather Channel –BBC –Yahoo –kml –GeoRSS Kml also includes altitude Different mapping systems will return different positions – one cause are different datums because the earth is not round. Google Earth uses WSG84 This creates difficulties in system integration

16 DSA Week 1516 Dynamic kml kml is just another XML file so we can get PHP to output kml just as we did html A few differences –You have to set the mime-type to kml –You have to create a valid kml file The full definition of the syntax of kml is very large, but most developers work from examples (XML schema has only recently been defined)

17 DSA Week 1517 A trivial kml generator Basic demonstration –Read a BBC weather feed from a file –Generate a kml file with one Placemark Key features –header("Content-type: application/vnd.google- earth.kml+xml;"); –Minimal elements On GoogleEarth –http://www.cems.uwe.ac.uk/~cjwallac/apps/phpxml/showPlace.p hp?name=Bristolhttp://www.cems.uwe.ac.uk/~cjwallac/apps/phpxml/showPlace.p hp?name=Bristol On GoogleMaps –http://maps.google.com/maps?q=http://www.cems.uwe.ac.uk/~cj wallac/apps/phpxml/showPlace.php?name=Bristolhttp://maps.google.com/maps?q=http://www.cems.uwe.ac.uk/~cj wallac/apps/phpxml/showPlace.php?name=Bristol

18 DSA Week 1518 PHP script <?php $name = $_REQUEST["name"] $places = simplexml_load_file("places.xml"); $place = $places->xpath("//Place[name='$name']"); $place= $place[0]; header("Content-type: application/vnd.google-earth.kml+xml; charset=UTF-8"); ?> A sample overlay A very interesting place longitude,$place->latitude,0"; ?>

19 DSA Week 1519 Typical output A sample overlay Bristol A very interesting place -2.6,51.45,0

20 DSA Week 1520 Workshop Use Google Earth to create a kml file Inspect it with a text editor Get the PHP code to convert from a Place name to a kml file working Read the current weather directly from the BBC Use Mikal’s geocoding service in a script which accepts a UK place name and generates a kml file [Use a public server to host the scripts and use GoogleMap to display the locations]


Download ppt "DSA Week 151 Mashups, Google Earth and Geo-coding."

Similar presentations


Ads by Google