[postgis-users] Function question

Paul Ramsey pramsey at cleverelephant.ca
Tue Mar 15 08:12:33 PDT 2022



> On Mar 14, 2022, at 11:40 PM, Simon SPDBA Greener <simon at spdba.com.au> wrote:
> 
> Fellow PostGISers, 
> 
> I have two environments.
> 
> select  Version()
>        "PostgreSQL 10.9 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-36), 64-bit"
> select PostGIS_Full_Version()
>        "POSTGIS=""2.5.3 r17699"" [EXTENSION] PGSQL=""100"" GEOS=""3.8.0-CAPI-1.13.1 "" PROJ=""Rel. 6.2.1, November 1st, 2019"" GDAL=""GDAL 3.0.2, released 2019/10/28"" LIBXML=""2.9.1"" LIBJSON=""0.11"" LIBPROTOBUF=""1.0.2"" RASTER"
> 
> And.
> 
> "PostgreSQL 13.3, compiled by Visual C++ build 1914, 64-bit"
> "POSTGIS=""3.1.2 3.1.2"" [EXTENSION] PGSQL=""130"" GEOS=""3.9.1-CAPI-1.14.1"" SFCGAL=""1.3.8"" PROJ=""7.1.1"" LIBXML=""2.9.9"" LIBJSON=""0.12"" LIBPROTOBUF=""1.2.1"" WAGYU=""0.5.0 (Internal)"" TOPOLOGY"
> 
> I have written the following function:
> 
> CREATE OR REPLACE FUNCTION spdba.STSquarifyLine(p_line geometry)
>  RETURNS geometry
> LANGUAGE 'plpgsql'
>  IMMUTABLE  
>  SECURITY DEFINER
> AS 
> blah...
> 
> The function does no calculations per se, it only swaps ordinates. 
> 
> PostGIS functions used are:
> 
> ST_MakeLine / ST_SetSRID ST_MakePoint ST_X / ST_Y / ST_GeomFromEWKT
> 
> The function does call another small function:
> 
> create or replace function spdba.STGeneralDirection(p_geom geometry)
> returns varchar(2)
> LANGUAGE 'plpgsql'
>  IMMUTABLE
>  SECURITY DEFINER
> as
> .... (It uses Uses ST_BoundingRectangle ST_X ST_Y ST_StartPoint ST_EndPoint)
> 
> This function returns the same result on both databases for a bunch of different inputs. Happy that it works as I wish.
> 
> However if I execute the STSquarifyLine function on the Linux box for a particular input, I get what I consider to be the "right" result. When I execute the same function with the same parameter value on the Windows box I do not get the same result. (I have played around with IMMUTABLE and VOLATILE but these make no difference.)
> 
> I know this is a bit vague but any tips as to what may be going on?

Still a little too vague. Like "different" as in 1.2341245129 and 1.2341245128 ? Or completely different? I think functions and data are required... ST_MakeLine takes whatever ordering you give it, so if you fed it directly from tables you might have different underlying ordering of inputs, and hence outputs.

P.


> 
> I am happy to supply the functions source (via email) if anyone is willing to help.
> 
> regards
> 
> Simon
> 
> 
> 
> <ForwardedMessage.eml>_______________________________________________
> postgis-users mailing list
> postgis-users at lists.osgeo.org
> https://lists.osgeo.org/mailman/listinfo/postgis-users



More information about the postgis-users mailing list