PostGis - ObjectVision/GeoDMS GitHub Wiki

PostGIS is the spatial extension of the open source PostgreSQL database. Vector data and non spatial data can be read from a PostgreSQL database with the gdal.vect StorageManager. The PostGIS extension needs to be installed in the database to read vector data. The GDAL PostgreSQL driver is part of the GDAL library included with the GeoDMS.

Unlike file based sources, a PostgreSQL database is addressed with a connection string. The StorageName property is configured with a string starting with the prefix PG:, in which the parameters host, port, user, password and dbname must be configured. This connection string is passed on to GDAL, which selects the PostgreSQL driver.

Read

Example:

container PostGreSQL
:  StorageName = "PG:host='localhost' port='5432' user='dms' password='dms' dbname='geo'"
,  StorageType = "gdal.vect"
{
   container administrative
   {
      unit<uint32> municipality: SqlString = "SELECT geom, name FROM cbs.munic ORDER BY code"
      {
         attribute<point_rd> geom (polygon);
         attribute<string>   name;
      }
   }
}

The database geo is configured for the container PostGreSQL. Within the subcontainer administrative, a domain unit is configured, called municipality.

The attributes geom (the feature attribute with the polygon geometry) and the name of the municipality are read from the database.

In the SqlString property the fields geom and name are selected. Their source name in the database (the FROM clause) is cbs.munic, in which cbs indicates the schema name and munic the table name within that schema. The ORDER BY clause guarantees all municipalities are always read in the same sequence (ordered by code) from the database. As the GeoDMS calculates with arrays, this sequence is relevant, see SqlString.

issues with reading from PostgreSQL/PostGIS

The issues described for database sources in general also apply to PostgreSQL:

  1. A PostgreSQL database is not file oriented. The timestamp mechanism of the GeoDMS can therefore not determine if the primary data has changed since the last results were calculated.
  2. Exchanging data with a non file oriented database between partners in projects is often less easy than with files.

For these reasons we advise, where possible, to work with file based sources such as a Geopackage, for instance by exporting the relevant tables from the PostgreSQL database.

see also

⚠️ **GitHub.com Fallback** ⚠️