6 Replies Latest reply: Jan 28, 2013 10:44 PM by don123 RSS

    tin

    don123
      hi,

      i have following sample polygon geometry, working with oracle 11g.
      i want to how to create TIN from this geometry.
      i have seen the documentation, but not clear how to use the sub program and their parameters
      =========================

      IDNUMBER     GEOMETRY

      5cOB     MDSYS.SDO_GEOMETRY(3,8307,NULL,MDSYS.SDO_ELEM_INFO_ARRAY(1,3,1),MDSYS.SDO_ORDINATE_ARRAY(-87.899208,41.953219,-87.899233,41.953198,-87.899299,41.953241,-87.899315,41.953252,-87.899562,41.953416,-87.899584,41.95343,-87.899648,41.953472,-87.899631,41.953487,-87.899622,41.953494,-87.898705,41.954268,-87.895787,41.956731,-87.894383,41.957917,-87.892065,41.959873,-87.890731,41.960999,-87.88793,41.963363,-87.885875,41.965097,-87.883067,41.967466,-87.881899,41.968451,-87.880914,41.969282,-87.880019,41.970038,-87.880005,41.970049,-87.879981,41.97007,-87.879913,41.970024,-87.879897,41.970014,-87.879656,41.969854,-87.879634,41.969839,-87.879567,41.969795,-87.879591,41.969775,-87.899208,41.953219))

      5cOF     MDSYS.SDO_GEOMETRY(3,8307,NULL,MDSYS.SDO_ELEM_INFO_ARRAY(1,3,1),MDSYS.SDO_ORDINATE_ARRAY(-87.90904,41.983694,-87.91133,41.983693,-87.911317,41.983704,-87.910882,41.984099,-87.910868,41.984111,-87.908758,41.984112,-87.908419,41.984112,-87.900568,41.984115,-87.900293,41.984115,-87.897663,41.984115,-87.896842,41.984116,-87.89514,41.984116,-87.895126,41.984103,-87.894791,41.983805,-87.894768,41.983785,-87.894758,41.983776,-87.894735,41.983756,-87.894682,41.983708,-87.894669,41.983697,-87.896208,41.983696,-87.897884,41.983696,-87.900045,41.983696,-87.90135,41.983695,-87.904412,41.983695,-87.905635,41.983694,-87.906249,41.983694,-87.90904,41.983694))

      thanks
        • 1. Re: tin
          Stefan Jager
          Hi Don,

          First of all: Your SDO_GTYPE is not valid:

          MDSYS.SDO_GEOMETRY( <font color="red">*3*</font> ,8307,NULL,MDSYS.SDO_ELEM_INFO_ARRAY(1,3,1),MDSYS.SDO_ORDINATE_ARRAY ...

          From the fact that the first and last ordinates are the same I'd say these are Polygons, which means your SDO_GTYPE should be 3003 if these are 3-dimensional polygons. I suspect that they are 2-dimensional however, looking at the ordinates. This means your TIN will be flat.

          But back to setting up a TIN, your original question:

          1. Create a table with a column of type SDO_TIN
          2. Create the TIN Block table: CREATE TABLE <table-name> AS select * from mdsys.sdo_tin_blk_table;
          3. Create the points table: CREATE TABLE <table-name> (RID (VARCHAR2(24)), VAL_D1 (NUMBER), VAL_D2 (NUMBER), VAL_D3 (NUMBER));
          4. Now extract the points from your geometries, and insert them in the points table (there's examples on this forum to be found how you get the ordinates out of an SDO_GEOMETRY)
          5. Initialize the TIN, using the SDO_TIN_PKG.INIT function
          6. Create the TIN, using the SDO_TIN_PKG.CREATE_TIN procedure

          The exact parameters and everything, including examples, are pretty well described [url http://docs.oracle.com/cd/E11882_01/appdev.112/e11830/sdo_tin_pkg_ref.htm#CACGDACE]here. There is even an example delivered with the installation:
          The following example performs a clip operation on a TIN. It is taken from the sdo_tin.sql example program, which is under >$ORACLE_HOME/md/demo/examples/TIN/plsql/ if you installed the files from the Oracle Database Examples media
          HTH,
          Stefan
          • 2. Re: tin
            don123
            hi stefan,

            thanks..

            As suggested, i have corrected gtype to 2003 (2-dimensional). As you said it is polygon geometry.

            (1) created table (RTEST) with column MYTIN as SDO_TIN type
            (2) created tin block (RBLOCK) table
            (3) created points table (RPOINTS), what is RID column in this table ??
            (4) extracted points X,Y from polygon geometry into RPOINTS table by using sdo_util.getvertices
            (5) initialized tin succesfully with following.

            declare
            tin sdo_tin;
            begin
            -- Initialize the TIN object.
            tin := sdo_tin_pkg.init(
            'RTEST', -- Table that has the SDO_TIN column defined
            'MYTIN', -- Column name of the SDO_TIN object
            'RBLOCK', -- Table to store blocks of the TIN
            'blk_capacity=1000', -- max # of points per block
            mdsys.sdo_geometry(2003, null, null,
            mdsys.sdo_elem_info_array(1,1003,3),
            mdsys.sdo_ordinate_array(-180, -90, 180, 90)), -- Extent
            0.0000000005, -- Tolerance for TIN
            2, -- Total number of dimensions
            null);
            end;


            (6) Now stopped at this step, Can you explain the input parameters to run SDO_TIN_PKG.CREATE_TIN


            regards
            • 3. Re: tin
              Stefan Jager
              Hi Don,

              I think it's pretty wel explained [url http://docs.oracle.com/cd/E11882_01/appdev.112/e11830/sdo_tin_pkg_ref.htm#CACJHFFD]here. But basically, continuing on what you've got, this is what you should do:
              tin := sdo_tin_pkg.init(
              'RTEST', -- Table that has the SDO_TIN column defined
              'MYTIN', -- Column name of the SDO_TIN object 
              'RBLOCK', -- Table to store blocks of the TIN
              'blk_capacity=1000', -- max # of points per block 
              mdsys.sdo_geometry(2003, null, null,
              mdsys.sdo_elem_info_array(1,1003,3),
              mdsys.sdo_ordinate_array(-180, -90, 180, 90)), -- Extent 
              0.0000000005, -- Tolerance for TIN
              2, -- Total number of dimensions
              null);
              
              -- Create the blocks for the TIN.
              sdo_tin_pkg.create_tin(
                tin,       -- Initialized TIN object
                'RPOINTS', -- Name of input table to ingest into the pointcloud
              );
              But, as I said before: a 2-Dimensional TIN does not add much value. It will be flat, and give you no extra information that the normal geometry can't give you. So why you would want to do this with 2D-data?

              Cheers,
              Stefan
              • 4. Re: tin
                don123
                stfean,

                I am trying to tesselate polygons into triangles, i am not sure my approach is correct, but trying to see the results.

                As suggested by you, i made changes as below and succesfully executed.

                How to see / display the output of TIN, what should be structure of output table, do i need to create before executing this.


                declare
                tin sdo_tin;

                begin
                -- Initialize the TIN object.
                tin := sdo_tin_pkg.init(
                'RUNWAYTEST', -- Table that has the SDO_TIN column defined
                'MYTIN', -- Column name of the SDO_TIN object
                'RUNWAYBLOCK', -- Table to store blocks of the TIN
                'blk_capacity=1000', -- max # of points per block
                mdsys.sdo_geometry(2003, null, null,
                mdsys.sdo_elem_info_array(1,1003,3),
                mdsys.sdo_ordinate_array(-180, -90, 180, 90)), -- Extent
                0.0000000005, -- Tolerance for TIN
                2, -- Total number of dimensions
                null);

                sdo_tin_pkg.create_tin(tin, 'RPOINTS');

                end;

                regards
                • 5. Re: tin
                  Stefan Jager
                  Hi Don,

                  [url http://docs.oracle.com/cd/E11882_01/appdev.112/e11830/sdo_tin_pkg_ref.htm#CACFHAAH]SDO_TIN_PKG.TO_GEOMETRY creates an SDO_GEOMETRY from all or part of your TIN. You should be able to see that, using the application of your choice.

                  Be aware though that
                  The number of polygons in the SDO_GEOMETRY is limited by the number of ordinates that can be in the SDO_ORDINATES_ARRAY.
                  An SDO_TIN object, on the other hand, models the surface as a network of triangles with no explicit limit on the number of triangles.
                  according to [url http://docs.oracle.com/cd/E11882_01/appdev.112/e11830/sdo_intro.htm#BABJBBEB]the documentation.

                  Didn't fully read the question, so adding this:
                  Create table ENDRESULT (ID NUMBER, geom SDO_GEOMETRY);
                  insert into ENDRESULT (ID, GEOM) values (1, SDO_TIN_PKG.TO_GEOMETRY(<fill in parameters>));
                  Add ENDRESULT to USER_SDO_GEOM_METADATA, and any application that can access Oracle's SDO_GEOMETRY should be able to show you what the result is.
                  Stefan

                  Edited by: Stefan Jager on Jan 28, 2013 1:38 PM
                  • 6. Re: tin
                    don123
                    Stefan,

                    Though the output is not correct, I am thankful to you for your support on explanation of procedures and marked this thread as answered.