Example #1
0
 public static void OnGpsPositionUpdated(esriGpsPositionInfo position)
 {
     if (GpsPositionUpdated != null)
     {
         GpsPositionUpdated(position);
     }
 }
Example #2
0
        private static void m_RealTimeFeedEvents_Event_PositionUpdated(ref esriGpsPositionInfo position, bool estimate)
        {
            CurrentGpsPositionInfoIsValid = true;
            CurrentGpsPositionInfo        = position;
            IPoint p = new PointClass();

            if (m_CurrentPosition == null)
            {
                m_CurrentPosition = new PointClass();
                m_CurrentPosition.SpatialReference = m_RealTimeFeedManager.RealTimeFeed.SpatialReference;
            }
            m_CurrentPosition.PutCoords(position.longitude, position.latitude);
            p.PutCoords(position.longitude, position.latitude);
            p.SpatialReference = m_RealTimeFeedManager.RealTimeFeed.SpatialReference;
            if ((m_RealTimeFeedManager.Map != null) && (m_RealTimeFeedManager as IGpsDisplayProperties).AutoPan)
            {
                IActiveView map = m_RealTimeFeedManager.Map as IActiveView;
                if (
                    !((p.SpatialReference is IUnknownCoordinateSystem) ||
                      (m_RealTimeFeedManager.Map.SpatialReference is IUnknownCoordinateSystem)))
                {
                    p.Project(m_RealTimeFeedManager.Map.SpatialReference);
                }
                IEnvelope extent = map.Extent;
                extent.CenterAt(p);
                map.Extent = extent;
                map.Refresh();
            }
            OnGpsPositionUpdated(position);
        }
