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.GeometrycreatePolygonHintFrom(GeometryAngle hint)org.locationtech.jts.geom.PolygoncreateSquare(double dimension)voidextendSearchSquare()extends the current search area by creating a square, doubled dimension of previous square, and intersecting with every previous hintvoidinit(org.locationtech.jts.geom.Point searcherStartPosition)org.locationtech.jts.geom.GeometryintersectWithPrevious(java.util.List<GeometryAngle> previousHints, org.locationtech.jts.geom.Geometry square)SearchPathmove()Use this to perform a initial move, without a hint given.SearchPathmove(AngleHint hint)org.locationtech.jts.geom.PointnextPosition()First, many ideas for next position are possible.SearchPathscanCompleteSearchArea()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:SearcherUse this to perform a initial move, without a hint given. This is for the case, the searcher starts. (as he does normally)- Specified by:
movein interfaceSearcher<AngleHint>- Returns:
SearchPaththeSearchPaththe searcher did
-
move
public SearchPath move(AngleHint hint)
- Specified by:
movein interfaceSearcher<AngleHint>- Parameters:
hint- the hint, theHidergave last.- Returns:
SearchPaththeSearchPath, 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
-
-