[postgis-users] adding additional points to multipoint

Christo Du Preez christo at mecola.com
Fri Mar 31 02:57:32 PST 2006


Thank you,

When trying 

update meclabel
set the_geom = geomunion(the_geom, GeomFromText('POINT(23 4)', -1))

I get:: ERROR:  new row for relation "meclabel" violates check 
constraint "enforce_geotype_the_geom"

This is how my table looks? Do I have to cast the result of geomunion?

-- Table: meclabel

-- DROP TABLE meclabel;

CREATE TABLE meclabel
(
  gid int4 NOT NULL DEFAULT nextval('meclabel_gid_seq'::regclass),
  name text,
  "type" text,
  "class" text,
  angle float4,
  refgid int4,
  x float4,
  y float4,
  the_geom geometry,
  CONSTRAINT meclabel_pkey PRIMARY KEY (gid),
  CONSTRAINT enforce_dims_the_geom CHECK (ndims(the_geom) = 2),
  CONSTRAINT enforce_geotype_the_geom CHECK (geometrytype(the_geom) = 
'MULTIPOINT'::text OR the_geom IS NULL),
  CONSTRAINT enforce_srid_the_geom CHECK (srid(the_geom) = -1)
)
WITHOUT OIDS;
ALTER TABLE meclabel OWNER TO postgres;


-- Index: meclabel_gist_the_geom

-- DROP INDEX meclabel_gist_the_geom;

CREATE INDEX meclabel_gist_the_geom
  ON meclabel
  USING gist
  (the_geom);





Markus Schaber wrote:
> Hi, Christo,
>
> Christo Du Preez wrote:
>
>   
>> How do I add an additional point to a multipoint geometry in an update
>> statement?
>>     
>
> select asText(geomunion('MULTIPOINT(1 1,3 3)','POINT(2 2)'));
>
>          astext
> -------------------------
>  MULTIPOINT(1 1,2 2,3 3)
> (1 row)
>
>
> So you can
>   UPDATE geocolumn = geomunion(geocolumn,'YOURPOINT') WHERE condition;
>
> However, note that you don't have any influence on the ordering of the
> points in the resulting multipoint, it depends on the internal geometry
> indexing in geomunion.
>
> Strk, maybe we should allow addpoint() to work with multipoints, too?
>
> Or as alternative, add an "addgeom(collection, geometry)" that adds a
> geometry to a MULTI*/GeometryCollection?
>
> HTH,
>
> Markus
>   

-- 
Kind Regards,
Christo Du Preez

Senior Software Engineer
Mecola IT
http://www.mecola.com
+27 [0]83 326 8087




More information about the postgis-users mailing list