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

Michael Fuhr mike at fuhr.org
Mon Jun 26 07:16:05 PDT 2006


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



More information about the postgis-users mailing list