Permalink
Browse files

Return all the data when no bbox is given

Previously you always needed to supply a bounding
box, else you would get an error. With this commit
all the data of the index will be returned when no
bounding box is specified.

Change-Id: Ib21713767e75001d7b9134acc3854d719ba79fc3
Reviewed-on: http://review.couchbase.org/11653
Reviewed-by: Chris Anderson <jchris@couchbase.com>
Reviewed-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
Tested-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
  • Loading branch information...
1 parent 01c60ac commit 72fb18f3647e2b74a6e20e75e278896a34d04126 @vmx vmx committed with alk Dec 14, 2011
Showing with 18 additions and 0 deletions.
  1. +4 −0 share/www/script/test/spatial.js
  2. +14 −0 src/vtree/vtree.erl
@@ -186,6 +186,10 @@ couchTests.spatial = function(debug) {
TEquals(['2'], extract_ids(xhr.responseText),
"bbox collapsed to a point should return the geometries there");
+ xhr = CouchDB.request("GET", url_pre + "basicIndex");
+ TEquals(['0','1','2','3','4','5','6','7','8','9', 'stale1', 'stale2'],
+ extract_ids(xhr.responseText),
+ "no bounding box given should return all geometries");
// count parameter tests
View
@@ -131,6 +131,20 @@ lookup(_Fd, nil, _Bbox, {_FoldFun, InitAcc}) ->
{ok, InitAcc};
lookup(_Fd, _Pos, [], {_FoldFun, InitAcc}) ->
{ok, InitAcc};
+% No bounding box given. Return all the data.
+lookup(Fd, Pos, nil, {FoldFun, InitAcc}) ->
+ {ok, Parent} = couch_file:pread_term(Fd, Pos),
+ {_ParentMbr, ParentMeta, NodesPos} = Parent,
+ case ParentMeta#node.type of
+ inner ->
+ foldl_stop(fun(EntryPos, Acc) ->
+ lookup(Fd, EntryPos, nil, {FoldFun, Acc})
+ end, InitAcc, NodesPos);
+ leaf ->
+ foldl_stop(fun({Mbr, _Meta, {Id, {Geom, Value}}}, Acc) ->
+ FoldFun({{Mbr, Id}, {Geom, Value}}, Acc)
+ end, InitAcc, NodesPos)
+ end;
% Only a single bounding box. No bounds given. If bounding box is flipped,
% throw an error.
lookup(Fd, Pos, Bbox, FoldFunAndAcc) when not is_list(Bbox) ->

0 comments on commit 72fb18f

Please sign in to comment.