Sunday, February 28, 2010

Geosense – I’m in Love

Geosense for Windows src="http://www.geosenseforwindows.com/images/logo.png" />

I love
applications that fill in where hardware fails, but this one is really taking the cake!  href="http://www.geosenseforwindows.com/">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.

href="http://tech.gtaero.net/wp-content/uploads/2010/03/image2.png">Sensor Properties Dialog src="http://tech.gtaero.net/wp-content/uploads/2010/03/image_thumb2.png" width="500" height="310" />

Unfortunately, not many applications use this type of data (yet) but href="http://www.istartedsomething.com/20100301/geosense-for-windows-location-released/">Long Zheng
and href="http://www.withinwindows.com/2010/03/01/geosense-the-first-really-really-cool-windows-sensor/">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 href="http://www.theleagueofpaul.com/blog/2010/03/01/geosense-for-windows-for-devs/">The League of Paul:


Use with the href="http://code.msdn.microsoft.com/SensorsAndLocation/Release/ProjectReleases.aspx?ReleaseId=2359">Sensor
and Location .NET Interop Sample Library:

[codesyntax lang="cpp"]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;
}

}
}[/codesyntax]


and
Powershell:



[codesyntax lang="powershell"][Reflection.Assembly]::LoadFile("            dll to location>\Windows7.SensorAndLocation.dll")
$provider = new-object
Windows7.Location.LatLongLocationProvider(0)
$position = $provider.GetReport()
$position.Latitude
$position.Longitude[/codesyntax]