ERROR: 42883: function extent(geometry) does not exist

Topics: Data Access, SharpMap v0.9 / v1.x, WinForms Controls
Jan 27, 2009 at 6:36 PM
Edited Jan 27, 2009 at 6:56 PM
I get this error when trying to MapBox1.Map.ZoomToBox(MapBox1.Map.GetLayerByName("geom").Envelope). The layer has a postgis datasource and there are 2 points in it. Shouldn't this work, or do I need to use some workaround to get an extent for that layer? BTW, I am using SharpMap 0.9.
Jan 28, 2009 at 10:10 AM
It looks like a PostGIS error to me so I guess the database is not configured correctly hth jd
Jan 28, 2009 at 10:33 AM
Are you sure your postgis database is setup correct? In that case you should be able to access the extent function on the postgis database.

If you are using a different schema than public, you need to add the public schema to the search_path. You can test if its there by
SHOW search_path;
If public is missing in that list than use
SET search_path TO [the results of the above statement], public
Jan 29, 2009 at 3:37 PM
Sorry I took a while to reply, but this site only seems to work correctly with internet anti-explorer...

The postgis table is in public (for this test, as I normally use a different schema). It seems to work ok as far as plotting the points on the geometry layer, as well as the label layer and accessing the feature data table. Only the extents fail. Here is the script I used for creating the table:

CREATE TABLE riegotemp
  id bigint NOT NULL,
  percent real NOT NULL,
  rot character(3) NOT NULL,
  pres boolean NOT NULL,
  CONSTRAINT riegotemp_pkey PRIMARY KEY (id)
ALTER TABLE riegotemp OWNER TO postgres;

SELECT AddGeometryColumn('public', 'riegotemp', 'pos', 4326, 'POINT', 2);

CREATE INDEX riegotemp_id_pos
  ON riegotemp
  USING gist

Jan 29, 2009 at 8:39 PM
SELECT extent(pos) FROM riegotemp;
execute in psql or pgAdmin ok?

Are you passing the name of the geometry column to the constructor of the postgis provider?
If not, its name is queried from the geometry_columns table. Unfortunately the schema is not
considered, so if you have another table 'riegotemp' in a different schema with a geometry column
named other than 'pos' you may be getting that error. If I query
SELECT extent(id) FROM riegotemp;
I'm getting the error you describe.

Perhaps checking the entries in geometry_columns table may solve your problem
Feb 3, 2009 at 3:23 PM
Thanks, that helped me figure out that it was a bad (partial) postgis install on the database. After an error message about some missing function, I set up a local postgres/postgis server and tested on it, now it all works again.