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


C++ WeatherData类代码示例

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


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

示例1: main

int main(void)
{
    printf("Enter main...\n");
    WeatherData *wd = newWeatherData();
    CurrentConditionDisplay *displayForecast = newCurrentConditionDisplay(wd, 0);
    CurrentConditionDisplay *displayCurrentSituation = newCurrentConditionDisplay(wd, 1);

    //add displays to weather data
    ((WeatherData *)(displayForecast->weatherData))->registerConditionDisplay(wd, displayForecast);
    ((WeatherData *)(displayCurrentSituation->weatherData))->registerConditionDisplay(wd, displayCurrentSituation);

    //weather data changed
    wd->setMeasurements(wd, 35, 80.5f, 48.0f);
    wd->setMeasurements(wd, 55, 60.5f, 80);

    //display forecast cancle to observer weather data
    ((WeatherData *)(displayForecast->weatherData))->removeConditionDisplay(wd, displayForecast);
    wd->setMeasurements(wd, 25, 67, 90);

    deleteCurrentConditionDisplay(displayCurrentSituation);
    deleteCurrentConditionDisplay(displayForecast);
    deleteWeatherData(wd);
    printf("Exit main.\n");
    return 0;
}
开发者ID:libin89,项目名称:GOF,代码行数:25,代码来源:weather.c

示例2: main

int main()
{
	// subject
	WeatherData *weatherData = new WeatherData();

	// 초기값
	weatherData->setMeasurements(77, 88, 31.1f);

	// observers
	CurrentConditionsDisplay *currentDisplay = new CurrentConditionsDisplay(weatherData);
	StatisticDisplay *statisticDisplay = new StatisticDisplay(weatherData);
	ForecastDisplay *forecastDisplay = new ForecastDisplay(weatherData);

	// 기상대 시뮬레이션 - pull
	currentDisplay->pullState();

	// 기상대 시뮬레이션 - push
	weatherData->setMeasurements(80, 65, 30.4f);
	weatherData->setMeasurements(82, 70, 29.2f);
	weatherData->setMeasurements(78, 90, 29.2f);

	delete weatherData;
	delete currentDisplay;
	delete statisticDisplay;
	delete forecastDisplay;

	return 0;
}
开发者ID:Edunga1,项目名称:edunga1.github.com,代码行数:28,代码来源:WeatherStation.cpp

示例3: interval_

	ETCalcParameters::ETCalcParameters(pt::time_period interval, const WeatherData& data)
      : interval_(interval)
   {
      for(WeatherData::const_iterator i = data.AllSetValues();
         i < data.end(); ++i) {
         if ((*i).first == WeatherDataValue_t::MinTemp) {
            SetValue(ETCalcData_t::MinTemp, (*i).second);
         } else if ((*i).first == WeatherDataValue_t::MaxTemp) {
            SetValue(ETCalcData_t::MaxTemp, (*i).second);
         } else if ((*i).first == WeatherDataValue_t::AvgTemp) {
            SetValue(ETCalcData_t::AvgTemp, (*i).second);
         } else if ((*i).first == WeatherDataValue_t::MinRH) {
            SetValue(ETCalcData_t::MinRH, (*i).second);
         } else if ((*i).first == WeatherDataValue_t::MaxRH) {
            SetValue(ETCalcData_t::MaxRH, (*i).second);
         } else if ((*i).first == WeatherDataValue_t::StartTemp) {
            SetValue(ETCalcData_t::StartTemp, (*i).second);
         } else if ((*i).first == WeatherDataValue_t::EndTemp) {
            SetValue(ETCalcData_t::EndTemp, (*i).second);
         } else if ((*i).first == WeatherDataValue_t::AvgPressure) {
            SetValue(ETCalcData_t::AvgPressure, (*i).second);
         } else if ((*i).first == WeatherDataValue_t::AvgWindSpeed) {
            SetValue(ETCalcData_t::AvgWindSpeed, (*i).second);
         }
      }

      SetLengthType();
   }
开发者ID:fgarsombke,项目名称:Mist,代码行数:28,代码来源:ETCalcParameters.cpp

示例4: qWarning

