St_AsEwkt

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

St_AsEwkt

Olivier Leprêtre

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


Garanti sans virus. www.avast.com

_______________________________________________
postgis-users mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/postgis-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: St_AsEwkt

Tom van Tilburg-2
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 <[hidden email]> 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


Garanti sans virus. www.avast.com

_______________________________________________
postgis-users mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/postgis-users


_______________________________________________
postgis-users mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/postgis-users
Loading...