bool WeatherDataModel::readLocation(QString line)
{
    QStringList list = line.split(',');
    // Require 10 items in the list
    if(list.size() > 10) {
        LOG(warning) << "Location: Expected 10 entries, got " << list.size();
    } else if(list.size() != 10) {
        LOG(error) << "Location: Expected 10 entries, got " << list.size();
        return false;
    }
    setCity(list[1].toStdString());
    setStateProvinceRegion(list[2].toStdString());
    setCountry(list[3].toStdString());
    setSource(list[4].toStdString());
    setWMO(list[5].toStdString());
    if(!setLatitude(list[6].toStdString())) {
        LOG(error) << QString("Location: Bad latitude value '%1'").arg(list[6]).toStdString();
        return false;
    }
    if(!setLongitude(list[7].toStdString())) {
        LOG(error) << QString("Location: Bad latitude value '%1'").arg(list[7]).toStdString();
        return false;
    }
    if(!setTimeZone(list[8].toStdString())) {
        LOG(error) << QString("Location: Bad time zone value '%1'").arg(list[8]).toStdString();
        return false;
    }
    if(!setElevation(list[9].toStdString())) {
        LOG(error) << QString("Location: Bad elevation value '%1'").arg(list[9]).toStdString();
        return false;
    }
    return true;
}
Esempio n. 2
0
//--------------------------------------------------------------
PositionEditorWidget::PositionEditorWidget
    				( QWidget *parent,
    				  double lat,
    				  double lon,
					  QString userOrient_lat,   /* "Auto" "North+" "South+" */
					  QString userOrient_lon    /* "Auto" "East+" "West+"   */
					)
    : QWidget(parent)
{
    setupUi(this);
	orientLat = userOrient_lat;
	orientLon = userOrient_lon;
	
    lat_NS->addItem(tr("N"),"N");
    lat_NS->addItem(tr("S"),"S");
    lon_EW->addItem(tr("E"),"E");
    lon_EW->addItem(tr("W"),"W");
    lat_sign->addItem(tr("+"),"+");
    lat_sign->addItem(tr("-"),"-");
    lon_sign->addItem(tr("+"),"+");
    lon_sign->addItem(tr("-"),"-");

	setLatitude  (lat);
	setLongitude (lon);
}
Esempio n. 3
0
/**
 * Executes a movement cycle for the moving target.
 */
void MovingTarget::move()
{
	calculateSpeed();
	if (_dest != 0)
	{
		if (getDistance(_dest) > _speedRadian)
		{
			setLongitude(_lon + _speedLon);
			setLatitude(_lat + _speedLat);
		}
		else
		{
			setLongitude(_dest->getLongitude());
			setLatitude(_dest->getLatitude());
		}
	}
}
Esempio n. 4
0
    Sector::Sector() {
        setLatitude(0);
        setLongtitude(0);

        _mapSize = 1201;

        resize(_mapSize);
    }
Esempio n. 5
0
/**
 * Moves the UFO to its destination.
 */
void Ufo::think()
{
	if (!isCrashed())
	{
		setLongitude(_lon + _speedLon);
		setLatitude(_lat + _speedLat);
		if (_dest != 0 && finishedRoute())
		{
			_lon = _dest->getLongitude();
			_lat = _dest->getLatitude();
			setSpeed(0);
		}
	}
}
Esempio n. 6
0
    void Sector::parseLocation(const std::string& fileName) {
        char xDir, yDir;
        int x, y;

        sscanf(fileName.c_str(), "%c%d%c%d", &yDir, &y, &xDir, &x);

        if(xDir == 'W' || xDir == 'w')
            x = -x;

        if(yDir == 'S' || yDir == 's')
            y = -y;

        setLatitude(y);
        setLongtitude(x);
    }
