Browse Source

geo_point fix

Vitaly Shutko 10 years ago
parent
commit
8ba10d2bf0
1 changed files with 4 additions and 2 deletions
  1. 4 2
      src/store/store_mongo.erl

+ 4 - 2
src/store/store_mongo.erl

@@ -73,8 +73,10 @@ list_to_doc([F|Fields],[V|Values]) ->
 make_id({<<ObjectId:12/binary>>}) -> {ObjectId};
 make_id({<<ObjectId:12/binary>>}) -> {ObjectId};
 make_id(Term)                     -> to_binary(Term, true).
 make_id(Term)                     -> to_binary(Term, true).
 
 
-make_field({geo_point, Coords}) when length(Coords) == 2 -> {type, <<"Point">>, coordinates, Coords};
-make_field({geo_polygon, Coords}) when is_list(Coords) -> {type, <<"Polygon">>, coordinates, Coords};
+make_field({geo_point, Coords}) when length(Coords) == 2; length(Coords) == 0 -> 
+  {type, <<"Point">>, coordinates, Coords};
+make_field({geo_polygon, Coords}) when is_list(Coords) -> 
+  {type, <<"Polygon">>, coordinates, Coords};
 make_field(V) ->
 make_field(V) ->
   if is_atom(V) -> case V of
   if is_atom(V) -> case V of
                      true  -> to_binary(V);
                      true  -> to_binary(V);