[postgis-users] Is there a difference between geomFromText andGeometryFromText?

Willem Nieuwenhuis nieuwenhuis at itc.nl
Tue Jun 27 02:23:40 PDT 2006


For as far as I could see there was no problem whatsoever in PostGIS;
also the 

SELECT gid, AsText(the_geom) FROM bugplaces WHERE gid IN (89, 100);

functioned as you would expect. This I had already checked before
sending the question.

To explain my setup:
The features are stored in PostGIS and retrieved through WFS (GeoServer
1.3.0RC2).
The display is taken care of by uDIG or ArcMap (through the FME
interoperability extension).
The problem as I encountered was somewhere in the chain after the
storage in PostGIS.

This morning I tried again (fresh start) and I could not reproduce the
problem. I am somewhat confused...

Thanks for your response anyway

Willem


-----Original Message-----
From: postgis-users-bounces at postgis.refractions.net
[mailto:postgis-users-bounces at postgis.refractions.net] On Behalf Of
Michael Fuhr
Sent: Monday, June 26, 2006 16:16
To: PostGIS Users Discussion
Subject: Re: [postgis-users] Is there a difference between geomFromText
andGeometryFromText?

On Mon, Jun 26, 2006 at 02:54:02PM +0200, Willem Nieuwenhuis wrote:
> When experimenting with entering features into PostGIS, I encountered
a
> difference in behaviour between GeomFromText and GeometryFromText. In
my
> understanding the first should only be a shorthand notation for the
> second.

GeomFromText is defined in lwpostgis.sql as:

CREATE OR REPLACE FUNCTION GeomFromText(text)
        RETURNS geometry AS 'SELECT geometryfromtext($1)'
        LANGUAGE 'SQL' IMMUTABLE STRICT; -- WITH (isstrict,iscachable);

CREATE OR REPLACE FUNCTION GeomFromText(text, int4)
        RETURNS geometry AS 'SELECT geometryfromtext($1, $2)'
        LANGUAGE 'SQL' IMMUTABLE STRICT; -- WITH (isstrict,iscachable);

> But when I combine both notations (in a SQL script) only the
> GeometryFromText function adds (valid) geometries.
> For example:
> 
> insert into bugplaces (gid,ID,CAT_ID,the_geom) values
> ('89','90','90',GeometryFromText('POINT (7.3618176 44.3867629)','0')
);
> INSERT INTO bugplaces(gid,the_geom,class)
> VALUES('100',GeomFromText('POINT (11.582294629385492
> 42.33848278926086)','0'),'Amphibia');
> 
> The first geometry is OK, but the second not. In uDIG I only see the
> first point.

Did the second insert produce any errors?  Are you sure the problem
isn't with how you're querying the data?  Have you connected to the
database with psql and queried the table directly?  What's the output
of the following?

SELECT gid, AsText(the_geom) FROM bugplaces WHERE gid IN (89, 100);

I created a test table and ran the two inserts you posted; the above
query then returned:

 gid |                  astext                  
-----+------------------------------------------
  89 | POINT(7.3618176 44.3867629)
 100 | POINT(11.5822946293855 42.3384827892609)
(2 rows)

Do you get something else?

-- 
Michael Fuhr
_______________________________________________
postgis-users mailing list
postgis-users at postgis.refractions.net
http://postgis.refractions.net/mailman/listinfo/postgis-users



More information about the postgis-users mailing list