-// SpatialIndex.java\r
-// Java Spatial Index Library\r
-// Copyright (C) 2002-2005 Infomatiq Limited.\r
-// \r
-// This library is free software; you can redistribute it and/or\r
-// modify it under the terms of the GNU Lesser General Public\r
-// License as published by the Free Software Foundation; either\r
-// version 2.1 of the License, or (at your option) any later version.\r
-// \r
-// This library is distributed in the hope that it will be useful,\r
-// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
-// Lesser General Public License for more details.\r
-// \r
-// You should have received a copy of the GNU Lesser General Public\r
-// License along with this library; if not, write to the Free Software\r
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
-\r
-package com.infomatiq.jsi;\r
-\r
-import gnu.trove.TIntProcedure;\r
-\r
-import java.util.Properties;\r
-\r
-/**\r
- * Defines methods that must be implemented by all \r
- * spatial indexes. This includes the RTree and its variants.\r
- * \r
- * @author aled@sourceforge.net\r
- * @version 1.0b8\r
- */\r
-public interface SpatialIndex {\r
- \r
- /**\r
- * Initializes any implementation dependent properties\r
- * of the spatial index. For example, RTree implementations\r
- * will have a NodeSize property.\r
- * \r
- * @param props The set of properties used to initialize the spatial index.\r
- */\r
- public void init(Properties props);\r
- \r
- /**\r
- * Adds a new rectangle to the spatial index\r
- * \r
- * @param r The rectangle to add to the spatial index.\r
- * @param id The ID of the rectangle to add to the spatial index.\r
- * The result of adding more than one rectangle with\r
- * the same ID is undefined.\r
- */ \r
- public void add(Rectangle r, int id);\r
- \r
- /**\r
- * Deletes a rectangle from the spatial index\r
- * \r
- * @param r The rectangle to delete from the spatial index\r
- * @param id The ID of the rectangle to delete from the spatial\r
- * index\r
- * \r
- * @return true if the rectangle was deleted\r
- * false if the rectangle was not found, or the \r
- * rectangle was found but with a different ID\r
- */\r
- public boolean delete(Rectangle r, int id);\r
- \r
- /**\r
- * Finds the nearest rectangles to the passed rectangle and calls \r
- * v.execute(id) for each one.\r
- * \r
- * If multiple rectangles are equally near, they will\r
- * all be returned. \r
- * \r
- * @param p The point for which this method finds the\r
- * nearest neighbours.\r
- * \r
- * @param v The IntProcedure whose execute() method is is called\r
- * for each nearest neighbour.\r
- * \r
- * @param furthestDistance The furthest distance away from the rectangle\r
- * to search. Rectangles further than this will not be found. \r
- * \r
- * This should be as small as possible to minimise\r
- * the search time.\r
- * \r
- * Use Float.POSITIVE_INFINITY to guarantee that the nearest rectangle is found,\r
- * no matter how far away, although this will slow down the algorithm.\r
- */\r
- public void nearest(Point p, TIntProcedure v, float furthestDistance);\r
- \r
- /**\r
- * Finds the N nearest rectangles to the passed rectangle, and calls\r
- * execute(id, distance) on each one, in order of increasing distance.\r
- * \r
- * Note that fewer than N rectangles may be found if fewer entries\r
- * exist within the specified furthest distance, or more if rectangles\r
- * N and N+1 have equal distances. \r
- * \r
- * @param p The point for which this method finds the\r
- * nearest neighbours.\r
- * \r
- * @param v The IntfloatProcedure whose execute() method is is called\r
- * for each nearest neighbour.\r
- * \r
- * @param n The desired number of rectangles to find (but note that \r
- * fewer or more may be returned)\r
- * \r
- * @param distance The furthest distance away from the rectangle\r
- * to search. Rectangles further than this will not be found. \r
- * \r
- * This should be as small as possible to minimise\r
- * the search time.\r
- * \r
- * Use Float.POSITIVE_INFINITY to guarantee that the nearest rectangle is found,\r
- * no matter how far away, although this will slow down the algorithm.\r
- */\r
- public void nearestN(Point p, TIntProcedure v, int n, float distance);\r
- \r
- /**\r
- * Same as nearestN, except the found rectangles are not returned\r
- * in sorted order. This will be faster, if sorting is not required\r
- */\r
- public void nearestNUnsorted(Point p, TIntProcedure v, int n, float distance);\r
- \r
- /**\r
- * Finds all rectangles that intersect the passed rectangle.\r
- * \r
- * @param r The rectangle for which this method finds\r
- * intersecting rectangles.\r
- * \r
- * @param ip The IntProcedure whose execute() method is is called\r
- * for each intersecting rectangle.\r
- */\r
- public void intersects(Rectangle r, TIntProcedure ip); \r
-\r
- /**\r
- * Finds all rectangles contained by the passed rectangle.\r
- * \r
- * @param r The rectangle for which this method finds\r
- * contained rectangles.\r
- * \r
- * @param ip The procedure whose visit() method is is called\r
- * for each contained rectangle.\r
- */\r
- public void contains(Rectangle r, TIntProcedure ip); \r
- \r
- /**\r
- * Returns the number of entries in the spatial index\r
- */\r
- public int size();\r
- \r
- \r
- /**\r
- * Returns the bounds of all the entries in the spatial index,\r
- * or null if there are no entries.\r
- */\r
- public Rectangle getBounds();\r
- \r
- /**\r
- * Returns a string identifying the type of\r
- * spatial index, and the version number, \r
- * eg "SimpleIndex-0.1"\r
- */\r
- public String getVersion();\r
- \r
-}\r
+// SpatialIndex.java
+// Java Spatial Index Library
+// Copyright (C) 2002-2005 Infomatiq Limited.
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+package com.infomatiq.jsi;
+
+import gnu.trove.TIntProcedure;
+
+import java.util.Properties;
+
+/**
+ * Defines methods that must be implemented by all
+ * spatial indexes. This includes the RTree and its variants.
+ *
+ * @author aled@sourceforge.net
+ * @version 1.0b8
+ */
+public interface SpatialIndex {
+
+ /**
+ * Initializes any implementation dependent properties
+ * of the spatial index. For example, RTree implementations
+ * will have a NodeSize property.
+ *
+ * @param props The set of properties used to initialize the spatial index.
+ */
+ public void init(Properties props);
+
+ /**
+ * Adds a new rectangle to the spatial index
+ *
+ * @param r The rectangle to add to the spatial index.
+ * @param id The ID of the rectangle to add to the spatial index.
+ * The result of adding more than one rectangle with
+ * the same ID is undefined.
+ */
+ public void add(Rectangle r, int id);
+
+ /**
+ * Deletes a rectangle from the spatial index
+ *
+ * @param r The rectangle to delete from the spatial index
+ * @param id The ID of the rectangle to delete from the spatial
+ * index
+ *
+ * @return true if the rectangle was deleted
+ * false if the rectangle was not found, or the
+ * rectangle was found but with a different ID
+ */
+ public boolean delete(Rectangle r, int id);
+
+ /**
+ * Finds the nearest rectangles to the passed rectangle and calls
+ * v.execute(id) for each one.
+ *
+ * If multiple rectangles are equally near, they will
+ * all be returned.
+ *
+ * @param p The point for which this method finds the
+ * nearest neighbours.
+ *
+ * @param v The IntProcedure whose execute() method is is called
+ * for each nearest neighbour.
+ *
+ * @param furthestDistance The furthest distance away from the rectangle
+ * to search. Rectangles further than this will not be found.
+ *
+ * This should be as small as possible to minimise
+ * the search time.
+ *
+ * Use Float.POSITIVE_INFINITY to guarantee that the nearest rectangle is found,
+ * no matter how far away, although this will slow down the algorithm.
+ */
+ public void nearest(Point p, TIntProcedure v, float furthestDistance);
+
+ /**
+ * Finds the N nearest rectangles to the passed rectangle, and calls
+ * execute(id, distance) on each one, in order of increasing distance.
+ *
+ * Note that fewer than N rectangles may be found if fewer entries
+ * exist within the specified furthest distance, or more if rectangles
+ * N and N+1 have equal distances.
+ *
+ * @param p The point for which this method finds the
+ * nearest neighbours.
+ *
+ * @param v The IntfloatProcedure whose execute() method is is called
+ * for each nearest neighbour.
+ *
+ * @param n The desired number of rectangles to find (but note that
+ * fewer or more may be returned)
+ *
+ * @param distance The furthest distance away from the rectangle
+ * to search. Rectangles further than this will not be found.
+ *
+ * This should be as small as possible to minimise
+ * the search time.
+ *
+ * Use Float.POSITIVE_INFINITY to guarantee that the nearest rectangle is found,
+ * no matter how far away, although this will slow down the algorithm.
+ */
+ public void nearestN(Point p, TIntProcedure v, int n, float distance);
+
+ /**
+ * Same as nearestN, except the found rectangles are not returned
+ * in sorted order. This will be faster, if sorting is not required
+ */
+ public void nearestNUnsorted(Point p, TIntProcedure v, int n, float distance);
+
+ /**
+ * Finds all rectangles that intersect the passed rectangle.
+ *
+ * @param r The rectangle for which this method finds
+ * intersecting rectangles.
+ *
+ * @param ip The IntProcedure whose execute() method is is called
+ * for each intersecting rectangle.
+ */
+ public void intersects(Rectangle r, TIntProcedure ip);
+
+ /**
+ * Finds all rectangles contained by the passed rectangle.
+ *
+ * @param r The rectangle for which this method finds
+ * contained rectangles.
+ *
+ * @param ip The procedure whose visit() method is is called
+ * for each contained rectangle.
+ */
+ public void contains(Rectangle r, TIntProcedure ip);
+
+ /**
+ * Returns the number of entries in the spatial index
+ */
+ public int size();
+
+
+ /**
+ * Returns the bounds of all the entries in the spatial index,
+ * or null if there are no entries.
+ */
+ public Rectangle getBounds();
+
+ /**
+ * Returns a string identifying the type of
+ * spatial index, and the version number,
+ * eg "SimpleIndex-0.1"
+ */
+ public String getVersion();
+
+}