Update of /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31811
Modified Files:
VertexFacade.java
Log Message:
Added findByLocation()
Index: VertexFacade.java
===================================================================
RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/VertexFacade.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** VertexFacade.java 28 Jul 2005 10:16:02 -0000 1.3
--- VertexFacade.java 2 Aug 2005 07:18:25 -0000 1.4
***************
*** 203,205 ****
--- 203,254 ----
return result;
}
+
+ /**
+ * Find vertex based upon location and delta
+ * @param x The x coordinate
+ * @param y The y coordinate
+ * @param z The z coordinate
+ * @param delta The delta value
+ * @return The vertexs
+ */
+ public Set findByLocation(double x, double y, double z, double delta) {
+ Set result = new HashSet();
+
+ HibernateUtil hu = HibernateUtil.getInstance();
+ try {
+ Session session = hu.currentSession();
+ Transaction tx = session.beginTransaction();
+
+ double minX = x - delta;
+ double maxX = x + delta;
+ double minY = y - delta;
+ double maxY = y + delta;
+ double minZ = z - delta;
+ double maxZ = z + delta;
+
+ Query q = session.createQuery("SELECT v FROM Vertex AS v WHERE " +
+ "v.x BETWEEN :minX AND :maxX AND " +
+ "v.y BETWEEN :minY AND :maxY AND " +
+ "v.z BETWEEN :minZ AND :maxZ");
+ q.setDouble("minX", minX);
+ q.setDouble("maxX", maxX);
+ q.setDouble("minY", minY);
+ q.setDouble("maxY", maxY);
+ q.setDouble("minZ", minZ);
+ q.setDouble("maxZ", maxZ);
+
+ Iterator it = q.iterate();
+ while (it.hasNext()) {
+ result.add((Vertex)it.next());
+ }
+
+ tx.commit();
+ } catch (Exception ex) {
+ log.error(ex.getMessage(), ex);
+ } finally {
+ hu.closeSession();
+ }
+
+ return result;
+ }
}
|