0% found this document useful (0 votes)
3 views15 pages

Capstone Softcopy

The document is a capstone project report for a Weather Monitoring System developed by students at Sri Ramakrishna Engineering College. The application provides real-time weather updates for any city using the OpenWeatherMap API, featuring an intuitive interface built with C++ and ImGui. It effectively demonstrates the integration of modern programming techniques and API utilization, with potential for future enhancements.

Uploaded by

mathan08052006
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views15 pages

Capstone Softcopy

The document is a capstone project report for a Weather Monitoring System developed by students at Sri Ramakrishna Engineering College. The application provides real-time weather updates for any city using the OpenWeatherMap API, featuring an intuitive interface built with C++ and ImGui. It effectively demonstrates the integration of modern programming techniques and API utilization, with potential for future enhancements.

Uploaded by

mathan08052006
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 15

SRI RAMAKRISHNA ENGINEERING COLLEGE

[Educational Service: SNR Sons Charitable Trust]


[Autonomous Institution, Reaccredited by NAAC with ‘A+’ Grade]
[Approved by AICTE and Permanently Affiliated to Anna University, Chennai]
[ISO 9001:2015 Certified and all eligible programmes Accredited by NBA]
Vattamalaipalayam, N.G.G.O. Colony Post, Coimbatore – 641 022.

Department of Artificial Intelligence and Data Science

CAPSTONE PROJECT REPORT

Project Title

Aayush Chapagain – 71812411063


Sachin Singh – 71812411043
MadhanKumar– 71812411035
SanjeevKumar– 71812411048

I B. TECH AI&DS – I SEM

Academic Year 2024-2025

20IT292 - OBJECT ORIENTED PROGRAMMING USING C++


LABORATORY

Course Coordinator

Mrs. K. Archana, AP/AI&DS

1
SRI RAMAKRISHNA ENGINEERING COLLEGE
[Educational Service: SNR Sons Charitable Trust]
[Autonomous Institution, Reaccredited by NAAC with ‘A+’ Grade]
[Approved by AICTE and Permanently Affiliated to Anna University, Chennai]
[ISO 9001:2015 Certified and all eligible programmes Accredited by NBA]
Vattamalaipalayam, N.G.G.O. Colony Post, Coimbatore – 641 022.

Department of Artificial Intelligence and Data Science

CAPSTONE PROJECT REPORT

20IT292 - OBJECT ORIENTED PROGRAMMING USING C++


LABORATORY

Project title

Assessment

Implementation
Abstract (2)

Report (5)
Demo (3)
Total
(10)

S.No. Roll No & Name


(20)

1. Aayush Chapagain – 7181241163

2. Sachin Singh – 7181241143

3. Madhan Kumar – 71812411035

4. Sanjeev Kumar – 71812411048

Signature of Course Coordinator


Mrs. K. Archana, AP/AI&DS
2
CONTENTS

PAGE
S. No. TITLE NUMBER

1. PROJECT DESCRIPTION 4

2. INTRODUCTION 5

3. SOURCE CODE 6

4. SCREENSHOTS 13

5. CONCLUSION 15

3
1. PROJECT DESCRIPTION

The Weather Monitoring System is a robust desktop application


designed to deliver real-time weather updates for any city entered
by the user. Built using the Walnut Framework and ImGui, the
application features an intuitive and interactive user interface
where users can input a city name and retrieve up-to-date weather
information. By integrating with the OpenWeatherMap API, it
fetches essential weather metrics, including temperature (in
Kelvin), humidity (percentage), and general weather conditions
(e.g., clear, cloudy). The application utilizes the C++ REST SDK
for efficient HTTP requests and JSON parsing, ensuring seamless
communication with the API. It also incorporates robust error
handling to display meaningful messages in case of issues such as
incorrect city names or network failures. This project exemplifies
the effective combination of modern GUI design with real-time
API integration, providing a practical and engaging tool for
weather monitoring and daily planning.

4
2. INTRODUCTION

This C++ project implements a real-time Weather Monitoring System, enabling users to
receive accurate and up-to-date weather information for any city worldwide. Utilizing
object-oriented programming principles, the system encapsulates its functionality within a
user-friendly interface powered by ImGui. It leverages the OpenWeatherMap API for data
retrieval and the C++ REST SDK for seamless HTTP communication and JSON handling.
Users can interact with the interface to enter a city name, fetch weather details, and view
key metrics such as temperature (in Kelvin), humidity (percentage), and overall weather
conditions. Robust error handling ensures smooth operation, providing meaningful
feedback in cases of invalid input or connectivity issues. The project adheres to modern
programming standards and demonstrates a sophisticated integration of APIs, GUI design,
and backend functionality, offering an intuitive and practical tool for weather tracking.