Esempio n. 7
0
void Ufo::releaseEscort()
{
	if (_escorting)
	{
		setLatitude(_escorting->getLatitude());
		setLongitude(_escorting->getLongitude());

		auto ii = std::find(_escorting->_escorts.begin(), _escorting->_escorts.end(), this);
		if (ii != _escorting->_escorts.end())
		{
			_escorting->_escorts.erase(ii);
		}
		_escorting = nullptr;

		Game::getSavedGame()->getUfos()->push_back(this);
		/*_mission = primary->_mission;
		_trajectory = primary->_trajectory;
		_trajectoryPoint = primary->_trajectoryPoint;*/
	}
}
Esempio n. 8
0
WGoogleMap::Coordinate::Coordinate(const std::pair<double, double>& lat_long)
{
  setLatitude(lat_long.first);
  setLongitude(lat_long.second);
}
Esempio n. 9
0
WGoogleMap::Coordinate::Coordinate(double lat, double lon)
{
  setLatitude(lat);
  setLongitude(lon);
}
void commandInterfaceTick() {
  int packetSize = cmdsock.parsePacket();
  if(cmdsock.available()) {
    
    // read the packet into packetBufffer
    cmdsock.read(udpPacketBuffer, PACKET_SIZE);

    if(memcmp("INGV\0", udpPacketBuffer, 5) != 0) {
      return;
    }

    bool reboot = false;
    unsigned long unixTimeM = getUNIXTime();
    unsigned long uptime = getUNIXTime() - getBootTime();
    byte macaddress[6] = { 0 };
    getMACAddress(macaddress);
    uint32_t probeSpeed = getProbeSpeedStatistic();
    uint32_t freeramkb = freeMemory();
    float latency = 0;
    if(udpPacketBuffer[5] == PKTTYPE_GETINFO) {
      latency = tcpLatency();
    }

    float longitude = 0;
    float latitude = 0;

    switch(udpPacketBuffer[5]) {
      case PKTTYPE_DISCOVERY:
        // Reply to discovery
        udpPacketBuffer[5] = PKTTYPE_DISCOVERY_REPLY;

        memcpy(udpPacketBuffer + 6, macaddress, 6);
        
        memcpy(udpPacketBuffer + 12, getVersionAsString().c_str(), 4);
        memcpy(udpPacketBuffer + 16, "uno", 3);
        break;
      case PKYTYPE_PING:
        // Reply to ping
        udpPacketBuffer[5] = PKYTYPE_PONG;
        break;
      case PKTTYPE_SENDGPS:
        // Get coords
        udpPacketBuffer[5] = PKTTYPE_OK;

        memcpy(&latitude, udpPacketBuffer + 12, 4);
        memcpy(&longitude, udpPacketBuffer + 16, 4);
        reverse4bytes((byte*)&latitude);
        reverse4bytes((byte*)&longitude);
        
        break;
      case PKTTYPE_REBOOT:
        // Reboot
        // Reply with OK
        udpPacketBuffer[5] = PKTTYPE_OK;
        reboot = true;
        break;
      case PKTTYPE_GETINFO:
        udpPacketBuffer[5] = PKTTYPE_GETINFO_REPLY;

        memcpy(udpPacketBuffer + 6, macaddress, 6);
        memcpy(udpPacketBuffer + 28, &uptime, 4);
        memcpy(udpPacketBuffer + 32, &unixTimeM, 4);
        memcpy(udpPacketBuffer + 36, VERSION, 4);
        memcpy(udpPacketBuffer + 40, &freeramkb, 4);
        memcpy(udpPacketBuffer + 44, &latency, 4);
        memcpy(udpPacketBuffer + 53, "uno", 3);
        memcpy(udpPacketBuffer + 57, "MMA7361", 7);
        memcpy(udpPacketBuffer + 65, &probeSpeed, 4);

        break;
#ifdef RESET_ENABLED
      case PKTTYPE_RESET:
        initEEPROM();
        reboot = true;
        break;
#endif
      default:
        // Unknown packet or invalid command
        return;
    }

    if(longitude != 0 && latitude != 0) {
      setLongitude(longitude);
      setLatitude(latitude);
    }

    cmdsock.beginPacket(cmdsock.remoteIP(), cmdsock.remotePort());
    cmdsock.write(udpPacketBuffer, PACKET_SIZE);
    cmdsock.endPacket();
    cmdsock.flush();

    if(reboot) {
      soft_restart();
    }
  }
}
Esempio n. 11
0
int QTweetStatusUpdateWithMedia::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QTweetNetBase::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        if (_id < 2)
            qt_static_metacall(this, _c, _id, _a);
        _id -= 2;
    } else if (_c == QMetaObject::RegisterMethodArgumentMetaType) {
        if (_id < 2)
            *reinterpret_cast<int*>(_a[0]) = -1;
        _id -= 2;
    }
