[postgis-users] Establish versus of a line
Andrea Peri
aperi2007 at gmail.com
Sat May 1 05:26:48 PDT 2010
Hi Nico,
Many thanks, I think this is the right way. :)
But there is some trouble :(
I will try with this code:
create and fill two tale (polygon and linestrings)
drop table if exists _test_mpoly;
delete from geometry_columns where f_table_schema='public' and
f_table_name='_test_mpoly';
create table _test_mpoly (id serial primary key);
SELECT AddGeometryColumn('_test_mpoly', 'geom', 3003, 'MULTIPOLYGON', 2);
insert into _test_mpoly (geom) values ( ST_GeomFromText('MULTIPOLYGON(
((4 8, 7 9, 10 7, 9 4, 6 1, 3 2, 2 3, 1 6, 4 8)))',3003 ));
drop table if exists _test_line;
delete from geometry_columns where f_table_schema='public' and
f_table_name='_test_line';
create table _test_line (id serial primary key,verso integer);
SELECT AddGeometryColumn('_test_line', 'geom', 3003, 'LINESTRING', 2);
insert into _test_line (geom) values ( ST_GeomFromText('LINESTRING(2
3, 3 2, 6 1)',3003 )); //
insert into _test_line (geom) values ( ST_GeomFromText('LINESTRING(6
1, 3 2, 2 3)',3003 )); // opposite to theb other line
As notable I insert in the linestring table 2 lines with opposite versus.
After this I try next sql select with the ST_OrderingEquals function.
select
a.id as id,
case
when ST_OrderingEquals(a.geom,c.geom)=true then 1
else 0
end as versus
from
public._test_line as a,
(select ST_Boundary(b.geom) as geom from public._test_mpoly as b) as c
where
ST_Intersects(a.geom,c.geom)=true
The results I will hope was
0 (first linestring is opposite versus to boundary polygon)
1 (second linestring is same versus to boundary polygon)
But the received results are
0
0
:(
I don't understand what is wrongly.
Regards, Andrea.
>Ok, so maybe you could rebuild polygons from the linestrings and test
>these polygons ?
>
>select st_orderingEquals(
> st_makepolygon(geom),
> st_forceRHR(st_makepolygon(geom))) from
>
>(select geometryFromText('LINESTRING (0 0, 1 0, 1 1, 0 1, 0 0)', -1) as geom
>union
>select geometryFromText('LINESTRING (2 2, 2 3, 3 3, 3 2, 2 2)', -1) as
>geom) as foo
>;
>
>Nico
--
-----------------
Andrea Peri
. . . . . . . . .
qwerty àèìòù
-----------------
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20100501/082d6e21/attachment.html>
More information about the postgis-users
mailing list