Sie sind auf Seite 1von 4

Bahria University

Department of Computer Sciences

Advanced Databases

Lab05: Using Spatial Database Concepts to Store a Design


Objectives

To appply few concepts of spatial Databases using relational databases


To learn how a design can be saved in the form of line segments and triangles

1. Using Line Segments


Any diagram or a design can be broken up into set of line segments and stored in a database.
To acurately reflect diagrams that have curves or maps, line segments need to be broken up into very
smaller sizes.
In case of maps, to find the direction and distance between two points, the distance of each line
segment must also be recorded in the database. The records should also specify which street or
highway the line segment is part of. Then a proper query need to be run that would find all the line
segments available on streets or highways that fall between the starting and destination points. To
provide the directions, the records retrieved might need to be in an order as well.

2. Using Triangles
Design diagrams can also be divided into sets of triangles and then recorded in database as such.
Each side of a triangle might need to be specified whether it should be drawn or not since it might be
part of boundry lines that are drawn in a diagram or it might not be.
3D desings can use triangulation technique. In this case it will be recorded whether each side is not
only a border side (or not) but also a front part or a back part that need to be drawn differently then
the front part. For example front parts will be drawn using solid lines and back parts using dotted
line.

BU, CS Department
Advanced Databases

2/4

Lab05: Using Spatial Database Concepts to Store a Design

BU, CS Department
Advanced Databases

3/4

Lab05: Using Spatial Database Concepts to Store a Design

3. Using C# for Drawing Line Segments


Using Visual Studio and C#, you can use following code to draw line segments:
System.Drawing.Graphics formGraphics;
public Form1()
{
InitializeComponent();
formGraphics = this.CreateGraphics();
formGraphics.Clear(Color.White);
}
private void button1_Click(object sender, EventArgs e)
{
System.Drawing.Pen myPen;
myPen = new System.Drawing.Pen(System.Drawing.Color.Red);
formGraphics.DrawLine(myPen, 0, 0, 200, 200);
myPen = new System.Drawing.Pen(System.Drawing.Color.Blue);
formGraphics.DrawLine(myPen, 0, 200, 200, 0);
myPen.Dispose();
}
private void button2_Click(object sender, EventArgs e)
{
formGraphics.Clear(Color.White);
}

BU, CS Department
Advanced Databases

4/4

Lab05: Using Spatial Database Concepts to Store a Design

Exercises
Exercise 1
1. Drawing an object:
a) Using a paper and a pencil to draw an object like a chair, table etc. that
looks like a 3-D object. (using a graph paper might make things easier)
b) Mark all the line segments in your drawing using x and y coordinates.
c) For each line segment also mark if it will be part of front view or back
view.
2. Create a table to store the line segments:
a) The table should be able to store x and y coordinates of both points of
your line segment.
b) The table should also store the object Id to which the line segment
belongs.
c) The table should also store whether a line segment is part of the front
view or the back view (for 3-D look).
3. Write and execute following queries:
a) Retrieve all line segments in ascending order on x and then y.
b) Retrieve all line segments that are part of front view in same order.
c) Retrieve all line segments that are part of back view in same order.
4. Use Visual Studio and C# to draw the line segments retrieved from the
database. (see the sample code for C# programming above.
Comments:
You can draw the line segments and fill colors in closed shapes.
You can use different color for front view and different for back view.
You can draw a street, divide it into line-segments, record each line
segment in a database and then find the distance between two points on
the street using the SQL queries.

Das könnte Ihnen auch gefallen