当前位置: 首页>>代码示例>>C++>>正文


C++ WeatherData::setCondition方法代码示例

本文整理汇总了C++中WeatherData::setCondition方法的典型用法代码示例。如果您正苦于以下问题:C++ WeatherData::setCondition方法的具体用法?C++ WeatherData::setCondition怎么用?C++ WeatherData::setCondition使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在WeatherData的用法示例。


在下文中一共展示了WeatherData::setCondition方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: getAdditionalItems

void FakeWeatherService::getAdditionalItems( const GeoDataLatLonAltBox& box,
                         qint32 number )
{
    Q_UNUSED( box );
    Q_UNUSED( number );

    FakeWeatherItem *item = new FakeWeatherItem( this );
    item->setStationName( "Fake" );
    item->setPriority( 0 );
    item->setCoordinate( GeoDataCoordinates( 1, 1 ) );
    item->setId( "fake1" );
    
    WeatherData data;
    data.setCondition( WeatherData::ClearDay );
    data.setTemperature( 14.0, WeatherData::Celsius );
    item->setCurrentWeather( data );
        
    emit createdItems( QList<AbstractDataPluginItem*>() << item );
}
开发者ID:PayalPradhan,项目名称:marble,代码行数:19,代码来源:FakeWeatherService.cpp

示例2: coordinates

AbstractDataPluginItem *GeoNamesWeatherService::parse( const QScriptValue &value )
{
    QString condition = value.property( "weatherCondition" ).toString();
    QString clouds = value.property( "clouds" ).toString();
    int windDirection = value.property( "windDirection" ).toInteger();
    QString id = value.property( "ICAO" ).toString();
    int temperature = value.property( "temperature" ).toInteger();
    int windSpeed = value.property( "windSpeed" ).toInteger();
    int humidity = value.property( "humidity" ).toInteger();
    double pressure = value.property( "seaLevelPressure" ).toNumber();
    QString name = value.property( "stationName" ).toString();
    QDateTime date = QDateTime::fromString(
                value.property( "datetime" ).toString(), "yyyy-MM-dd hh:mm:ss" );
    double longitude = value.property( "lng" ).toNumber();
    double latitude = value.property( "lat" ).toNumber();

    if ( !id.isEmpty() ) {
        WeatherData data;

        // Weather condition
        if ( clouds != "n/a" && condition != "n/a" ) {
            if ( dayConditions.contains( condition ) ) {
                data.setCondition( dayConditions[condition] );
            } else {
                mDebug() << "UNHANDLED GEONAMES WEATHER CONDITION, PLEASE REPORT: " << condition;
            }
        } else {
            if ( dayConditions.contains( clouds ) ) {
                data.setCondition( dayConditions[clouds] );
            } else {
                mDebug() << "UNHANDLED GEONAMES CLOUDS CONDITION, PLEASE REPORT: " << clouds;
            }
        }

        // Wind direction. Finds the closest direction from windDirections array.
        if ( windDirection >= 0 ) {
            double tickSpacing = 360.0 / windDirections.size();
            data.setWindDirection( windDirections[int(( windDirection / tickSpacing ) + 0.5)
                                   % windDirections.size()] );
        }

        // Wind speed
        if ( windSpeed != 0 ) {
            data.setWindSpeed( windSpeed, WeatherData::knots );
        }

        // Temperature
        data.setTemperature( temperature, WeatherData::Celsius );

        // Humidity
        data.setHumidity( humidity );

        // Pressure
        if ( pressure != 0.0 ) {
            data.setPressure( pressure, WeatherData::HectoPascal );
        }

        // Date
        data.setDataDate( date.date() );
        data.setPublishingTime( date );

        // ID
        id = "geonames_" + id;

        GeoDataCoordinates coordinates( longitude, latitude, 0.0, GeoDataCoordinates::Degree );
        GeoNamesWeatherItem *item = new GeoNamesWeatherItem( this );
        item->setMarbleWidget( marbleWidget() );
        item->setId( id );
        item->setCoordinate( coordinates );
        item->setPriority( 0 );
        item->setStationName( name );
        item->setCurrentWeather( data );
        return item;
    } else {
        return 0;
    }
}
开发者ID:calincru,项目名称:marble,代码行数:77,代码来源:GeoNamesWeatherService.cpp


注:本文中的WeatherData::setCondition方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。