コード例 #1
0
void 
GlobeMapMovingInterface::setPoint(const MC2Coordinate& newCoord,
                                  const MC2Point& screenPoint )
{
   MC2Point gbScreenPoint = screenToGlobe( screenPoint );
	if (!m_globe)
		return;

	float c[2];
	GBGlobe_screenToWorld( m_globe, 
                         (float)gbScreenPoint.getX(), 
                         (float)gbScreenPoint.getY(), c );

	WGS84Coordinate wgsCoord = WGS84Coordinate( newCoord );
	float longitude = (float)wgsCoord.lonDeg;
	float latitude = (float)wgsCoord.latDeg;

	if (gbFAbs(c[0] - longitude) > 180.0f)
	{
		if (c[0] < longitude)
			longitude -= 360.0f;
		else if (c[0] > longitude)
			longitude += 360.0f;
	}

	WGS84Coordinate n( m_center );
	
	n.lonDeg -= c[0] - longitude;
	n.latDeg -= c[1] - latitude;
	
	setCenter( n );
}
コード例 #2
0
void 
GlobeMapMovingInterface::setWorldBox( const MC2Coordinate& oneCorner,
                                      const MC2Coordinate& otherCorner )
{
   if (!m_globe)
      return;

   float firstNormal[3];
   float secondNormal[3];

   WGS84Coordinate wgsFirst = WGS84Coordinate( oneCorner );
   WGS84Coordinate wgsSecond = WGS84Coordinate( otherCorner );

   GBGlobe_worldToWorldNormal( m_globe, (float)wgsSecond.lonDeg, (float)wgsFirst.latDeg, firstNormal );
   GBGlobe_worldToWorldNormal( m_globe, (float)wgsFirst.lonDeg, (float)wgsSecond.latDeg, secondNormal );

   float result[3];
   result[0] = firstNormal[0] + secondNormal[0];
   result[1] = firstNormal[1] + secondNormal[1];
   result[2] = firstNormal[2] + secondNormal[2];

   gbFVec3Normalize( result );

   float resultWorld[2];
   GBGlobe_normalToWorld( m_globe, result, resultWorld );

   setCenter( WGS84Coordinate( resultWorld[1], resultWorld[0] ) );

   double a = acos(firstNormal[0] * secondNormal[0] + firstNormal[1] * secondNormal[1] + firstNormal[2] * secondNormal[2]);

   double b = atan(6.0 / 15.0);
   double c = GB_PI - (a + b) / 2.0;

   m_scale = sin(c) / sin(b / 2);
   m_scale = ((m_scale - 2.0f) / 4.0f + m_zoomTweak) * (double)GB_MIN_SCALE * 6.0 + (double)GB_MIN_SCALE;
	
   if ( m_scale > 100000 ) {
      m_scale = 100000;
   }

	m_moved = true;
}
コード例 #3
0
ファイル: WGS84Coordinate.cpp プロジェクト: tomkek/projects
            const WGS84Coordinate WGS84Coordinate::transform(const Point3 &coordinate, const double &accuracy) const {
                WGS84Coordinate result(*this);
                Point3 point3Result;

                double addLon = 1e-7;
                int32_t signLon = (coordinate.getX() < 0) ? -1 : 1;
                double addLat = 1e-7;
                int32_t signLat = (coordinate.getY() < 0) ? -1 : 1;

                double epsilon = accuracy;
                if (epsilon < 0) {
                    epsilon = 1e-2;
                }

                point3Result = transform(result);
                double dOld = numeric_limits<double>::max();
                double d = abs(coordinate.getY() - point3Result.getY());
                uint32_t iterations = 0;
//                while ( (d < dOld) && (d > epsilon) && (iterations < 50000)) {
                while ( (d < dOld) && (d > epsilon) ) {
                    result = WGS84Coordinate(result.getLatitude() + signLat * addLat, result.getLATITUDE(), result.getLongitude(), result.getLONGITUDE());
                    point3Result = transform(result);
                    dOld = d;
                    d = abs(coordinate.getY() - point3Result.getY());
                    iterations++;
                }

                // Use the last transformed point3Result here.
                dOld = numeric_limits<double>::max();
                d = abs(coordinate.getX() - point3Result.getX());
                iterations = 0;
//                while ( (d < dOld) && (d > epsilon) && (iterations < 50000)) {
                while ( (d < dOld) && (d > epsilon) ) {
                    result = WGS84Coordinate(result.getLatitude(), result.getLATITUDE(), result.getLongitude() + signLon * addLon, result.getLONGITUDE());
                    point3Result = transform(result);
                    dOld = d;
                    d = abs(coordinate.getX() - point3Result.getX());
                    iterations++;
                }

                return result;
            }
コード例 #4
0
void 
GlobeMapMovingInterface::setPixelBox( const MC2Point& oneCorner,
                                      const MC2Point& otherCorner )
{
   MC2Point gbOneCorner = screenToGlobe( oneCorner );
   MC2Point gbOtherCorner = screenToGlobe( otherCorner );

   if (!m_globe)
      return;

   float first[2];
   float second[2];

   GBGlobe_screenToWorld( m_globe, (float)gbOneCorner.getX(), (float)gbOneCorner.getY(), first );
   GBGlobe_screenToWorld( m_globe, (float)gbOtherCorner.getX(), (float)gbOtherCorner.getY(), second );

   setWorldBox( WGS84Coordinate( first[1], first[0] ), WGS84Coordinate( second[1], second[0] ) );

   m_moved = true;
}
コード例 #5
0
void 
GlobeMapMovingInterface::transform( MC2Point& point,
                                    const MC2Coordinate& coord ) const
{
   if (!m_globe)
      return;

   WGS84Coordinate wgsCoord = WGS84Coordinate( coord );
   float latitude = (float)wgsCoord.latDeg;
   float longitude = (float)wgsCoord.lonDeg;
   float result[2];
   GBGlobe_worldToScreen( m_globe, latitude, longitude, result );
   /* result[0] is the screen horizontal coordinate */
   /* result[1] is the screen vertical coordinate */
   point = globeToScreen( MC2Point( (int)result[0], (int)result[1] ) );
}
コード例 #6
0
void 
GlobeMapMovingInterface::inverseTransform( MC2Coordinate& coord,
                                           const MC2Point& point ) const
{
   MC2Point gbPoint = screenToGlobe( point );
   if (!m_globe)
      return;

   float result[2];
   float x = (float)gbPoint.getX(); /* screen horizontal coordinate */
   float y = (float)gbPoint.getY(); /* screen vertical coordinate */
   GBGlobe_screenToWorld( m_globe, x, y, result );
   /* result[0] is the longitude in degrees */
   /* result[1] is the latitude in degrees */
   coord = WGS84Coordinate( (double)result[1], (double)result[0] );
}