Accuracy issues when calling GeoCoordinateWatcher

%3CLINGO-SUB%20id%3D%22lingo-sub-1519830%22%20slang%3D%22en-US%22%3EAccuracy%20issues%20when%20calling%20GeoCoordinateWatcher%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1519830%22%20slang%3D%22en-US%22%3E%3CP%3EI%20am%20using%20PowerShell%20to%20have%20a%20script%20on%20Windows%2010%20that%20reports%20back%20some%20position%20information.%20The%20laptops%20have%20GPS%20receivers%20built%20into%20them%2C%20when%20using%20software%20to%20query%20GPS%20information%20via%20a%20comm%20port%2C%20the%20position%20information%20is%20highly%20accurate%2C%20within%20a%20few%20meters.%20When%20I%20use%20the%20Location%20API%20via%20PowerShell%2C%20the%20location%20reported%20is%20usually%20within%20300%20meters%20at%20best%2C%2030K%2B%20meters%20at%20worst.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EHere%20is%20a%20sample%20of%20the%20code%20I'm%20using%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-powershell%22%3E%3CCODE%3E%23%20Time%20to%20see%20if%20we%20can%20get%20some%20location%20information%0A%23%20Required%20to%20access%20System.Device.Location%20namespace%0AAdd-Type%20-AssemblyName%20System.Device%0A%0A%23%20Create%20the%20required%20object%0A%24GeoWatcher%20%3D%20New-Object%20System.Device.Location.GeoCoordinateWatcher%0A%0A%23%20Begin%20resolving%20current%20locaton%0A%24GeoWatcher.Start()%0A%0Awhile%20((%24GeoWatcher.Status%20-ne%20'Ready')%20-and%20(%24GeoWatcher.Permission%20-ne%20'Denied'))%20%0A%7B%0A%23Wait%20for%20discovery%0AStart-Sleep%20-Seconds%2015%0A%7D%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CBR%20%2F%3EThe%20original%20code%20sample%20I%20found%20on%20the%20internet%20had%20the%20discovery%20pause%20for%20100%20milliseconds%2C%20I've%20tried%20going%20as%20high%20as%2045%20seconds%20with%20no%20change%20in%20accuracy.%20I%20get%20the%20position%20via%20this%20method%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-powershell%22%3E%3CCODE%3E%23Select%20the%20relevent%20results.%0A%24LocationArray%20%3D%20%24GeoWatcher.Position.Location%0AAfter%20reviewing%20the%20documentation%20for%20System.Device.Location%2C%20I%20did%20try%20using%3A%0A%0ASystem.Device.Location.GeoCoordinateWatcher(1)%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CBR%20%2F%3EFor%20a%20desired%20accuracy%20of%20%22high%22%20but%20the%20results%20appear%20to%20be%20roughly%20the%20same.%20I%20did%20confirm%20my%20request%20for%20higher%20accuracy%20data%20is%20being%20processed%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-powershell%22%3E%3CCODE%3EDesiredAccuracy%20%3A%20High%0AMovementThreshold%20%3A%200%0APermission%20%3A%20Granted%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CBR%20%2F%3EIs%20there%20a%20way%20for%20me%20to%20get%20GPS%20information%20via%20the%20Location%20API%20that%20is%20as%20accurate%20as%20when%20I%20query%20the%20GPS%20comm%20port%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1519830%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EPowerShell%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
Occasional Visitor

I am using PowerShell to have a script on Windows 10 that reports back some position information. The laptops have GPS receivers built into them, when using software to query GPS information via a comm port, the position information is highly accurate, within a few meters. When I use the Location API via PowerShell, the location reported is usually within 300 meters at best, 30K+ meters at worst.

 

Here is a sample of the code I'm using:

 

# Time to see if we can get some location information
# Required to access System.Device.Location namespace
Add-Type -AssemblyName System.Device

# Create the required object
$GeoWatcher = New-Object System.Device.Location.GeoCoordinateWatcher

# Begin resolving current locaton
$GeoWatcher.Start()

while (($GeoWatcher.Status -ne 'Ready') -and ($GeoWatcher.Permission -ne 'Denied')) 
{
#Wait for discovery
Start-Sleep -Seconds 15
}

 


The original code sample I found on the internet had the discovery pause for 100 milliseconds, I've tried going as high as 45 seconds with no change in accuracy. I get the position via this method:

 

 

#Select the relevent results.
$LocationArray = $GeoWatcher.Position.Location
After reviewing the documentation for System.Device.Location, I did try using:

System.Device.Location.GeoCoordinateWatcher(1)

 


For a desired accuracy of "high" but the results appear to be roughly the same. I did confirm my request for higher accuracy data is being processed:

 

 

DesiredAccuracy : High
MovementThreshold : 0
Permission : Granted

 


Is there a way for me to get GPS information via the Location API that is as accurate as when I query the GPS comm port?

0 Replies