开发者

What is the equivalent of GPS Intermediate Driver for the Windows platform?

With Windows Mobile development your .Net applications could make use of the GPS Intermediate Driver to ensure that multiple applications can make use of the GPS device without one application locking the other. I have a mobile application (.Net Compact Framework) that makes use of the GPS Intermediate Driver, and I also have a Windows version of this application with the GPS functionality excluded. Now I am needing to build the GPS functionality in for a tablet PC that is running Windows 7 and which has a GPS receiver built into it. Connections to the GPS receiver are established via a com port.

Is there an equivalent of GPS Intermedi开发者_如何学编程ate Driver for Windows that will allow my application to use the GPS receiver but without blocking the GPS receiver for other navigation software that is runnning on the PC?


Is right! GeoFramework it's a best free GPS framework. If you need to project/Deproject the coordinates in a plane, these classes can help you:

public interface IProjector
    {
        PointD Deproject(PointD projectedCoordinate);
        PointD Project(PointD geographicCoordinate);
        PointD Project(Position position);
        PointD Project(Latitude latitude, Longitude longitude);
    }

[StructLayout(LayoutKind.Sequential)]
    public struct PointD : IEquatable<PointD>, IFormattable
    {
        private double _x;
        private double _y;
        public static PointD Empty;
        public PointD(double x, double y)
        {
            this._x = x;
            this._y = y;
        }

        public PointD(PointD p)
        {
            this._x = p.X;
            this._y = p.Y;

        }

        public double X
        {
            get
            {
                return this._x;
            }
            set
            {
                this._x = value;
            }
        }
        public double Y
        {
            get
            {
                return this._y;
            }
            set
            {
                this._y = value;
            }
        }
        public bool IsEmpty
        {
            get
            {
                return this.Equals(Empty);
            }
        }
        public Point ToPoint()
        {
            return new Point((int)this._x, (int)this._y);
        }

        public void Normalize()
        {
            double num = Math.Sqrt((this.X * this.X) + (this.Y * this.Y));
            this.X /= num;
            this.Y /= num;
        }

        public static PointD FromSize(Size size)
        {
            return new PointD((double)size.Width, (double)size.Height);
        }

        public static PointD FromSize(SizeF size)
        {
            return new PointD((double)size.Width, (double)size.Height);
        }

        public static bool operator ==(PointD left, PointD right)
        {
            return left.Equals(right);
        }

        public static bool operator !=(PointD left, PointD right)
        {
            return !left.Equals(right);
        }

        public static PointD operator -(PointD left, PointD right)
        {
            return new PointD(left.X - right.X, left.Y - right.Y);
        }

        public override bool Equals(object obj)
        {
            return ((obj is PointD) && this.Equals((PointD)obj));
        }

        public override int GetHashCode()
        {
            return (this._x.GetHashCode() ^ this._y.GetHashCode());
        }

        public override string ToString()
        {
            return this.ToString("G", CultureInfo.CurrentCulture);
        }

        public bool Equals(PointD other)
        {
            return (this._x.Equals(other.X) && this._y.Equals(other.Y));
        }

        public string ToString(string format, IFormatProvider formatProvider)
        {
            CultureInfo info = (CultureInfo)formatProvider;
            return (this._x.ToString(format, formatProvider) + info.TextInfo.ListSeparator + " " + this._y.ToString(format, formatProvider));
        }

        static PointD()
        {
            Empty = new PointD(0.0, 0.0);
        }
    }

public class Projector : IProjector
    {


        private const double DEGREEStoRADIANS = System.Math.PI / 180;
        private const double RADIANStoDEGREES = 180 / System.Math.PI;

        /* These values represent the equatorial radius of the WGS84 ellipsoid in meters.
         * resulting in projected coordinates which are also in meters
         */
        private const double WGS84SEMIMAJOR = 6378137.0;
        private const double ONEOVERWGS84SEMIMAJOR = 1.0 / WGS84SEMIMAJOR;



        public PointD Deproject(PointD projectedCoordinate)
        {

            .PointD result = new PointD();

            // Calculate the geographic X coordinate (longitude)
            result.X = (float)(projectedCoordinate.X * ONEOVERWGS84SEMIMAJOR / System.Math.Cos(0) * RADIANStoDEGREES);

            // Calculate the geographic Y coordinate (latitude)
            result.Y = (float)(projectedCoordinate.Y * ONEOVERWGS84SEMIMAJOR * RADIANStoDEGREES);

            return result;
        }

        public PointD Project(PointD geographicCoordinate)
        {

          PointD result = new PointD();

            // Calculate the projected X coordinate
            result.X = (float)(geographicCoordinate.X * DEGREEStoRADIANS * System.Math.Cos(0) * WGS84SEMIMAJOR);

            // Calculate the projected Y coordinate
            result.Y = (float)(geographicCoordinate.Y * DEGREEStoRADIANS * WGS84SEMIMAJOR);

            // Return the result
            return result;       

        }

        public PointD Project(Position position)
        {
           PointD td = new PointD();
            td.X = ((position.Latitude.DecimalDegrees * DEGREEStoRADIANS) * System.Math.Cos(0.0)) * WGS84SEMIMAJOR;
            td.Y = (position.Longitude.DecimalDegrees * DEGREEStoRADIANS) * WGS84SEMIMAJOR;
            return td;
        }

        public PointD Project(Latitude latitude, Longitude longitude)
        {
            PointD td = new RTGeoFramework.Math.PointD();
            td.X = ((latitude.DecimalDegrees * DEGREEStoRADIANS) * System.Math.Cos(0.0)) * WGS84SEMIMAJOR;
            td.Y = (longitude.DecimalDegrees * DEGREEStoRADIANS) * WGS84SEMIMAJOR;
            return td;
        }

    }


I solved this by making use of the GeoFramework, which is open source code for handling location services. The website for GeoFramework is here: http://geoframework.codeplex.com/ and as it mentions on its site, GeoFramework is now part of the DotSpatial open source project, which can be found here: http://dotspatial.codeplex.com/

One advantage, I found with GeoFramework is that it runs both on Windows and Windows Mobile, which took me a step further in my goal of having the application running on both Windows and Windows Mobile platforms, but with only one code base.

As I mentioned in the comments, I did have a problem with both the navigation software that my client is using and my application both trying to open the same com port which resulted in one of these applications not being able to establish a connection to the com port. I resolved this by making use of a com port splitter which turned the one physical com port into two virtual com ports. In this way, both my application and the navigation software are able to read the location data at the same time.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