CSC234 - Project 4
Location, Location, Location

Assigned April 20th 1 p.m.
Due April 29th 1 p.m.


Overview

Say you're looking for a game store in Shreveport. Your first instinct might be to try a search in Google Maps.

We would like to efficiently search this space for nearby locations. The naive way to do this would be to walk through a list of objects and sort them based on their distance from the starting location.

In this project, you will implement a version of this type of proximity search, using a QuadTree and a Heap. A QuadTree is a two-dimensional version of a Binary Tree, such that instead of a left and a right, there is a NW, NE, SW and SE child. The particular version we will implement is called a PR QuadTree. Each child is exactly 1/4 of the size of it's parent.

To implement our QuadTree and proximity search, we will need a number of smaller instantiable objects. Each object should have the usual accessor and mutator methods for each data member, and a toString and equals method.

Point.java

First, we create a Point object.

Data Members

Methods

Location.java

The Location object represents unique locations on the map, as well as the location of interest to the proximity search.

Data Members

Methods

QuadNode.java

The QuadNode implements similar methods to the BinaryNode class discussed in class.

Data Members

Methods

QuadTree.java

A full QuadTree should have an add and a remove method; for our purposes, we will only need to implement the add method. The key method of the QuadTree for us is the proximitySearch algorithm.

Data Members

Methods

DistHolder.java

This temporarily holds the distance between a QuadNode and the search Location, so they can be sorted in the Heap. This class must implement the Comparable interface.

Data Members

Methods

ProximitySearch.java

ProximitySearch is the main class, and responsible for running your program.

The main method of your ProximitySearch.java class should begin by asking the user for a file to load with the geographical data. The first line of this file will contain four numbers. The first two are the minimum x,y coordinates for the upper left corner, and the second two are the maximum x,y coordinates for the lower right corner. All subsequent lines will be three data values, the first being the x coordinate, the second being the y coordinate, and the third being the name of the location. Your program should add the rest of this data into a QuadTree following the QuadTree construction algorithm above.

The user is then asked for a starting location x and y, and the number of results they would like to see.

Your program should then begin searching the QuadTree for locations near to the starting location. Internally, you should use a Heap (the code is linked below) to store your DistHolder, such that the closest QuadNode is searched next, and the children of that QuadNode are placed on the Heap to be found later.

The results of this search are then displayed to the user in the format of Name, Distance, X, Y, with one entry per line.

You can test your code with the following data files:

Extra Credit

Create a graphical depiction of the QuadTree class, such that the space is divided into quadrants as new data is added.

Implement an efficient remove method for the QuadTree class. Test this method in your ProximitySearch main method.

What to turn in

  1. Point.java
  2. Location.java
  3. QuadNode.java
  4. QuadTree.java
  5. DistHolder.java
  6. Heap.java
  7. ProximitySearch.java
To hand in your Project 4 files, follow the steps listed below from the Wright Lab computers:
  1. Open the Terminal application.
  2. SSH with ssh username@cs.centenary.edu to connect with the cs server.
  3. Type in your password.
  4. Make a new directory with mkdir csc234/project4
  5. Log out of the cs server with logout
  6. Change to the directory where you have your files on the local computer.
  7. Securely copy your files to your directory with scp filenames username@cs.centenary.edu:"csc234/project3"

© Mark Goadrich 2009, Centenary College of Louisiana