double max = 0; for (int j = 0; j < stepCount; j++) { LineSegment stepLine = new LineSegment(vStart.add(v.multiply(j)).toCoordinate(), vStart.add(v.multiply(j + 1)).toCoordinate()); LineString rayStep = stepLine.toGeometry(factory); List<LineString> interEnv = sTRtree.query(rayStep.getEnvelopeInternal());