public class CityUtilities extends Object
| Modifier and Type | Field and Description |
|---|---|
private IMap |
map |
private com.google.common.collect.Range<Double> |
range |
private Random |
rnd |
| Constructor and Description |
|---|
CityUtilities() |
| Modifier and Type | Method and Description |
|---|---|
private double |
calculateDistance(javafx.geometry.Point2D p1,
javafx.geometry.Point2D p2) |
private boolean |
checkCities(ICity startCity,
List<ICity> exclude)
Check if there is a city that can be choosen
|
com.google.common.base.Optional<ICity> |
findNearbyCity(ICity startCity,
double radiusFactor,
int max,
List<ICity> exclude)
Find a city nearby.
|
ICity |
findNearbyCityRepeated(ICity startCity,
double radiusFactor,
int max,
List<ICity> exclude)
Find a nearby city.
|
ICity |
findNearestCity(javafx.geometry.Point2D p)
Find the nearest city to a point
|
ICity |
findRandomCity(ICity excludedCity)
Find a random city that is not the excluded city.
|
@Autowired private IMap map
@Autowired private Random rnd
private final com.google.common.collect.Range<Double> range
public com.google.common.base.Optional<ICity> findNearbyCity(ICity startCity, double radiusFactor, int max, List<ICity> exclude)
max dimension of the map the radius is calculated with this
factor.
Repeated calls with the same arguments are not guaranteed to deliver the same resultstartCity - city where to startradiusFactor - factor for the radius calculationmax - maximal dimension of the mapexclude - potentially empty list of cities, that should be excluded from the searchpublic ICity findNearbyCityRepeated(ICity startCity, double radiusFactor, int max, List<ICity> exclude)
startCity - city where to startradiusFactor - factor for the radius calculationmax - maximal dimension of the mapexclude - potentially empty list of cities, that should be excluded from the searchfindNearbyCity(ICity, double, int, List)private boolean checkCities(ICity startCity, List<ICity> exclude)
startCity - exclude - public ICity findNearestCity(javafx.geometry.Point2D p)
p - public ICity findRandomCity(ICity excludedCity)
excludedCity - city that cannot be chosen.private double calculateDistance(javafx.geometry.Point2D p1,
javafx.geometry.Point2D p2)
Copyright © 2011-2015 Sahits GmbH. All Rights Reserved.