Home » Server Options » Spatial » how to put the Lan Long in a variable (11)
how to put the Lan Long in a variable [message #614722] Mon, 26 May 2014 09:35 Go to next message
abbasgol
Messages: 3
Registered: January 2013
Junior Member
Hello World ,

Declare
dd SDO_GEOMETRY:=50.39703369140625,26.172694044887898,50.39531707763672,26.16807213199397,50.39154052734375,26.16591517661071;
tg_1 SDO_GEOMETRY := SDO_GEOMETRY (2007,
8307,
sdo_point_type (NULL, NULL, NULL),
sdo_elem_info_array (1,
1003,
1,
51,
1003,
1
),
sdo_ordinate_array ( dd )

is there a way to pass the coordinates to variable the put it inside the sdo_ordinate_array , the above not working put when i put the coordinates directly it works
Re: how to put the Lan Long in a variable [message #614770 is a reply to message #614722] Tue, 27 May 2014 01:51 Go to previous messageGo to next message
Barbara Boehmer
Messages: 7970
Registered: November 2002
Location: California, USA
Senior Member
It helps to know where the coordinates are coming from. In the following example, the coordinates come from a table.

SCOTT@orcl12c> CREATE TABLE coordinate_tab
  2    (coordinates  NUMBER)
  3  /

Table created.

SCOTT@orcl12c> INSERT ALL
  2  INTO coordinate_tab (coordinates) VALUES (50.39703369140625)
  3  INTO coordinate_tab (coordinates) VALUES (26.172694044887898)
  4  INTO coordinate_tab (coordinates) VALUES (50.39531707763672)
  5  INTO coordinate_tab (coordinates) VALUES (26.16807213199397)
  6  INTO coordinate_tab (coordinates) VALUES (50.39154052734375)
  7  INTO coordinate_tab (coordinates) VALUES (26.16591517661071)
  8  SELECT * FROM DUAL
  9  /

6 rows created.

SCOTT@orcl12c> SELECT * FROM coordinate_tab
  2  /

COORDINATES
-----------
 50.3970337
  26.172694
 50.3953171
 26.1680721
 50.3915405
 26.1659152

6 rows selected.

SCOTT@orcl12c> CREATE TABLE geom_tab
  2    (geom  SDO_GEOMETRY)
  3  /

Table created.

SCOTT@orcl12c> DECLARE
  2    dd    SDO_ORDINATE_ARRAY;
  3    tg_1  SDO_GEOMETRY;
  4  BEGIN
  5    SELECT CAST (COLLECT (coordinates) AS SDO_ORDINATE_ARRAY) INTO dd FROM coordinate_tab;
  6    tg_1 :=
  7  	 SDO_GEOMETRY
  8  	   (2007, 8307,
  9  	    SDO_POINT_TYPE (NULL, NULL, NULL),
 10  	    SDO_ELEM_INFO_ARRAY (1, 1003, 1, 51, 1003, 1),
 11  	    dd);
 12    INSERT INTO geom_tab (geom) VALUES (tg_1);
 13  END;
 14  /

PL/SQL procedure successfully completed.

SCOTT@orcl12c> SELECT * FROM geom_tab
  2  /

GEOM(SDO_GTYPE, SDO_SRID, SDO_POINT(X, Y, Z), SDO_ELEM_INFO, SDO_ORDINATES)
--------------------------------------------------------------------------------
SDO_GEOMETRY(2007, 8307, SDO_POINT_TYPE(NULL, NULL, NULL), SDO_ELEM_INFO_ARRAY(1
, 1003, 1, 51, 1003, 1), SDO_ORDINATE_ARRAY(50.3970337, 26.172694, 50.3953171, 2
6.1680721, 50.3915405, 26.1659152))


1 row selected.

Re: how to put the Lan Long in a variable [message #614892 is a reply to message #614722] Wed, 28 May 2014 06:41 Go to previous message
_jum
Messages: 489
Registered: February 2008
Senior Member
You could do it this way too:

SET SERVEROUTPUT ON SIZE 900000;

DECLARE
  dd   SDO_ORDINATE_ARRAY := SDO_ORDINATE_ARRAY (50.39703369140625,26.172694044887898, 50.39531707763672,26.16807213199397, 50.39154052734375,26.16591517661071);
  tg_1 SDO_GEOMETRY := SDO_GEOMETRY 
 (2007, 8307, NULL, SDO_ELEM_INFO_ARRAY (1, 1003, 1, 51, 1003, 1), dd);
BEGIN
  dbms_output.put_line (SDO_GEOM.VALIDATE_GEOMETRY(tg_1,0.001));
END;

13034
PL/SQL procedure successfully completed.


But the SDO_GEOMETRY is invalid !
13034 - Invalid data in the SDO_ORDINATE_ARRAY in SDO_GEOMETRY object

Have a look at the documentation.

[Updated on: Wed, 28 May 2014 06:50]

Report message to a moderator

Previous Topic: Size of Spatial Data
Next Topic: LAS to Oracle Converter
Goto Forum:
  


Current Time: Sat Aug 23 01:20:07 CDT 2014

Total time taken to generate the page: 0.21173 seconds