TerraLib and TerraView Wiki Page

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
wiki:designimplementation:dataaccess [2014/04/11 10:57]
marisa [Data Access]
wiki:designimplementation:dataaccess [2014/08/18 14:14] (current)
marisa [DataSource]
Line 5: Line 5:
 This module provides the base foundation for an application discover what is stored in a data source and how the data is organized in it. Keep in mind that this organization is the low-level organization of the data. For instance, in a DBMS, you can find out the tables stored in a database and the relationships between them or detailed informations about their columns (data type, name and constraints). This module provides the base foundation for an application discover what is stored in a data source and how the data is organized in it. Keep in mind that this organization is the low-level organization of the data. For instance, in a DBMS, you can find out the tables stored in a database and the relationships between them or detailed informations about their columns (data type, name and constraints).
  
-It is not the role of this module to provide higher-level metadata about the data stored in a data source. This support is provided by another TerraLib module: [[:wiki:terralib5_designimplementation#​metadata|Spatial Metadata module]].+It is not the role of this module to provide higher-level metadata about the data stored in a data source. This support is provided by another TerraLib module: [[:wiki:designimplementation#​metadata|Spatial Metadata module]].
  
 This section describes the Data Access module in details. This section describes the Data Access module in details.
Line 39: Line 39:
 Each data source driver must have a unique identifier. This identifier is a string (//in capital letters//) with the data source type name and it is available through the method ''​getType''​. Examples of identifiers are: POSTGIS, OGR, GDAL, SQLITE, WFS, WCS, MYSQL, ORACLE, SHP, MICROSOFT_ACCESS. ​ Each data source driver must have a unique identifier. This identifier is a string (//in capital letters//) with the data source type name and it is available through the method ''​getType''​. Examples of identifiers are: POSTGIS, OGR, GDAL, SQLITE, WFS, WCS, MYSQL, ORACLE, SHP, MICROSOFT_ACCESS. ​
  
-A data source is also characterized by a set of parameters that can be used to set up an access channel to its underlying repository. This information is referred as the data source connection information. This information may be provided as an associative container (a set of key-value pairs) through the method ''​setConnectionInfo''​ or using a plain connection string through the method ''​setConnectionStr''​. The key-value pairs (kvp) may contain information about maximum number of accepted connections,​ user name and password required for establishing a connection, the url of a service or any other information needed by the data source to operate. The parameters are dependent on the data source driver. So, please, check the driver documentation for any additional information on the supported parameters. When using a plain string, the information is encoded by a set of key-value pairs separated by an equal sign and each pair is separated by the ampersand (''&''​) and they must be URL encoded. For instance, in a PostGIS data source it is usual to use the following syntax:+A data source is also characterized by a set of parameters that can be used to set up an access channel to its underlying repository. This information is referred as the data source connection information. This information may be provided as an associative container (a set of key-value pairs) through the method ''​setConnectionInfo''​. The key-value pairs (kvp) may contain information about maximum number of accepted connections,​ user name and password required for establishing a connection, the url of a service or any other information needed by the data source to operate. The parameters are dependent on the data source driver. So, please, check the driver documentation for any additional information on the supported parameters. For instance, in a PostGIS data source it is usual to use the following syntax:
  
 <code cpp> <code cpp>
-std::string connInfo ​"host=atlas.dpi.inpe.br&port=5432&​dbname=mydb&​user=postgres&​password=mypasswd&​connect_timeout=20";+  std::​map<​std::string, std::​string> ​connInfo
 +  pgisInfo["PG_HOST"​] ​"atlas.dpi.inpe.br" ;   // or "​localhost";​ 
 +  pgisInfo["​PG_PORT"​] ​"​5433"​ ; 
 +  pgisInfo["​PG_USER"​] ​"postgres"; 
 +  pgisInfo["​PG_PASSWORD"​] ​"​xxxxxxx";​ 
 +  pgisInfo["​PG_DB_NAME"​] ​"​terralib4";​ 
 +  pgisInfo["​PG_CONNECT_TIMEOUT"​] = "​4";​ 
 +  pgisInfo["​PG_CONNECT_TIMEOUT"​] = "​4";​ 
 +  pgisInfo["​PG_CLIENT_ENCODING"​] = "​CP1252"; ​
 </​code>​ </​code>​
  
 For a WFS data source available at ''​http://​www.dpi.inpe.br/​wfs''​ the connection string could be: For a WFS data source available at ''​http://​www.dpi.inpe.br/​wfs''​ the connection string could be:
 <code cpp> <code cpp>
-std::string connInfo ​"service=http%3A%2F%2Fwww.dpi.inpe.br%2Fwfs";+std::​map<​std::string, std::​string> ​connInfo
 +connInfo["URI"​] ​"http://www.dpi.inpe.br/wfs";
 </​code>​ </​code>​
  
-The method ''​getConnectionInfo''​ returns an associative container (set of key-value pairs) with the connection information. The same information is also available in an URL encoded string through the method ''​getConnectionStr''​.+The method ''​getConnectionInfo''​ returns an associative container (set of key-value pairs) with the connection information.
  
 Another useful information available in a data source is its known [[:​wiki:​designimplementation:​dataaccess#​common_data_source_capabilities|capabilities]]. The method ''​getCapabilities''​ returns all information about what the data source can perform. Here you will find if the data source implementation supports primary keys, foreign keys, if it can be used in a thread environment and much more information. There is a list of common key-value pairs that every data access driver must supply although each implementation can provide additional information. Another useful information available in a data source is its known [[:​wiki:​designimplementation:​dataaccess#​common_data_source_capabilities|capabilities]]. The method ''​getCapabilities''​ returns all information about what the data source can perform. Here you will find if the data source implementation supports primary keys, foreign keys, if it can be used in a thread environment and much more information. There is a list of common key-value pairs that every data access driver must supply although each implementation can provide additional information.