views:

410

answers:

2

I have a table in postgis, which has 4 columns: ID, name, the_geom, SRID. I need to write an SQL query which will insert this exterior polygon (Element 1) in the table named "woods", ID = 44, the name of that exterior polygon is "oak", and SRID is "4412".

The coordinate values for Element 1 and Element 2 (the hole): Element 1= [P1(6,15), P2(10,10), P3(20,10), P4(25,15), P5(25,35), P6(19,40), P7(11,40), P8(6,25), P1(6,15)] Element 2= [H1(12,15), H2(15,24)]

Here is the image: http://download.oracle.com/docs/html/A85337_01/sdo_objb.gif

+1  A: 

Take a look at ST_MakePolygon:

Edmund
thank you, I solved the problem.
luckyluke
A: 

Alternative solution is to use geometry constructor function ST_GeomFromText

INSERT INTO woods (ID, name, SRID, geom)
VALUES (44, 'oak', 4326,
ST_GeomFromText(
    'POLYGON((6 15, 10 10, 20 10, 25 15, 25 35, 19 40, 11 40, 6 25, 6 15))',
     4326))

with example of SRID equal to EPSG:4326

mloskot