[postgis-users] Using OGC / PostGIS data types in PL/PGSQL functions

Markus Schaber schabi at logix-tt.com
Thu Feb 9 12:02:03 PST 2006


Hi, Chip,

Chip Masters wrote:

> I am starting to write some PL/PGSQL scripts that
> utilize PostGIS data types and functions, and I notice
> that there seems to be some difficulty when using the
> PostGIS 'Point' and 'Polygon' data types as arg
> constraints, since (I presume) there is ambiguity
> between these and the PostgreSQL datatypes of the same
> name. For example, I have included two functions in
> the attached file:

PostGIS does not have Point and Polygon datatypes from PostgreS' point
of view. PostgreSQL only and opaquely sees geometry, and PostGIS
internally distinguishes the different datatypes.

>>counterClockwisePoints(Point, Point, Point)

This method works with the PostgreSQL datatypes.

>>counterClockwiseGeometries(Geometry, Geometry, 
>>Geometry)

And this one works with the PostGIS datatypes.

>>counterClockwisePoints
>>  (PointFromText('POINT(0 0)', -1),
>>   PointFromText('POINT(1 0)', -1),
>>   PointFromText('POINT(1 1)', -1));
> 
> I get
> 
>>ERROR:  function counterclockwisePoints(geometry, 
>>geometry, geometry) does not exist

This is because you call the PostgreSQL function with the PostGIS datatypes.

> while selecting counterClockwiseGeometries with the
> same args works as expected. Again, I assume this is
> because when I use 'Point' as the arg constraint in
> counterClockwisePoints, PostgreSQL interprets this as
> its 'point' data type instead of the PostGIS one. Am I
> right? Is there a way to explicitly declare the
> PostGIS  data types so there is no ambiguity?

You only can declare geometry.


HTH,
Markus
-- 
Markus Schaber | Logical Tracking&Tracing International AG
Dipl. Inf.     | Software Development GIS

Fight against software patents in EU! www.ffii.org www.nosoftwarepatents.org



More information about the postgis-users mailing list