A Web API and Web Application Development for Dissemination of Air Quality Information

Various studies have been carried out since 2005 under the leadership of Ministry of Environment and Urbanism of Turkey, in order to observe the quality of air in Turkey, to develop new policies and to develop a sustainable air quality management strategy. For this reason, a national air quality monitoring network has been developed providing air quality indices. By this network, the quality of the air has been continuously monitored and an important information system has been constructed in order to take precautions for preventing a dangerous situation. The biggest handicap in the network is the data access problem for instant and time series data acquisition and processing because of its proprietary structure. Currently, there is no service offered by the current air quality monitoring system for exchanging information with third party applications. Within the context of this work, a web service has been developed to enable location based querying of the current/past air quality data in Turkey. This web service is equipped with up-todate and widely preferred technologies. In other words, an architecture is chosen in which applications can easily integrate. In the second phase of the study, a web-based application was developed to test the developed web service and this testing application can perform location based acquisition of air-quality data. This makes it possible to easily carry out operations such as screening and examination of the area in the given time-frame which cannot be done with the national monitoring network.


Introduction
The longest period of hunger of which the human life can continue is usually expressed in weeks.The maximum duration of dehydration is expressed in days, while the duration of maximum asphyxiation is expressed in minutes.The amount of oxygen in the air is a primary concern for the continuity of life.The quality of the air plays a crucial role for humans for being able to enjoy and perform life in the wild (Colls and Tiwarky, 2009).Air quality has proven to affect not only to the vital quality and continuity but also on the person's mental state, motivation, and ability to perform (Boubel et al, 2013).Air pollution artefacts affect the quality of the air based on the impacts such as the installation of industrial facilities in the wrong place, the deterioration of the nature and the insufficient protection measures, improper construction, improper construction, increase of number of motorized vehicles for traffic (Colls and Tiwarky, 2009).Impact of air quality to life is very crucial and very risky situations can occur in bad air quality conditions.Nations develop policies aimed at preventing air pollution and reducing air pollutant emissions.Nevertheless, one or more of the 2010 emission limits for four major air pollutants in various countries have been exceeded.To prevent this, scientists and politicians are constantly preparing new regulations and resolutions, tracking systems and perform situation analysis.
* Corresponding author

