Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
wdb:manuals:wdb_call_interface [2012-04-04 12:56:38] michaeloa [WDB Call Interface User Manual] |
wdb:manuals:wdb_call_interface [2022-05-31 09:29:32] (current) |
||
---|---|---|---|
Line 6: | Line 6: | ||
This is the User's Manual for WDB Call Interface. | This is the User's Manual for WDB Call Interface. | ||
- | ===== Chapter�1.�Introduction | + | ===== Introduction |
- | + | ||
- | **Table of Contents** | + | |
- | + | ||
- | [[# | + | |
The WDB Call Interface (WCI) is the official API used for retrieving data from the WDB system. | The WDB Call Interface (WCI) is the official API used for retrieving data from the WDB system. | ||
- | ===== About this Manual | + | ==== About this Manual ==== |
This manual is intended for system designers, application developers and programmers. It describes in technical terms how weather data can be retrieved from the WDB system through the WCI. It is assumed that the reader has some familiarity with databases and weather data. | This manual is intended for system designers, application developers and programmers. It describes in technical terms how weather data can be retrieved from the WDB system through the WCI. It is assumed that the reader has some familiarity with databases and weather data. | ||
Line 20: | Line 16: | ||
For a more elaborate description of the vision and system architecture of the WDB system, see the WDB Developer' | For a more elaborate description of the vision and system architecture of the WDB system, see the WDB Developer' | ||
- | ===== Intended Usage ===== | + | ==== Intended Usage ==== |
WCI is intended to be used for retrieving weather data (e.g., temperature, | WCI is intended to be used for retrieving weather data (e.g., temperature, | ||
- | ===== Outline | + | ==== Outline ==== |
This document is structured as follows: | This document is structured as follows: | ||
Line 36: | Line 32: | ||
* Known bugs and limitations | * Known bugs and limitations | ||
- | ===== Chapter�2.�Key | + | ===== Key Concepts ===== |
- | + | ||
- | **Table of Contents** | + | |
- | + | ||
- | [[# | + | |
This section provides an overview of the WCI, including some important definitions and explanations. | This section provides an overview of the WCI, including some important definitions and explanations. | ||
- | ===== Overview | + | ==== Overview ==== |
WCI is an API designed to retrieve weather data from the WDB system. The WCI API resides on the database server. | WCI is an API designed to retrieve weather data from the WDB system. The WCI API resides on the database server. | ||
Line 64: | Line 56: | ||
The dimensions are described in the following sections. | The dimensions are described in the following sections. | ||
- | ===== Data Provider | + | ==== Data Provider ==== |
The Data Provider identifies the source of the data; literally, //the entity that provides the data//. Where multiple sources could be identified as the source of the data, the entity that can be identified closest to the creation of the data item at the time of loading is usually used. | The Data Provider identifies the source of the data; literally, //the entity that provides the data//. Where multiple sources could be identified as the source of the data, the entity that can be identified closest to the creation of the data item at the time of loading is usually used. | ||
Line 82: | Line 74: | ||
SELECT * FROM wci.getDataProvider( NULL ); | SELECT * FROM wci.getDataProvider( NULL ); | ||
- | ===== Place (Geographic Location) | + | ==== Place (Geographic Location) ==== |
The place (geographic location) of a data item is the position of the item on the earth in a 2D space. In WDB, the geographic location is by default specified using longitude and latitude in a WGS84 coordinate system (though this can be changed when the database is set up; consult your system administrator). The geographic dimension is specified using a geometry object and can be either a point or a polygon. | The place (geographic location) of a data item is the position of the item on the earth in a 2D space. In WDB, the geographic location is by default specified using longitude and latitude in a WGS84 coordinate system (though this can be changed when the database is set up; consult your system administrator). The geographic dimension is specified using a geometry object and can be either a point or a polygon. | ||
Line 112: | Line 104: | ||
SELECT * FROM wci.getPlaceDefinition( NULL ); | SELECT * FROM wci.getPlaceDefinition( NULL ); | ||
- | ===== Reference Time ===== | + | ==== Reference Time ==== |
The reference time of a data item is the moment when the data item is referenced from. For forecast data, this would typically be the reference time of the data values the forecast is based upon; for observation data, it would typically be the time when the observation data was recorded. | The reference time of a data item is the moment when the data item is referenced from. For forecast data, this would typically be the reference time of the data values the forecast is based upon; for observation data, it would typically be the time when the observation data was recorded. | ||
Line 144: | Line 136: | ||
Denotes that the user wants to return all data inside the time period between the time point of 11:20 UTC, on the 31st of March, 2009 and the same time two months later. | Denotes that the user wants to return all data inside the time period between the time point of 11:20 UTC, on the 31st of March, 2009 and the same time two months later. | ||
- | ===== Valid Time ===== | + | ==== Valid Time ==== |
The valid time of a data item is the time period for which the data item is valid. The valid time is always stored in the database as a time interval. | The valid time of a data item is the time period for which the data item is valid. The valid time is always stored in the database as a time interval. | ||
Line 176: | Line 168: | ||
The contains keyword returns all the data with valid times beginning prior to the specified time and ending after the specified time. Semantics are inclusive, so a valid time that matches exactly would be returned as a row by this query. | The contains keyword returns all the data with valid times beginning prior to the specified time and ending after the specified time. Semantics are inclusive, so a valid time that matches exactly would be returned as a row by this query. | ||
- | ===== Value Parameter | + | ==== Value Parameter ==== |
Each data value can be described using a "value parameter" | Each data value can be described using a "value parameter" | ||
Line 190: | Line 182: | ||
SELECT * FROM wci.getValueParameter( NULL ); | SELECT * FROM wci.getValueParameter( NULL ); | ||
- | ===== Level ===== | + | ==== Level ==== |
The //Level// dimension is normally used to designate the altitude or depth of the data value. Level is designated using a level interval (height from and to) and a level parameter (e.g., height above sea level, pressure). The level definition can be prefixed with a level interpolation option that permits the user a large degree of flexibility in expressing searches. Levels are specified using a level specification in string form that is parsed by the WCI. | The //Level// dimension is normally used to designate the altitude or depth of the data value. Level is designated using a level interval (height from and to) and a level parameter (e.g., height above sea level, pressure). The level definition can be prefixed with a level interpolation option that permits the user a large degree of flexibility in expressing searches. Levels are specified using a level specification in string form that is parsed by the WCI. | ||
Line 220: | Line 212: | ||
SELECT * FROM wci.getLevelParameter( NULL ); | SELECT * FROM wci.getLevelParameter( NULL ); | ||
- | ===== Data Version | + | ==== Data Version ==== |
There can be several different versions of the same data value that is valid for the same time, position, etc. This can happen with probability forecast calculations or when a data value is edited (in which case the new value may often be inserted with a higher data version). A data version is always a positive whole number. | There can be several different versions of the same data value that is valid for the same time, position, etc. This can happen with probability forecast calculations or when a data value is edited (in which case the new value may often be inserted with a higher data version). A data version is always a positive whole number. | ||
Line 228: | Line 220: | ||
There is no wci.browse functionality to list all of the data versions of the data in the database. | There is no wci.browse functionality to list all of the data versions of the data in the database. | ||
- | ===== Chapter�3.�Using | + | ===== Using the WCI ===== |
- | + | ||
- | **Table of Contents** | + | |
- | + | ||
- | [[# | + | |
This section gives an overview on how to use the WCI to retrieve data values from WDB. | This section gives an overview on how to use the WCI to retrieve data values from WDB. | ||
- | ===== Outline | + | ==== Outline ==== |
The following list provides a brief overview of the actions that the user takes in order to retrieve data from WCI. | The following list provides a brief overview of the actions that the user takes in order to retrieve data from WCI. | ||
Line 246: | Line 234: | ||
* Close database connection | * Close database connection | ||
- | ===== Open a connection | + | ==== Open a connection ==== |
To enable communication with WCI, the user must open a connection to the database. How this is done depends very much on the application or API that is being used (consult the documentation of the program or API for information). | To enable communication with WCI, the user must open a connection to the database. How this is done depends very much on the application or API that is being used (consult the documentation of the program or API for information). | ||
Line 256: | Line 244: | ||
The connection must be open and valid as long as commands are being sent and data retrieved from the database. It is worth noting that connections are a resource; the database will have limits on how many connections can be open at the same time. This is particularly important for massively multi-user applications (e.g., web applications). In such cases, the database connections must be managed with some care. There is also an amount overhead involved with setting up a connection, so it will always be more efficient to connect once and perform multiple database operations, than to connect repeatedly for each operation. | The connection must be open and valid as long as commands are being sent and data retrieved from the database. It is worth noting that connections are a resource; the database will have limits on how many connections can be open at the same time. This is particularly important for massively multi-user applications (e.g., web applications). In such cases, the database connections must be managed with some care. There is also an amount overhead involved with setting up a connection, so it will always be more efficient to connect once and perform multiple database operations, than to connect repeatedly for each operation. | ||
- | ===== Initialize WCI ===== | + | ==== Initialize WCI ==== |
Before WCI may be used by the user, it must be initialized. | Before WCI may be used by the user, it must be initialized. | ||
Line 268: | Line 256: | ||
Name spaces are used to identify what set of names should be used for searching the database. While the user is in a namespace, only the data defined in that namespace is visible to the user. If the user should wish, for some reason, to combine data from different namespaces within an application, | Name spaces are used to identify what set of names should be used for searching the database. While the user is in a namespace, only the data defined in that namespace is visible to the user. If the user should wish, for some reason, to combine data from different namespaces within an application, | ||
- | ===== Read from the WCI ===== | + | ==== Read from the WCI ==== |
As soon as the user has initialized WCI using wci.begin, the database is ready for retrieval of data. Data is retrieved using the wci.read function, and data is searched for by setting the appropriate dimensions in that call. | As soon as the user has initialized WCI using wci.begin, the database is ready for retrieval of data. Data is retrieved using the wci.read function, and data is searched for by setting the appropriate dimensions in that call. | ||
- | ==== Reading Point Data from WCI ==== | + | === Reading Point Data from WCI === |
The wci.read function is overloaded to permit the user to read either point data or binary data (entire grids) from the database. The last parameter in the wci.read function allows the user to specify the return type of the query. To return point data values, the user specifies wci.returnFloat. | The wci.read function is overloaded to permit the user to read either point data or binary data (entire grids) from the database. The last parameter in the wci.read function allows the user to specify the return type of the query. To return point data values, the user specifies wci.returnFloat. | ||
Line 304: | Line 292: | ||
The above call returns all precipitation parameters valid for the 10 days following the given referencetime measured at the nearest point to oslo. Oslo, in this case, is a place name usually defined as a geographical point within the database. Prefixing the place name is the interpolation that we wish to use when retrieving points; we could also have used any of the alternatives defined in the reference manual below. Note the use of SQL wildcard characters in the value parameter; although these slow down queries (since wildcard searching is not as efficient as a straight comparison), | The above call returns all precipitation parameters valid for the 10 days following the given referencetime measured at the nearest point to oslo. Oslo, in this case, is a place name usually defined as a geographical point within the database. Prefixing the place name is the interpolation that we wish to use when retrieving points; we could also have used any of the alternatives defined in the reference manual below. Note the use of SQL wildcard characters in the value parameter; although these slow down queries (since wildcard searching is not as efficient as a straight comparison), | ||
- | === Return values | + | == Return values == |
The return value from this call is one row for each value. This means that if you have chosen an interpolation type that will return several values for each grid, you will get many rows for each grid. | The return value from this call is one row for each value. This means that if you have chosen an interpolation type that will return several values for each grid, you will get many rows for each grid. | ||
Line 310: | Line 298: | ||
The actual data value is given in the column " | The actual data value is given in the column " | ||
- | ==== Reading Grid Data from WCI ==== | + | === Reading Grid Data from WCI === |
Reading grid data from the database is a two-step process. First the user retrieves the Grid ID with wci.read function (with wci.returnGId), | Reading grid data from the database is a two-step process. First the user retrieves the Grid ID with wci.read function (with wci.returnGId), | ||
Line 336: | Line 324: | ||
The above call returns a single row, containing a binary string containing the actual grid data. It also includes additional information detailing the configuration of the grid. For details about the wci.fetch call, see the function reference. | The above call returns a single row, containing a binary string containing the actual grid data. It also includes additional information detailing the configuration of the grid. For details about the wci.fetch call, see the function reference. | ||
- | === Return values | + | == Return values == |
The return value from this call is one row for each grid. The number given in the " | The return value from this call is one row for each grid. The number given in the " | ||
- | ===== Release WCI ===== | + | ==== Release WCI ==== |
Once the user has finished retrieving data using WCI, it is a good idea to close down WCI. | Once the user has finished retrieving data using WCI, it is a good idea to close down WCI. | ||
Line 348: | Line 336: | ||
This is not strictly necessary, but allows the system to graciously deallocate resources and reset any settings that may have been changed by WCI. | This is not strictly necessary, but allows the system to graciously deallocate resources and reset any settings that may have been changed by WCI. | ||
- | ===== Close Connection | + | ==== Close Connection ==== |
Closes down the connection to the database, freeing up the resources on the database to be used by other applications. | Closes down the connection to the database, freeing up the resources on the database to be used by other applications. | ||
Line 356: | Line 344: | ||
PQfinish(connection_); | PQfinish(connection_); | ||
- | ===== Chapter�4.�Function | + | ===== Function |
- | + | ||
- | **Table of Contents** | + | |
- | + | ||
- | [[# |