[OSGeo-Discuss] Fwd: Test polygons from "About Invalid, Valid and Clean Polygons"

Mateusz Loskot mateusz at loskot.net
Thu Nov 14 07:21:52 PST 2013


Wilko Quak is sending SQL script related to the thread:

Test polygons from "About Invalid, Valid and Clean Polygons"
http://lists.osgeo.org/pipermail/discuss/2013-October/012509.html

Mateusz

---------- Forwarded message ----------
From: Wilko Quak <c.w.quak at tudelft.nl>
Date: 14 November 2013 15:16
Subject: Re: [OSGeo-Discuss] Test polygons from "About Invalid, Valid
and Clean Polygons"
To: Mateusz Loskot <mateusz at loskot.net>
Cc: Paul Ramsey <pramsey at cleverelephant.ca>, discuss at lists.osgeo.org,
Wilko Quak <W.Quak at otb.tudelft.nl>, Peter van Oosterom
<P.J.M.vanOosterom at tudelft.nl>, Theo Tijssen
<T.P.M.Tijssen at tudelft.nl>


Hi All,

Maybe it's a bit late but I found the PostGIS sql script that we used
10 years ago. I'll attach the old script that we used at the time.
With a little bit of work it should run on a current version of
PostGIS.

Best wishes, Wilko Quak

Ps. I cannot send messages to the OSGeo-Discuss mailing list, so if
the discussion is still relevant could someone forward it?



> On 27 October 2013 22:04, Wilko Quak <c.w.quak at tudelft.nl> wrote:
>>
>> Hi All,
>>
>> The paper is from 2005
>
> Yes, that's what Springer says:
>
> http://link.springer.com/chapter/10.1007%2F3-540-26772-7_1
>
>> and uses PostGIS 0.6.2.
>
> I see,  I missed that important detail.
>
>> I am not sure whether PostGIS
>> had an ST_IsValid function at the time. Anyway when I am back in the office
>> I'll try to find the original scripts.
>
> That would be helpful, thanks!
>
> Best regards,




-- 
Mateusz  Loskot, http://mateusz.loskot.net
-------------- next part --------------
SELECT DropGeometryColumn('quak', 'test_polygon', 'geom');
drop table test_polygon;

create table test_polygon (id varchar(5));
SELECT AddGeometryColumn('quak', 'test_polygon', 'geom', -1, 'POLYGON', 2 );
-- tolerance 4000 units

insert into test_polygon values ('1a', GeometryFromText(
 'POLYGON((33300 19200, 19200 30000, 8300 15000, 20000 4200, 33300 19200))',-1));
insert into test_polygon values ('1b', GeometryFromText(
 'POLYGON((33300 19200, 20000 4200, 8300 15000, 19200 30000, 33300 19200))',-1));