void AppModel::handleForecastNetworkData(QObject *replyObj)
{
    QNetworkReply *networkReply = qobject_cast<QNetworkReply*>(replyObj);
    if (!networkReply)
        return;

    if (!networkReply->error()) {
        QJsonDocument document = QJsonDocument::fromJson(networkReply->readAll());

        QJsonObject jo;
        QJsonValue jv;
        QJsonObject root = document.object();
        jv = root.value(QStringLiteral("list"));
        if (!jv.isArray())
            qWarning() << "Invalid forecast object";
        QJsonArray ja = jv.toArray();
        //we need 4 days of forecast -> first entry is today
        if (ja.count() != 5)
            qWarning() << "Invalid forecast object";

        QString data;
        for (int i = 1; i<ja.count(); i++) {
            WeatherData *forecastEntry = new WeatherData();

            //min/max temperature
            QJsonObject subtree = ja.at(i).toObject();
            jo = subtree.value(QStringLiteral("temp")).toObject();
            jv = jo.value(QStringLiteral("min"));
            data.clear();
            data += niceTemperatureString(jv.toDouble());
            data += QChar('/');
            jv = jo.value(QStringLiteral("max"));
            data += niceTemperatureString(jv.toDouble());
            forecastEntry->setTemperature(data);

            //get date
            jv = subtree.value(QStringLiteral("dt"));
            QDateTime dt = QDateTime::fromMSecsSinceEpoch((qint64)jv.toDouble()*1000);
            forecastEntry->setDayOfWeek(dt.date().toString(QStringLiteral("ddd")));

            //get icon
            QJsonArray weatherArray = subtree.value(QStringLiteral("weather")).toArray();
            jo = weatherArray.at(0).toObject();
            forecastEntry->setWeatherIcon(jo.value(QStringLiteral("icon")).toString());

            //get description
            forecastEntry->setWeatherDescription(jo.value(QStringLiteral("description")).toString());

            d->forecast.append(forecastEntry);
        }

        if (!(d->ready)) {
            d->ready = true;
            emit readyChanged();
        }

        emit weatherChanged();
    }
    networkReply->deleteLater();
}
开发者ID:lollinus,项目名称:qt-5.3-examples,代码行数:60,代码来源:appmodel.cpp

示例5: deleteCurrentConditionDisplay

void deleteCurrentConditionDisplay(struct CurrentConditionDisplay *ccd)
{
    WeatherData *wd = (WeatherData *)ccd->weatherData;
    if (ccd && wd) {
        wd->removeConditionDisplay(wd, ccd);
        free(ccd);
    }
}
开发者ID:libin89,项目名称:GOF,代码行数:8,代码来源:weather.c

示例6: updateV2

void updateV2(struct CurrentConditionDisplay *ccd)
{
    WeatherData *wd = (WeatherData *)ccd->weatherData;

    ccd->temperature = wd->getTemperature(wd);
    ccd->humidity = wd->getHumidity(wd);
    ccd->display(ccd);
}
开发者ID:libin89,项目名称:GOF,代码行数:8,代码来源:weather.c

示例7: main

int main()
{
        WeatherData* weatherData = new WeatherData();

		CurrentConditionsDisplay* currentDisplay = new CurrentConditionsDisplay(weatherData);

		weatherData->setMeasurements(80, 65);
		weatherData->setMeasurements(82, 70);
		weatherData->setMeasurements(78, 90);
}
开发者ID:Wajihulhassan,项目名称:DesignPattern,代码行数:10,代码来源:main.cpp

示例8: main

int main(void)
{
	WeatherData weather;
	currentweather current;
	forcastweather forcast;

	weather.registerobserver(&current);
	weather.registerobserver(&forcast);

	weather.setmeasurement(30,75,29);
	int i;
	cin >> i;
	return 0;
}
开发者ID:LanghuaYang,项目名称:origin,代码行数:14,代码来源:main.cpp

示例9: main

int main() {
    FirstDisplay fd;
    SecondDisplay sd;
    
    WeatherData data;
    data.RegisterObserver(&fd);
    data.RegisterObserver(&sd);
    
    data.RemoveObserver(&sd);
    
    data.Changed(2,1,0);
    
    system("pause");
    
    return 0;
}
开发者ID:familymrfan,项目名称:fanfei,代码行数:16,代码来源:observer.cpp

示例10: Q_UNUSED

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

示例11: main

