Difference between revisions of "NearestCity"
From CMSC 420
(Created page with "Will return the name and location of the closest city to the specified point in space. To do this correctly, you may want to use an algorithm using a PriorityQueue, such as [...") |
|||
Line 1: | Line 1: | ||
− | Will return the name and location of the closest city to the specified point in | + | Will return the name and location of the closest city to the specified point in the spatial map, where the set of valid cities excludes isolated cities. To do this correctly, you may want to use the PriorityQueue from part 1 ([http://www.cs.umd.edu/users/meesh/cmsc420/Notes/neighbornotes/incnear.pdf this] or [http://www.cs.umd.edu/users/meesh/cmsc420/Notes/neighbornotes/incnear2.pdf this])–otherwise, you might not be fast enough. In the case of a tie (two cities equally far away from the point), choose the city with the asciibetically least name. The ordering by name is asciibetical according to the java.lang.String.compareTo() method. |
== Parameters (In output order) == | == Parameters (In output order) == | ||
Line 12: | Line 12: | ||
== Possible ''<error>'' types == | == Possible ''<error>'' types == | ||
− | * | + | * cityNotFound |
== ''<success>'' Example == | == ''<success>'' Example == | ||
<code> | <code> | ||
<success> | <success> | ||
− | <command name="nearestCity"/> | + | <command name="nearestCity" id="8"/> |
<parameters> | <parameters> | ||
<x value="1"/> | <x value="1"/> |
Latest revision as of 16:25, 30 September 2013
Will return the name and location of the closest city to the specified point in the spatial map, where the set of valid cities excludes isolated cities. To do this correctly, you may want to use the PriorityQueue from part 1 (this or this)–otherwise, you might not be fast enough. In the case of a tie (two cities equally far away from the point), choose the city with the asciibetically least name. The ordering by name is asciibetical according to the java.lang.String.compareTo() method.
Parameters (In output order)[edit]
- x
- y
Possible <output>[edit]
The output will contain one city tag which is the nearest city. This is an example of a city tag:
<city name="city1" x="coordx" y="coordy" color="color1" radius="radius1"/>
Possible <error> types[edit]
- cityNotFound
<success> Example[edit]
<success>
<command name="nearestCity" id="8"/>
<parameters>
<x value="1"/>
<y value="2"/>
</parameters>
<output>
<city name="Annapolis" x="20" y="30" color="red" radius="12"/>
</output>
</success>