insert into test_polygon values ('2', GeometryFromText(
 'POLYGON((33300 19200, 19200 30000, 8300 15000, 20000 4200, 33300 19200),
  (25000 13300, 17500 13300, 17500 19200, 25000 19200, 25000 13300))',-1));
insert into test_polygon values ('3', GeometryFromText(
 'POLYGON((33300 19200, 19200 30000, 8300 15000, 20000 4200, 33300 19200),
  (22500 11700, 16700 11700, 16700 15800, 22500 15800, 22500 11700),
  (23300 19200, 17500 19200, 17500 23300, 23300 23300, 23300 19200))',-1));
insert into test_polygon values ('4a', GeometryFromText(
 'POLYGON((33300 19200, 19200 30000, 8300 15000, 20000 4200, 33300 19200),
  (22500 15000, 13750 15000, 13750 22500, 22500 22500, 22500 15000))',-1));

insert into test_polygon values ('4b', GeometryFromText(
 'POLYGON((33300 19200, 19200 30000, 13750 22500, 22500 22500, 22500 15000, 
  13750 15000, 13750 22500, 8300 15000, 20000 4200, 33300 19200))',-1));

insert into test_polygon values ('5', GeometryFromText(
 'POLYGON((33300 19200, 19200 30000, 8300 15000, 20000 4200, 33300 19200),
  (20000 13300, 14200 13300, 14200 17500, 20000 17500, 20000 13300),
  (25800 17500, 20000 17500, 20000 21700, 25800 21700, 25800 17500))',-1));

insert into test_polygon values ('6', GeometryFromText(
 'POLYGON((33300 19200, 19200 30000, 8300 15000, 20000 4200, 33300 19200),
  (20000 15800, 13314 15800, 13314 21900, 20000 21900, 20000 15800),
  (24200 12500, 20000 12500, 20000 15800, 24200 15800, 24200 12500),
  (27500 15800, 24200 15800, 24200 20800, 27500 20800, 27500 15800))',-1));

insert into test_polygon values ('7', GeometryFromText(
 'POLYGON((33300 19200, 19200 30000, 13300 21700, 18300 18300, 25000 18300,
  25000 13300, 18300 13300, 18300 18300, 13300 21700, 8300 15000, 20000 4200, 
  33300 19200))',-1));

insert into test_polygon values ('8', GeometryFromText(
 'POLYGON((33300 19200, 19200 30000, 13300 21700, 18300 18300, 25000 18300,
  25000 13300, 18300 13300, 18300 18300, 5800 26800, 8300 15000, 20000 4200, 
  33300 19200))',-1));

insert into test_polygon values ('9', GeometryFromText(
 'POLYGON((33300 19200, 19200 30000, 8300 15000, 20000 4200, 33300 19200),
  (22500 15800, 10698 18300, 14840 24000, 22500 15800))',-1));

insert into test_polygon values ('10', GeometryFromText(
 'POLYGON((33300 19200, 19200 30000, 8300 15000, 20000 4200))',-1));

insert into test_polygon values ('11', GeometryFromText(
 'POLYGON((33300 19200, 28300 23300, 38300 27500, 28300 23300, 
  19200 30000, 8300 15000, 20000 4200, 33300 19200))',-1));

insert into test_polygon values ('12', GeometryFromText(
 'POLYGON((33300 19200, 24200 25800, 21700 15800, 24200 25800, 
  19200 30000, 8300 15000, 20000 4200, 33300 19200))',-1));

insert into test_polygon values ('13', GeometryFromText(
 'POLYGON((33300 19200, 19200 30000, 8300 15000, 20000 4200, 33300 19200),
  (30000 19200, 20000 19200, 20000 26700, 30000 26700, 30000 19200))',-1));

insert into test_polygon values ('14a', GeometryFromText(
 'POLYGON((33300 19200, 19200 30000, 8300 15000, 20000 4200, 33300 19200),
  (36700 8300, 46700 4200, 47500 23300, 36700 8300))',-1));

insert into test_polygon values ('14b', GeometryFromText(
 'POLYGON((33300 19200, 19200 30000, 8300 15000, 20000 4200, 33300 19200),
  (36700 8300, 47500 23300, 46700 4200, 36700 8300))',-1));

insert into test_polygon values ('15', GeometryFromText(
 'POLYGON((33300 19200, 19200 30000, 8300 15000, 20000 4200, 33300 19200, 
  36700 8300, 46700 4200, 47500 23300, 36700 8300, 33300 19200))',-1));

insert into test_polygon values ('16', GeometryFromText(
 'POLYGON((33300 19200, 19200 30000, 8300 15000, 20000 4200,
  23300 7500, 10698 18300, 14840 24000, 28300 14200, 33300 19200))',-1));

insert into test_polygon values ('17', GeometryFromText(
 'POLYGON((33300 19200, 19200 30000, 8300 15000, 20000 4200,
  23300 7500, 14840 24000, 28300 14200, 33300 19200))',-1));

insert into test_polygon values ('18', GeometryFromText(
 'POLYGON((33300 19200, 19200 30000, 8300 15000, 20000 4200, 33300 19200),
  (29775 18300, 13314 18300, 13314 21900, 29775 21900, 29775 18300))',-1));

insert into test_polygon values ('19', GeometryFromText(
 'POLYGON((33300 19200, 19200 30000, 8300 15000, 20000 4200, 33300 19200),
  (20800 16700, 13750 16700, 13750 22500, 20800 22500, 20800 16700),
  (25852 10800, 20800 19899, 20800 16700, 25852 16700, 25852 10800))',-1));

insert into test_polygon values ('20', GeometryFromText(
 'POLYGON((33300 19200, 19200 30000, 8300 15000, 20000 4200, 33300 19200),
  (20800 11700, 16700 11700, 16700 15800, 20800 15800, 20800 11700),
  (26700 15800, 20800 15800, 20800 20000, 26700 20000, 26700 15800),
  (25852 10800, 20800 11700, 26700 15800, 25852 10800))',-1));

insert into test_polygon values ('21', GeometryFromText(
 'POLYGON((33300 19200, 19200 30000, 8300 15000, 20000 4200, 33300 19200),
  (18300 12500, 14200 12500, 14200 16700, 18300 16700, 18300 12500),
  (24200 16700, 18300 16700, 18300 20800, 24200 20800, 24200 16700),
  (22500 10800, 18300 12500, 24200 16700, 22500 10800))',-1));

insert into test_polygon values ('22', GeometryFromText(
 'POLYGON((33300 19200, 19200 30000, 20000 4200, 8300 15000, 33300 19200))',-1));

insert into test_polygon values ('23', GeometryFromText(
 'POLYGON((33300 19200, 19200 30000, 19600 16900, 8300 15000, 20000 4200, 
  19600 16900, 33300 19200))',-1));

insert into test_polygon values ('24', GeometryFromText(
 'POLYGON((33300 19200, 19200 30000, 8300 15000, 20000 4200, 33300 19200),
  (25000 12500, 15000 12500, 15000 21700, 25000 21700, 25000 12500),
  (21700 18300, 17500 18300, 17500 15800, 21700 15800, 21700 18300))',-1));

insert into test_polygon values ('25', GeometryFromText(
 'POLYGON((33300 19200, 19200 30000, 8300 15000, 20000 4200, 33300 19200),
  (24200 13300, 15800 13300, 15800 21700, 20000 21700, 18300 16700, 
  21700 16700, 20000 21700, 24200 21700, 24200 13300))',-1));

insert into test_polygon values ('26', GeometryFromText(
 'POLYGON((33300 19200, 19200 30000, 8300 15000, 20000 4200, 25852 10800,
  33300 19200))',-1));

insert into test_polygon values ('27', GeometryFromText(
 'POLYGON((33300 19200, 19200 30000, 8300 15000, 20000 4200, 28300 13300,
  30000 15000, 33300 19200))',-1));

insert into test_polygon values ('28', GeometryFromText(
 'POLYGON((33300 19200, 19200 30000, 8300 15000, 20000 4200, 28300 13300,
  41700 2500, 30000 15000, 33300 19200))',-1));

insert into test_polygon values ('29', GeometryFromText(
 'POLYGON((33300 19200, 19200 30000, 8300 15000, 20000 4200, 28300 13300,
  20000 21700, 30000 15000, 33300 19200))',-1));

insert into test_polygon values ('30', GeometryFromText(
 'POLYGON((33300 19200, 19200 30000, 8300 15000, 20000 4200, 28300 13300,
  9200 27500, 30000 15000, 33300 19200))',-1));

insert into test_polygon values ('31', GeometryFromText(
 'POLYGON((33300 19200, 19200 30000, 8300 15000, 20000 4200, 33300 19200),
  (23300 15000, 15300 15000, 15300 22500, 23300 22500, 23300 15000))',-1));

insert into test_polygon values ('32', GeometryFromText(
 'POLYGON((33300 19200, 19200 30000, 8300 15000, 20000 4200, 33300 19200),
  (23300 15800, 12500 15800, 12500 22500, 23300 22500, 23300 15800))',-1));

insert into test_polygon values ('33', GeometryFromText(
 'POLYGON((33300 19200, 19200 30000, 8300 15000, 20000 4200,
  23300 7500, 11700 17500, 15800 23300, 28300 14200, 33300 19200))',-1));

insert into test_polygon values ('34', GeometryFromText(
 'POLYGON((33300 19200, 19200 30000, 8300 15000, 20000 4200,
  23300 7500, 15800 23300, 28300 14200, 33300 19200))',-1));

insert into test_polygon values ('35', GeometryFromText(
 'POLYGON((33300 19200, 19200 30000, 8300 15000, 20000 4200,
  23300 7500, 14200 25800, 28300 14200, 33300 19200))',-1));

insert into test_polygon values ('36', GeometryFromText(
 'POLYGON((33300 19200, 19200 30000, 8300 15000, 20000 4200, 33300 19200),
  (27500 15800, 15000 15800, 15000 22500, 27500 22500, 27500 15800))',-1));

insert into test_polygon values ('37', GeometryFromText(
 'POLYGON((33300 19200, 19200 30000, 8300 15000, 20000 4200, 33300 19200),
  (26000 15800, 14400 15800, 14400 25800, 26000 25800, 26000 15800))',-1));


--
--
--

SELECT DropGeometryColumn('quak', 'test_map', 'geom');
drop table test_map;

create table test_map (id varchar(5));
SELECT AddGeometryColumn('quak', 'test_map', 'geom', -1, 'POLYGON', 2 );

--
-- Row one.
--
insert into test_map
select id,translate(geom,0,0,0)
from test_polygon
where id = '1a';

insert into test_map
select id,translate(geom,50000,0,0)
from test_polygon
where id = '1b';

insert into test_map
select id,translate(geom,100000,0,0)
from test_polygon
where id = '2';

insert into test_map
select id,translate(geom,150000,0,0)
from test_polygon
where id = '3';

--
-- Row two.
--
insert into test_map
select id,translate(geom,0,-50000,0)
from test_polygon
where id = '4a';

insert into test_map
select id,translate(geom,50000,-50000,0)
from test_polygon
where id = '4b';

insert into test_map
select id,translate(geom,100000,-50000,0)
from test_polygon
where id = '5';

insert into test_map
select id,translate(geom,150000,-50000,0)
from test_polygon
where id = '6';

--
-- Row three.
--
insert into test_map
select id,translate(geom,0,-100000,0)
from test_polygon
where id = '7';

insert into test_map
select id,translate(geom,50000,-100000,0)
from test_polygon
where id = '8';

insert into test_map
select id,translate(geom,100000,-100000,0)
from test_polygon
where id = '9';

insert into test_map
select id,translate(geom,150000,-100000,0)
from test_polygon
where id = '10';

--
-- Row four.
--
insert into test_map
select id,translate(geom,0,-150000,0)
from test_polygon
where id = '11';

insert into test_map
select id,translate(geom,50000,-150000,0)
from test_polygon
where id = '12';

insert into test_map
select id,translate(geom,100000,-150000,0)
from test_polygon
where id = '13';

insert into test_map
select id,translate(geom,150000,-150000,0)
from test_polygon
where id = '14a';

--
-- Row five.
--
insert into test_map
select id,translate(geom,0,-200000,0)
from test_polygon
where id = '14b';

insert into test_map
select id,translate(geom,50000,-200000,0)
from test_polygon
where id = '15';

insert into test_map
select id,translate(geom,100000,-200000,0)
from test_polygon
where id = '16';

insert into test_map
select id,translate(geom,150000,-200000,0)
from test_polygon
where id = '17';

--
-- Row six.
--
insert into test_map
select id,translate(geom,0,-250000,0)
from test_polygon
where id = '18';

insert into test_map
select id,translate(geom,50000,-250000,0)
from test_polygon
where id = '19';

insert into test_map
select id,translate(geom,100000,-250000,0)
from test_polygon
where id = '20';

insert into test_map
select id,translate(geom,150000,-250000,0)
from test_polygon
where id = '21';

--
-- Row seven.
--
insert into test_map
select id,translate(geom,0,-300000,0)
from test_polygon
where id = '22';

insert into test_map
select id,translate(geom,50000,-300000,0)
from test_polygon
where id = '23';

insert into test_map
select id,translate(geom,100000,-300000,0)
from test_polygon
where id = '24';

insert into test_map
select id,translate(geom,150000,-300000,0)
from test_polygon
where id = '25';

--
-- Row eight.
--
insert into test_map
select id,translate(geom,0,-350000,0)
from test_polygon
where id = '26';

insert into test_map
select id,translate(geom,50000,-350000,0)
from test_polygon
where id = '27';

insert into test_map
select id,translate(geom,100000,-350000,0)
from test_polygon
where id = '28';

insert into test_map
select id,translate(geom,150000,-350000,0)
from test_polygon
where id = '29';


--
-- Row nine.
--
insert into test_map
select id,translate(geom,0,-400000,0)
from test_polygon
where id = '30';

insert into test_map
select id,translate(geom,50000,-400000,0)
from test_polygon
where id = '31';

insert into test_map
select id,translate(geom,100000,-400000,0)
from test_polygon
where id = '32';

insert into test_map
select id,translate(geom,150000,-400000,0)
from test_polygon
where id = '33';

--
-- Row nine.
--
insert into test_map
select id,translate(geom,0,-450000,0)
from test_polygon
where id = '34';

insert into test_map
select id,translate(geom,50000,-450000,0)
from test_polygon
where id = '35';

insert into test_map
select id,translate(geom,100000,-450000,0)
from test_polygon
where id = '36';

insert into test_map
select id,translate(geom,150000,-450000,0)
from test_polygon
where id = '37';



More information about the Discuss mailing list