5
3. SOURCE CODE

#include "Walnut/Application.h"
#include "Walnut/EntryPoint.h"
#include "Walnut/Image.h"

#include <iostream>
#include <string>
#include <cpprest/http_client.h>
#include <cpprest/filestream.h>
using namespace std;
using namespace web;
using namespace web::http;
using namespace web::http::client;

class ExampleLayer : public Walnut::Layer


{
public:
virtual void OnAttach() override
{
// Initialize weather data
ResetWeatherData();
}
6
virtual void OnUIRender() override
{
ImGui::Begin("Weather Monitoring System");

ImGui::Text("Welcome to the Weather Monitoring


System!");
ImGui::TextWrapped("Plan your day with real-time weather
updates. Enter the city name below:");
ImGui::Separator();
ImGui::Spacing();

// Input text box for city name


static char cityBuffer[256] = "";
ImGui::InputTextWithHint("##CityInput", "Type a city name
here...", cityBuffer, sizeof(cityBuffer));

ImGui::Spacing();
if (ImGui::Button("Get Weather", ImVec2(150, 40)))
{
city = string(cityBuffer);
FetchWeatherData(city);
}

7
ImGui::Spacing();
ImGui::Separator();
ImGui::Spacing();

// Display weather data if available


if (!temperature.empty() && temperature != "Error")
{
ImGui::Text("Weather Information:");
ImGui::Separator();
ImGui::Text("City: %s", city.c_str());
ImGui::Text("Temperature: %s K", temperature.c_str());
ImGui::Text("Humidity: %s%%", humidity.c_str());
ImGui::Text("Condition: %s", condition.c_str());

ImGui::Spacing();
ImGui::TextWrapped("Stay safe and have a wonderful
day!");
}
else if (temperature == "Error")
{
ImGui::TextColored(ImVec4(1.0f, 0.0f, 0.0f, 1.0f), "Failed
to fetch weather data. Please try again.");
}
else
8
{
ImGui::TextWrapped("Enter a city name and press 'Get
Weather' to see the forecast.");
}

ImGui::End();
}

private:
void ResetWeatherData()
{
city.clear();
temperature.clear();
humidity.clear();
condition.clear();
}

void FetchWeatherData(const string& cityName)


{
try
{
// Set up HTTP client and request
http_client
client(U("https://api.openweathermap.org/data/2.5"));
9
uri_builder builder(U("/weather"));
builder.append_query(U("q"),
utility::conversions::to_string_t(cityName));
builder.append_query(U("appid"),
U("d1499edaf881207975639c3498d3864b"));

http_request request(methods::GET);
request.set_request_uri(builder.to_string());

// Send the request and process the response


client.request(request)
.then([](http_response response) {
if (response.status_code() != status_codes::OK)
{
throw runtime_error("Failed to get weather data: " +
to_string(response.status_code()));
}
return response.extract_json();
})
.then([this](web::json::value body) {
// Extract weather information
double temp =
body[U("main")][U("temp")].as_double();
double hum =
body[U("main")][U("humidity")].as_double();
10
string weather =
utility::conversions::to_utf8string(body[U("weather")][0][U("main
")].as_string());

// Update UI variables
temperature = to_string(temp);
humidity = to_string(hum);
condition = weather;
})
.wait();
}
catch (const exception& ex)
{
cerr << "Error: " << ex.what() << endl;
ResetWeatherData(); // Reset weather data on error
temperature = "Error";
}
}

string city;
string temperature;
string humidity;
string condition;
};
11
Walnut::Application* Walnut::CreateApplication(int argc, char**
argv)
{
Walnut::ApplicationSpecification spec;
spec.Name = "Weather Monitoring System";

Walnut::Application* app = new Walnut::Application(spec);


app->PushLayer<ExampleLayer>();
app->SetMenubarCallback([app]() {
if (ImGui::BeginMenu("File"))
{
if (ImGui::MenuItem("Exit"))
{
app->Close();
}
ImGui::EndMenu();
}
});
return app;
}

For more details about the source code, please visit my GitHub repository.

12
4. SCREENSHOTS

1.

2.

13
3.

4.

14
5.CONCLUSION

The Weather Monitoring System effectively achieves its


primary goal of providing real-time weather updates based
on user input. It displays essential weather parameters,
including temperature, humidity, and general weather
conditions, with a user-friendly interface. This project
demonstrates the integration of modern technologies to
retrieve and display weather data dynamically, highlighting
the practical application of programming and API
utilization.
By offering accurate weather information, the system serves
as a valuable tool for planning daily activities and promoting
user convenience. Future improvements could include
expanding functionality, such as multi-city weather
tracking, forecast prediction, or enhanced graphical
elements for an even better user experience.

15

You might also like