Example #3
0
        /// <summary>
        /// The real-time feed position updated event handler
        /// </summary>
        /// <param name="position">a GPS position information</param>
        /// <param name="estimate">indicates whether this is an estimated time or real time</param>
        void OnPositionUpdated(ref esriGpsPositionInfo position, bool estimate)
        {
            try
            {
                //add the tracking element to the tracking graphics layer (should happen only once)
                if (-1 == m_trackObjectIndex)
                {
                    int index = AddTrackElement(m_globeGraphicsLayer, position);
                    if (-1 == index)
                    {
                        throw new Exception("could not add tracking object");
                    }

                    //cache the element's index
                    m_trackObjectIndex = index;

                    return;
                }
                //get the element by its index
                IElement elem = ((IGraphicsContainer3D)m_globeGraphicsLayer).get_Element(m_trackObjectIndex);

                //keep the previous location
                double lat, lon, alt;
                ((IPoint)elem.Geometry).QueryCoords(out lon, out lat);
                alt = ((IPoint)elem.Geometry).Z;

                //update the element's position
                IPoint point = elem.Geometry as IPoint;
                point.X       = position.longitude;
                point.Y       = position.latitude;
                point.Z       = alt;
                elem.Geometry = (IGeometry)point;

                //update the element in the graphics layer.
                lock (m_globeGraphicsLayer)
                {
                    m_globeGraphicsLayer.UpdateElementByIndex(m_trackObjectIndex);
                }

                IGlobeCamera globeCamera = m_sceneViwer.Camera as IGlobeCamera;

                //set the camera position in order to track the element
                if (m_bTrackAboveTarget)
                {
                    TrackAboveTarget(globeCamera, point);
                }
                else
                {
                    TrackFollowTarget(globeCamera, point.X, point.Y, point.Z, lon, lat, alt);
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Trace.WriteLine(ex.Message);
            }
        }
Example #4
0
        /// <summary>
        /// Adds a sphere element to the given graphics layer at the specified position
        /// </summary>
        /// <param name="globeGraphicsLayer"></param>
        /// <param name="position"></param>
        /// <returns></returns>
        private int AddTrackElement(IGlobeGraphicsLayer globeGraphicsLayer, esriGpsPositionInfo position)
        {
            if (null == globeGraphicsLayer)
            {
                return(-1);
            }

            //create a new point at the given position
            IPoint point = new PointClass();

            ((IZAware)point).ZAware = true;
            point.X = position.longitude;
            point.Y = position.latitude;
            point.Z = 0.0;

            //set the color for the element (red)
            IRgbColor color = new RgbColorClass();

            color.Red   = 255;
            color.Green = 0;
            color.Blue  = 0;

            //create a new 3D marker symbol
            IMarkerSymbol markerSymbol = new SimpleMarker3DSymbolClass();

            //set the marker symbol's style and resolution
            ((ISimpleMarker3DSymbol)markerSymbol).Style             = esriSimple3DMarkerStyle.esriS3DMSSphere;
            ((ISimpleMarker3DSymbol)markerSymbol).ResolutionQuality = 1.0;

            //set the symbol's size and color
            markerSymbol.Size  = 700;
            markerSymbol.Color = color as IColor;

            //crate the graphic element
            IElement trackElement = new MarkerElementClass();

            //set the element's symbol and geometry (location and shape)
            ((IMarkerElement)trackElement).Symbol = markerSymbol;
            trackElement.Geometry = point as IPoint;


            //add the element to the graphics layer
            int elemIndex = 0;

            ((IGraphicsContainer)globeGraphicsLayer).AddElement(trackElement, 0);

            //get the element's index
            globeGraphicsLayer.FindElementIndex(trackElement, out elemIndex);
            return(elemIndex);
        }
Example #5
0
 private void GPSManager_GpsPositionUpdated(esriGpsPositionInfo position)
 {
     if (position.satellitesInUseValid == 1)
     {
         this.lblInuseStateCount.Text = position.satellitesInUse.ToString();
     }
     else
     {
         this.lblInuseStateCount.Text = "N/A";
     }
     this.lblLat.Text  = position.latitude.ToString("0.###");
     this.lblLong.Text = position.longitude.ToString("0.###");
     if (position.altitudeValid == 1)
     {
         this.lblAlti.Text = position.altitude.ToString("0.###");
     }
     else
     {
         this.lblAlti.Text = "N/A";
     }
 }
Example #6
0
 void TrackDynamicObject_PositionUpdated(ref esriGpsPositionInfo position, bool estimate)
 {
 }
 void TrackDynamicObject_PositionUpdated(ref esriGpsPositionInfo position, bool estimate)
 {
   
 }
    /// <summary>
    /// The real-time feed position updated event handler
    /// </summary>
    /// <param name="position">a GPS position information</param>
    /// <param name="estimate">indicates whether this is an estimated time or real time</param>
    void OnPositionUpdated(ref esriGpsPositionInfo position, bool estimate)
    {
      try
      {
        //add the tracking element to the tracking graphics layer (should happen only once)
        if (-1 == m_trackObjectIndex)
        {
          int index = AddTrackElement(m_globeGraphicsLayer, position);
          if (-1 == index)
            throw new Exception("could not add tracking object");

          //cache the element's index
          m_trackObjectIndex = index;

          return;
        }
        //get the element by its index
        IElement elem = ((IGraphicsContainer3D)m_globeGraphicsLayer).get_Element(m_trackObjectIndex);

        //keep the previous location
        double lat, lon, alt;
        ((IPoint)elem.Geometry).QueryCoords(out lon, out lat);
        alt = ((IPoint)elem.Geometry).Z;

        //update the element's position
        IPoint point = elem.Geometry as IPoint;
        point.X = position.longitude;
        point.Y = position.latitude;
        point.Z = alt;
        elem.Geometry = (IGeometry)point;

        //update the element in the graphics layer.
        lock (m_globeGraphicsLayer)
        {
          m_globeGraphicsLayer.UpdateElementByIndex(m_trackObjectIndex);
        }

        IGlobeCamera globeCamera = m_sceneViwer.Camera as IGlobeCamera;

        //set the camera position in order to track the element
        if (m_bTrackAboveTarget)
          TrackAboveTarget(globeCamera, point);
        else
          TrackFollowTarget(globeCamera, point.X, point.Y, point.Z, lon, lat, alt);

      }
      catch (Exception ex)
      {
        System.Diagnostics.Trace.WriteLine(ex.Message);
      }
    }
    /// <summary>
    /// Adds a sphere element to the given graphics layer at the specified position
    /// </summary>
    /// <param name="globeGraphicsLayer"></param>
    /// <param name="position"></param>
    /// <returns></returns>
    private int AddTrackElement(IGlobeGraphicsLayer globeGraphicsLayer, esriGpsPositionInfo position)
    {
      if (null == globeGraphicsLayer)
        return -1;

      //create a new point at the given position
      IPoint point = new PointClass();
      ((IZAware)point).ZAware = true;
      point.X = position.longitude;
      point.Y = position.latitude;
      point.Z = 0.0;

      //set the color for the element (red)
      IRgbColor color = new RgbColorClass();
      color.Red = 255;
      color.Green = 0;
      color.Blue = 0;

      //create a new 3D marker symbol
      IMarkerSymbol markerSymbol = new SimpleMarker3DSymbolClass();

      //set the marker symbol's style and resolution
      ((ISimpleMarker3DSymbol)markerSymbol).Style = esriSimple3DMarkerStyle.esriS3DMSSphere;
      ((ISimpleMarker3DSymbol)markerSymbol).ResolutionQuality = 1.0;

      //set the symbol's size and color
      markerSymbol.Size = 700;
      markerSymbol.Color = color as IColor;

      //crate the graphic element
      IElement trackElement = new MarkerElementClass();

      //set the element's symbol and geometry (location and shape)
      ((IMarkerElement)trackElement).Symbol = markerSymbol;
      trackElement.Geometry = point as IPoint;


      //add the element to the graphics layer
      int elemIndex = 0;
      ((IGraphicsContainer)globeGraphicsLayer).AddElement(trackElement, 0);

      //get the element's index
      globeGraphicsLayer.FindElementIndex(trackElement, out elemIndex);
      return elemIndex;
    }