PostGIS is a spatial operation extension of the PostgreSQL relational database. It provides PostgreSQL with the ability to store, query, and modify spatial relationships.
PostgreSQL is an open-source spatial database, and the spatial object extension module PostGIS built on it makes it a truly large spatial database. SuperMap provides the SDX+ for PostGIS engine, which can directly access PostgreSQL spatial databases and make full use of the capabilities of spatial information service databases, such as spatial objects, spatial indexes, spatial operation functions, and spatial operators, to manage and access spatial data efficiently.
PostGIS is described in the following aspects:
Deploying the PostGIS Spatial Database Environment
Displaying PostGIS Spatial Data
Deploying the PostGIS Spatial Database Environment
It includes two parts: installing and configuring the PostgreSQL database, and installing and configuring PostGIS.
- Step 1: Install and configure the PostgreSQL database. For detailed steps of PostgreSQL installation, please refer to Installing PostgreSQL.
After installing PostgreSQL, find the pg_hba.conf file under the database data storage path (D:\Program Files\PostgreSQL\9.6\data), and add the content boxed in the figure at the position shown below, so that the PostgreSQL database service can be accessed via IP address.

Figure: Modifying the PostgreSQL Configuration File - Step 2: Install and configure PostGIS
Precautions:The version of PostGIS must be consistent with the version of PostgreSQL; otherwise, you may fail to create or open a database-type datasource on the SuperMap iDesktopX desktop after successful installation.
- Start the installer: postgis-bundle-pg96x64-setup-2.4.2-1.exe.

- You can choose to create a spatial database here, so that after the installation is completed, you can finish creating the database according to the wizard dialog box; you can also create it through the pgAdmin tool after the installation is completed.

- Specify the installation path of the program and execute the installation. The installation path must be consistent with the installation path of PostgreSQL.

- After the installation is completed, a dialog box will pop up asking about the configuration of raster functions. Select as needed; click "Yes" here to finally complete all installation steps.


- Start the installer: postgis-bundle-pg96x64-setup-2.4.2-1.exe.
Creating a PostGIS Database
First, make sure the PostgreSQL database service has been started. Create a PostgreSQL database through pgAdmin to manage PostGIS spatial data. The specific operations are as follows.
- Run pgAdmin, right-click "Databases", and select Create>Database.

- Specify parameters such as the database name (Database), owner (Owner), and encoding (Encoding).


- Click "Save" to finish creating the database.
SDX+ for PostGIS
Manage PostGIS spatial data in the PostgreSQL database through the SDX+ for PostGIS engine. Using the SuperMap desktop to manage PostGIS spatial data is simple and convenient, and all maintenance of related tables in the PostgreSQL database is completed by the SDX+ for PostGIS engine.
The management of PostGIS spatial data generally includes: creating databases, creating/deleting datasources, creating/deleting datasets, adding/deleting records (geometric objects), adding/deleting fields in datasets, updating field values, and querying data.
- Creating a PostGIS Datasource
- When creating a PostGIS database-type datasource through the SuperMap desktop, you can either specify an existing PostgreSQL database name to create the datasource, or specify a new database name, in which case the corresponding PostgreSQL database will be created first and then the datasource. Only one PostGIS database-type datasource can be created for one PostgreSQL database.
- Meanwhile, after a PostGIS database-type datasource is created, a series of system tables for datasource management will be added to the PostgreSQL database.

Figure: The geometry_columns system table records which tables have spatial information 
Figure: The spatial_ref_sys system table stores the spatial coordinate system information of the OGC standard - In a PostGIS database-type datasource, you can create datasets or import data from other sources. The dataset types supported by the SDX+ for PostGIS engine include: point, line, region, text, CAD, attribute table, 3D point/line/region/model, EPS composite point/line/region/text, raster, image, and mosaic dataset. In addition, if the specified database already contains third-party spatial data conforming to the PostGIS spatial data structure, the data will also be read and managed by the datasource after the PostGIS database-type datasource is created.
- Editing PostGIS Spatial Data
SDX+ for PostGIS supports various editing operations on geometric objects:
- Adding/deleting geometric objects: multiple types of geometric objects can be added: point, line, region, and text.
- Editing geometric objects: supports editing nodes of geometric objects, splitting geometric objects, island and hole polygon processing, etc.
- Operations on geometric objects: supports basic operations such as union and intersection of geometric objects.
- Displaying PostGIS Spatial Data
- SDX+ for PostGIS supports the visualization of PostGIS spatial data, and can be used to configure styles and make various thematic maps based on PostGIS spatial data.
- The operations on PostGIS spatial data supported by the SDX+ for PostGIS engine are all implemented through PostGIS functions. PostGIS provides a large number of spatial data operation functions, including both geometric object operations and raster data operations. Currently, the PostGIS functions connected by the SDX+ for PostGIS engine can meet the needs of map cartography and basic spatial analysis operations. If your application requirements go beyond this scope, please refer to the PostGIS reference manual: https://postgis.net/docs/manual-2.4/