Home » Server Options » Spatial » Data Type: Spatial
Data Type: Spatial [message #151606] Thu, 15 December 2005 19:01
ken_ken
Messages: 3
Registered: December 2005
Location: newbury
Junior Member
I have done a Check to see if a Certain Point are inside a box. I solved this by creating a point and box and a check for this, and getting the answer (in the code below).

Question: How can i create a table which will hold the BOX values and another table with Point values.
And try and use a Select statement to do the TEST is point is in Box.
I am typing to get a grip with SQL statement.

Please help!

A point has Xval and Y val (numeric)
A box has fields BOTTOM and TOP which are TYPE POINT

On a grid where a box is placed:
A point on the top right corner is Y Value (top), X value (right)
A point on the bottom right corner has Y value (bottom), and X value (left)

I completed the following

create or replace type POINT as object
(xval number, yval number,
member function x return number,
member function y return number
)
/
create or replace type body point as
member function X return number is
begin
return xval;
end;
member function y return number is
begin
return yval;
end;
end; /

create or replace type box as object
(
top_right point,
bottom_left point,
member function ContainPB( aPoint Point) return number
) ;
/

create or replace type body box as
member function ContainPB(aPoint Point)
return number
as
begin
if (aPoint.X <= top_right.X) and
(aPoint.X >= bottom_left.X) and
(aPoint.Y <= top_right.Y) and
(aPoint.Y >= bottom_left.Y)
THEN
return 1;
else
return 0;
end if;
end;
end;
/



It is this bit below, i could like to do through appropriate TABLES and use Select statement
declare
Point1 POINT := POINT(50,50);
Point2 POINT := POINT(400,350);
Box1 box := Box( ( Point (474,419), Point (149,109));
begin

DBMS_OUTPUT.PUT_LINE('Result Point 1=' || Box1.containpb(point1));
DBMS_OUTPUT.PUT_LINE('Result Point 2=' || Box1.containpb(point2));

END;
Previous Topic: topology
Next Topic: Oracle Spatial
Goto Forum:
  


Current Time: Thu Apr 18 17:50:52 CDT 2024