[postgis-users] Problem with 3D polygon intersection test

Ed Linde edolinde at gmail.com
Tue Oct 30 03:14:02 PDT 2012


Hi Nicolas,
Not quite sure what to make of the output from ST_DumpPoints, how do I
transform it to just raw x,y,z coordinates?

 select st_astext(geomtext) from small_tris where id=0;
                       st_astext
-------------------------------------------------------
 POLYGON Z ((10 10 805,20 10 809,10 20 814,10 10 805))
(1 row)

bounds=#  select id, st_dumpPoints( geomtext ) from small_tris where id=0;
 id |                            st_dumppoints
----+----------------------------------------------------------------------
  0 | ("{1,1}",0101000080000000000000244000000000000024400000000000288940)
  0 | ("{1,2}",0101000080000000000000344000000000000024400000000000488940)
  0 | ("{1,3}",0101000080000000000000244000000000000034400000000000708940)
  0 | ("{1,4}",0101000080000000000000244000000000000024400000000000288940)
(4 rows)


Thanks,Ed


On Tue, Oct 30, 2012 at 11:05 AM, Ed Linde <edolinde at gmail.com> wrote:

> Ok thanks!
>
>
> On Tue, Oct 30, 2012 at 11:04 AM, Nicolas Ribot <nicolas.ribot at gmail.com>wrote:
>
>> st_dumpRings will return the rings (closed linestrings) composing the
>> polygon (exterior first, then interiors)
>> and st_dumpPoints will return all the points forming the rings, in the
>> right order.
>>
>> Nicolas
>>
>>
>> On 30 October 2012 10:56, Ed Linde <edolinde at gmail.com> wrote:
>>
>>> Ok, for a polygon, is there a good postgis function that can return the
>>> edges to me in the
>>> right sequence? Or at least the points that constitute the polygon in
>>> the right order, so I can
>>> generate the edges in a script?
>>>
>>> Thanks,
>>> Ed
>>>
>>>
>>> On Tue, Oct 30, 2012 at 10:46 AM, Ed Linde <edolinde at gmail.com> wrote:
>>>
>>>> Ah drat! Ok then I have to basically do edge intersection tests by
>>>> myself.
>>>> Ah well. bad news! :(
>>>>
>>>>
>>>> On Tue, Oct 30, 2012 at 10:44 AM, Nicolas Ribot <
>>>> nicolas.ribot at gmail.com> wrote:
>>>>
>>>>> Hi,
>>>>>
>>>>> st_intersection is only suitable for 2D operations. Third dimension is
>>>>> not taken into account.
>>>>>
>>>>> Nicolas
>>>>>
>>>>> On 30 October 2012 09:44, Ed Linde <edolinde at gmail.com> wrote:
>>>>>
>>>>>> Hi All,
>>>>>> Is there a simpler test I can do? I am quite sure that I am probably
>>>>>> not using the right
>>>>>> function in my SQL, or not doing the intersection test correctly. Is
>>>>>> there any simpler
>>>>>> way to test this 3D intersection? Am waiting on the postgis gurus to
>>>>>> come along and
>>>>>> give me some ideas, coz I am at my wits ends on this one! :) The
>>>>>> polygons look good
>>>>>> to me when I visualize them, but don't get how all triangles are
>>>>>> found as intersecting?
>>>>>> Anyway will wait.
>>>>>>
>>>>>> Cheers,
>>>>>> Ed
>>>>>>
>>>>>> On Tue, Oct 30, 2012 at 9:00 AM, Ed Linde <edolinde at gmail.com> wrote:
>>>>>>
>>>>>>> Hi All,
>>>>>>> I am having some troubles getting the *ST_Intersect* function to
>>>>>>> work with 3D polygons.
>>>>>>> I have a table to hold triangles as polygons in *"small_tris"*
>>>>>>> Another table for holding the polygonal faces of a 3D voronoi
>>>>>>> diagram in *"vfaces"*
>>>>>>> So now I am trying to do an intersection between the triangles and
>>>>>>> the voronoi faces
>>>>>>> to get the triangles that intersect with the faces. And it seems
>>>>>>> that *ALL* triangles
>>>>>>> are intersecting. I have attached a PDF where I have plotted the
>>>>>>> triangles and the
>>>>>>> voronoi cells. so the box around in red and blue with a major face
>>>>>>> going through is
>>>>>>> the voronoi diagram. The Voronoi partition in 3D is shown at the
>>>>>>> bottom too for clarity
>>>>>>> Can someone please help and let me know what am I doing wrong here?
>>>>>>> Is the select assuming something? So the polygons are flat and the
>>>>>>> intersections
>>>>>>> should just be lines or points. I am under some pressure to get this
>>>>>>> to work, so if
>>>>>>> anyone needs more information to help, the please let me know! :)
>>>>>>>
>>>>>>> Cheers,
>>>>>>> Ed
>>>>>>>
>>>>>>> *-- TABLE SCHEMAS*
>>>>>>> bounds=# \d vfaces;
>>>>>>>       Table "public.vfaces"
>>>>>>>   Column  |   Type   | Modifiers
>>>>>>> ----------+----------+-----------
>>>>>>>  gen_id   | integer  |
>>>>>>>  geomtext | geometry |
>>>>>>>
>>>>>>> bounds=# \d small_tris;
>>>>>>>     Table "public.small_tris"
>>>>>>>   Column  |   Type   | Modifiers
>>>>>>> ----------+----------+-----------
>>>>>>>  id       | integer  | not null
>>>>>>>  v0       | integer  |
>>>>>>>  v1       | integer  |
>>>>>>>  v2       | integer  |
>>>>>>>  geomtext | geometry |
>>>>>>> Indexes:
>>>>>>>     "small_tris_pkey" PRIMARY KEY, btree (id)
>>>>>>>     "small_idx" gist (geomtext)
>>>>>>>
>>>>>>>
>>>>>>> *
>>>>>>> -- TABLE CONTENT*
>>>>>>> bounds=# select id, st_astext( geomtext ) from small_tris;
>>>>>>>  id |                       st_astext
>>>>>>> ----+-------------------------------------------------------
>>>>>>>   0 | POLYGON Z ((10 10 805,20 10 809,10 20 814,10 10 805))
>>>>>>>   1 | POLYGON Z ((10 20 814,20 10 809,20 20 819,10 20 814))
>>>>>>>   2 | POLYGON Z ((20 20 819,30 10 809,30 20 812,20 20 819))
>>>>>>>   3 | POLYGON Z ((30 10 809,20 20 819,20 10 809,30 10 809))
>>>>>>>   4 | POLYGON Z ((30 20 812,30 10 809,40 10 826,30 20 812))
>>>>>>>   5 | POLYGON Z ((20 20 819,30 20 812,20 30 827,20 20 819))
>>>>>>>   6 | POLYGON Z ((10 20 814,20 20 819,20 30 827,10 20 814))
>>>>>>>   7 | POLYGON Z ((10 40 805,10 30 814,20 30 827,10 40 805))
>>>>>>>   8 | POLYGON Z ((10 50 804,10 40 805,20 40 807,10 50 804))
>>>>>>>   9 | POLYGON Z ((20 30 827,20 40 807,10 40 805,20 30 827))
>>>>>>>  10 | POLYGON Z ((30 30 817,20 40 807,20 30 827,30 30 817))
>>>>>>>  11 | POLYGON Z ((30 40 816,20 50 809,20 40 807,30 40 816))
>>>>>>>  12 | POLYGON Z ((20 40 807,20 50 809,10 50 804,20 40 807))
>>>>>>>  13 | POLYGON Z ((10 30 814,10 20 814,20 30 827,10 30 814))
>>>>>>>  14 | POLYGON Z ((30 30 817,20 30 827,30 20 812,30 30 817))
>>>>>>>  15 | POLYGON Z ((30 20 812,40 20 823,30 30 817,30 20 812))
>>>>>>>  16 | POLYGON Z ((40 20 823,30 20 812,40 10 826,40 20 823))
>>>>>>>  17 | POLYGON Z ((40 20 823,40 10 826,50 10 803,40 20 823))
>>>>>>>  18 | POLYGON Z ((30 30 817,40 20 823,40 30 814,30 30 817))
>>>>>>>  19 | POLYGON Z ((40 20 823,50 20 808,40 30 814,40 20 823))
>>>>>>>  20 | POLYGON Z ((50 20 808,40 20 823,50 10 803,50 20 808))
>>>>>>>  21 | POLYGON Z ((40 30 814,50 20 808,50 30 816,40 30 814))
>>>>>>>  22 | POLYGON Z ((30 30 817,40 30 814,40 40 800,30 30 817))
>>>>>>>  23 | POLYGON Z ((30 40 816,40 40 800,30 50 813,30 40 816))
>>>>>>>  24 | POLYGON Z ((30 40 816,30 30 817,40 40 800,30 40 816))
>>>>>>>  25 | POLYGON Z ((30 50 813,40 40 800,40 50 817,30 50 813))
>>>>>>>  26 | POLYGON Z ((30 40 816,30 50 813,20 50 809,30 40 816))
>>>>>>>  27 | POLYGON Z ((50 40 821,40 50 817,40 40 800,50 40 821))
>>>>>>>  28 | POLYGON Z ((50 50 809,40 50 817,50 40 821,50 50 809))
>>>>>>>  29 | POLYGON Z ((50 40 821,40 40 800,50 30 816,50 40 821))
>>>>>>>  30 | POLYGON Z ((40 30 814,50 30 816,40 40 800,40 30 814))
>>>>>>>  31 | POLYGON Z ((30 30 817,30 40 816,20 40 807,30 30 817))
>>>>>>> (32 rows)
>>>>>>>
>>>>>>>  select st_astext(geomtext) from vfaces;
>>>>>>>
>>>>>>> st_astext
>>>>>>>
>>>>>>> -----------------------------------------------------------------------------------------------
>>>>>>>  POLYGON Z ((51 17.8 799,9 38.8 799,9 51 819.33333333333,19.4 51
>>>>>>> 828,51 35.2 828,51 17.8 799))
>>>>>>>  POLYGON Z ((51 17.8 799,9 38.8 799,9 51 799,51 51 799,51 17.8 799))
>>>>>>>  POLYGON Z ((51 35.2 828,19.4 51 828,51 51 828,51 35.2 828))
>>>>>>>  POLYGON Z ((9 9 799,9 38.8 799,51 17.8 799,51 9 799,9 9 799))
>>>>>>>  POLYGON Z ((51 17.8 799,9 38.8 799,9 51 819.33333333333,19.4 51
>>>>>>> 828,51 35.2 828,51 17.8 799))
>>>>>>>  POLYGON Z ((9 9 828,9 51 828,19.4 51 828,51 35.2 828,51 9 828,9 9
>>>>>>> 828))
>>>>>>> (6 rows)
>>>>>>>
>>>>>>> *select distinct a.id
>>>>>>> from small_tris a, vfaces b
>>>>>>> where st_intersects (a.geomtext, b.geomtext)
>>>>>>> order by a.id;*
>>>>>>>  id
>>>>>>> ----
>>>>>>>   0
>>>>>>>   1
>>>>>>>   2
>>>>>>>   3
>>>>>>>   4
>>>>>>>   5
>>>>>>>   6
>>>>>>>   7
>>>>>>>   8
>>>>>>>   9
>>>>>>>  10
>>>>>>>  11
>>>>>>>  12
>>>>>>>  13
>>>>>>>  14
>>>>>>>  15
>>>>>>>  16
>>>>>>>  17
>>>>>>>  18
>>>>>>>  19
>>>>>>>  20
>>>>>>>  21
>>>>>>>  22
>>>>>>>  23
>>>>>>>  24
>>>>>>>  25
>>>>>>>  26
>>>>>>>  27
>>>>>>>  28
>>>>>>>  29
>>>>>>>  30
>>>>>>>  31
>>>>>>> (32 rows)
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>
>>>>>> _______________________________________________
>>>>>> postgis-users mailing list
>>>>>> postgis-users at postgis.refractions.net
>>>>>> http://postgis.refractions.net/mailman/listinfo/postgis-users
>>>>>>
>>>>>>
>>>>>
>>>>> _______________________________________________
>>>>> postgis-users mailing list
>>>>> postgis-users at postgis.refractions.net
>>>>> http://postgis.refractions.net/mailman/listinfo/postgis-users
>>>>>
>>>>>
>>>>
>>>
>>> _______________________________________________
>>> postgis-users mailing list
>>> postgis-users at postgis.refractions.net
>>> http://postgis.refractions.net/mailman/listinfo/postgis-users
>>>
>>>
>>
>> _______________________________________________
>> postgis-users mailing list
>> postgis-users at postgis.refractions.net
>> http://postgis.refractions.net/mailman/listinfo/postgis-users
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20121030/6511bf01/attachment.html>


More information about the postgis-users mailing list