int main()
{
    WeatherData *weatherData = new WeatherData();
    CurrentConditionsDisplay* currentDisplay = 
        new CurrentConditionsDisplay(weatherData);
    StatisticsDisplay* statisticsDisplay = new StatisticsDisplay(weatherData);
    ForecastDisplay* forecastDisplay = new ForecastDisplay(weatherData);

    weatherData->setMeasurements(80, 65, 30.4f);
    cout << endl;
    weatherData->setMeasurements(82, 70, 29.2f);
    cout << endl;

    weatherData->removeObserver(currentDisplay);
    weatherData->removeObserver(currentDisplay);
    weatherData->removeObserver(currentDisplay);
    weatherData->removeObserver(currentDisplay);
    weatherData->setMeasurements(78, 90, 29.2f);
    cout << endl;

    delete weatherData;
    delete currentDisplay;
    delete statisticsDisplay;
    delete forecastDisplay;

    return 0;
}
开发者ID:GangHoyong,项目名称:Head-First-Design-Patterns-1,代码行数:27,代码来源:main.cpp

示例12: main

int main()
{
    WeatherData w; // The Observable Subject.

    // Observer objects are created on heap in order to demonstrate
    // their ability to unsubscribe themselves from Subject
    // in their destructors.
    auto cond = new CurrentConditions(w);
    auto stats = new StatisticsDisplay(w);
    auto forecast = new ForecastDisplay(w);

    w.set_measurements(34, 50, 120); // Changes in the Subject are pushed as notifications to the Observers.
    w.set_measurements(12, 34, 126);
    w.set_measurements(-12, 60, 70);

    delete cond;
    delete stats;
    delete forecast;

    w.set_measurements(0,0,12);
    return 0;
}
开发者ID:lolportal,项目名称:ObserverDemo,代码行数:22,代码来源:main.cpp

示例13: collidesWithWeatherDataSet

/**
   \brief test if the radius r ball centered at current node conflict with the weatherdata

   This only does 2d testing if their z coordinates collide with each other

   This routine has been updated from treating weather data as the lower left corners
   of cellWidth*cellWidth squares.  Now they are circles of radius cellWidth.

   This returns true if any weather with a deviationProbability >= thresh is closer
   than r to any points in the weather ensemble wData.

   \param r Radius of node i.e. how far node must be from edge of weather.
   \param WeatherData A single weather ensemble.
   \param thresh Minimum deviationProbability for a weather cell to be dangerous
                        

*/
bool Node::collidesWithWeatherDataSet(double r, const WeatherData &wData, double thres)
{
    if(wData.size() == 0)
    {
        return false;                                   // if the weather data does not exist, then just return false
    }
    double x1;
    double y1;
    double z1;
    double cellWidth;
    double cellHeight;
    double deviationProbability;
    for(unsigned int i=0; i<wData.size() ; i++)
    {
        // if successfully read out all the cell data, the bottomleft corner of the cell is (x1, y1, z1)
        if(wData.getCellData(i, &x1, &y1, &z1, &deviationProbability, &cellWidth, &cellHeight)) 
        {
            if(deviationProbability <= thres)           // if the cell is not severe enough, simply skip
            {
                continue;                                               // test the next one                                                    
            }
            if(z < z1 || z > z1+cellHeight)             // if the ranges in z direction have no overlap, then skip
            {
                continue;
            }
            else
            {
                double distanceInPixels = sqrt( (x-x1)*(x-x1) + (y-y1)*(y-y1) );
                double distanceInNM = distanceInPixels*NMILESPERPIXEL;
                // If it intersects with the current cell
                if(distanceInNM < cellWidth+r ) 
                {
                    return true;        
                }
            }
        }
    }
    return false;                                                                                                       // all the cells are tested and free of intersection
}
开发者ID:herrGagen,项目名称:robustTreePlanner,代码行数:56,代码来源:NodeAndEdge.cpp

示例14: main

int main()
{
    Subject *s;
    WeatherData weather;
    s = &weather;
    CurrentConditionDisplay currentDisplay;
    CurrentConditionDisplay currentDisplay2;
    ForcastConditionDisplay forcastDisplay;

    weather.registerObserver(&currentDisplay);
    weather.registerObserver(&currentDisplay2);
    weather.registerObserver(&forcastDisplay);

    weather.setMeasurements(80,62,30.4);
    weather.removeObserver(&currentDisplay2);
    weather.setMeasurements(80,62,30.4);
    return 0;
}
开发者ID:gmyofustc,项目名称:CS-notes,代码行数:18,代码来源:observer.cpp

示例15: mDebug

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