Class PolygonStrategy
- java.lang.Object
-
- com.treasure.hunt.strategy.searcher.impl.PolygonStrategy
-
public class PolygonStrategy extends java.lang.Object implements Searcher<AngleHint>
The idea is to maintain a square called search area of variable size, given a hint one use Geometry.intersection() to exclude area. Hints need to be transformed into objects of class Geometry. (see createPolygonHintFrom(GeometryAngle hint)) At a given moment one can extend the search area for example: area smaller constant the next position will be calculated dependent of the interior point of the search area (see nextPosition())
-
-
Constructor Summary
Constructors Constructor Description PolygonStrategy()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description org.locationtech.jts.geom.Geometry
createPolygonHintFrom(GeometryAngle hint)
org.locationtech.jts.geom.Polygon
createSquare(double dimension)
void
extendSearchSquare()
extends the current search area by creating a square, doubled dimension of previous square, and intersecting with every previous hintvoid
init(org.locationtech.jts.geom.Point searcherStartPosition)
org.locationtech.jts.geom.Geometry
intersectWithPrevious(java.util.List<GeometryAngle> previousHints, org.locationtech.jts.geom.Geometry square)
SearchPath
move()
Use this to perform a initial move, without a hint given.SearchPath
move(AngleHint hint)
org.locationtech.jts.geom.Point
nextPosition()
First, many ideas for next position are possible.SearchPath
scanCompleteSearchArea()
if the search area is too tight (height smaller 2) and bounded than every vertices will be visited
-
-
-
Method Detail
-
init
public void init(org.locationtech.jts.geom.Point searcherStartPosition)
-
move
public SearchPath move()
Description copied from interface:Searcher
Use this to perform a initial move, without a hint given. This is for the case, the searcher starts. (as he does normally)- Specified by:
move
in interfaceSearcher<AngleHint>
- Returns:
SearchPath
theSearchPath
the searcher did
-
move
public SearchPath move(AngleHint hint)
- Specified by:
move
in interfaceSearcher<AngleHint>
- Parameters:
hint
- the hint, theHider
gave last.- Returns:
SearchPath
theSearchPath
, this searcher chose.
-
scanCompleteSearchArea
public SearchPath scanCompleteSearchArea()
if the search area is too tight (height smaller 2) and bounded than every vertices will be visited- Returns:
- SearchPath including every vertices of the search area
-
createPolygonHintFrom
public org.locationtech.jts.geom.Geometry createPolygonHintFrom(GeometryAngle hint)
- Parameters:
hint
- a geometry angle which will be used to create a intersectable (Geometry.intersect()) hint for the search area- Returns:
- a square intersected with given hint. The initial square is centered at 0,0 and of dim 2*currentSearchFieldDim
-
nextPosition
public org.locationtech.jts.geom.Point nextPosition()
First, many ideas for next position are possible. this is just one of them! this will head to the interior point (geometric centroid) of the search area, preferable of length 1, otherwise if the searcher is not in the search area the length will be added with a constant until reaching the interior- Returns:
- the point the instance will next head to
-
extendSearchSquare
public void extendSearchSquare()
extends the current search area by creating a square, doubled dimension of previous square, and intersecting with every previous hint
-
createSquare
public org.locationtech.jts.geom.Polygon createSquare(double dimension)
- Parameters:
dimension
- the side length of the square- Returns:
- square of side length dimension
-
intersectWithPrevious
public org.locationtech.jts.geom.Geometry intersectWithPrevious(java.util.List<GeometryAngle> previousHints, org.locationtech.jts.geom.Geometry square)
- Parameters:
previousHints
- List of all previous hintssquare
- the to be intersected square with all previous hints- Returns:
- a square intersected with all previous hints
-
-