Difference between revisions of "Part 1"

From CMSC 420
(Updated for Spring 2013)
Line 21: Line 21:
 
#** [[listBorderCities]]
 
#** [[listBorderCities]]
 
#** [[clearAll]]
 
#** [[clearAll]]
# Spatial Map ([[PR Quadtree]] (Updated) for part 1)
+
# Spatial Map ([[PM Quadtree]] (Updated) for part 1)
 
#* Related commands:
 
#* Related commands:
 
#** [[deleteCity]] (if the city is mapped)
 
#** [[deleteCity]] (if the city is mapped)

Revision as of 19:31, 31 January 2013

Part 1 of the MeeshQuest project:

  • Due Date: found on class webpage
  • All part 1 files can be found here
  • The official spec is here with name p1x, for the largest value of x in that directory.
  • As always, the spec will freeze 1 week (5 days summer) prior to the due date.
  • Test Files

Overview[edit]

From the spec:

For the first part of your project, you will implement a data dictionary that supports both city names and city coordinates as keys. You will also need to write an interpreter that will be able to handle basic XML commands. Your data dictionary can be written by merely playing games with comparators, thereby convincing a good old TreeMap or TreeSet to act like it's something else altogether. Commands will require you to insert verified cities into the spatial map, and to delete them from the spatial map. The role of the spatial map is to support range searches where, given a location in 2-d space and a radius, you will find all the cities within that circle, including on the border. These types of operations are not efficient using the TreeMap of coordinates.

Data structures[edit]

  1. Data Dictionary (TreeMap and TreeSet for part 1)
  2. Spatial Map (PM Quadtree (Updated) for part 1)

Commands[edit]

The operations you will need to support can be gleaned from the input specification:

  • createCity and deleteCity: You will need to be able to register cities with and remove them from the data dictionary. No two cities can have the same coordinates or name.
  • mapRoad : Insert a road between two mapped cities.
  • listCities: Output a sorted (XML) list of cities in the data dictionary.
  • rangeCities: This searches the spatial data structure for all cities within a given radius of a given point.
  • nearestCity: This finds the nearest city to a given point in the spatial map.
  • shortestPath: This prints the shortest path and direction traveled between start and end cities.
  • printPMQuadtree: This outputs an XML (textual) representation of the spatial map.
  • saveMap: This outputs a visual representation (an image) of the spatial data structure. See CanvasPlus.
  • clearAll: Clears all of the data structures, removing all elements.

Output[edit]

The conventions in the spec can be found here

  • <success>: This is when your parser has sucessfully parsed and finished a command.
  • <error>: When an error occurs after attempting to run a command
  • <fatal error>: There is a problem with the entire document
  • <undefined error>: Defalut error, when we aren't sure exactly what happened
  • <city>: The spec says it should be sorted and in the <output> tag but I am not sure how this works... explain if you do please

Testing[edit]

Your code will be run from the public static void main(String[]) method of the Main class in the default package. It will read in its input from stdin and write its output to stdout.

You can see exactly how your code will be tested by examining the public tests. For some example student-generated tests, see Test Files.