本文整理汇总了C++中GeoDataCoordinates::geoCoordinates方法的典型用法代码示例。如果您正苦于以下问题:C++ GeoDataCoordinates::geoCoordinates方法的具体用法?C++ GeoDataCoordinates::geoCoordinates怎么用?C++ GeoDataCoordinates::geoCoordinates使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GeoDataCoordinates
的用法示例。
在下文中一共展示了GeoDataCoordinates::geoCoordinates方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: resolves
bool ViewportParams::resolves ( const GeoDataCoordinates &coord1,
const GeoDataCoordinates &coord2 ) const
{
qreal lon1, lat1;
coord1.geoCoordinates( lon1, lat1 );
qreal lon2, lat2;
coord2.geoCoordinates( lon2, lat2 );
// We take the manhattan length as an approximation for the distance
return ( fabs( lon2 - lon1 ) + fabs( lat2 - lat1 ) < angularResolution() );
}
示例2: screenCoordinates
bool EquirectProjection::screenCoordinates( const GeoDataCoordinates &geopoint,
const ViewportParams *viewport,
qreal &x, qreal &y, bool &globeHidesPoint ) const
{
globeHidesPoint = false;
// Convenience variables
int radius = viewport->radius();
int width = viewport->width();
int height = viewport->height();
qreal lon;
qreal lat;
qreal rad2Pixel = 2.0 * viewport->radius() / M_PI;
const qreal centerLon = viewport->centerLongitude();
const qreal centerLat = viewport->centerLatitude();
geopoint.geoCoordinates( lon, lat );
// Let (x, y) be the position on the screen of the geopoint.
x = ((qreal)(viewport->width()) / 2.0 + rad2Pixel * (lon - centerLon));
y = ((qreal)(viewport->height()) / 2.0 - rad2Pixel * (lat - centerLat));
// Return true if the calculated point is inside the screen area,
// otherwise return false.
return ( ( 0 <= y && y < height )
&& ( ( 0 <= x && x < width )
|| ( 0 <= x - 4 * radius && x - 4 * radius < width )
|| ( 0 <= x + 4 * radius && x + 4 * radius < width ) ) );
}
示例3: screenCoordinates
bool EquirectProjection::screenCoordinates( const GeoDataCoordinates &geopoint,
const ViewportParams *viewport,
qreal *x, qreal &y,
int &pointRepeatNum,
const QSizeF& size,
bool &globeHidesPoint ) const
{
pointRepeatNum = 0;
// On flat projections the observer's view onto the point won't be
// obscured by the target planet itself.
globeHidesPoint = false;
// Convenience variables
int radius = viewport->radius();
qreal width = (qreal)(viewport->width());
qreal height = (qreal)(viewport->height());
qreal lon;
qreal lat;
qreal rad2Pixel = 2.0 * radius / M_PI;
const qreal centerLon = viewport->centerLongitude();
const qreal centerLat = viewport->centerLatitude();
geopoint.geoCoordinates( lon, lat );
// Let (itX, y) be the first guess for one possible position on screen.
qreal itX = ( width / 2.0 + rad2Pixel * ( lon - centerLon ) );
y = ( height / 2.0 - rad2Pixel * ( lat - centerLat ) );
// Make sure that the requested point is within the visible y range:
if ( 0 <= y + size.height() / 2.0 && y < height + size.height() / 2.0 ) {
// First we deal with the case where the repetition doesn't happen
if ( !repeatX() ) {
*x = itX;
if ( 0 < itX + size.width() / 2.0 && itX < width + size.width() / 2.0 ) {
return true;
}
else {
// the requested point is out of the visible x range:
return false;
}
}
// For the repetition case the same geopoint gets displayed on
// the map many times.across the longitude.
int xRepeatDistance = 4 * radius;
// Finding the leftmost positive x value
if ( itX + size.width() > xRepeatDistance ) {
const int repeatNum = (int)( ( itX + size.width() ) / xRepeatDistance );
itX = itX - repeatNum * xRepeatDistance;
}
if ( itX + size.width() / 2.0 < 0 ) {
itX += xRepeatDistance;
}
// The requested point is out of the visible x range:
if ( itX > width + size.width() / 2.0 ) {
return false;
}
// Now iterate through all visible x screen coordinates for the point
// from left to right.
int itNum = 0;
while ( itX - size.width() / 2.0 < width ) {
*x = itX;
++x;
++itNum;
itX += xRepeatDistance;
}
pointRepeatNum = itNum;
return true;
}
// The requested point is out of the visible y range.
return false;
}