<div dir="ltr">Dear Paul<div><br></div><div>I fully understand. But what about an include file (e.g., PostgisAPI.h) containing all SQL functions from the API with a content such as the following one ?<div><br></div><div><div>extern Datum transform(PG_FUNCTION_ARGS);</div><div>extern Datum buffer(PG_FUNCTION_ARGS);</div><div>extern Datum centroid(PG_FUNCTION_ARGS);</div></div><div>....</div><div><br></div><div>That would already simplify the life of developers that build upon PostGIS since they can call these functions directly on the C code with e.g.,</div><div><br></div><div>DirectFunctionCallX(FUNCTION, ARGS)</div><div><br></div><div>and this does not add any dependency and have a better performance that sending SQL queries to call the corresponding function.<br></div><div><br></div><div>Regards</div><div><br></div><div>Esteban</div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Mar 25, 2019 at 3:30 PM Paul Ramsey <<a href="mailto:pramsey@cleverelephant.ca">pramsey@cleverelephant.ca</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Harsh but true.<br>
When building “dependent” things for PostGIS I like to get the dependency down to a bare minimum. So, call SQL functions, in SQL. And use EWKB as the transport layer rather than assuming I know what the PostGIS serialization format it. You can see an example in pointcloud_postgis. By using EWKB I can integrate with PostGIS via casts through bytea. For something computationally expensive like a spanning tree algorithm, you probably won’t even notice the slight extra overhead of the one spare format to transit through.<br>
You do end up needing your own WKB reader/writer on your side, but it’s not the end of the world.<br>
P.<br>
<br>
> On Mar 25, 2019, at 4:34 AM, Raúl Marín Rodríguez <<a href="mailto:rmrodriguez@carto.com" target="_blank">rmrodriguez@carto.com</a>> wrote:<br>
> <br>
> Hi,<br>
> <br>
> Postgis was never intented to be a building block that you could use<br>
> to build C code on top; the only thing we guarantee (or try to) is<br>
> that we won't break your SQL code on an upgrade*. In fact in the next<br>
> release (3.0), the default will be to not install neither headers nor<br>
> liblwgeom.so. The main reasoning behind this is that we don't keep<br>
> internal ABI stability, so you'd depend on something that can break<br>
> even within minor releases and these changes won't be documented.<br>
> <br>
> * This means that we also keep the exposed C API, since removing those<br>
> functions would break installations.<br>
> <br>
> If you only need the functionality within liblwgeom, I'd recommend you<br>
> to have a look at <a href="https://git.osgeo.org/gitea/rttopo/librttopo" rel="noreferrer" target="_blank">https://git.osgeo.org/gitea/rttopo/librttopo</a>, but<br>
> for the Postgres part (which both of you seem to require) there isn't<br>
> an alternative to creating the functionality directly inside Postgis.<br>
> <br>
> On Mon, Mar 25, 2019 at 12:24 PM Esteban Zimanyi <<a href="mailto:ezimanyi@ulb.ac.be" target="_blank">ezimanyi@ulb.ac.be</a>> wrote:<br>
>> <br>
>> Dear all<br>
>> <br>
>> I have similar problems when building MobilityDB, a temporal extension of PostGIS that takes care of the temporal aspects and fully delegates all spatial functionality to PostGIS. I ended up adding a file PostGIS.h in which I put all declarations of PostGIS functions that are not in liblwgeom.h, e.g.,<br>
>> <br>
>> extern void srid_is_latlong(FunctionCallInfo fcinfo, int srid);<br>
>> ....<br>
>> <br>
>> but also the functions from the API that I call directly<br>
>> <br>
>> extern Datum transform(PG_FUNCTION_ARGS);<br>
>> extern Datum buffer(PG_FUNCTION_ARGS);<br>
>> extern Datum centroid(PG_FUNCTION_ARGS);<br>
>> ...<br>
>> <br>
>> Regards<br>
>> <br>
>> Esteban<br>
>> <br>
>> <br>
>> On Mon, Mar 25, 2019 at 12:06 PM Adam Dadvar <<a href="mailto:adam.dadvar@gmail.com" target="_blank">adam.dadvar@gmail.com</a>> wrote:<br>
>>> <br>
>>> Hi All,<br>
>>> <br>
>>> I have been trying to develop a separate function that builds on top of the PostGIS types. Effectively what I'm trying to do is use MultiLineStrings as a network to compute a minimum spanning tree. The end of each line is a node in this case.<br>
>>> I think I have a basic understanding of how your code-base works but I am having issues where functions that I think should be available in postgis-devel are not.<br>
>>> <br>
>>> I know that liblwgeom.h is included in the postgis-devel library which provides the basic types and some utility functions, but for example, I want to input a MultiLineString (LWMLINE in the C code) so I use PG_GETARG_GSERIALIZED_P(0), but this is not included in liblwgeom.h. For that I can write my own function that does that from PG_DETOAST_DATUM, but for other functions it gets much more complicated - in order to convert the GSERIALIZED object I can either write my own function (which would take a long time) or just use the lwgeom_from_gserialized function that has already been written, however this function is not included in postgis-devel and has a large number of dependencies.<br>
>>> <br>
>>> I could just copy all of the header files from the source code and include them in my file but I'd prefer to just be able to say that the file depends on postgis-devel and then it can be compiled (this file needs to be rolled out to AWS in future).<br>
>>> <br>
>>> I understand that the recommendation might just be to produce the MST function within the PostGIS code-base, which I'd be open to do. It just seems strange that the postgis-devel library is basically unusable if you want to use it to extend PostGIS. Does anyone have any pointers on how to proceed?<br>
>>> <br>
>>> All advice is appreciated,<br>
>>> Adam Dadvar<br>
>>> _______________________________________________<br>
>>> postgis-devel mailing list<br>
>>> <a href="mailto:postgis-devel@lists.osgeo.org" target="_blank">postgis-devel@lists.osgeo.org</a><br>
>>> <a href="https://lists.osgeo.org/mailman/listinfo/postgis-devel" rel="noreferrer" target="_blank">https://lists.osgeo.org/mailman/listinfo/postgis-devel</a><br>
>> <br>
>> _______________________________________________<br>
>> postgis-devel mailing list<br>
>> <a href="mailto:postgis-devel@lists.osgeo.org" target="_blank">postgis-devel@lists.osgeo.org</a><br>
>> <a href="https://lists.osgeo.org/mailman/listinfo/postgis-devel" rel="noreferrer" target="_blank">https://lists.osgeo.org/mailman/listinfo/postgis-devel</a><br>
> <br>
> <br>
> <br>
> -- <br>
> Raúl Marín Rodríguez<br>
> <a href="http://carto.com" rel="noreferrer" target="_blank">carto.com</a><br>
> _______________________________________________<br>
> postgis-devel mailing list<br>
> <a href="mailto:postgis-devel@lists.osgeo.org" target="_blank">postgis-devel@lists.osgeo.org</a><br>
> <a href="https://lists.osgeo.org/mailman/listinfo/postgis-devel" rel="noreferrer" target="_blank">https://lists.osgeo.org/mailman/listinfo/postgis-devel</a><br>
<br>
_______________________________________________<br>
postgis-devel mailing list<br>
<a href="mailto:postgis-devel@lists.osgeo.org" target="_blank">postgis-devel@lists.osgeo.org</a><br>
<a href="https://lists.osgeo.org/mailman/listinfo/postgis-devel" rel="noreferrer" target="_blank">https://lists.osgeo.org/mailman/listinfo/postgis-devel</a></blockquote></div>