Skip to content

Commit

Permalink
Rephrase README.md and postgis package docs version and description
Browse files Browse the repository at this point in the history
This commit updates the README  and postgis package docs version and
description:

This commit includes the following changes:
1. README.md:
   - Replaced all instances of "Greenplum" with "Cloudberry" to reflect
     the new naming convention.
2. postgis/package/gppkg_spec.yml.in:
   - update the version of hashdata and cloudberry database and the
     description of postgis.
3. postgis/package/gppkg_spec_v2.yml.in:
   - update the version of hashdata and cloudberry database and the
     description of postgis.
4. postgis/package/postgis.spec:
  - update the summary and description of postgis.

 Related to Issue#id <cloudberry-contrib#2>
  • Loading branch information
August-beaulo committed Jun 13, 2024
1 parent e0d25bd commit 6feaab7
Show file tree
Hide file tree
Showing 4 changed files with 140 additions and 62 deletions.
186 changes: 132 additions & 54 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,72 +1,150 @@
# geospatial repo
PostGIS 3.3.2 for Greenplum 7.x
# PostGIS 3.3.2 for Cloudberry Database

## License
This project is developed under GPL v2, because PostGIS is GPL v2.
[![Slack](https://img.shields.io/badge/Join_Slack-6a32c9)](https://communityinviter.com/apps/cloudberrydb/welcome)
[![Twitter Follow](https://img.shields.io/twitter/follow/cloudberrydb)](https://twitter.com/cloudberrydb)
[![Website](https://img.shields.io/badge/Visit%20Website-eebc46)](https://cloudberrydb.org)
[![GitHub Discussions](https://img.shields.io/github/discussions/cloudberrydb/cloudberrydb)](https://github.com/orgs/cloudberrydb/discussions)

---

## What's PostGIS

[PostGIS](https://postgis.net/) extends the capabilities of the PostgreSQL by adding support for storing, indexing, and querying geospatial data. This repo is dedicated and optimized for Cloudberry Database clusters.

## Compile PostGIS for Cloudberry Database

We need to install the pre-requested dependencies and compile a few components before we install the PostGIS for Cloudberry Database. Currently, we only support compiling it on CentOS (Rocky Linux is in the plan).

Also, please make sure Cloudberry Database has been installed on your machine correctly before we start. If not, please follow the [document](https://cloudberrydb.org/docs/) to install.

Now, let's get started.

1. Install the pre-requested dependencies.

```bash
yum install -y libtool proj-devel boost-devel gmp-devel mpfr-devel pcre-devel protobuf protobuf-c protobuf-devel protobuf-c-devel && \
yum install -y gcc make subversion gcc-c++ sqlite-devel libxml2-devel swig expat-devel libcurl-devel python36-devel json-c
```

2. Build the components (GDAL, CGAL, SFCGAL, and GEOS). Make sure to build them by `root`.

2.1 Build GDAL

[GDAL](https://gdal.org/index.html) is a translator library for raster and vector geospatial data formats. Follow the commands to install it:

```bash
wget https://download.osgeo.org/gdal/2.2.1/gdal-2.2.1.tar.gz --no-check-certificate
tar xf gdal-2.2.1.tar.gz
cd gdal-2.2.1/
./configure --prefix=/usr/local/gdal-2.2.1
make && make install
```

## How to compile it
Currently, we support building geospatial on rhel/centos. To compile geospatial form source code, please install the following third-party libraries as described in [README.libs](https://github.com/greenplum-db/geospatial/blob/master/postgis/README.libs).
For normal use without raster, please install json-c, geos and proj.4.
To enable raster functionality, please install gdal and expat. The minimum version requirments are listed in [Makefile.version](https://github.com/greenplum-db/geospatial/blob/master/postgis/Makefile.version).
2.2 Build CGAL

Before setting up geospatial, please make sure GPDB is installed correctly.
To compile and install geospatial, use following command:
[CGAL](https://www.cgal.org/) provides easy access to efficient and reliable geometric algorithms in the form of a C++ library. Follow the commands to install it:

```
cd postgis/build/postgis-3.3.2/
./autogen.sh
./configure --with-pgconfig=$GPHOME/bin/pg_config --with-raster --without-topology --prefix=$GPHOME
make USE_PGXS=1 clean all install
```
```bash
wget https://github.com/CGAL/cgal/archive/releases/CGAL-4.13.tar.gz
tar xf CGAL-4.13.tar.gz
cd cgal-releases-CGAL-4.13/
mkdir build && cd build
cmake ..
make && make install
```

Here USE_PGXS will specify the correct install path to gpdb.
2.3 Build SFCGAL

Note that if psql is in path, there is no need to use --with-pgconfig flag.
[SFCGAL](https://github.com/Oslandia/SFCGAL) is a C++ wrapper library around CGAL to support ISO 19107:2013 and OGC Simple Features Access 1.2 for 3D operations. Follow the commands to install it:

## How to use it
After installing geospatial extension, run the following commands to enable it:
```bash
wget https://github.com/Oslandia/SFCGAL/archive/v1.3.6.tar.gz
tar xf v1.3.6.tar.gz
cd SFCGAL-1.3.6/
mkdir build && cd build
cmake -DCMAKE_INSTALL_PREFIX=/usr/local/sfcgal-1.3.6 ..
make && make install
```

```
psql mydatabase
mydatabase# CREATE EXTENSION postgis; -- enables postgis and raster
mydatabase# CREATE EXTENSION fuzzystrmatch; -- required for installing tiger geocoder
mydatabase# CREATE EXTENSION postgis_tiger_geocoder; -- enables tiger geocoder
mydatabase# CREATE EXTENSION address_standardizer; -- enable address_standardizer
mydatabase# CREATE EXTENSION address_standardizer_data_us;
```
2.4 Build GEOS

To configure raster utilities, please set the following environment variables on the master host and all the segment hosts. A suggested way to do this is to add these variables into your `$GPHOME/greenplum_path.sh` file to ensure they get set in all the segment hosts and the master host. **Make sure that you restart the database after setting them**.
[GEOS](https://libgeos.org/) is a C/C++ library for computational geometry with a focus on algorithms used in geographic information systems (GIS) software. Follow the commands to install it:

```
export GDAL_DATA=$GPHOME/share/gdal
export POSTGIS_ENABLE_OUTDB_RASTERS=0
export POSTGIS_GDAL_ENABLED_DRIVERS=DISABLE_ALL
```
```bash
wget https://download.osgeo.org/geos/geos-3.7.0.tar.bz2 --no-check-certificate
tar xf geos-3.7.0.tar.bz2
cd geos-3.7.0/
./configure --prefix=/usr/local/geos-3.7.0/
make && make install
```

Note: to guarantee that `make check` test cases run correctly, all the gdal drivers are disabled. To enable specific types of gdal drivers for a certain use case, please refer to this [postgis manual](http://postgis.net/docs/manual-3.3/postgis_installation.html#install_short_version). An example can be like this:
2.5 Update `/etc/ld.so.conf`

```
POSTGIS_GDAL_ENABLED_DRIVERS="GTiff PNG JPEG GIF XYZ"
```
In near future we plan to create GUCs for these variables after we backport necessary features into the gpdb repository.
After installing the above components, we need to update `/etc/ld.so.conf` to configure the dynamic loader to search for their directories:

## Workaround for missing .so files
```bash
cat << EOF >> /etc/ld.so.conf
/usr/lib/
/usr/lib64/
/usr/local/sfcgal-1.3.6/lib64/
/usr/local/gdal-2.2.1/lib/
/usr/local/geos-3.7.0/lib/
EOF
```
If any of the third party libraries are not installed in the default system path, you may see this issue while running the postgis.sql file
```sql
psql -d mydatabase -f ${GPHOME}/share/postgresql/contrib/postgis-3.3/postgis.sql
postgis-3.so": libgeos_c.so.1: cannot open shared object file: No such file or directory
```
then run the command `ldconfig`.
This may happen because `postgis.so` cannot find one or more of the third party .so files to link against. Here is a workaround
3. Build and install the PostGIS
3.1 Download this repo to your `gpadmin` directory:
```bash
git clone https://github.com/cloudberrydb/postgis.git /home/gpadmin/postgis
chown -R gpadmin:gpadmin /home/gpadmin/postgis
```
3.2 Compile the PostGIS
Before starting the compile process, run the following commands to make sure the environment variables are set ready:
```bash
source /usr/local/cloudberrydb/greenplum_path.sh
source /home/gpadmin/cloudberrydb/gpAux/gpdemo/gpdemo-env.sh
scl enable devtoolset-10 bash
source /opt/rh/devtoolset-10/enable
```
Then we continue:
```bash
cd /home/gpadmin/postgis/postgis/build/postgis-3.3.2/
./autogen.sh
./configure --prefix="${GPHOME}" --with-pgconfig="${GPHOME}"/bin/pg_config --with-raster --without-topology --with-gdalconfig=/usr/local/gdal-2.2.1/bin/gdal-config --with-sfcgal=/usr/local/sfcgal-1.3.6/bin/sfcgal-config --with-geosconfig=/usr/local/geos-3.7.0/bin/geos-config
make && make install
```
## Use the PostGIS in Cloudberry Database
Assume you installed the Cloudberry Database sucessfully and started the demo cluster. Then you can run the following commands to enable it:
```sql
$ psql -p 7000 postgres
postgres=# CREATE EXTENSION postgis; -- enables postgis and raster
postgres=# CREATE EXTENSION fuzzystrmatch; -- required for installing tiger geocoder
postgres=# CREATE EXTENSION postgis_tiger_geocoder; -- enables tiger geocoder
postgres=# CREATE EXTENSION address_standardizer; -- enable address_standardizer
postgres=# CREATE EXTENSION address_standardizer_data_us;
```
For more usages, you can follow [PostGIS manual](https://postgis.net/documentation/manual/).
## License
1. Edit /etc/ld.so.conf and add all the non default library paths that are used by geospatial.
This project is under GPL v2, because PostGIS is under GPL v2, see the [LICENSE](./LICENSE). PostGIS also includes some files not
under GPL v2 license, you can check the original [LICENSE](./postgis/build/postgis-3.3.2/LICENSE.TXT) in PostGIS
project for details.
For e.g. if you compiled and installed `proj` in /tmp/proj-install, this is how
/etc/ld.so.conf would look like
```
include ld.so.conf.d/*.conf
/tmp/proj-install/lib
```
2. Run ldconfig
## Acknowledgment
PostGIS is one project forked from [greenplum-db/geospatial](https://github.com/greenplum-db/geospatial/). Thanks to all the original contributors.
6 changes: 3 additions & 3 deletions postgis/package/gppkg_spec.yml.in
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
Pkgname: postgis
Architecture: #arch
OS: #os
Version: ossv3.3.2+pivotal.1_pv3.3_gpdb7.0
Version: ossv3.3.2+HashData_pv2.5_Cloudberry1.0.0
GPDBVersion: #gpver
Description: PostGIS provides spatial database functions for the Greenplum Database.
Description: PostGIS provides spatial database functions for the Cloudberry Database.
PostInstall:
- Master: "echo 'Please run the following commands to enable the PostGIS package:
CREATE EXTENSION postgis;'"
PostUpdate:
- Master: "echo 'Please run the following commands to finish the upgrade:
$GPHOME/share/postgresql/contrib/postgis-3.3/postgis_manager.sh mydatabase upgrade'"
$GPHOME/share/postgresql/contrib/postgis-3.3/postgis_manager.sh mydatabase upgrade'"
6 changes: 3 additions & 3 deletions postgis/package/gppkg_spec_v2.yml.in
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ Pkgname: postgis
Architecture: #arch
OS: #os
GPDBVersion: #gpver
Version: ossv3.3.2+pivotal.2_pv3.3_gpdb7.1
Description: PostGIS provides spatial database functions for the Greenplum Database.
Version: ossv3.3.2+HashData_pv2.5_Cloudberry1.0.0
Description: PostGIS provides spatial database functions for the Cloudberry Database.
PreInstall:
All: |
# Check if libtiff.so.* is available in the shared library cache
Expand All @@ -19,4 +19,4 @@ PostInstall:
PostUpdate:
All: |
echo "Please run the following commands to finish the upgrade:"
echo '$GPHOME/share/postgresql/contrib/postgis-3.3/postgis_manager.sh mydatabase upgrade'
echo '$GPHOME/share/postgresql/contrib/postgis-3.3/postgis_manager.sh mydatabase upgrade'
4 changes: 2 additions & 2 deletions postgis/package/postgis.spec
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Summary: Geospatial extensions for Greenplum Database
Summary: Geospatial extensions for Cloudberry Database
License: GPLv2
Name: postgis
Version: %{postgis_ver}
Expand All @@ -10,7 +10,7 @@ AutoProv: no
Provides: postgis = %{postgis_ver}

%description
The PostGIS module provides geospatial extensions for Greenplum Database.
The PostGIS module provides geospatial extensions for Cloudberry Database.

%install
make -C %{postgis_dir} BLD_TOP=%{bld_top} install prefix=%{buildroot}/temp
Expand Down

0 comments on commit 6feaab7

Please sign in to comment.