Package nz.org.riskscape.engine.geo
Class NearestNeighbourIndex
java.lang.Object
nz.org.riskscape.engine.geo.NearestNeighbourIndex
An index that when queried will return the nearest neighbour should one exist within a max distance.
-
Nested Class Summary
-
Constructor Summary
ConstructorDescriptionNearestNeighbourIndex
(nz.org.riskscape.engine.types.Struct.StructMember geometryMember, Double maxDistanceInCrsUnits) Create a nearest neighbour index. -
Method Summary
Modifier and TypeMethodDescriptionorg.locationtech.jts.geom.Envelope
double
final void
insert
(nz.org.riskscape.engine.Tuple item) Insert aTuple
into the index.nz.org.riskscape.engine.Tuple
query
(org.locationtech.jts.geom.Coordinate coordinate) Find the indexed entry that is closest to coordinate but still withinmaxDistanceInCrsUnits
.
-
Constructor Details
-
NearestNeighbourIndex
public NearestNeighbourIndex(nz.org.riskscape.engine.types.Struct.StructMember geometryMember, Double maxDistanceInCrsUnits) Create a nearest neighbour index.
- Parameters:
geometryMember
- the geometry membermaxDistanceInCrsUnits
- the max distance (in CRS units) that match must be within
-
-
Method Details
-
insert
public final void insert(nz.org.riskscape.engine.Tuple item) Insert a
Tuple
into the index. The tuple will be indexed by to the geometry accessed withgeometryMemberAccessor
.- Parameters:
item
- to add to index
-
getEnvelope
public org.locationtech.jts.geom.Envelope getEnvelope()- Returns:
- the envelope that the index may provide matches within.
-
query
public nz.org.riskscape.engine.Tuple query(org.locationtech.jts.geom.Coordinate coordinate) Find the indexed entry that is closest to coordinate but still within
maxDistanceInCrsUnits
.- Parameters:
coordinate
- where to query the index- Returns:
- closest entry to coordinate, or null if there no entry is found with maxDistance.
-
getMaxDistanceInCrsUnits
public double getMaxDistanceInCrsUnits()
-