3 Replies Latest reply on Apr 8, 2003 1:19 AM by 319250

    OO4O to Retrieve Spatial Data (SDO_GEOMETRY)

      Does anyone have any sample code in VB or C++ to retrieve data from the SDO_GEOMETRY object? Any code or suggestions would be much appreciated.
        • 1. Re: OO4O to Retrieve Spatial Data (SDO_GEOMETRY)
          hi,I am tring using the OO4O too.And here is some code that I think can help u,but in which IDE do u use the oo4o,I just can not use the OO4O in DELPHI AND C++ BUILDER.
          Dim OraSession As OraSession
          Dim OraDatabase As OraDatabase
          Dim LRS As OraDynaset
          Dim Ordinates As OraCollection
          Dim sdo_geometry As OraObject
          Dim i As Integer
          Set OraSession = CreateObject("OracleInProcServer.XOraSession")
          Set OraDatabase = OraSession.DbOpenDatabase("n12dev6", "gis/spatial", ORADB_DEFAULT)
          Set LRS = OraDatabase.CreateDynaset("select * from GPS_LRS where id ='11SR012001'", ORADB_DEFAULT)
          Set sdo_geometry = LRS.Fields("geometry").Value
          Set Ordinates = sdo_geometry.Item("sdo_ordinates").Value
          'access all elements of the SDO_ORDINATES VArray
          For i = 1 To Ordinates.Size
          MsgBox Ordinates(i)
          Next i
          • 2. Re: OO4O to Retrieve Spatial Data (SDO_GEOMETRY)
            Thanks for the help...I use Visual Studios as my IDE. Do you know how to retrieve data using a 'query window'...ie. specify a rectangle and Oracle will return only spatial objects within this rectangle (in VB still)?
            • 3. Re: OO4O to Retrieve Spatial Data (SDO_GEOMETRY)
              oracle spatial has built-in functions that can do this job,I think you can find in the spatial reference book,here is an example that find the nearest 5 outlet beside a warehouse

              REM Finds the 5 closest customers to warehouse_id = 3
              REM who reside in NY state, and return the distance in miles,
              REM and order the results by distance


              set lines 132
              set pages 1000

              select /*+ordered*/
              c.cust_address.state_province state,
              sdo_nn_distance(1) distance_in_miles
              from warehouses w,
              customers c
              where w.warehouse_id = 3
              and sdo_nn (c.cust_geo_location, w.wh_geo_location,
              'sdo_batch_size =5 unit=mile', 1) = 'TRUE'
              and c.cust_address.state_province = 'NY'
              and rownum < 6
              order by distance_in_miles;