Home » Server Options » Spatial » Data Type: Spatial
Data Type: Spatial [message #151606] Thu, 15 December 2005 19:01
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
return xval;
member function y return number is
return yval;
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
if (aPoint.X <= top_right.X) and
(aPoint.X >= bottom_left.X) and
(aPoint.Y <= top_right.Y) and
(aPoint.Y >= bottom_left.Y)
return 1;
return 0;
end if;

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

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

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

Current Time: Thu Mar 23 06:08:39 CDT 2023