Air Quality
The air, which has vital importance for the life of human beings and other living things, is defined as a mixture of gases in the atmosphere.The thickness of the air layer in the atmosphere is about 150 km's.In fact, only about 5 km's of it is suitable for living creatures.As one moves away from the earth, the density of the air layer decreases.The atmosphere acts like a protective cover around the earth.Pure air comes from a mixture of argon, carbon dioxide, water vapor, neon, helium, methane, krypton, hydrogen, nitrogen monoxide, xenon, ozone, ammonia and nitrogen dioxide, mainly nitrogen and oxygen.Air is a polluted environment like water and soil.Air pollution can be defined as existence of one or more pollutants in the open air, human, plant and animal life.Examples of pollutants are dust smoke, (artificial) fog, steam, coarse particles, gasses (NOx, SOx, CO, VOC) and odorous substances that adversely affect the quality of the air and harm the quality of life.The air quality varies based on the intensity of the air pollutants originating from the three sources (heating, transport and industry).For this reason, it is important to keep the air quality constantly monitored and controlled.
Air pollution is defined as the accumulation of gases or particulate matter, especially fuel residues, that are released by various chemical processes in amounts that will damage the lives of living things in the atmosphere.Rapid urbanization, industrialization, increase in the number of motor vehicles, meteorological conditions, fuels used in heating, industrial establishments and the spread of thermal power plants play an important role in increasing air pollution.The burning of fossil fuels, such as oil and coal, causes many pollutants to mix into the air.One tonne of pollutants are given to the air from each car exhaust (Güler and Vaizoglu, 2006).
Living in cities with high air pollution, there will be more heart disease, respiratory problems and lung cancer than the population living in clean air urban areas.It is estimated that 1.3 million people die from urban and outdoor air pollution every year, with more than half of the developing countries.Health effects related to both short and long term exposure of air pollution are observed.For example, in asthmatics, high ozone concentration in a single day is an increased risk for the asthma attack.However, individuals who are chronically exposed to a high level of particulate matter are at increased risk for chronic respiratory disease, lung cancer and cardiovascular disease (Public Health and Environment, 2017).
Air pollution, which has adverse effects on the environment and human health, is known to be an important factor on the quality of urban life.
"Air quality index" is obtained as a result of evaluating and interpreting the valid and reliable information about the current pollution situation measured at various time intervals and locations and at an accepted confidence level.Air Quality Index (PQI) is an index used to report daily air quality.It contains information on how clean and dirty the air of the zone is, and what kind of health effects can occur.PQI refers to the health effects that may occur within a few hours or a few days after the inhalation of polluted air.PQI can be thought of as a scale regulated between 0-500.It should be considered that air pollution increases and health risk increases as the PQI value increases.
The air quality index, (where air quality is measured) gives information about the quality of the air as good, medium, unhealthy, bad or harmful.The air quality index, together with the different air qualities, determines the effect on general public health, the level of air pollution, and the steps that should be taken when it goes up to the unhealthy level.Air quality index is an important indicator to keep the air pollution level under control without any danger.Air quality index is a simple way to report daily air quality.Air quality index is calculated for 5 basic pollutants.These; Particulate matter, carbon monoxide, CO, quartz dioxide, SO2 and nitrogen dioxide, NO2, ozone thanks to space, O3.Air quality index values have been developed for each of these pollutants (WHO, 2000).Table 1 provides U.S EPA Air Quality Index Levels as an example index.
Table 1.Air Quality Index Levels Air pollution increases as the air quality index increases.When the air quality index is over 100, it can be said that the air quality is bad for health.When the air quality index is over 300, the air quality is detrimental to health.Some indicators are as follows: Good: When the air quality index is between 0 and 50, it is assessed that the air quality is good for health and the air pollution has little effect.
Medium: Air quality can be considered when the air quality index is between 51 and 100.It means within boundaries.Some pollutants have negative effects for some people.Respiratory symptoms are seen in people who are very sensitive to ozone.Unhealthy for sensitive groups: When the air quality index is between 101 and 150, the health of sensitive group members is adversely affected.People with lung disease are at greatest risk.People with lung disease who are exposed to particle pollution are at greater risk.When the air quality index is within this range, generally healthy people are not affected much.
Unhealthy: When the air quality index is between 151 and 200, health effects do not appear in any person.More serious health effects begin to appear in sensitive people.
Very Unhealthy: Air quality index between 201-300, AQI indicates alarm sign for health.Serious health effects can be seen in any person.