#ifndef QT_NO_PROPERTIES
      else if (_c == QMetaObject::ReadProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: *reinterpret_cast< QString*>(_v) = status(); break;
        case 1: *reinterpret_cast< QString*>(_v) = imageFilename(); break;
        case 2: *reinterpret_cast< bool*>(_v) = isSensitive(); break;
        case 3: *reinterpret_cast< qint64*>(_v) = inReplyToStatusID(); break;
        case 4: *reinterpret_cast< double*>(_v) = latitude(); break;
        case 5: *reinterpret_cast< double*>(_v) = longitude(); break;
        case 6: *reinterpret_cast< QString*>(_v) = placeID(); break;
        case 7: *reinterpret_cast< bool*>(_v) = displayCoordinates(); break;
        }
        _id -= 8;
    } else if (_c == QMetaObject::WriteProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: setStatus(*reinterpret_cast< QString*>(_v)); break;
        case 1: setImageFilename(*reinterpret_cast< QString*>(_v)); break;
        case 2: setSensitive(*reinterpret_cast< bool*>(_v)); break;
        case 3: setReplyToStatusID(*reinterpret_cast< qint64*>(_v)); break;
        case 4: setLatitude(*reinterpret_cast< double*>(_v)); break;
        case 5: setLongitude(*reinterpret_cast< double*>(_v)); break;
        case 6: setPlaceID(*reinterpret_cast< QString*>(_v)); break;
        case 7: setDisplayCoordinates(*reinterpret_cast< bool*>(_v)); break;
        }
        _id -= 8;
    } else if (_c == QMetaObject::ResetProperty) {
        _id -= 8;
    } else if (_c == QMetaObject::QueryPropertyDesignable) {
        _id -= 8;
    } else if (_c == QMetaObject::QueryPropertyScriptable) {
        _id -= 8;
    } else if (_c == QMetaObject::QueryPropertyStored) {
        _id -= 8;
    } else if (_c == QMetaObject::QueryPropertyEditable) {
        _id -= 8;
    } else if (_c == QMetaObject::QueryPropertyUser) {
        _id -= 8;
    } else if (_c == QMetaObject::RegisterPropertyMetaType) {
        if (_id < 8)
            *reinterpret_cast<int*>(_a[0]) = -1;
        _id -= 8;
    }
