I am trying to use the GpsAveragingTool class, but even though my SerialPortGpsConnection is collecting coordinates, the averaging tool is not collecting any coordinates. Here is a small application that reproduces the problem. All it does is send some information to Debug when the events of the connection and the averaging tool fire. When the connection has a GPS change, it prints information on both the connection and the averaging tool, and it only prints information on the averaging tool when its event fires.My results are that the connection's event fires frequently, but the averaging tool's event never fires. Worse, the number of coordinates the averaging tool picks up remains zero. I've ensured that the PDOP is well below the quality filter's max PDOP and that the FixStatus matches that of the quality filter.Any ideas on the cause?There's no code on the designer side. You can drop this into a new Smart Device project named "AveragingToolTest" targeting .NET CF 2.0.using System;
using System.ComponentModel;
using System.Diagnostics;
using System.Text;
using System.Windows.Forms;
using ESRI.ArcGIS.Mobile.Geometries;
using ESRI.ArcGIS.Mobile.Gps;
using ESRI.ArcGIS.Mobile.SpatialReferences;
namespace AveragingToolTest
{
public partial class Form1 : Form
{
#region Variables
private SerialPortGpsConnection Connection { get; set; }
private GpsQualityFilter QualityFilter { get; set; }
private Point OutputPoint { get; set; }
private GpsAveragingTool AveragingTool { get; set; }
#endregion
#region Constructor
public Form1()
{
InitializeComponent();
this.Closing += new CancelEventHandler(Form1_Closing);
this.Load +=new EventHandler(Form1_Load);
this.Connection = new SerialPortGpsConnection();
this.Connection.PortName = "COM0";
this.Connection.BaudRate = GpsBaudRate.BaudRate4800;
this.Connection.GpsChanged += new EventHandler(Connection_GpsChanged);
this.QualityFilter = new GpsQualityFilter();
this.QualityFilter.FixStatus = GpsFixStatus.GpsFix;
this.QualityFilter.MaximumPdop = 50;
this.OutputPoint = new Point();
this.AveragingTool = new GpsAveragingTool(this.QualityFilter, this.Connection,
this.OutputPoint, SpatialReference.CreateWgs84SpatialReference());
this.AveragingTool.GoodPositionAcquired += new EventHandler(AveragingTool_GoodPositionAcquired);
}
#endregion
#region GPS Events
private void Connection_GpsChanged(object sender, EventArgs e)
{
this.Output("Connection.GpsChanged:");
this.Output(true,
"FixStatus: " + this.Connection.FixStatus,
"PDOP:" + this.Connection.PositionDilutionOfPrecision,
"AveragingTool.IsConstructing: " + AveragingTool.IsConstructing,
"AveragingTool.IsGpsQualityAcceptable: " + AveragingTool.IsGpsQualityAcceptable,
"AveragingTool.GoodPositionsAcquired: " + AveragingTool.GoodPositionsAcquired);
}
private void AveragingTool_GoodPositionAcquired(object sender, EventArgs e)
{
this.Output("AveragingTool.GoodPositionAcquired");
this.Output(true, "GoodPositionsAcquired: " + AveragingTool.GoodPositionsAcquired);
if (this.AveragingTool.GoodPositionsAcquired >= 5)
{
this.AveragingTool.Stop();
this.AveragingTool.AcceptCurrentVertex();
this.Output(true, "Averaged Vertex: " + this.OutputPoint.Coordinate);
}
}
#endregion
#region Form Events
private void Form1_Load(object sender, EventArgs e)
{
this.Connection.Open();
this.AveragingTool.Start();
}
private void Form1_Closing(object sender, CancelEventArgs e)
{
if (this.AveragingTool.IsConstructing)
{
this.AveragingTool.Stop();
}
if (this.Connection.IsOpen)
{
this.Connection.Close();
}
this.AveragingTool.Dispose();
this.Connection.Dispose();
}
#endregion
#region Debug Output Methods
private const String newline = "\r\n";
private void Output(bool indent, params String[] lines)
{
StringBuilder output = new StringBuilder();
foreach (String line in lines)
{
output.Append((indent ? " " : String.Empty) + line + newline);
}
Debug.Write(output.ToString());
}
private void Output(params String[] lines)
{
this.Output(false, lines);
}
#endregion
}
}