Docsity

Database Systems Homework Assignment 2: Spatial Database Design and Querying, Assignments of Deductive Database Systems

Toggle sidebar
bg1
CSCI 585- Database Systems
Spring 2009
Homework Assignment 2
Due: 03/30/2009 @ 07:00 PM
Description
The goal of this assignment is to design an application that queries a spatial
database. This assignment will make you familiar with spatial data types
using Oracle10g, Oracle Spatial features, and Java (JDBC).
You are required to write two Java programs to 1) store and 2) query your
spatial database.
Scenario:
For security purposes, USC campus is installed with a surveillance camera
network composed of many cameras that are mounted on the rooftops of
buildings. These cameras are used to monitor and track small vehicles in the
campus (e.g. motorcycles, bicycles). The related information is stored and
managed in a spatial database that you are going to design.
Input Files:
You will be given three files:
1. Image file: MAP - an 820x580 JPEG file that is an image of some area of
USC.
2. Three input files:
a). building.xy. Each building is represented by a 2D polygon. Col 1:
building ID. Col 2: building name. Col3: number of vertices on the
polygon. The numbers after column 3 are the coordinates of the
vertices. They are ordered as
1
x,
1
y,
2
x,
2
y, ....,
n
x
,
n
y
. For example, a
row:
b1, PHA, 4, 100, 120, 150, 130, 120, 200, 120, 220
represents a building with its building ID as "b1" and its name as
"PHA". It has 4 vertices whose coordinates are (100, 120), (150, 130),
(120, 200) and (120, 220) respectively.
b). camera.xy. Col 1: camera ID. Col 2: x coordinate of the camera
location. Col 3: y coordinate of the camera location. For simplicity,
you can assume that all camera locations are outside of all building
polygons (the cameras are not exactly on the polygons).
pf3
pf4
pf5

Partial preview of the text

Download Database Systems Homework Assignment 2: Spatial Database Design and Querying and more Assignments Deductive Database Systems in PDF only on Docsity!

CSCI 585- Database Systems

Spring 2009

Homework Assignment 2

Due: 03/30/2009 @ 07:00 PM

Description

The goal of this assignment is to design an application that queries a spatial database. This assignment will make you familiar with spatial data types using Oracle10 g , Oracle Spatial features, and Java (JDBC). You are required to write two Java programs to 1) store and 2) query your spatial database.

Scenario: For security purposes, USC campus is installed with a surveillance camera network composed of many cameras that are mounted on the rooftops of buildings. These cameras are used to monitor and track small vehicles in the campus (e.g. motorcycles, bicycles). The related information is stored and managed in a spatial database that you are going to design.

Input Files: You will be given three files:

  1. Image file: MAP - an 820x580 JPEG file that is an image of some area of USC.
  2. Three input files: a). building.xy. Each building is represented by a 2D polygon. Col 1: building ID. Col 2: building name. Col3: number of vertices on the polygon. The numbers after column 3 are the coordinates of the vertices. They are ordered as x 1 , y 1 , x (^) 2 , y 2 , ...., x (^) n , yn. For example, a row: b1, PHA, 4, 100, 120, 150, 130, 120, 200, 120, 220 represents a building with its building ID as "b1" and its name as "PHA". It has 4 vertices whose coordinates are (100, 120), (150, 130), (120, 200) and (120, 220) respectively. b). camera.xy. Col 1: camera ID. Col 2: x coordinate of the camera location. Col 3: y coordinate of the camera location. For simplicity, you can assume that all camera locations are outside of all building polygons (the cameras are not exactly on the polygons).

c). vehicle.xy. Col 1: vehicle ID. Col2: x coordinate of the vehicle location. Col3: y coordinate of the vehicle location. Col4: vehicle’s type.

Required .sql files: You are required to create two .sql files:

  1. createdb.sql: This file should create all required tables. In addition, it should include constraints, indexes, and any other DDL statements you might need for your application.
  2. dropdb.sql: This file should drop all tables and the other objects once created by your createdb.sql file.

