Class NearestNeighbourIndex

java.lang.Object
nz.org.riskscape.engine.geo.NearestNeighbourIndex

public class NearestNeighbourIndex extends Object

An index that when queried will return the nearest neighbour should one exist within a max distance.

  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static class 
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    NearestNeighbourIndex(nz.org.riskscape.engine.types.Struct.StructMember geometryMember, Double maxDistanceInCrsUnits)
    Create a nearest neighbour index.
  • Method Summary

    Modifier and Type
    Method
    Description
    org.locationtech.jts.geom.Envelope
     
    double
     
    final void
    insert(nz.org.riskscape.engine.Tuple item)
    Insert a Tuple 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 within maxDistanceInCrsUnits.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • NearestNeighbourIndex

      public NearestNeighbourIndex(nz.org.riskscape.engine.types.Struct.StructMember geometryMember, Double maxDistanceInCrsUnits)

      Create a nearest neighbour index.

      Parameters:
      geometryMember - the geometry member
      maxDistanceInCrsUnits - 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 with geometryMemberAccessor.

      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()