Strapi Plugin Postgis

screenshot of Strapi Plugin Postgis

Strapi Plugin Postgis

Add native postgis support to strapi.

Overview

This article discusses the process of adding native PostGIS support to Strapi, a popular Node.js framework. PostGIS is an extension for PostgreSQL that allows for the storage and manipulation of geographic objects, such as points, lines, and polygons. The purpose of adding PostGIS support to Strapi is to enable the use of spatial data in Strapi applications.

Features

  • Native PostGIS support for Strapi
  • Conversion of geometry objects to GeoJSON format
  • Compatibility with PostGIS versions 3.1 and 3.2
  • Support for various data types, including points, lines, polygons, and geometry collections
  • Possibility to add custom components to Strapi content types
  • Integration with popular plugins such as Leaflet Editor

Installation

  1. Make sure you have at least Strapi version 4.5.0 installed.
  2. Install the pg and strapi-plugin-postgis npm packages.
  3. Configure your Strapi app to use PostgreSQL as the backend database. Refer to the Strapi documentation for assistance with this step.
  4. Install PostGIS on your database server. Follow the instructions provided by the PostGIS documentation.
  5. Modify the middlewares in your Strapi app to allow loading OpenStreetMap tiles. Add *.tile.openstreetmap.org to the img-src as specified in the article.
  6. Start your Strapi app and ensure that the required changes are applied.

Summary

This article demonstrates how to add native PostGIS support to Strapi, enabling the use of spatial data in Strapi applications. By converting geometry objects to the GeoJSON format, Strapi becomes compatible with PostGIS versions 3.1 and 3.2. The installation process involves installing the necessary npm packages, configuring the app to use PostgreSQL with PostGIS, and making some modifications to the middlewares. With PostGIS support added, users can work with various data types and integrate additional features and plugins for enhanced functionality.