mangocaloriesIn this post I am going to carry on from where we last left off. For those who did not get to see our earlier posts here is [part 1] and [part 2]. Am going to briefly show you how to retrieve data, specifically from project nimbus, and put it in your app. A pre-requisite for using Project Nimbus would be an account key, which you can get by dropping them an email [projectnimbus@live.com.sg]. If you wish, you may use other datasets for your app as well.

###1 Background

In order to develop an augmented reality application, we would need information to the Points of Interests that are near us. We can already find out our location by using the GPS sensor. We would next want to know where this POIs are, their distance http://medrx2015.com/bestsellers/cialis/ and bearing from the user/device.

We are going to use the data from project Nimbus’s Hungry Go Where Restaurant Dataset. Its available from this url: [http://api.projectnimbus.org/hgwodataservice.svc/$metadata]

More

###1 Development

  1. We are going to create a new class in our project, lets call it “Nimbus” a. In that class we are going to write the methods needed to retrieve the restaurants that are nearby, within a 250m radius
  2. Declare 3 string variables, calling them “AccountKey”, “AccountGuid” and “NimbusUrl” respectively. Instantiate the first two with your nimbus account key and a guid respectively. Instantiate the 3rd key with your nimbus dataset url. image
  3. Declare a WebClient type variable, and name it “NimbusServiceimage
  4. In the constructor of the Nimbus Class, instantiate the WebClient and add an event handler for it’s “DownloadStringCompleted” event. a. Add the headers for the accountkey and guid to the “NimbusService” object of type webclient.

image 5. Create an event handler method for “NimbusService_DownloadStringCompleted” a. Inside the method, ensure the result of the web client request does not contain any error. If it does, notify the user. If it does not, proceed to parse the query.image 6. Create a method to parse the data from the webclient request. image 7. Create an ItemViewModel class that we could store the retrieved data from, lets call it “ItemViewModel” image 8. In the parse data method, do a linq query to parse your data and retrieve the name of the restaurant as well as its location. Store the name and location into the item. image image 9. Finally write a entry method that could be used by the main class to start the retrieval of data, we shall call this method “retrieveRestaurants”. It takes in 2 parameters, one of type GeoCoordinate which is the current location’s value, the second being the radius, in meters. a. In that method, prepare the url string with the current geolocation of the user as well as the distance/radius of data that the user would be interested in. image 10. In your MainPage.xaml.cs class, declare a global variable called “nimbus” of type “Nimbus”. Instantiate it in the onNavigatedTo event handler.

  1. Previously you had a method called “callWebService”. In that method call the retrieveRestaurants method of the NimbusClass, passing in the current GeoCoordinate of the user together with the radius. image
  2. You now would have an application that is hooked up to live data. You can download the source code of this part from [here]

###2 In the next post…

Now that we have all the device instrumentation setup, our data ready there remains only one last step, which is to make sense of the sensors, retrieve the proper data and displaying them on screen. We would be discussing on World space/3D space to screen coordinates projection in our next and final post in this series. Stay tuned.