当前仓库属于暂停状态,部分功能使用受限,详情请查阅 仓库状态说明
1 Star 0 Fork 43

井三崩 / Module_Qt_Geography
暂停

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README

Qt_Geography

项目类关系图见下: 类图

功能1:地理多边形

封装Qt的QGeoCircle、QGeoRectangle和QPolygonF类,成为地理多边形、地理圆形和地理矩形,共同的基类为MyQtGeoShapeBase。
提供一个常用功能:查询某个坐标是否在某个地理形状内。
当从西向东运动的时候,经度值逐渐增大,直到东经180度后突变为-180度(西经用复数表示),然后再逐渐增长到-179度,-178度,以此类推。当一个空间区域跨东经180度的时候,进行特殊处理,判断覆盖范围。下图是地球上的经度划分:

经度

如下图所示,是一个横跨180度经度线的多边形区域,绿色点是海上的目标。通过提供的GeoShapes库,可以生成多边形空间对象,判断某个坐标点是否在该多边形内。

横跨国际日期变更线的多边形区域

功能2:地理扇形及扇环

在地理圆形的基础上进一步封装为地理扇形,地理扇形的基础上封装为地理扇环。

功能3:空间距离计算及日出日落计算

  • 计算两个经纬度间的距离(great circle)
  • 计算给定经纬度给定日期的日出日落时间

基类接口

virtual bool containsPoint(QGeoCoordinate geoCoordinate, Qt::FillRule fillRule=Qt::OddEvenFill) =0;
qint32 getGeoShapObjectID() const;
void setGeoShapObjectID(const qint32 &value);  
virtual qreal distanceFromPointInMeters(const QGeoCoordinate &geoCoordPoint)=0;

多边形类接口

// use x to represent longitude, y to represent latitude.
// Note the difference from QGeoCoordinate: first parameter is latitude, second parameter is longitude.
explicit MyQtGeoPolygon(QVector<QPointF> paramGeoPointsInDegreesBeforeTranslate, bool *ok,QObject *parent = 0);
virtual bool containsPoint(QGeoCoordinate geoCoordinate, Qt::FillRule fillRule=Qt::OddEvenFill) ;
QPolygonF getPolygonFTranslated() const;
QVector<QPointF> getGeoPointsInDegreesBeforeTranslate() const;
QVector<QPointF> getGeoPointsInDegreeAfterTranslate() const;

矩形类接口

explicit MyQtGeoRectangle(const QGeoCoordinate &bottomLeft, const QGeoCoordinate &topRight, bool *ok, QObject *parent = 0);
virtual bool containsPoint(QGeoCoordinate geoCoordinate, Qt::FillRule fillRule=Qt::OddEvenFill) ;
QGeoRectangle getGeoRectangle() const;
void setGeoRectangle(const QGeoRectangle &value);

圆形类接口

explicit MyQtGeoCircle(const QGeoCoordinate &center, qreal radiusInMeters,bool *ok,QObject *parent = 0);
virtual bool containsPoint(QGeoCoordinate geoCoordinate, Qt::FillRule fillRule=Qt::OddEvenFill) ;
QGeoCircle getGeoCircle() const;
void setGeoCircle(const QGeoCircle &value);

扇形类接口

explicit  MyQtGeoCircularSector(const QGeoCoordinate &center, const qreal &radiusInMeters,bool *ok,const qint32 &geoShapeObjectID, const QString &name, const double &startDirectionInDegree,const double &endDirectionInDegree,  QObject *parent = 0);
virtual bool containsPoint(QGeoCoordinate geoCoordinate, Qt::FillRule fillRule=Qt::OddEvenFill) ;
virtual Enum_MyQtGeoShapeType getGeoShapeType() const;

扇环类接口

explicit  MyQtGeoAnnularSector(const QGeoCoordinate &center, const qreal &radiusInMeters,bool *ok,const qint32 
&geoShapeObjectID, const QString &name, const double &startDirectionInDegree, const double &endDirectionInDegree,
 const float &radiusInnerInKM, QObject *parent = 0);
virtual bool containsPoint(QGeoCoordinate geoCoordinate, Qt::FillRule fillRule=Qt::OddEvenFill) ;
virtual Enum_MyQtGeoShapeType getGeoShapeType() const;  

线段类接口

explicit MyQtGeoLineSegment(const QGeoCoordinate &geoCoordStart, const QGeoCoordinate &geoCoordEnd, bool *ok,
                                const   qint32 &geoShapeObjectID, const QString &name, QObject *parent = 0);
virtual bool containsPoint(const QGeoCoordinate &geoCoordinate, Qt::FillRule fillRule=Qt::OddEvenFill)=0 ; //To be implemented
virtual qreal distanceFromPointInMeters(const QGeoCoordinate &geoCoordPoint); //To be implemented
virtual Enum_MyQtGeoShapeType getGeoShapeType() const;
qreal getLineLength() const;

Geography接口

static  qreal GetDistance(double lat1, double lng1, double lat2, double lng2);
static  qreal GetAzimuth(double lat1, double lng1, double lat2, double lng2);
static  float calculateSunriseAsUTCHour(int year, int month, int day, float lat, float lng);
static  float calculateSunsetAsUTCHour(int year, int month, int day, float lat, float lng);

使用示例

构造一个跨过东经180度线的矩形,然后判断(20,180)这一个点是否在区域内。

QGeoCoordinate coorBottomLeft(10,160); //第一个参数是纬度,第二个参数是经度
QGeoCoordinate coorUpperRight(40,-160);
MyQtGeoRectangle *myGeoRect=new MyQtGeoRectangle (coorBottomLeft,coorUpperRight,&ok);
qDebug()<<myGeoRect->getGeoRectangle().bottomLeft()<<myGeoRect->getGeoRectangle().bottomRight();
MyQtGeoShapeBase *myShape=myGeoRect;
QGeoCoordinate pFTestb(20,180);
qDebug()<<myShape->containsPoint(pFTestb);

空文件

简介

基于Qt的GUI库开发的地理信息模块,处理了180度经线的问题,提供:矩形、圆形、多边形、线段、折线、扇形、扇环类。提供了日出日落计算时间等方法。 展开 收起
C++
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
C++
1
https://gitee.com/jingsanbeng/Qt_GeoPolygon.git
git@gitee.com:jingsanbeng/Qt_GeoPolygon.git
jingsanbeng
Qt_GeoPolygon
Module_Qt_Geography
master

搜索帮助