#endif // QT_NO_PROPERTIES
    return _id;
}
Esempio n. 12
0
PositionItem::PositionItem( const float Latitude, const float Longitude )
{
    setLatitude( Latitude );
    setLongitude( Longitude );
}
Esempio n. 13
0
QTweetGeoCoord::QTweetGeoCoord(double latitude, double longitude)
{
    setLatitude(latitude);
    setLongitude(longitude);
}
Place3D::Place3D(double a, double b, double c)
{
	setLongitude(a);
	setLatitude(b);
	setHeight(c);
}
Esempio n. 15
0
void Gprmc::stringInterpretation(String gpsString)
{
	
	gprmcIndex			= 0; 
	firstCommaIndex		= 0; 
	secondCommaIndex	= 0; 
	thirdCommaIndex		= 0; 
	fourthCommaIndex	= 0; 
	fifthCommaIndex		= 0; 
	sixthCommaIndex		= 0;  
	seventhCommaIndex	= 0; 
	eighthCommaIndex	= 0; 
	ninthCommaIndex		= 0;  
	tenthCommaIndex		= 0; 
	eleventhCommaIndex  = 0; 
	twelfthCommaIndex	= 0; 
	

	 time = 0; 
	 status = "V"; 
	 latitude = 0; 
	 longitude = 0; 
	 speedOverGround = 0; 
	 date = 0; 

	 gprmcFound = false; 
	 checksumFound		= false; 

	 checksum = 0;
	 character = '0'; 

	 if(gpsString.indexOf("GPRMC") != -1)
	 {
		 gprmcFound = true; 
	 }
	 
	 if(gprmcFound)
	 {
		gprmcIndex = gpsString.indexOf("GPRMC"); 
		firstCommaIndex		= gpsString.indexOf	(',', gprmcIndex		 + 1); 
		secondCommaIndex	= gpsString.indexOf	(',', firstCommaIndex	 + 1); 
		thirdCommaIndex		= gpsString.indexOf	(',', secondCommaIndex	 + 1); 
		fourthCommaIndex	= gpsString.indexOf	(',', thirdCommaIndex	 + 1); 
		fifthCommaIndex		= gpsString.indexOf	(',', fourthCommaIndex	 + 1); 
		sixthCommaIndex		= gpsString.indexOf	(',', fifthCommaIndex	 + 1); 
		seventhCommaIndex	= gpsString.indexOf	(',', sixthCommaIndex	 + 1); 
		eighthCommaIndex	= gpsString.indexOf	(',', seventhCommaIndex  + 1); 
		ninthCommaIndex		= gpsString.indexOf	(',', eighthCommaIndex	 + 1); 
		tenthCommaIndex		= gpsString.indexOf	(',', ninthCommaIndex    + 1); 
		eleventhCommaIndex	= gpsString.indexOf	(',', tenthCommaIndex	 + 1); 
		twelfthCommaIndex	= gpsString.indexOf (',', eleventhCommaIndex + 1); 



		/*
		 * substring()
		 * der Startindex ist inklusive, der Endindex ist exkluiv!
		 */

		if (gpsString.substring(twelfthCommaIndex + 2, twelfthCommaIndex + 3).equals("*"))
		{
			gprmcSentence			= gpsString.substring (gprmcIndex,			   twelfthCommaIndex + 5); 
		}

		timeString					= gpsString.substring (firstCommaIndex + 1,	     secondCommaIndex  ); 
		statusString 				= gpsString.substring (secondCommaIndex + 1,     thirdCommaIndex   ); 
		latitudeString				= gpsString.substring (thirdCommaIndex + 1,	     fourthCommaIndex  ); 
	 // northSouthString			= gpsString.substring (fourthCommaIndex + 1,     fifthCommaIndex   ); 
		longitudeString				= gpsString.substring (fifthCommaIndex + 1,	     sixthCommaIndex   ); 
	 // westEastString				= gpsString.substring (sixthCommaIndex + 1,	     seventhCommaIndex ); 
		speedOverGroundString		= gpsString.substring (seventhCommaIndex + 1,    eighthCommaIndex  ); 
	 // trackAngleString			= gpsString.substring (eighthCommaIndex + 1,     ninthCommaIndex   ); 
		dateString					= gpsString.substring (ninthCommaIndex + 1,	     tenthCommaIndex   ); 
	 // magneticVariationString		= gpsString.substring (tenthCommaIndex + 1,      eleventhCommaIndex); 
	 // magneticVariationSignString	= gpsString.substring (eleventhCommaIndex + 1,   twelfthCommaIndex ); 
		
		if (gpsString.substring(twelfthCommaIndex + 2, twelfthCommaIndex + 3).equals("*"))
		{
			checksumString			= gpsString.substring (twelfthCommaIndex + 3, twelfthCommaIndex + 5); 
			checksumFound			= true; 
		}

		/*
		 * Checksumme überprüfen:
		 * Die Checksumme wird berechnet, indem alle Zeichen zwischen dem $ und dem *
		 * duch ein (bitweise) exklusiv-oder berechnet werden.
		 * Angegeben wird die Checksumme durch eine Hexadezimalzahl, die hiner dem * steht. 
		 */

		for (int i = 0; i < gprmcSentence.length() - 3; i++)
		{
			checksum = checksum ^ byte(gprmcSentence[i]); 
		}

		/*
		 * Die Daten werden nur gesetzt, falls die empfangenen Daten
		 * valide sind und die Checksumme korrekt ist.
		 */

		if(statusString.equals("A") && hexToDec(checksumString) == checksum)
		{
			char floatBufferTime[15];
			timeString.toCharArray(floatBufferTime, sizeof(floatBufferTime)); 	
			setTime(atof(floatBufferTime)); 
	
			setStatus(statusString); 
	
			char floatBufferLat[15];
			latitudeString.toCharArray(floatBufferLat, sizeof(floatBufferLat)); 	
			setLatitude(atof(floatBufferLat)); 

			char floatBufferLon[15];
			longitudeString.toCharArray(floatBufferLon, sizeof(floatBufferLon)); 	
			setLongitude(atof(floatBufferLon)); 

			char floatBufferSpeed[15];
			speedOverGroundString.toCharArray(floatBufferSpeed, sizeof(floatBufferSpeed)); 	
			setSpeedOverGround(atof(floatBufferSpeed)); 

			char floatBufferDate[15];
			dateString.toCharArray(floatBufferDate, sizeof(floatBufferDate)); 	 
			setDate(atol(floatBufferDate)); 
		}
	 }

}