Re: [Neo4j] Neo4J-Spatial Delete Note Exception

2011-05-16 Thread Deniz Demir
Hi Peter,

I had fixed it by removing the bounding box property if there were no chid
nodes but your fix works too.

Thank you for help.

Deniz


On Mon, May 16, 2011 at 7:39 AM, Peter Neubauer 
peter.neuba...@neotechnology.com wrote:

 Deniz,
 just pushed a change and test that should fix this,

 https://github.com/neo4j/neo4j-spatial/commit/b44f55b5bd94dc2c6b9f1f5db9d3c13575ae9dc4

 Could you try it out?

 Cheers,

 /peter neubauer

 GTalk:  neubauer.peter
 Skype   peter.neubauer
 Phone   +46 704 106975
 LinkedIn   http://www.linkedin.com/in/neubauer
 Twitter  http://twitter.com/peterneubauer

 http://www.neo4j.org   - Your high performance graph database.
 http://startupbootcamp.org/- Ă–resund - Innovation happens HERE.
 http://www.thoughtmade.com - Scandinavia's coolest Bring-a-Thing party.


 On Sun, May 15, 2011 at 12:22 AM, Deniz Demir demi...@gmail.com wrote:

  I am trying to use neo4j-spatial, and wrote a simple test code just to
 add
  one node and then delete; however, delete operation causes an exception.
 
 IndexHitsNode hits = names.get(name, Deniz);
 
 Node n = hits.getSingle();
 
 System.out.println(node hit:  + n.getProperty(name));
 
 
 
 Transaction tx = graph.beginTx();
 
 try {
 
 layer.delete(n.getId());
 
 tx.success();
 
 } finally {
 
 tx.finish();
 
 }
 
  It throws this exception:
 
  node hit: Deniz
 
  Exception in thread main java.lang.NullPointerException
 
  at org.neo4j.gis.spatial.RTreeIndex.adjustParentBoundingBox(
  RTreeIndex.java:613)
 
  at org.neo4j.gis.spatial.RTreeIndex.remove(RTreeIndex.java:131)
 
  at
  org.neo4j.gis.spatial.EditableLayerImpl.delete(EditableLayerImpl.java:74)
 
  at SimpleNeo4JExample.main(SimpleNeo4JExample.java:55)
 
 
  Looks like RTreeIndex.adjustParentBoundingBox() method expects parent
 node
  in any case but in my example there is parent because it is the only node
  in
  the layer:
 
  /**
 
   * Fix an IndexNode bounding box after a child has been removed
 
   * @param indexNode
 
   */
 
  private void adjustParentBoundingBox(Node indexNode, RelationshipType
  relationshipType) {
 
  Envelope bbox = null;
 
   IteratorRelationship iterator =
  indexNode.getRelationships(relationshipType,
  Direction.OUTGOING).iterator();
 
  while (iterator.hasNext()) {
 
  Node childNode = iterator.next().getEndNode();
 
  if (bbox == null) bbox = getLeafNodeEnvelope(childNode);
 
  else bbox.expandToInclude(getLeafNodeEnvelope(childNode));
 
  }
 
  indexNode.setProperty(PROP_BBOX, new double[] { bbox.getMinX(),
  bbox.getMinY(), bbox.getMaxX(), bbox.getMaxY() });
 
  }
 
 
  Any comments?
 
 
  Thanks,
 
  Deniz
  ___
  Neo4j mailing list
  User@lists.neo4j.org
  https://lists.neo4j.org/mailman/listinfo/user
 
 ___
 Neo4j mailing list
 User@lists.neo4j.org
 https://lists.neo4j.org/mailman/listinfo/user

___
Neo4j mailing list
User@lists.neo4j.org
https://lists.neo4j.org/mailman/listinfo/user


[Neo4j] Neo4J-Spatial Delete Note Exception

2011-05-15 Thread Deniz Demir
I am trying to use neo4j-spatial, and wrote a simple test code just to add
one node and then delete; however, delete operation causes an exception.

IndexHitsNode hits = names.get(name, Deniz);

Node n = hits.getSingle();

System.out.println(node hit:  + n.getProperty(name));



Transaction tx = graph.beginTx();

try {

layer.delete(n.getId());

tx.success();

} finally {

tx.finish();

}

It throws this exception:

node hit: Deniz

Exception in thread main java.lang.NullPointerException

at org.neo4j.gis.spatial.RTreeIndex.adjustParentBoundingBox(
RTreeIndex.java:613)

at org.neo4j.gis.spatial.RTreeIndex.remove(RTreeIndex.java:131)

at org.neo4j.gis.spatial.EditableLayerImpl.delete(EditableLayerImpl.java:74)

at SimpleNeo4JExample.main(SimpleNeo4JExample.java:55)


Looks like RTreeIndex.adjustParentBoundingBox() method expects parent node
in any case but in my example there is parent because it is the only node in
the layer:

/**

 * Fix an IndexNode bounding box after a child has been removed

 * @param indexNode

 */

private void adjustParentBoundingBox(Node indexNode, RelationshipType
relationshipType) {

Envelope bbox = null;

 IteratorRelationship iterator =
indexNode.getRelationships(relationshipType, Direction.OUTGOING).iterator();

while (iterator.hasNext()) {

Node childNode = iterator.next().getEndNode();

if (bbox == null) bbox = getLeafNodeEnvelope(childNode);

else bbox.expandToInclude(getLeafNodeEnvelope(childNode));

}

indexNode.setProperty(PROP_BBOX, new double[] { bbox.getMinX(),
bbox.getMinY(), bbox.getMaxX(), bbox.getMaxY() });

}


Any comments?


Thanks,

Deniz
___
Neo4j mailing list
User@lists.neo4j.org
https://lists.neo4j.org/mailman/listinfo/user