Skip to main content
added 15 characters in body
Source Link
John Powell
  • 13.7k
  • 5
  • 48
  • 62

It is something of a hack, but you can use a textthe replace function on the TIN zZs, convert thatthose to POLYGON zZs, and then use ST_Dump to extract the individual triangles as polygons. For example:

WITH 
    tin (id, geom) AS (
       SELECT (ST_DUMPST_Dump(
                  ST_GEOMFROMTEXTST_GeomFromText(
                     replace(
                        'TIN Z (((0 0 0,0 0 0.5,0 0.5 0.5,0 0 0)),
                        ((0 0.5 0,0 0 0,0 0.5 0.5,0 0.5 0)))'::text, 
                        'TIN Z', 'MULTIPOLYGON')))
               ).*), 
    tin1 (id, geom) AS (
        SELECT (ST_DUMPST_Dump(
                   ST_GEOMFROMTEXTST_GeomFromText(
                     replace(
                         'TIN Z (((0 0 0,0 0 0.5,0 0.5 0.5,0 0 0)),
                          ((0 0.5 0,1 1 1,1 0.5 0.5,0 0.5 0)))'::text, 
                          'TIN Z', 'MULTIPOLYGON')))
                ).*)
 SELECT 
      a.id[0], 
      b.id[0], 
      ST_3dIntersects(a.geom, b.geom) 
    FROM tin a, tin1 b;

As there is no 3D equivalent of ST_Contains, you would have to ensure that your TINs are closed in 3D (ie, are solids) and use ST_3DIntersection of of the two TINs and compare against ST_Volume of each individual one.

It is something of a hack, but you can use a text replace on TIN z, convert that to POLYGON z, and then use ST_Dump to extract the individual triangles as polygons. For example:

WITH 
    tin (id, geom) AS (
       SELECT (ST_DUMP(
                  ST_GEOMFROMTEXT(
                     replace(
                        'TIN Z (((0 0 0,0 0 0.5,0 0.5 0.5,0 0 0)),
                        ((0 0.5 0,0 0 0,0 0.5 0.5,0 0.5 0)))'::text, 
                        'TIN Z', 'MULTIPOLYGON')))
               ).*), 
    tin1 (id, geom) AS (
        SELECT (ST_DUMP(
                   ST_GEOMFROMTEXT(
                     replace(
                         'TIN Z (((0 0 0,0 0 0.5,0 0.5 0.5,0 0 0)),
                          ((0 0.5 0,1 1 1,1 0.5 0.5,0 0.5 0)))'::text, 
                          'TIN Z', 'MULTIPOLYGON')))
                ).*)
 SELECT 
      a.id[0], 
      b.id[0], 
      ST_3dIntersects(a.geom, b.geom) 
    FROM tin a, tin1 b;

As there is no 3D equivalent of ST_Contains, you would have to ensure that your TINs are closed in 3D (ie, are solids) and use ST_3DIntersection of of the two TINs and compare against ST_Volume of each individual one.

It is something of a hack, but you can use a the replace function on the TIN Zs, convert those to POLYGON Zs, and then use ST_Dump to extract the individual triangles as polygons. For example:

WITH 
    tin (id, geom) AS (
       SELECT (ST_Dump(
                  ST_GeomFromText(
                     replace(
                        'TIN Z (((0 0 0,0 0 0.5,0 0.5 0.5,0 0 0)),
                        ((0 0.5 0,0 0 0,0 0.5 0.5,0 0.5 0)))'::text, 
                        'TIN Z', 'MULTIPOLYGON')))
               ).*), 
    tin1 (id, geom) AS (
        SELECT (ST_Dump(
                   ST_GeomFromText(
                     replace(
                         'TIN Z (((0 0 0,0 0 0.5,0 0.5 0.5,0 0 0)),
                          ((0 0.5 0,1 1 1,1 0.5 0.5,0 0.5 0)))'::text, 
                          'TIN Z', 'MULTIPOLYGON')))
                ).*)
 SELECT 
      a.id[0], 
      b.id[0], 
      ST_3dIntersects(a.geom, b.geom) 
    FROM tin a, tin1 b;

As there is no 3D equivalent of ST_Contains, you would have to ensure that your TINs are closed in 3D (ie, are solids) and use ST_3DIntersection of of the two TINs and compare against ST_Volume of each individual one.

added 490 characters in body
Source Link
John Powell
  • 13.7k
  • 5
  • 48
  • 62

It is something of a hack, but you can use a text replace on TIN z, convert that to POLYGON z, and then use ST_Dump to extract the individual triangles as polygons. For example:

