anchor.diff:          _ -> error
       end.
   
  +
  +-spec to_integer(binary()) -> error | integer().
  +to_integer(Bin) ->
  +    try list_to_integer(binary_to_list(Bin))
  +    catch
  +        _ -> error
  +    end.
  +
  +
  +% Returns a single line of an assoication given
  +% a GID and Geo objet
  +association_line(ID, Geo) ->
  +    #geometry{mbr=[{Lat, _}, {Lng, _}]} = Geo,
  +    IDs = integer_to_list(ID),
  +    LatS = float_to_list(Lat),
  +    LngS = float_to_list(Lng),
  +    [<<"GID=">>, IDs, ?SPACE, <<"lat=">>, LatS, ?SPACE, <<"lng=">>, LngS].
  +
  +
  +% Checks if a latitude is invalid
  +invalid_lat(Lat) ->
  +    if
  +        not is_float(Lat) -> true;
  +        Lat < -90 orelse Lat > 90 -> true;
  +        true -> false
  +    end.
  +
  +
  +% Checks if a longitude is invalid
  +invalid_lng(Lng) ->
  +    if
  +        not is_float(Lng) -> true;
  +        Lng < -180 orelse Lng > 180 -> true;
  +        true -> false
  +    end.
  +
  +
  +% Tries to convert a distance to meters
  +dist_to_float(Dist) ->
  +    % Convert to a list
  +    DistL = binary_to_list(Dist),
  +
  +    % Partition into the digits and units
  +    {DistDig, Unit} = lists:partition(fun(Char) ->
  +        Char >= "0" orelse Char =< "9" orelse Char == "-" orelse Char == "."
  +    end, DistL),
  +
  +    % Convert the distance to a float
  +    DistV = try list_to_float(DistDig)
  +    catch
  +        _ -> error
  +    end,
  +
  +    % Switch on the units
  +    case DistV of
  +        error -> error;
  +        _ ->
  +            case Unit of
  +                [] -> DistV;
  +                "m" -> DistV;
  +                "km" -> DistV * 1000.0;
  +                "mi" -> DistV * 1609.0;
  +                "y"  -> DistV * 0.9144;
  +                "ft" -> DistV * 0.3048
  +            end
  +    end.
  +
  
positive.code:             % Check for proper types
              if
                  not is_float(Lat) or not is_float(Lng) ->
                      gen_tcp:send(Sock, <<"Client Error: Bad Lat/Lng format\n">>);
  
                  true ->
                      case teles_data_manager:associate(Sp, Obj, Lat, Lng, undefined) of
  
negative.code:             buffer=[]
          }).
  
  -include_lib("rstar/include/rstar.hrl").
  
  -define(NEWLINE, <<"\n">>).
  -define(DONE, <<"Done\n">>).
  -define(START, <<"START\n">>).
  -define(END, <<"END\n">>).
  -define(SPACE, <<" ">>).
  -define(OBJ_NOT_FOUND, <<"Object not found\n">>).
  -define(BAD_LATLNG, <<"Client Error: Bad lat/lng format\n">>).
  
  
  start_link(Socket) ->
  