Class RTreeIndexedSpatialSet<V extends NFEGeoObject>
- java.lang.Object
-
- oracle.spatial.network.nfe.model.spatial.RTreeIndexedSpatialSet<V>
-
- Type Parameters:
V- The type of elements in the set. Any subclass of NFEGeoObject
- All Implemented Interfaces:
java.lang.Iterable<V>,java.util.Collection<V>,java.util.Set<V>,IndexedSpatialSet<V>
public class RTreeIndexedSpatialSet<V extends NFEGeoObject> extends java.lang.Object implements IndexedSpatialSet<V>
An implementation of IndexedSpatialSet that uses an R-tree index and stores instances of NFEGeoObject.
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.Set<java.lang.Integer>geometryTypesprotected java.util.Map<java.lang.Object,V>geoObjectMapprotected AbstractSpatialIndexspatialIndex
-
Constructor Summary
Constructors Constructor Description RTreeIndexedSpatialSet()RTreeIndexedSpatialSet(int[] expectedGeometryTypes)Creates an instance of RTreeIndexedSpatialSet
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanadd(V geoObj)booleanaddAll(java.util.Collection<? extends V> geoObjects)voidclear()booleancontains(java.lang.Object obj)booleancontainsAll(java.util.Collection<?> geoObjects)Vget(java.awt.geom.Point2D point, double tolerance)Gets the element which is closer to the given point but within the tolerance.Vget(java.lang.Object key)Gets the object identified by the given keyjava.util.Collection<V>getAll(java.awt.geom.Point2D point, double tolerance)Gets all the elements which distance to the given point is within the tolerancejava.util.Collection<V>getAnyInteract(java.awt.geom.Area area)Gets all the elements interacting in some way with the given areajava.util.Collection<V>getAnyInteract(java.awt.geom.Rectangle2D mbr)Gets all the elements interacting in some way with the given rectangleprotected doublegetDistance(java.awt.geom.Point2D point1, java.awt.geom.Point2D point2)protected java.util.Collection<V>getLines(java.util.Collection<V> geoObjects, java.awt.geom.Point2D point, double tolerance)protected doublegetMinDistanceToLine(java.awt.geom.Point2D point, java.awt.geom.Point2D[] linePoints)protected doublegetMinDistanceToMiltiPoint(java.awt.geom.Point2D point, JGeometry multiPoint)protected doublegetMinDistanceToMultiLine(java.awt.geom.Point2D point, JGeometry line)Returns the distance between point and a line (or multiline) from the line segment closest to the point.protected VgetNearestLine(java.util.Collection<V> geoObjects, java.awt.geom.Point2D point, double tolerance)protected VgetNearestPoint(java.util.Collection<V> geoObjects, java.awt.geom.Point2D point, double tolerance)protected java.util.Collection<V>getPoints(java.util.Collection<V> geoObjects, java.awt.geom.Point2D point, double tolerance)AbstractSpatialIndexgetSpatialindex()Gets the underlying implementation used to perform spatial-indexingbooleanisEmpty()booleanisGeometryTypeExpected(int geometryType)Tells whether the set is expecting the specified geometry type (from JGeometry).java.util.Iterator<V>iterator()booleanrefreshIndex(java.lang.Object key)Rebuilds the index associated to an object identified by the given keybooleanremove(java.lang.Object obj)booleanremoveAll(java.util.Collection<?> geoObjects)booleanretainAll(java.util.Collection<?> arg0)intsize()java.lang.Object[]toArray()<T> T[]toArray(T[] array)
-
-
-
Field Detail
-
spatialIndex
protected AbstractSpatialIndex spatialIndex
-
geoObjectMap
protected java.util.Map<java.lang.Object,V extends NFEGeoObject> geoObjectMap
-
geometryTypes
protected java.util.Set<java.lang.Integer> geometryTypes
-
-
Constructor Detail
-
RTreeIndexedSpatialSet
public RTreeIndexedSpatialSet()
-
RTreeIndexedSpatialSet
public RTreeIndexedSpatialSet(int[] expectedGeometryTypes)
Creates an instance of RTreeIndexedSpatialSet- Parameters:
geometryTypes- A list of geometry types (from JGeometry) which will be expected to be contained in the set. By providing this values, spatial searches may be optimized since only geometries of the expected types will be looked.
-
-
Method Detail
-
getSpatialindex
public AbstractSpatialIndex getSpatialindex()
Description copied from interface:IndexedSpatialSetGets the underlying implementation used to perform spatial-indexing- Specified by:
getSpatialindexin interfaceIndexedSpatialSet<V extends NFEGeoObject>- Returns:
- an AbstractSpatialIndex instance
-
add
public boolean add(V geoObj)
- Specified by:
addin interfacejava.util.Collection<V extends NFEGeoObject>- Specified by:
addin interfacejava.util.Set<V extends NFEGeoObject>
-
size
public int size()
- Specified by:
sizein interfacejava.util.Collection<V extends NFEGeoObject>- Specified by:
sizein interfacejava.util.Set<V extends NFEGeoObject>
-
isEmpty
public boolean isEmpty()
- Specified by:
isEmptyin interfacejava.util.Collection<V extends NFEGeoObject>- Specified by:
isEmptyin interfacejava.util.Set<V extends NFEGeoObject>
-
clear
public void clear()
- Specified by:
clearin interfacejava.util.Collection<V extends NFEGeoObject>- Specified by:
clearin interfacejava.util.Set<V extends NFEGeoObject>
-
refreshIndex
public boolean refreshIndex(java.lang.Object key)
Description copied from interface:IndexedSpatialSetRebuilds the index associated to an object identified by the given key- Specified by:
refreshIndexin interfaceIndexedSpatialSet<V extends NFEGeoObject>- Parameters:
key- an object's key- Returns:
- true if the index could be refreshed
-
get
public V get(java.lang.Object key)
Description copied from interface:IndexedSpatialSetGets the object identified by the given key- Specified by:
getin interfaceIndexedSpatialSet<V extends NFEGeoObject>- Parameters:
key- an object's key- Returns:
- the object associated to the key or null if no object is related to the key
-
get
public V get(java.awt.geom.Point2D point, double tolerance)
Description copied from interface:IndexedSpatialSetGets the element which is closer to the given point but within the tolerance.- Specified by:
getin interfaceIndexedSpatialSet<V extends NFEGeoObject>- Parameters:
point- a spatial pointtolerance- the maximum distance an element can be from the point to be selected- Returns:
- the element closest to the given point with a distance equal or less to the tolerance
-
getAll
public java.util.Collection<V> getAll(java.awt.geom.Point2D point, double tolerance)
Description copied from interface:IndexedSpatialSetGets all the elements which distance to the given point is within the tolerance- Specified by:
getAllin interfaceIndexedSpatialSet<V extends NFEGeoObject>- Parameters:
point- a spatial pointtolerance- tolerance the maximum distance an element can be from the point to be selected- Returns:
- a collection containing all the elements which distance to the given point is within the tolerance
-
getAnyInteract
public java.util.Collection<V> getAnyInteract(java.awt.geom.Rectangle2D mbr)
Description copied from interface:IndexedSpatialSetGets all the elements interacting in some way with the given rectangle- Specified by:
getAnyInteractin interfaceIndexedSpatialSet<V extends NFEGeoObject>- Parameters:
mbr- a rectangle- Returns:
- a collection containing all the elements interacting in some way with the given rectangle
-
getAnyInteract
public java.util.Collection<V> getAnyInteract(java.awt.geom.Area area)
Description copied from interface:IndexedSpatialSetGets all the elements interacting in some way with the given area- Specified by:
getAnyInteractin interfaceIndexedSpatialSet<V extends NFEGeoObject>- Parameters:
area- a java area- Returns:
- a collection containing all the elements interacting in some way with the given area
-
addAll
public boolean addAll(java.util.Collection<? extends V> geoObjects)
- Specified by:
addAllin interfacejava.util.Collection<V extends NFEGeoObject>- Specified by:
addAllin interfacejava.util.Set<V extends NFEGeoObject>
-
contains
public boolean contains(java.lang.Object obj)
- Specified by:
containsin interfacejava.util.Collection<V extends NFEGeoObject>- Specified by:
containsin interfacejava.util.Set<V extends NFEGeoObject>
-
containsAll
public boolean containsAll(java.util.Collection<?> geoObjects)
- Specified by:
containsAllin interfacejava.util.Collection<V extends NFEGeoObject>- Specified by:
containsAllin interfacejava.util.Set<V extends NFEGeoObject>
-
iterator
public java.util.Iterator<V> iterator()
- Specified by:
iteratorin interfacejava.util.Collection<V extends NFEGeoObject>- Specified by:
iteratorin interfacejava.lang.Iterable<V extends NFEGeoObject>- Specified by:
iteratorin interfacejava.util.Set<V extends NFEGeoObject>
-
remove
public boolean remove(java.lang.Object obj)
- Specified by:
removein interfacejava.util.Collection<V extends NFEGeoObject>- Specified by:
removein interfacejava.util.Set<V extends NFEGeoObject>
-
removeAll
public boolean removeAll(java.util.Collection<?> geoObjects)
- Specified by:
removeAllin interfacejava.util.Collection<V extends NFEGeoObject>- Specified by:
removeAllin interfacejava.util.Set<V extends NFEGeoObject>
-
retainAll
public boolean retainAll(java.util.Collection<?> arg0)
- Specified by:
retainAllin interfacejava.util.Collection<V extends NFEGeoObject>- Specified by:
retainAllin interfacejava.util.Set<V extends NFEGeoObject>
-
toArray
public java.lang.Object[] toArray()
- Specified by:
toArrayin interfacejava.util.Collection<V extends NFEGeoObject>- Specified by:
toArrayin interfacejava.util.Set<V extends NFEGeoObject>
-
toArray
public <T> T[] toArray(T[] array)
- Specified by:
toArrayin interfacejava.util.Collection<V extends NFEGeoObject>- Specified by:
toArrayin interfacejava.util.Set<V extends NFEGeoObject>
-
isGeometryTypeExpected
public boolean isGeometryTypeExpected(int geometryType)
Tells whether the set is expecting the specified geometry type (from JGeometry). If the set has no expected geometry types defined it will always return true for any type.- Parameters:
geometryType-- Returns:
-
getPoints
protected java.util.Collection<V> getPoints(java.util.Collection<V> geoObjects, java.awt.geom.Point2D point, double tolerance)
-
getNearestPoint
protected V getNearestPoint(java.util.Collection<V> geoObjects, java.awt.geom.Point2D point, double tolerance)
-
getMinDistanceToMiltiPoint
protected double getMinDistanceToMiltiPoint(java.awt.geom.Point2D point, JGeometry multiPoint)
-
getDistance
protected double getDistance(java.awt.geom.Point2D point1, java.awt.geom.Point2D point2)
-
getLines
protected java.util.Collection<V> getLines(java.util.Collection<V> geoObjects, java.awt.geom.Point2D point, double tolerance)
-
getNearestLine
protected V getNearestLine(java.util.Collection<V> geoObjects, java.awt.geom.Point2D point, double tolerance)
-
getMinDistanceToMultiLine
protected double getMinDistanceToMultiLine(java.awt.geom.Point2D point, JGeometry line)Returns the distance between point and a line (or multiline) from the line segment closest to the point.- Parameters:
line- A geometry of type line or multilinepoint-- Returns:
-
getMinDistanceToLine
protected double getMinDistanceToLine(java.awt.geom.Point2D point, java.awt.geom.Point2D[] linePoints)
-
-