Knowledge Base

KB10810 - Connecting a TatukGIS product to a PostGIS SQL layer.

TatukGIS Developer Kernel Enterprise version and desktop GIS Editor products support reading/writing PostGIS SQL database vector data structure and its spatial indexes. (The free GIS Viewer provides read-only support.) Further to the information contained in this knowledge base item, detailed and more frequently updated information about TatukGIS support for PostGIS layer class and data structures is found in the Developer Kernel product documentation web site at:

The PostGIS layer can be opened by opening a *.ttkls file with the name_of_layer.ttkls or, without the use of a *.ttkls file, by i) embedding all the *.ttkls file parameters into the Path property as a CRLF or '\n' delimited sting (as a new line) or ii) assigning the *.ttkls file parameters to the SQLParameters property using SQLParameters[‘KEY’] = VALUE.

The TTKLS is a TatukGIS stub file which contains the connection settings for database map layer. A TTKLS file can be created i) manually using any text editor (such as Note Pad) or ii) using the SQL connection Wizard feature in the TatukGIS Editor product (refer to the helpfile for menu item: Layer/Add SQL Layer). The structure of the *.ttkls file for a PostGIS layer must be:

  [TatukGIS Layer]
  Layer=name|name;schema|name;schema;catalog (can be case sensitive)
  Features=table/view name; if provided will replace standard features table
  ADO=ADO connection string if not exist then DBX connection will be used
  GeometryFieldCast=Text|Binary|EWKB - default is Text if parameter omitted
  GeometryRelationships=Server|Client - default is Client if parameter omitted
  DriverName=see DBExpress help for TSQL Connection
  GetDriverFunc=see DBExpress help for TSQL Connection
  VendorLib=see DBExpress help for TSQL Connection
  LibraryName=see DBExpress help for TSQL Connection
  Parameters key=value

For example:

  [TatukGIS Layer]

  [TatukGIS Layer]
  ADO=Provider=PostgreSQL.1;Password=123456;User ID=postgres; Data Source=localhost;
    Location=postgis; Extended Properties=""

This layer can also be opened by providing SQLParameters property. OnPassword event will be fired upon connecting to a database to resolve <#user#>, <#password#> or any other <#token#> embedded into connection options.

Using PgOleDB driver

For freely available PgOleDB driver up to

The driver at this time does not support bytea data type, so set initialization parameter to GeometryFieldCast=Text. Updates and import at the read-write connection uses INSERT INTO or UPDATE command because there is no implementation for methods like AddNew, property Field.Items.Value. Working in read, read-write access with PostGIS layers is only possible for (GeometryFieldCast=Text).

Using PostgreSQL ODBC driver

For freely available PostgreSQL ODBC driver from PostgreSQL Development Group.

In read-only or read-write access, any value (EWKB, Text, Binary) for GeometryFieldCast is possible. But the last value (GeometryFieldCast=Binary) makes for much faster access to layer. In the case of EWKB, every BLOB will be translated to Extended Well-Known Binary form, which extends the standard with support for 3DZ (Z - elevation), 3DM (M - measure), and 4D coordinates. Access to the layer at EWKB mode is slower than the two other modes. Import to PostGIS layer is only possible for (GeometryFieldCast=Text).

Using DBX

Working in read, read-write access with PostGIS layers is only possible for (GeometryFieldCast=Binary|EWKB). If you check DE9-IM coincidence between geometry objects, you should take into consideration the setting of GeometryRelationships. You may decrease the number of returned rows from the server, but access to the layer will be slower if you set GeometryRelationships=Server. For GeometryRelationships=Client, access to layer will be fast.

Created: June 05, 2009, Modified: February 13, 2017
follow us on Facebook  follow us on Twitter  follow us on Google +  follow us on LinkedIn  Embarcadero