Required Java Programs: You are required to implement two Java programs:

  1. populate.java: This program should get the names of the input files as command line parameters and populate them in to your database. It should be executed as: “> java populate building.xy camera.xy vehicle.xy”. Note that every time you run this program, it should remove the previous data in your tables, otherwise the tables will have redundant data.
  2. hw2.java: This program should provide a GUI, similar to figure 1, to query your database. The GUI should include: a) An 820x580 panel that shows the map when the application is started up. b) The title of the program (main window) should display your full name and your student ID. c) Two text fields that show the coordinates (x, y) of the current mouse location as it moves over the image. Please notice that the coordinates given in .xy files are based on the origin (0, 0) at the upper left corner of the image and (820, 580) at its lower right corner. d) 3 Check boxes that specify the feature types that we are currently interested in. Multiple feature types can be checked at the same time. They are called active feature types. e) 5 Radio buttons that specify the kind of query we are going to do. There are 5 kinds of queries: Whole Region, Range Query, Line query, Find Cameras and Find Vehicle. Details are given later. Only one radio button can be checked at any moment. f) One button to submit the required query. g) One text field to display the SQL statements for the queries that has been submitted so far. Use incremental counter for the queries, and

right mouse button to close the polygon. The vertices should be connected by red line segments on the screen as they are being selected. When the Range Query radio button is unchecked, the selected polygon should disappear.

  1. Line Query. When this radio button is checked, the user can draw a line in the map. After pushing the Submit Query button, only the features of the active feature types that are close to this line are displayed. A feature is regarded to be close to a line if the distance between the feature location and the line is less than 75 pixels. Features should be displayed in the same way as specified in Table 1. The user draws the line by clicking the left mouse button to select its vertices sequentially (line can have more that two vertices). The vertices should be connected by red line segments on the screen as they are being selected. When the Line Query radio button is unchecked, the selected line should disappear.
  2. Find Cameras. When this radio button is checked, all the features of all feature types in the map should be displayed (in the way specified in Table 1). The user can select a vehicle by clicking the left mouse button to select a point in the map. The vehicle that is nearest to this point is selected and is displayed as a red square (6x6 pixels). After pushing the Submit Query button, all the cameras that can see this vehicle are queried. A camera can see a vehicle if a) the line segment between them does not intersect with any building and b) the distance between them is less that 75 pixels. These cameras should be displayed in red color.
  3. Find Vehicle. When this radio button is checked, all the features of all feature types in the map should be displayed (in the way specified in Table 1). The user should be able to select a building in two ways: a) by clicking the left mouse button to select a point inside the building’s polygon or b) by typing building’s name (e.g. OHE) in a text box (you have to provide this text box). The color of this building should be then changed into red. After pushing the Submit Query button, all the cameras that are mounted on the selected building should be displayed in red color. A camera is regarded to be mounted on a building if and only if the distance between the camera location and the building polygon is within 15 pixels. Finally, the vehicles that can be seen by any of these cameras should be displayed in pink color (if they are bicycles) or in

brown color (if they are motorcycle).

Submission Guidelines

  1. The links to the document for Oracle Spatial Reference are posted on the course website. The map image and the 3 input files are provided on course website.
  2. Oracle JDBC Driver and Spatial Java APIs: Oracle Spatial Java Library (sdoapi.zip), is located in $ORACLE_HOME/md/doc/ on shams.usc.edu. It is required to manipulate spatial objects of Oracle10g in Java program. Oracle Spatial Java API document is also available on the course website. You can compile your source as: $ javac – classpath .:$ORACLE_HOME/jdbc/lib/classes12.zip:$ORACLE_HOME/md/lib/sdoapi.zi p hw2.java You run your application as: $ java – classpath .:$ORACLE_HOME/jdbc/lib/classes12.zip:$ORACLE_HOME/md/lib/sdoapi.zi p hw
  3. You need to have a readme.txt file that should include your name, student id, your user name on shams.usc.edu, the list of the submitted files, and how to compile/run them. There is 25 points penalty if this file or some of the required information is missing from your submission.
  4. For the second Java program (i.e., hw2.java), you may develop your assignment using more than one Java program. It is recommended (but not required) to separate the GUI codes and database related codes into different files.
  5. You must make a .tar file to include all of your files in one file (e.g., hw2.tar) using the following command: *> tar cvf hw2.tar .java createdb.sql dropdb.sql readme.txt Please note that you can do this in your shams.usc.edu account. Do NOT include the .class files, input files, or sdoapi.zip in your .tar file. We will compile your .java files.