Improvements in Air Quality Management in Turkey
It is stated that the initial observations on air pollution extend back to 1200 years.In U.S. and U.K., it is known that in 1948 and 1952 acute air pollution caused many people to get sick and die (Çobanoğlu,2004).The maximum amount of substances that can be found in the air has been determined by the World Health Organization(2000) and proposed to all countries of the world.With the policies and regulations applied by the European Union (EU), it has managed to keep the air quality far below the limit values.By adopting similar approaches of the EU in Turkey, the country always aims to keep the quality of the air below the limit values (Air Quality Guidelines For Europe, 2017).
The procedures and principles regarding the management and monitoring of air quality in Turkey have been determined by the "Air Quality Assessment and Management Regulation (AQAAM)" which is fully compatible with the European Union (EU) environmental legislation.This regulation ultimately aims to reach air quality values in EU countries.With this Regulation, basically 13 substance limiters (SO2, PM10, NOx, ..) and the limit values required to protect human health and environment have been determined.
For the measurement and follow-up of the air quality according to the limit values set forth in the (AQAAM) Regulation, an 81day measurement station was established between 2005-2007 with a National Air Quality Monitoring Network that was established throughout Turkey.The Turkish air quality data and analysis is maintained within the scope of this network, which is under the responsibility of the Ministry of Environment and Urbanization.The data is presented with a web-based application tool.The application accessed via the http://www.havaizleme.gov.tr, it is possible to follow up and analyse the active stations on a Web map.The system has approximately 250 built-in stations and mobile vehicles and stores 13 different parameters for air quality measurement in Turkey.Yahşi (2008), who is in charge of the Ministry, emphasized the complementary and inclusive direction of the monitoring network and stated that the effort was not only new installations of air quality stations but also management of measurements in stations previously established with public facilities throughout Turkey.The most important aspect of was system centralization.The data obtained from the stations are stored in the Environmental Reference Laboratory, the Centre of the Air Quality Monitoring Network within the Ministry.The data is analysed and validated on daily basis.Daily, monthly and annual reporting studies are carried out using validated data and integrated into the web based application.
Prior to the implementation of the National Air Quality Monitoring Network, air quality measurements were carried out by the Ministry of Health nationwide by semi-automatic devices until 2005, under the 1986 Regulation on the Protection of Air Quality.Because the measurements were made with semiautomatic devices, the results of the measurements were evaluated only after several days by the authorities.With the established network structure, the data for air quality can be transferred without any problem to the digital environment.However, the data obtained was kept in a proprietary application and data processing was limited to the capabilities and capabilities of the application.Although a central structure exists, the data are not transformed into a form that is as accessible and workable as centralized.For this reason, analysis and evaluation can only be carried out within the limits and possibilities of implementation and implementers.It was not possible to access the data by the third party software or components.The architecture of the proprietary system is provided in Figure 1.

Open Data and Processing Technologies
Reusable and shareable data that can be freely accessed by anyone who wants it.It is freely accessible, usable, and distributable so that a particular data can be used and published by anyone without the restrictions of copyright, patent and other control mechanisms.Open data encourages innovation, enhances efficiency and enhances economic development.At this point, it is important that the air quality data for a country presented in a structure that permits open access.Open data can be controlled through technological facilities.Web technologies play a key role in dissemination of open data.Web services help the exchange and transfer of the open data over the web resources as representations of data objects.Web services are functions that can be published, searched, and accessed via the web.RESTful software architectures are accepted as the gold standard for providing web service interfaces to applications.These interfaces are called Web APIs or simply APIs.There are data representation standards in the use of web services.These include XML (Extensible Markup Language) and Java Script Object Notation (JSON).JSON is a data transfer method between programming languages (Fang H et al., 2013).Compared to XML, JSON is more convenient to use, both in terms of speed and coverage.The use of JSON format as direct server code provides great convenience for the development of servers and clients.JSON format is used for data exchange on the web service developed in this application.

The Purpose and Importance of Research
The first objective of the National Air Quality Monitoring Network was to explore the relationship and impact of data collected in different areas with clear and secure access to the collected data.In order to be able to demonstrate the significance of meteorological phenomena and regional data in air quality, it is important to fit the data into a processable form.This national network plays an important role in centralizing the data and aggregating at a single point, but requires open access for enabling co-ordination with third party applications.As there was no service offered by the current air quality monitoring system for exchanging information with third party applications.The main questions of the research were formulated as follows: 1. Can air quality data be exported and processed by third party applications in a secure manner?2. Is it possible to develop a third party application and convert the data obtained at stations into regional or spatial monitoring ?A web service has been developed within the context of this work, to enable location based querying of the current/past air quality data in Turkey.

Limitations
The existing monitoring network design and architecture are excluded from the research and are expected to meet the necessary conditions and international criteria.The adequacy of the number and distribution of air quality monitoring stations required for the development of a such web service was not tested in the scope of this study.Since the validity and reliability of the obtained data is made by the monitoring network management, it is assumed that all air quality data is accurate and up-to-date.

