I am having trouble coding my own GPS Data Collection workflow.Basically I want the user to click a button (Start GPS) and then it should average based on the application settings and layers' gps quality.Then show the attributes page and then save the attributes once completed.Here is what I have so far:It works on its own, and will put the point on the map and fill in the 2 attributes hardcoded below. But I don't want it to be like that. Can someone please help, I am using ArcGIS Mobile 10, the out of the box solution.Thanks!void StartAveraging()
{
CurrentFeature();
// set quality filter
GpsQualityFilter quality = new GpsQualityFilter();
quality.MaximumPdop = _feature.FeatureLayerInfo.CurrentGpsQualityFilter.MaximumPdop;
quality.FixStatus = GpsFixStatus.GpsFix;
try
{
pt = new ESRI.ArcGIS.Mobile.Geometries.Point();
m_gpsAveragingTool = new GpsAveragingTool(quality, MobileApplication.Current.GpsConnectionManager.Connection, pt, MobileApplication.Current.Project.SpatialReference);
m_gpsAveragingTool.GoodPositionAcquired += new EventHandler(m_gpsAveragingTool_GoodPositionAcquired6);
//m_gpsAveragingTool.GpsQualityChanged += new EventHandler(m_gpsAveragingTool_GpsQualityChanged);
// apply offset
//int distance = Convert.ToInt32(textBoxDistance.Text.Trim());
//int bearing = Convert.ToInt32(textBoxBearing.Text.Trim());
//// the distance unit can be specified here as well
//gpstool.ApplyOffset(distance, bearing, ESRI.ArcGIS.Mobile.SpatialReferences.Unit.Mile);
m_gpsAveragingTool.Start();
m_gpsAveragingSettings = _feature.FeatureLayerInfo.CurrentGpsAveragingSettings;
}
catch (Exception ex)
{
System.Windows.MessageBox.Show(ex.ToString());
}
}
void m_gpsAveragingTool_GoodPositionAcquired6(object sender, EventArgs e)
{
if (!m_gpsAveragingTool.IsConstructing)
return;
System.Windows.MessageBox.Show(m_gpsAveragingTool.GoodPositionsAcquired.ToString());
if (m_gpsAveragingTool.GoodPositionsAcquired >= m_gpsAveragingSettings.MinimumPositions)
{
System.Windows.MessageBox.Show("Before Accepting");
m_gpsAveragingTool.AcceptCurrentVertex();
System.Windows.MessageBox.Show("---- Accept Current Vertex ----- ");
FeatureLayer ptlayer = MobileApplication.Current.Project.FindFeatureLayer("Dose Rates");
FeatureDataTable ftable = ptlayer.GetDataTable();
FeatureDataRow newFeature = ftable.NewRow();
newFeature["VALUE"] = Convert.ToDouble("3");
newFeature["UNIT"] = "mSv/h";
newFeature.Geometry = pt;
ftable.Rows.Add(newFeature);
System.Windows.MessageBox.Show("Adds new Feature");
// Let user edit attributes
//if (_editFeatureAttributesPage == null)
// _editFeatureAttributesPage = new EditFeatureAttributesPage();
//System.Windows.MessageBox.Show("Event Handlers for Attributes Page");
//_editFeatureAttributesPage.ClickOk += new EventHandler(_editFeatureAttributesPage_ClickOk);
//_editFeatureAttributesPage.ClickCancel += new EventHandler(_editFeatureAttributesPage_ClickCancel);
//_editFeatureAttributesPage.Feature = _feature;
//MobileApplication.Current.Transition(_editFeatureAttributesPage);
ftable.SaveInFeatureLayer();
System.Windows.MessageBox.Show("Saves Feature");
}
}
void CurrentFeature()
{
try
{
Cursor.Current = Cursors.WaitCursor;
// Cache homepage for the application
// Once data collection is done, we come back to this cached page
_homePage = MobileApplication.Current.CurrentPage;
// Reset _feature and _featureType
_feature = null;
_featureType = FindFeatureTypeByName("Dose Rates");
if (_featureType == null)
{
ESRI.ArcGIS.Mobile.Client.Windows.MessageBox.ShowDialog("Can't find " + "Dose Rates" + ".", "Warning");
return;
}
// Create a new Feature, this will automatically call StartEditing on this feature
_feature = new Feature(_featureType, null);
}
catch (Exception ex)
{
System.Windows.MessageBox.Show(ex.ToString());
}
}