C# Windows平台的GPS中间驱动程序等效于什么?
使用Windows Mobile development,您的.Net应用程序可以使用GPS中间驱动程序来确保多个应用程序可以使用GPS设备,而无需一个应用程序锁定另一个应用程序。我有一个移动应用程序(.Net Compact Framework),它使用GPS中间驱动程序,我还有一个Windows版本的此应用程序,不包括GPS功能。现在我需要为一台运行Windows7的平板电脑内置GPS功能,该电脑内置GPS接收器。通过com端口建立与GPS接收器的连接C# Windows平台的GPS中间驱动程序等效于什么?,c#,.net,windows,gps.net,C#,.net,Windows,Gps.net,使用Windows Mobile development,您的.Net应用程序可以使用GPS中间驱动程序来确保多个应用程序可以使用GPS设备,而无需一个应用程序锁定另一个应用程序。我有一个移动应用程序(.Net Compact Framework),它使用GPS中间驱动程序,我还有一个Windows版本的此应用程序,不包括GPS功能。现在我需要为一台运行Windows7的平板电脑内置GPS功能,该电脑内置GPS接收器。通过com端口建立与GPS接收器的连接 是否有一个相当于Windows的GPS
是否有一个相当于Windows的GPS中间驱动程序,允许我的应用程序使用GPS接收器,但不会阻止PC上运行的其他导航软件的GPS接收器?我通过使用GeoFramework解决了这个问题,GeoFramework是处理定位服务的开放源代码。GeoFramework的网站在这里:正如它在网站上提到的,GeoFramework现在是DotSpatial开源项目的一部分,可以在这里找到: 我发现GeoFramework的一个优点是它可以在Windows和Windows Mobile上运行,这使我进一步实现了让应用程序同时在Windows和Windows Mobile平台上运行,但只使用一个代码库的目标
正如我在评论中提到的,我的客户端使用的导航软件和我的应用程序都试图打开同一个com端口,这导致其中一个应用程序无法建立到com端口的连接。我通过使用com端口拆分器解决了这个问题,该拆分器将一个物理com端口转换为两个虚拟com端口。这样,我的应用程序和导航软件都可以同时读取位置数据。我通过使用GeoFramework解决了这个问题,GeoFramework是处理位置服务的开放源代码。GeoFramework的网站在这里:正如它在网站上提到的,GeoFramework现在是DotSpatial开源项目的一部分,可以在这里找到: 我发现GeoFramework的一个优点是它可以在Windows和Windows Mobile上运行,这使我进一步实现了让应用程序同时在Windows和Windows Mobile平台上运行,但只使用一个代码库的目标
正如我在评论中提到的,我的客户端使用的导航软件和我的应用程序都试图打开同一个com端口,这导致其中一个应用程序无法建立到com端口的连接。我通过使用com端口拆分器解决了这个问题,该拆分器将一个物理com端口转换为两个虚拟com端口。这样,我的应用程序和导航软件都可以同时读取位置数据。没错!GeoFramework这是一个最好的免费GPS框架。 如果需要投影/取消投影平面中的坐标,这些类可以帮助您:
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;
}
}
公共接口IProjector
{
点式项目(点式项目坐标);
点式项目(点式地理坐标);
PointD项目(职位);
PointD项目(纬度、经度);
}
[StructLayout(LayoutKind.Sequential)]
公共结构点D:IEquatable,IFormattable
{
私人双x;
私人双人房;
公共静态指针为空;
公共点D(双x,双y)
{
这个.x=x;
这个._y=y;
}
公共点D(点D p)
{
这个.x=p.x;
这个._y=p.y;
}
公共双X
{
得到
{
把这个还给我;
}
设置
{
这是._x=值;
}
}
公共双Y
{
得到
{
把这个还给我;
}
设置
{
这个。_y=值;
}
}
公共图书馆是空的
{
得到
{
返回此值。等于(空);
}
}
公共点拓扑点()
{
返回新点((int)this.x,(int)this.y);
}
公共空间正常化()
{
double num=Math.Sqrt((this.X*this.X)+(this.Y*this.Y));
这个.X/=num;
这个.Y/=num;
}
公共静态点D FromSize(大小)
{
返回新的PointD((双精度)size.Width,(双精度)size.Height);
}
公共静态点d FromSize(SizeF size)
{
返回新的PointD((双精度)size.Width,(双精度)size.Height);
}
公共静态布尔运算符==(左点D,右点D)
{
返回左。等于(右);
}
公共静态布尔运算符!=(左点,右点)
{
返回!左。等于(右);
}
公共静态PointD运算符-(PointD left,PointD right)
{
返回新的点D(left.X-right.X,left.Y-right.Y);
}
公共覆盖布尔等于(对象对象对象)
{
返回((obj是PointD)&&this.Equals((PointD)obj));
}
公共覆盖int GetHashCode()
{
返回(this.x.GetHashCode()^this.y.GetHashCode());
}
公共重写字符串ToString()
{
返回此.ToString(“G”,CultureInfo.CurrentCulture);
}
公共布尔等于(指向其他)
{
返回(this.x.Equals(other.x)&&this.y.Equals(other.y));
}
公共字符串到字符串(字符串格式,IFormatProvider formatProvider)
{
CultureInfo信息=(CultureInfo)格式提供程序;
返回(这个)。