Doubt related to math operation with angle, distance and coordinate (Oracle Spatial)

From: Eriovaldo Andrietta <ecandrietta_at_gmail.com>
Date: Mon, 9 Jun 2014 22:23:30 -0300
Message-ID: <CAJdDhaOtS=cdwWm48EaEGEZkkToZduLRi3CMOysGaYAnbm61YQ_at_mail.gmail.com>



Hello,

I would like to know if anyone have experience doing this kind of math operation in order to determine a new coordinate, having as variable:

  • an angle
  • a distance
  • and x,y coordinate

Using this sample , I got difference after math operation. The goal is add the distance to the vertices x,y based on angle and get new x,y

1.) Is there any spatial instruction to convert unit degree to meter ?

      I cannot add meter to the radian ? 2.) I am getting a small difference after getting new coordinates

            distance : 5.024
            v_distance check   : 4.85907352139169

Any experience with this ?

declare

v_x         NUMBER;
v_y         NUMBER;
v_xt         NUMBER;
v_yt         NUMBER;
v_xc        NUMBER;
v_yc        NUMBER;
v_distance  NUMBER;
v_distanceC NUMBER;
v_rotation  NUMBER;
latlen      NUMBER;
longlen     NUMBER;

conv_factor NUMBER;
m1 NUMBER := 111132.92;    -- // latitude calculation term 1
m2 NUMBER := -559.82;      -- // latitude calculation term 2
m3 NUMBER := 1.175;        -- // latitude calculation term 3
m4 NUMBER := -0.0023;      -- // latitude calculation term 4
p1 NUMBER := 111412.84;    -- // longitude calculation term 1
p2 NUMBER := -93.5;        -- // longitude calculation term 2
p3 NUMBER := 0.118;        -- // longitude calculation term 3

begin
-- these coords are in the lat long

v_xt       := -76.32918128250318205449979638672173921913;
v_yt       := -35.06266837499263672797787725285434162194;
v_x        := v_xt;
v_y        := v_yt;

v_distance := 5.024;
v_rotation := 153.8+90;
dbms_output.put_line ('rotation : ' || v_rotation); SELECT SDO_UTIL.CONVERT_UNIT(v_rotation, 'Degree', 'Radian') into v_rotation FROM DUAL;

conv_factor := (2 * 3.14159265359)/360;
v_xc := v_x * conv_factor;
v_yc := v_y * conv_factor;

  • // Calculate the length of a degree of latitude and longitude in meters latlen := m1 + (m2 * cos(2 * v_xc)) + (m3 * cos(4 * v_xc)) + (m4 * cos(6 * v_xc)); longlen := m1 + (m2 * cos(2 * v_yc)) + (m3 * cos(4 * v_yc)) + (m4 * cos(6 * v_yc));
  • longlen := (p1 * cos(v_x)) + (p2 * cos(3 * v_x)) + (p3 * cos(5 * v_x));
dbms_output.put_line ('latlen   : ' || latlen);
dbms_output.put_line ('longlen  : ' || longlen);
dbms_output.put_line ('x before : ' || v_x);
dbms_output.put_line ('y before : ' || v_y);
dbms_output.put_line ('distance : ' || v_distance);

v_x := v_x + ((v_distance / latlen) * COS((v_rotation))); v_y := v_y + ((v_distance / longlen) * SIN((v_rotation)));

dbms_output.put_line ('x after : ' || v_x); dbms_output.put_line ('y after : ' || v_y);

SELECT SDO_GEOM.SDO_DISTANCE ( SDO_GEOMETRY(2001, 4326, SDO_POINT_TYPE(v_xt, v_yt, NULL), NULL, NULL)

                                             ,
SDO_DIM_ARRAY(SDO_DIM_ELEMENT('X', -74.5, -34.2, 0.001), SDO_DIM_ELEMENT('Y', -35, 5.5, 0.001))
                                             , SDO_GEOMETRY(2001, 4326,
SDO_POINT_TYPE(v_x, v_y, NULL), NULL, NULL)
                                             ,
SDO_DIM_ARRAY(SDO_DIM_ELEMENT('X', -74.5, -34.2, 0.001), SDO_DIM_ELEMENT('Y', -35, 5.5, 0.001))
                                             , DECODE(
measure_unit_info.length
                                                   , 'm' , 'unit=Meter'


                                                   , 'ft', 'unit=Foot'


                                                   , 'yd', 'unit=Yard'


                                                   , 'mi', 'unit=Mile')
  ) into v_distancec
FROM DUAL,measure_unit_info ;

dbms_output.put_line ('v_distance check : ' || v_distancec);

end;
/

Regards
Eriovaldo

--
http://www.freelists.org/webpage/oracle-l
Received on Tue Jun 10 2014 - 03:23:30 CEST

Original text of this message