I'm working with NTS(NetTopologySuite), then I get some geometries with type of LineString, and I want to create the IntervalRTree Index on them.
Here are some codes:
SortedPackedIntervalRTree<LineString> tree = new SortedPackedIntervalRTree<LineString>();
and the Insert Method looks like:
public void Insert(double min, double max, T item)
so, how can I get the "min" and "max" Value of LineString?
also, the Query Method of the tree looks like
public void Query(double min, double max, IItemVisitor<T> visitor)
and how to query the tree index?
Best Answer
You can create an
STRtree
, which is a query-only R-tree created using the Sort-Tile-Recursive (STR) algorithm for two-dimensional spatial data. More details are at the documentation page of JTS.To create a STRtree index in NTS,
You would insert geometries into the index using the geometry's envelope,
Now you can retrieve the items whos bounds intersect an envelope using,