Geosense – I’m in Love

I love applications that fill in where hardware fails, but this one is really taking the cake! Geosense for Windows gives you the capabilities of a GPS sensor in your computer (but without the actual hardware!) It uses Google Location Services to triangulate your location and provide your coordinates to applications that request them.
Unfortunately, not many applications use this type of data (yet) but Long Zheng and Rafael Rivera are hoping that with this new default driver for PCs without GPS, that many more developers will embrace the creation of geo-location in desktop applications.
Continue Reading for Code Snippets
To that effect, I’ve included some Code Snippets that were originally posted on The League of Paul:
Use with the Sensor and Location .NET Interop Sample Library:
using Windows7.Location; public class Location { public String City { get; set; } public String Country { get; set; } public double Latitude { get; set; } public double Longitude { get; set; } } public static class GlobalPosition { private static LatLongLocationProvider _provider; private static CivicAddressLocationProvider _civicprovider; private static bool _loadproviderthrowsexception = false; private const uint DEFAULT_REPORT_INTERVAL = 0; public static Location GetLocation() { Location l = new Location(); try { if (_loadproviderthrowsexception) { return null; } if (_provider == null) { _provider = new LatLongLocationProvider(DEFAULT_REPORT_INTERVAL); _civicprovider = new CivicAddressLocationProvider(DEFAULT_REPORT_INTERVAL); } var y = _civicprovider.GetReport() as CivicAddressLocationReport; l.City = y.City; l.Country = y.CountryOrRegion; var x = _provider.GetReport() as LatLongLocationReport; l.Latitude = x.Latitude; l.Longitude = x.Longitude; return l; } catch (Exception ex) { return null; } } }
and Powershell:
[Reflection.Assembly]::LoadFile("\Windows7.SensorAndLocation.dll") $provider = new-object Windows7.Location.LatLongLocationProvider(0) $position = $provider.GetReport() $position.Latitude $position.Longitude


