Hi,
Yes, you're certainly right, there must be other way of doing that, it's an old bigger script which I was revisiting. I just extracted a small part of it. It uses pgplsql because the purpose is to create tables of results. Using st_AsEwkt was the only way I found to get geometry from a loop and pass it in another loop. Thanks, Olivier De : postgis-users [mailto:postgis-users-boun...@lists.osgeo.org] De la part de Tom van Tilburg Envoyé : jeudi 6 juillet 2017 10:55 À : PostGIS Users Discussion Objet : Re: [postgis-users] St_AsEwkt Somehow I feel there is no need for plpgsql in what you are doing and that indeed the ST_AsEwkt is too much. I can't wrap my head around what this script is exactly trying to do though. Can you elaborate a bit on your use-case? What is the original data and what would you like to know from it? Best, Tom On Wed, Jul 5, 2017 at 7:54 PM, Olivier Leprêtre <o.lepre...@gmail.com> wrote: Hi, I'm using pgplsql to calculate shortest distance between points. This works but I'm wondering if my code is optimized because I'm using many ST_AsEwkt. sqls='SELECT id code,ST_AsEwkt(ST_StartPoint(the_geom)) as geom1,ST_AsEwkt(ST_EndPoint(the_geom)) as geom2 FROM ' || schem || '.trench'; FOR row IN EXECUTE (sqls) LOOP sqls1='SELECT id code1,ST_Distance(ST_AsEwkt(the_geom),St_AsEwkt(''%2$s'')) FROM %1$s.nodes order by ST_Distance(ST_AsEwkt(the_geom),ST_AsEwkt(''%2$s'')) LIMIT 1'; sqls1=format(sqls1,schem,row.geom1); FOR row1 IN EXECUTE (sqls1) ... Would it be possible to have a smarter syntax with less ST_AsEwkt ? Thanks, Olivier <https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=emailclient> Garanti sans virus. <https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=emailclient> www.avast.com _______________________________________________ postgis-users mailing list postgis-users@lists.osgeo.org https://lists.osgeo.org/mailman/listinfo/postgis-users --- L'absence de virus dans ce courrier électronique a été vérifiée par le logiciel antivirus Avast. https://www.avast.com/antivirus
_______________________________________________ postgis-users mailing list postgis-users@lists.osgeo.org https://lists.osgeo.org/mailman/listinfo/postgis-users