Today's Mobile Monday post is one that I thought could dispatch a number of birds with a single post...

Show off a kind of cool OData data source

How to use your location and others to see how "close" you are

Help you find your local Windows Phone Champion

Give you an app, with source, that brings both of those together

What do you think of when you hear the word “Champ”? Someone who is the best? A sports champion? How about someone who fights for a cause? Here at Microsoft we have employees called “Developer Evangelists”. Part of their job is to help get the word out about Microsoft products and technologies. The other part of their job is to champion our developers. Here in Windows Phone we call our evangelists “Phone Champs”. Champs ensure our developers get exactly the help & support they need and are the voice of the developer community. They are all experts on our platform and serve as local resources to answer questions from current or prospective developers. Champs can help you troubleshoot a problem in your app and can help you get your hands on a phone for testing. Oh, and some of our Champs are really funny and can tell you a good joke or two. So how do you find one of our great Phone Champs? Today I’m happy to announce a new application to help you find them. We originally wanted to call the app “Champ Acquisition and Discovery 1.0 for Workgroups Windows Phone Edition.” Luckily cooler heads prevailed and we’re calling it “Find My Champ”. ... Get the App Go download the app’s source code. Compile the code in our dev tools and side-load Find My Champ onto your developer device or into the emulator. The app will also be in the Marketplace soon for you to download. Find your local Phone Champ and get in touch with them. Ask them for help with your app or to let you know about events or hackathons in your area. We’d love to get your feedback on the Find My Champ application. Tell us what we can do to make it more useful. You can also come help us improve the app on Codeplex. Additionally, I suspect that many of you will have creative ideas for how to use the Champs OData feed in other applications, mashups, etc. Please let me know what you create!

The first thing that I thought was cool was that this is backed on an OData feed. This means that if we, the development community want to present our own view of the data, in our own apps, we can very easily.

Using the OData feed is very easy. Here's a snap from the must have LINQPad utility querying the feed.

LINQPad makes it almost too easy to play with this feed. Say I want all the Champs with a Last Name starting with E, order by LastName?

Or who have a MSDN blog and also have a Twitter account?

Okay, OData via Linq is cool, but what if you want the actual OData URL for this query? Again, LINQPad makes that click easy. Just click on the "SQL" right above the results;

Then to maybe finally blow your mind, did you know Notepad can open URL's?

So we're got the data, lets check out the app source.

First, when you download the source, you'll need to add one reference, easily done via NuGet.

When you first open the Solution you'll see this (if you expand the given items). Note the warning/missing icons;

Fire up NuGet and search for "SilverlightToolkitWP"

Click install.

That's it. You should now be good to go and able to run the app in the Emulator.

When first running the app in the Emulator, the Local list will be this default list. If you want to see the local people for a given location, set the location and then re-run the app (refresh doesn't yet seem to take a change in location into account).

So here I set the location;

Then exit and re-run the app in the Emulator.

Set to another location, exit and rerun the app. You don't need to kill the emulator or debugging session, just re-run it in the emulator (if that makes sense?)

The source is pretty easily readable and spelunkable;

Data binding is used as you would expect.

One of the things I thought key was how "local" was determined. How was your location and the Champ's Lat/Long's used to determine "local?"

public static double GetDistance(double fromLatitude, double fromLongitude, double toLatitude, double toLongitude) { int earthRadius = 6371; // earth's radius (mean) in km double chgLat = DegreeToRadians(toLatitude - fromLatitude); double chgLong = DegreeToRadians(toLongitude - fromLongitude); double a = Math.Sin(chgLat / 2) * Math.Sin(chgLat / 2) + Math.Cos(DegreeToRadians(fromLatitude)) * Math.Cos(DegreeToRadians(toLatitude)) * Math.Sin(chgLong / 2) * Math.Sin(chgLong / 2); double c = 2 * Math.Atan2(Math.Sqrt(a), Math.Sqrt(1 - a)); double d = earthRadius * c; return d; } private static double DegreeToRadians(double value) { return Math.PI * value / 180.0; }

private void UpdateDistance() { if (GeoData.Status != GeoPositionStatus.Ready) return; // when position is updated, update distance var _FromLat = GeoData.Location.Latitude; var _FromLong = GeoData.Location.Longitude; var _ToLat = (double)Latitude; var _ToLong = (double)Longitude; this.DistanceAway = FMCLocation.GetDistance(_FromLat, _FromLong, _ToLat, _ToLong); } // this is the same as PropertyChanged("Distance"), just easier to use public event EventHandler DistanceChanged; private double m_DistanceAway; public double DistanceAway { get { return m_DistanceAway; } set { m_DistanceAway = value; OnPropertyChanged("DistanceAway"); OnPropertyChanged("IsLocal"); if (DistanceChanged != null) DistanceChanged(this, EventArgs.Empty); } } public bool IsLocal { get { return (DistanceAway > 0 && DistanceAway < 250); } }

If you're looking for help in building your Windows Phone 7 applications and are looking for help, think about contacting your local Champ. That's part of their job and desire, to be there to help you. Finding them, is now super easy, via this app (which you have to agree is kind of meta-cool...