Re: [GENERAL] Development of an extension for PostgreSQL and PostGIS - Mailing list pgsql-general

From Paul Ramsey
Subject Re: [GENERAL] Development of an extension for PostgreSQL and PostGIS
Date
Msg-id CACowWR2HiifS2X_Ue3L1L-+5dxewDgNAwkp96Uy+0w6UDymMdA@mail.gmail.com
Whole thread Raw
In response to [GENERAL] Development of an extension for PostgreSQL and PostGIS  (Fabiana Zioti <fabi_zioti@hotmail.com>)
Responses Re: [GENERAL] Development of an extension for PostgreSQL and PostGIS  (Fabiana Zioti <fabi_zioti@hotmail.com>)
List pgsql-general
In order to get an LWGEOM from PostGIS you'll need to convert from the serialized form (GSERIALIZED) which you can read all about in the liblwgeom.h header. You'll be adding a hard dependency of course, but hopefully you're OK with that. 

If you're just hoping to build a compound type, as your example shows, you can do that without a C extension, just read up on CREATE TYPE.

For an alternate example of an extension with a lighter dependency on PostGIS, check out pgpointcloud, which has it's own structure for spatial data (a point patch) and exchanges data with PostGIS via well-known-binary. This removes the liblwgeom dependency, which means it's possible to compile and use pgpointcloud without PostGIS installed, which is not entirely uncommon.

P


On Mon, Aug 14, 2017 at 11:18 AM, Fabiana Zioti <fabi_zioti@hotmail.com> wrote:

Hello.

I will start developing an extension to PostgreSQL next to PostGIS using the C language.

If my new type were:


CREATE TYPE mytype (.., .., .., geom geometry);

The creation of the structure in c, would be something like?

#include "liblwgeom.h"

Struct mytype
{
   Int32 id;
   LWGEOM lwgeom;

};


In the extension I will create new data types for PostgreSQL, but I would like to use the geometric objects that the PostGIS extension offers, such as POINT, LINE, POLYGON, etc. In addition to their input functions (wkt- ST_GeomFromText ()), operators, index, etc.

In this case just importing the liblwgeom library would be enough to develop an extension to PostgreSQL / PostGIS? 

Would you have any examples of such a project?

Thanks in advance!!


pgsql-general by date:

Previous
From: Fabiana Zioti
Date:
Subject: [GENERAL] Development of an extension for PostgreSQL and PostGIS
Next
From: stimits@comcast.net
Date:
Subject: [GENERAL] Queries for Diagramming Schema Keys