Posts Tagged sparql

SPARQL & Pseudo Code Example – Sami

One of the technologies that Koh.Tu.Me will use is SPARQL [1] which is the query language of the Semantic Web. The University of Southampton has made a lot of Open Data available [2] and have set up a SPARQL Endpoint [3] in order to facilitate easy querying of this data.

This images below illustrates a SPARQL query that can be used to get the bus route and bus stops information, complete with name and latitude and longitude information. This means that if a user requested to travel by bus and put in their location details then this information could be used to locate the bus stop closest to their location, ascertain which bus routes that was on, and then locate which stop on one of those routes was closest to their start location.

The pseudo code would look something like this:

#in the case the user selects bus
select case: “bus”
      Stop dest_stop = nearestStopFromCoordinates(dest_lat,dest_long);
      List<Route> dest_routes = routeFromStop(dest_lat,dest_long);
      Stop start_stop = nearestStopFromCoordinates(user_lat,user_long,dest_routes);
Route bus_route = locate_root(start_stop, dest_stop); 

#works out the nearest bus stop from any route to the lat/long provided
nearestStopFromCoordinates(String lat, String long){};

#works out the nearest bus stop on the routes provided, using the lat/long provided
nearestStopFromCoordinates(String lat, String long, List<Route> routes){};

#works out which bus route has both of these stops on
locate_root(Stop start_stop, Stop end_stop);
SPARQL Query
Sparql

SPARQL Query & Results
Sparql2

 

 

References
[1] http://www.w3.org/TR/sparql11-query/
[2] http://data.southampton.ac.uk/
[3] http://sparql.data.southampton.ac.uk/

, , , , , , , , , , , , , ,

No Comments

Standards & Protocols Overview – Jokha & Sami

This post will discuss the different standards and protocols our social networking application will use.

Open Data Standards
As discussed in the previous post [1] Koh.Tu.Me will be using Open Data for it’s travel and weather data. A majority of Open Data is provided using Open data formats such as XML [2], JSON [3] or RDF [4] (for linked Open Data as is used in data.southampton.ac.uk). Linked Open Data uses URI’s (Unique Resource Identifiers) to identify each of their objects uniquely. This can be used to link together different open data sets.

Open Data can also be provided via an API (for data that changes regularly and will be queried on the fly), and some of the travel data sets looked at in our previous blog post [1] did indeed provide API’s. Additionally some of the data is just provided as a downloadable dump, for data such as postcodes which aren’t going to change on a daily basis.

Open Data Protocol
OData [5] is an Open Data Access Protocol which was built for the primary purpose of creating and accessing data API’s. It’s built on core internet protocols like HTTP and it uses the REST [6] Methodology. This could be used to access the Open Data API’s that Koh.Tu.Me would use to access the travel and weather data.

The weather data API [7] is available in various formats (JSON, XML & HTML) and can provide finely granulated data for precise locations. This level of data detail, in the real time format we wish to process it requires fast and easy access to the data API’s. Which this protocol can facilitate.

SPARQL
SPARQL [8] is the query language for the Semantic Web. It is used to query RDF (linked) data. As discussed in the previous blog post [1] some of the Open Data our social networking application will be using is Linked Data. Therefore we would use this query language to obtain our desired results from the Open Linked Data. A SPARQL Endpoint is required to allow users to query the data, and once that endpoint has been set up that query still needs to be sent from the web/mobile application. The Electronics and Computer Science School at Southampton University has created a tool to query SPARQL using PHP called Graphite [9]. For the Web version of our Koh.Tu.Me application, this could be used.

Yahoo! Query Language (YQL)
From a single interface developers can both query and filter data from any data source, or from web services such as Yahoo, Weather data, or Facebook. The query language is similar to SQL in syntax, and the open data tables are expressed as XML files and therefore can be mapped into our application, and manipulated as needed. YQL would also allow us to store our data in the Yahoo Sherpa cloud storage (we would not use this for users data, but potentially weather data for instance). There are also community open data tables, encouraging developers to share their open data tables with each other. Below is a picture illustrating obtaining gaining a weather forecast for a specific destination [10]:

weather

JQuery, AJAX & JSON
As mentioned above some of the data retrieved from the various API’s will be in JSON format. JSON stands for Javascript Object Notation. JQuery [11] is a javascript library that provides methods such as instant API data retrieval and easy JSON manipulation. This library would be used to query the API’s using AJAX [12] to provide a synchronous on the fly connection over HTTP.

References
[1] Open Data Within Our Application
[2] http://www.w3.org/XML/
[3] http://www.json.org/
[4] http://www.w3.org/RDF/
[5] http://www.odata.org/
[6] http://www.infoq.com/articles/rest-introduction
[7] http://openweathermap.org/
[8] http://www.w3.org/TR/rdf-sparql-query/
[9] http://graphite.ecs.soton.ac.uk/sparqllib/
[
10] https://www.datatables.org/
[11] https://api.jquery.com/
[12] https://api.jquery.com/jQuery.ajax/

 

, , , , , , , , , , ,

No Comments

Open Data within our Application – Someah & Jokha & Sami

There will be a multitude of different travel data used within our application. When a user accepts an event invitation they will be offered the option to choose their desired method of travel. This can be walking, bus, train, taxi, aeroplane. Koh.Tu.Me will provide suggestions for these different types of travel, complete with the time taken to use this method, prices, locations (e.g bus stops), and people in a close vicinity they can share travel with. In addition to this Koh.Tu.Me will also be using weather data to provide the weather forecast element of the application.

