[postgis-devel] Is posible to use function lwgeom_to_geojson in another c fuctions

Nicklas Aven nicklas.aven at jordogskog.no
Sat Jun 25 05:19:45 PDT 2016


Well converting to geojson on the fly will always be quite expensive. We are not using the resultndirectly, and it is not very big data. But my guess is that it will be hard to beat the performance of building jsonb with postgresql functions and cast to text string as a last step. But that is said without evidence. But aggregating to geojson including attributes also feels like a clean operation, not messing with custom aggregates and learning json-c api or even worse writing everything for building json. 

About postgrest I thing performance is ok. It is at least faster than the AGS server we are communicating with sometimes (and that is a beast compared to our Linode server)
/Nicklas

Skickat från min Sony Xperia™-smartphone

---- Jan Michálek skrev ----

> You are using postgrest on some bigger data with spatial parts? I tried it few days ago and on many features it was pretty slow... But i didn`t make any tuning, maybe is there space for optimaliyation for my usecase.
> 
> 
> 2016-06-25 13:43 GMT+02:00 Nicklas Aven <nicklas.aven at jordogskog.no>:
> 
> Just a comment.
> With all the new json functions in PostgreSQL this is very easy to do directly in sql too. I think it is fairly efficient too. I use it in production to export complete geojson through postgrest.
> 
> I have thougt about if we could get rid of json-c dependency and use postgresql functionality instead. 
> Building json with jsonb, I guess is a lot faster than dealing with text strings.
> 
> /Nicklas
> 
> Skickat från min Sony Xperia™-smartphone
> 
> ---- Jan Michálek skrev ----
> 
> > Hello
> > 
> > I need a advice about this problem
> > 
> > I'm trying to write some C fuction for making geojson as aggregate from records as full regular geojson with properties.
> > 
> > I tried to use function lwgeom_to_geojson inside my code.
> > 
> > something like this
> > 
> >                 case JSONTYPE_GEOM: //je;
> >                         {
> >                         LWGEOM *lwgeom;
> >                         lwgeom = lwgeom_from_gserialized(
> >                              (GSERIALIZED*)DatumGetPointer(val)
> >                               );
> >                         outputstr = lwgeom_to_geojson(lwgeom, 0, 0, false);
> >                         escape_json(result, outputstr);
> >                         pfree(outputstr);
> > 
> >                         break;
> > 
> >                         }
> > 
> > 
> > 
> > I have 
> > #include "liblwgeom.h"
> > 
> > And I`m able to compile this. But if I try use function in postgre, it get me an error
> > 
> > ERROR:  could not load library "/usr/lib/postgresql/jelejson.so": /usr/lib/postgresql/jelejson.so: undefined symbol: lwgeom_to_geojson.
> > 
> > What i should do? Is posible to use this function like this?
> > 
> > Thanks Je;
> > 
> > 
> > -- 
> > 
> > Jelen
> > 
> > Starší čeledín datovýho chlíva
> 
> 
> _______________________________________________
> postgis-devel mailing list
> postgis-devel at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/postgis-devel
> 
> 
> 
> 
> -- 
> 
> Jelen
> 
> Starší čeledín datovýho chlíva
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-devel/attachments/20160625/e9c27223/attachment.html>


More information about the postgis-devel mailing list