Data Collection
The web-based application of the National Air Quality (AQ) Monitoring Network was used for obtaining the data that is used in this research.AQ data is obtained periodically by utilizing the reporting module using conventional methods.It is possible to obtain data by querying the web application in the reporting module, but it is difficult to process the presented data formats in real time.The obtained data is regularly transferred to the database via the web service, so that it can be used in the application prepared within the scope of the research.

RESTFUL WEB API DEVELOPMENT
After the database structure and the schema is prepared, the web service structure is constructed.The study was carried out in two stages.The first phase includes web service activities developed to present the prepared database in a safe and convenient condition.With the web service developed, the historical AQ data can be accessed securely and without unnecessary resource consumption, excessive bandwidth consumption and problems caused by false inquiries are prevented.The web service has been developed with REST approach, one of the most widely used service oriented architectures today.As Richardson and Ruby (2007) points out, REST is a modern web architecture, it is often used and preferred because it is lightweight, simple and extensible.With the REST approach, web service APIs can be easily consumed by different development platforms, where consumer applications can focus on processing rather than data access.
The fact that REST is built on the HTTP protocol also allows easy development of client-side applications (Akyokus,2001).Richardson and Ruby (2007) states that REST does not force the use of a proxy or WSDL, such as SOAP, when compared to an alternative protocol, SOAP.This means that server-based application developers have become faster and more convenient adapters.
This study fulfils the REST protocol requirements in the web service that is developed.Two of REST's four existing request types have been developed as they are suitable for the purpose of the web service in this study.
In general GET, PUT, POST and DELETE request types are common, where in our implementation the developed API can be reached by the GET and PUT methods.The GET method was developed to provide data for clients and the PUT method was used to load the data obtained from the monitoring network into the service.The GET method defines 5 parameters that third-party application developers can use.
It is possible to interrogate three of these four parameters.Sample web service request queries are provided in Figure 2. The first request is to get AQ date between given dates, the response to second one provides the al historical AQ data for a chosen station, the result of the third query will provide all historical AQ data within the bounding box defined by geocoordinates.

Figure 2. Sample Web Service Requests
In the JSON datasets output for the GET method, all detailed parameters for air quality are available.If gas is present in the station without measurement, the value is returned as "NA".A sample JSON output is provided in Figure 3.

CONCLUSIONS
As a result of the ongoing research and implementations of the Web API and the Web Application, the historical air quality data for Turkey has been transformed into a form that can be used by third party applications.The balloon chart was chosen as the visualization method of the air quality and visualised on the map of the region.
In the future studies, the application will be extended to send warnings to the mobile users.Thus the necessary interventions can be done quickly and at a location when the AQ values go into dangerous/harmful levels for a period.Predictions can be made by checking AQ trends for specific months and precautions can be taken by making analysis from the historical data.Furthermore, the developed interface would be beneficial for researchers to reach historical AQ data for making analysis regarding other events in the city such as traffic congestion and energy consumption trends.

Figure 1 .
Figure 1.Architecture for Turkish AQ Monitoring System

Figure 3 .
Figure 3. Sample JSON Output4.DEVELOPMENT OF THE WEB APPLICATIONIn the first stage of the research, the historical air quality data was made available in real time to the third party applications by the developed web service API.Figure4provides a sequence diagram of the developed API.

Figure 4 .
Figure 4.AQ Web API Sequence Diagram In the second phase of the study, an application that uses the web service was developed and implemented.The reporting section of the National Air Quality Monitoring Network project allows station-based query and analysis only.Through the application developed in the second phase of the study, various

Figure 5 .
Figure 5.Web Application Query Interface-AAs illustrated in Figure5and Figure6, users can either select a location from the list or pick a location from a Web Map which would form the basis for the query.Later the users can select a date range(e.g. between 2002-2006)  for getting the AQ data between those dates.Later monitoring parameters that would e used to genrate a Air Quality Index are selected from a list.

Figure 6 .
Figure 6.Web Application Query Interface-BAs the result of the query the air quality indexes of the stations that are located in the chosen geographical region is visualised on the web map as illustrated in Figure7.

Figure 7 .
Figure 7.Visualisation of Air Quality Index