代码拉取完成,页面将自动刷新
同步操作将从 iOceanPlus_Modules/Module_Qt_Geography 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
项目类关系图见下:
封装Qt的QGeoCircle、QGeoRectangle和QPolygonF类,成为地理多边形、地理圆形和地理矩形,共同的基类为MyQtGeoShapeBase。
提供一个常用功能:查询某个坐标是否在某个地理形状内。
当从西向东运动的时候,经度值逐渐增大,直到东经180度后突变为-180度(西经用复数表示),然后再逐渐增长到-179度,-178度,以此类推。当一个空间区域跨东经180度的时候,进行特殊处理,判断覆盖范围。下图是地球上的经度划分:
如下图所示,是一个横跨180度经度线的多边形区域,绿色点是海上的目标。通过提供的GeoShapes库,可以生成多边形空间对象,判断某个坐标点是否在该多边形内。
在地理圆形的基础上进一步封装为地理扇形,地理扇形的基础上封装为地理扇环。
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 ¢er, 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 ¢er, 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 ¢er, 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;
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);
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。