Input will be provided via input redirection. In other words, input files will be passed to your program via the standard input stream (System.in).
The basic structure of the input XML will be a document whose root tag is <commands>. <commands> will contain, as its children, any series of the other commands. All commands (for Part 1 at least) will be single empty elements (recall that an empty element is one that has no children) which contain zero or more attributes. Input values that are numeric will always be integers. The schema and sample inputs will probably be sufficient in describing the input format. If the schema does not match the input a <fatalError> tag is printed without a <results> tag. Of most interest is the success and error conditions for each command and the corresponding messages each should provide. Here's the list:
The attributes are spatialWidth and spatialHeight, both powers of 2, but in the range of 32 bit 2's complement integers. These two attributes define the rectangular region the spatial data structure can store. Note that the lower left corner of this region is always , the origin, as we will not be dealing with negative city coordinates in this project. Thus, the spatial structure's bounding volume is the rectangle whose lower left corner is and whose width and height are given by these two parameters. You must setup your spatial structure to be centered accordingly. Note that although all of our coordinates will be given as integers, you may need to center your spatial structure around a coordinate that is not an integer; so, make sure you plan accordingly.
Observe that these two values have an impact on the success of the <mapCity> command, butDO NOT affect the success of the <createCity> command. Cities can be created in the data dictionary with coordinates outside the boundaries of this range, on the boundary as well as inside this range. However, only cities on the left and bottom boundaries of this range can be ``mapped'' or inserted into the PR quadtree.
Possible errors:
If there is any problem with the attributes in the <command> tag a <fatalError> tag is outputted without a <results> tag, and the program exits.
All names are case-sensitive.
Parameters: (In output order)
namePossible <output>:
x
y
radius
color
(none)Possible <error> types (In priority order):
duplicateCityCoordinates<success> Example:
duplicateCityName
<success> <command name=''createCity''/> <parameters> <name value=''Annapolis''/> <x value=''12''/> <y value=''14''/> <radius value=''15''/> <color value=''red''/> </parameters> <output/> </success>
namePossible <output>:
If the city is in the spatial data structure, a cityUnmapped tag will appear as:
<cityUnmapped name=''city1'' x=''coordx'' y=''coordy'' color=''color1'' radius=''radius1''/>Possible <error> types (In priority order):
cityDoesNotExist<success> Example:
<success> <command name=''deleteCity''/> <parameters> <name value=''Annapolis''/> </parameters> <output/> </success>
(none)Possible <output>:
(none)Possible <error> types:
(none)<success> Example:
<success> <command name=''clearAll''/> <parameters/> <output/> </success>
Parameter:
sortByPossible <output>:
A <cityList> tag will be contained in output and will contain 1 or more city tags of the form:Possible <error> types:
<city name=''city1'' x=''coordx'' y=''coordy'' color=''color1'' radius=''radius1''/>
noCitiesToList<success> Example:
<success> <command name=''listCities''/> <parameters> <sortBy value=''name''/> </parameters> <output> <cityList> <city name=''Derwood'' x=''19'' y=''20'' color=''red'' radius=''40''/> <city name=''Annapolis'' x=''5'' y=''5'' color=''blue'' radius=''90''/> </cityList> </output> </success>
namePossible <output>:
(none)Possible <error> types:
nameNotInDictionary<success> Example:
cityAlreadyMapped
cityOutOfBounds
<success> <command name=''mapCity''/> <parameters> <name value=''Annapolis''/> </parameters> <output/> </success>
namePossible <output>:
(none)Possible <error> types:
nameNotInDictionary<success> Example:
cityNotMapped
<success> <command name=''unmapCity''/> <parameters> <name value=''Annapolis''/> </parameters> <output/> </success>
(none)Possible <output>:
A <quadtree> tag will be contained within output and will contain several <gray> <white> and <black> nodes.
The first node in the quadtree will be the root node, this node can be gray or black, then the rest of the PR Quadtree follows. Remember, the exact structure of the quadtree will be represented by the XML output.
<gray x=''72'' y=''40''> ... </gray>
mapIsEmpty<success> Example:
<success> <command name=''printPRQuadtree''/> <parameters/> <output> <quadtree> <gray x=''64'' y=''64''> <white/> <white/> <white/> <gray x=''96'' y=''32''> <gray x=''80'' y=''48''> <white/> <white/> <gray x=''72'' y=''40''> <black name=''Boston'' x=''71'' y=''42''/> <white/> <white/> <black name=''Baltimore'' x=''76'' y=''39''/> </gray> <gray x=''88'' y=''40''> <black name=''Chicago'' x=''81'' y=''47''/> <white/> <black name=''Atlanta'' x=''84'' y=''33''/> <white/> </gray> </gray> <black name=''Los_Angeles'' x=''118'' y=''33''/> <black name=''Miami'' x=''80'' y=''25''/> <white/> </gray> </gray> </quadtree> </output>
name - filename to save the image toPossible <output>:
(none)Possible <error> types:
(none)<success> Example:
<success> <command name=''saveMap''/> <parameters> <name value=''map_1''/> </parameters> <output/> </success>
<success> will result from the existence of at least one <city> that satisfies the range check condition. If none does, then an <error> tag will be the result. If the radius is 0 and no city occupies the point x,y, then <error> tag is the result.
It should be noted that the radius attribute for a city does not factor into this calculation; all cities are considered points.
If the saveMap attribute is present, the current map will be saved to an image file (see saveMap).
The image file should be saved with the correct name. It should match our image file: same dimensions, same cities, etc.
How to keep track of your graphic map is discussed in saveMap. Printing it out is discussed there too.
The main difference with saveMap is that the image file should have a blue unfilled circle centered at the (x,y) values passed in with the radius passed in.
Because CanvasPlus does not behave well when shapes exceed the bounds of the spatial map, the saveMap attribute will only be present when an entire
range circle lies inclusively within the bounds of the spatial map.
Parameters (Listed in output order):
xPossible <output>:
y
radius
saveMap (optional) - image filename
The output will contain one <cityList> which will contain the list of cities. This is an example of a city tag:
<city name=''city1'' x=''coordx'' y=''coordy'' color=''color1'' radius=''radius1''/>
The cities should be printed in descending asciibetical order of the names according to java.lang.String.compareTo().
Possible <error> types:
noCitiesExistInRange<success> Example:
<success> <command name=''rangeCities''/> <parameters> <x value=''1''/> <y value=''1''/> <radius value=''100''/> </parameters> <output> <cityList> <city name=''Derwood'' x=''20'' y=''30'' color=''red'' radius=''12''/> <city name=''Annapolis'' x=''20'' y=''40'' color=''blue'' radius=''23''/> </cityList> </output> </success>
www.cs.umd.edu/users/meesh/cmsc420/ContentBook/FormalNotes/neighbornotes/incnear2.pdf-otherwise, you
might not be fast enough. If two or more cities are
equidistant from the specified point in space, then output the
city with the larger name in asciibetical order. That is, if
city dark1 and city duck1 are the same
distance from the specified point, then the duck1
would be given as the nearest city.
Parameters (In output order):
xPossible <output>:
y
The output will contain one city tag which is the nearest city. This is an example of a city tag:Possible <error> types:
<city name=''city1'' x=''coordx'' y=''coordy'' color=''color1'' radius=''radius1''/>
mapIsEmpty<success> Example:
<success> <command name=''nearestCity''/> <parameters> <x value=''1''/> <y value=''2''/> </parameters> <output> <city name=''Annapolis'' x=''20'' y=''30'' color=''red'' radius=''12''/> </output> </success>
The the XML specification appears in www.cs.umd.edu/users/meesh/cmsc420/ProjectBook/part1/part1in.xsd. Do note: except for one set of tests per project, we will provide syntactically error-free XML, which means that we will only test your error checking on one set of test inputs. However, we will check the syntactic validity of every output file produced from your code.
MM Hugue 2019-01-27