Hi, I 'm currently working in integrating lucene spatial into the search engine of my customer but I'm facing a problem :
If I ask to CartesianPolyFilterBuilder.getShapeLoop the list of areas covering the following bounding box { 45.71342*-0.00007 ; 45.71346*0.00096 } (a portion of road in France) (lat*long ; lat*long) i got an OutOfMemoryException after a few minutes. After looking inside the code, I suppect this portion to be wrong : double startX = beginAt - (beginAt %1); double startY = beginAt - startX ; //should give a whole number double endX = endAt - (endAt %1); double endY = endAt -endX; //should give a whole number For the given bounding box, we have got 2 calls using rules about the meridian: getShapeLoop(shape, ctp, 45.71342, 0.0, 45.71346, 0.00096) : this one is ok getShapeLoop(shape, ctp, 45.71342, -0.00007, 45.71346, 0.0) : this one is faulty Debugging the second call gave the following values : double beginAt = ctp.getTierBoxId(latX, longX); // -0.99855 as id -- step 1 double endAt = ctp.getTierBoxId(latY, longY); // 0.00145 as id -- step 2 if (beginAt > endAt){ // test is false double tmp = beginAt; beginAt = endAt; endAt = tmp; } double tierVert = ctp.getTierVerticalPosDivider(); //System.err.println(" | "+ beginAt+" | "+ endAt); double startX = beginAt - (beginAt %1); // 0 as start <- Wrong for me -- step 3 double startY = beginAt - startX ; //should give a whole number // -0.99855 <- Wrong cause of previous result -- step 4 double endX = endAt - (endAt %1); // 0 , it s ok for me -- step 5 double endY = endAt -endX; //should give a whole number // 0.00145 , ok for me -- step 6 The startX value should be -1 (negative one) for me and not 0 (zero) according to the methods CartesianPolyFilterBuilder.getBoxId & IProjector.coords at step 1: double[] coords = projector.coords(45.71342,-0.00007) => [-8.530704150702293E-7 , 0.7978496913470262] CartesianPolyFilterBuilder.getBoxId(coords[0]); => -1 as long part for id CartesianPolyFilterBuilder.getBoxId(getBoxId(coords[1]) / tierVerticalPosDivider); => 0.00145 as lat part for id double id = getBoxId(coords[0]) + (getBoxId(coords[1]) / tierVerticalPosDivider); => -0.99855 at step 3, we have the following stuff : beginAt%1 => -0.99855 startX = beginAt - beginAt%1 => startX = -0.99855 - (-0.99855) => startX = 0 instead of -1 as seen before startY = beginAt - startX => startY = -0.99855 - 0 => startY = -0.99855 instead of 0.00145 as seen before If, instead of modulo, we do a "Math.floor" operation, we get the correct result : startX = Math.floor(beginAt) => startX = -1; startY = beginAt - startX => startY = -0.99855 - (-1) => 0.00145 With erroneous values of startX, startY and continuing to execute the method, we hit the Exception inside the while loops : double xInc = 1.0d / tierVert; // 0.000001 for (; startX <= endX; startX++) { double itY = startY; // = -0.99855 while (itY <= endY) { // endY = 0.00145 => 0.00145 - (-0.99855) / 0.000001 = 100001 iterations // create a boxId // startX.startY double boxId = startX + itY; shape.addBox(boxId); // <- OOM Exceptions while extending the list // System.err.println("----"+startX+" and "+itY); // System.err.println("----"+boxId); itY += xInc; // java keeps 0.0001 as 1.0E-1 // which ends up as 0.00011111 itY = new BigDecimal(itY).setScale(scale, RoundingMode.HALF_EVEN).doubleValue(); } } the 1000001 iterations to add a tile on a bounding box of nearly 100 x 100 meters is kinda strange. If anyone can confirm or invalidate my problem, I would really appreciate. Sincerely, Olivier --------------------------------------------------------------------- To unsubscribe, e-mail: java-user-unsubscr...@lucene.apache.org For additional commands, e-mail: java-user-h...@lucene.apache.org