Koh.Tu.Me will be looking to use Open Data as much as possible because this is data that is freely available for anybody to use under an Open Government License [1]. This post will be looking at the different types of travel data we need to use. As Koh.Tu.Me is being created in Southampton by Southampton University Students then potentially a Southampton prototype could be created first to test out the application. This post will be looking at travel data specifically in Southampton, and also for the rest of the UK. Following this, this post will then touch on travel difficulties in different countries, and weather forecast information.

Busses
There are a number of different bus companies in Southampton. UniLink runs the connecting services between all of the University Campus’s and Halls of Residences’s, as well as to both Train Stations and the Airport. BlueStar operates other bus services outside the University to provide services between Southampton, Eastleigh, Winchester, Romsey and Waterside areas of Hampshire.

Southampton Data
Southampton University has made much of it’s data ‘open’ including it’s bus information. The following datasets could be utilised by our application to freely access bus timetable information.

http://id.southampton.ac.uk/dataset/bus-info– this is the open linked data set of all of the latest bus information, including bus routes, bus stops, geographical positioning, and links to bus times.

http://id.southampton.ac.uk/dataset/transport-linkset – this is the open linked data set of bus and train information into the government “Naptan” scheme. Naptan is a system that can uniquely identify all access points to public transport.

http://id.southampton.ac.uk/dataset/transport-locations – this is the open linked data set of the location of bus stops relative to campuses.

UK Data
http://travelinedata.org.uk/nextbuses.htm – this is real time bus information that can be accessed via an API.

Clearly there is a lot of Open Data bus information that could be used within our application. This would mean that this set of data could be obtained and used for free under the Open Government License. An initial version of our social networking application could look to use one service such as NextBusses, and as new iterations get created it could expand to use different bus sets for different cities that have them available such as Southampton.

Trains:
There are also excellent train connections in Southampton by South West Trains, with two train stations: Southampton Central and Southampton Airport Parkway. South West Trains offers the option of group travel on certain journeys, enabling people to save money by travelling together in a group.There are several open data feeds that contain rail information:

Southampton Data
There is less Southampton specific data regarding trains, however there is still one dataset:

http://id.southampton.ac.uk/dataset/transport-linkset provides bus and train information for Southampton.

UK Data
http://www.networkrail.co.uk/data-feeds/ and http://www.opentraintimes.com/ both provide real time train information.

These datasets would definitely provide a large amount of train based data for use within Koh.Tu.Me. Combining this with the bus information would facilitate journeys with multiple types of travel within them.

Taxis:
There are a number of different taxi companies in Southampton, notably Radio Taxis which is widely advertised around Southampton. 

Southampton Data
There is no specific Southampton Open Data for taxi information. There are certain taxi companies such as Radio Taxis (mentioned above) that promote themselves to Southampton University during Freshers Fayre’s and other events. They would be the companies to approach to ask if they would pay to be promoted within our application, or even if they would pay us a small finders fee for any bookings made through Koh.Tu.Me.

UK Data
http://www.owenboswarva.com/opendata/Taxi_and_Private_Hire_Companies.xls – provides a list of taxi and private hire companies within the UK. Unfortunately despite providing Company name and address information they don’t provide phone numbers. Therefore in order to make use of this facility, Koh.Tu.Me could either provide taxi suggestions for the user to go and look up, or do an in-app google search for these taxi companies to provide phone numbers.

Aeroplanes & Ferry
Southampton has an airport and therefore that might be the natural choice to fly from if there were the right flights available. Additionally it also has a Ferry Port down at the docks.

Southampton Data
There is no specific Southampton Airport or Ferry Data although again it might be possible to liase with the airport/ferry port to make their data available to our application.

UK Data
http://openflights.org/data.html – this is an open data set of airports, airlines and flights all around the world. This would allow Koh.Tu.Me to provide information about how to fly to another country to our users. This could of course be used for Southampton flight data.

http://www.traveline.info/tnds.html – this is an open data set of public timetables for various methods of transport including ferries. This equally could also be used for Southampton ferry data.

Walking
As with most cities, the cheapest easiest way to get to and from certain locations is simply to walk. Southampton has certain footpaths that provide shortcuts around the city, and also has safer places to walk through such as the University Campus.

Southampton Data
http://id.southampton.ac.uk/dataset/southampton-postcodes – this is a dataset of the Southampton Postcodes which also contains lat/long information that could be used to identify places within close proximity to each other.

UK Data
http://www.openstreetmap.org/ – this is an open data set of map information which would enable our application to not only look up start and end locations and identify their proximity, but also to potentially provide directions between them.

Conclusions
There is a lot of Open Data available for all of the different travel elements of these locations. This is fantastic news for Koh.Tu.Me as it means not only is there a wealth of data available to use to build up our application, but also this data can be used for free.

Travel issues in different parts of the world:
Each country has different transportation systems that differ due to culture aspects, finance etc. In the Arab Gulf States (Someah is from there) there is a shortage of public transport in most regions, especially small towns. The majority of people use private cars to travel short distance, and aeroplanes to travel long distance. Once Koh.Tu.Me was expanded into an international application it could adopt different travel suggestions and use different data sets depending on the Country the user is in, (or indeed going to).

Weather Forecast Information
OpenWeatherMap is an example of open weather data. This site provides free open data about weather, along with APIs for developers to use within their applications. It receives its data from broadcasts and forecast from more than 40,000 weather stations. It has a variety of information such as week forecasts that would enable users to plan ahead for their events with relevant weather information.

References

[1] http://data.gov.uk/blog/new-open-government-license

, , , , , , , , , , , , , , , , , , , ,

No Comments