WITH 
    tin (id, geom) AS (
       SELECT (ST_DUMP(
                  ST_GEOMFROMTEXT(
                     replace(
                        'TIN Z (((0 0 0,0 0 0.5,0 0.5 0.5,0 0 0)),
                        ((0 0.5 0,0 0 0,0 0.5 0.5,0 0.5 0)))'::text, 
                        'TIN Z', 'MULTIPOLYGON')))
               ).*), 
    tin1 (id, geom) AS (
        SELECT (ST_DUMP(
                   ST_GEOMFROMTEXT(
                     replace(
                         'TIN Z (((0 0 0,0 0 0.5,0 0.5 0.5,0 0 0)),
                          ((0 0.5 0,1 1 1,1 0.5 0.5,0 0.5 0)))'::text, 
                          'TIN Z', 'MULTIPOLYGON')))
                ).*)
 SELECT 
      a.id[0], 
      b.id[0], 
      ST_3dIntersects(a.geom, b.geom) 
    FROM tin a, tin1 b;

As there is no 3D equivalent of ST_Contains, you would have to ensure that your TINs are closed in 3D (ie, are solids) and use ST_3DIntersection of of the two TINs and compare against ST_Volume of each individual one.

It is something of a hack, but you can use a text replace on TIN z, convert that to POLYGON z, and then use ST_Dump to extract the individual triangles as polygons. For example:

WITH 
    tin (id, geom) AS (
       SELECT (ST_DUMP(ST_GEOMFROMTEXT(replace(
              'TIN Z (((0 0 0,0 0 0.5,0 0.5 0.5,0 0 0)),
                      ((0 0.5 0,0 0 0,0 0.5 0.5,0 0.5 0)))'::text, 
                       'TIN Z', 'MULTIPOLYGON')))).*), 
    tin1 (id, geom) AS (
        SELECT (ST_DUMP(ST_GEOMFROMTEXT(replace(
               'TIN Z (((0 0 0,0 0 0.5,0 0.5 0.5,0 0 0)),
                       ((0 0.5 0,1 1 1,1 0.5 0.5,0 0.5 0)))'::text, 
                       'TIN Z', 'MULTIPOLYGON')))).*)
 SELECT 
      a.id[0], 
      b.id[0], 
      ST_3dIntersects(a.geom, b.geom) 
    FROM tin a, tin1 b;

It is something of a hack, but you can use a text replace on TIN z, convert that to POLYGON z, and then use ST_Dump to extract the individual triangles as polygons. For example:

WITH 
    tin (id, geom) AS (
       SELECT (ST_DUMP(
                  ST_GEOMFROMTEXT(
                     replace(
                        'TIN Z (((0 0 0,0 0 0.5,0 0.5 0.5,0 0 0)),
                        ((0 0.5 0,0 0 0,0 0.5 0.5,0 0.5 0)))'::text, 
                        'TIN Z', 'MULTIPOLYGON')))
               ).*), 
    tin1 (id, geom) AS (
        SELECT (ST_DUMP(
                   ST_GEOMFROMTEXT(
                     replace(
                         'TIN Z (((0 0 0,0 0 0.5,0 0.5 0.5,0 0 0)),
                          ((0 0.5 0,1 1 1,1 0.5 0.5,0 0.5 0)))'::text, 
                          'TIN Z', 'MULTIPOLYGON')))
                ).*)
 SELECT 
      a.id[0], 
      b.id[0], 
      ST_3dIntersects(a.geom, b.geom) 
    FROM tin a, tin1 b;

As there is no 3D equivalent of ST_Contains, you would have to ensure that your TINs are closed in 3D (ie, are solids) and use ST_3DIntersection of of the two TINs and compare against ST_Volume of each individual one.

Source Link
John Powell
  • 13.7k
  • 5
  • 48
  • 62

It is something of a hack, but you can use a text replace on TIN z, convert that to POLYGON z, and then use ST_Dump to extract the individual triangles as polygons. For example:

WITH 
    tin (id, geom) AS (
       SELECT (ST_DUMP(ST_GEOMFROMTEXT(replace(
              'TIN Z (((0 0 0,0 0 0.5,0 0.5 0.5,0 0 0)),
                      ((0 0.5 0,0 0 0,0 0.5 0.5,0 0.5 0)))'::text, 
                       'TIN Z', 'MULTIPOLYGON')))).*), 
    tin1 (id, geom) AS (
        SELECT (ST_DUMP(ST_GEOMFROMTEXT(replace(
               'TIN Z (((0 0 0,0 0 0.5,0 0.5 0.5,0 0 0)),
                       ((0 0.5 0,1 1 1,1 0.5 0.5,0 0.5 0)))'::text, 
                       'TIN Z', 'MULTIPOLYGON')))).*)
 SELECT 
      a.id[0], 
      b.id[0], 
      ST_3dIntersects(a.geom, b.geom) 
    FROM tin a, tin1 b;