function [xRD yRD lat lon]=rsp2rd2latlon(data,raaien,jrkinfo)

[xRD yRD lat lon]=deal(NaN);

%%
if size(data,1)~=length(raaien);disp('*** ERROR: inputdata should have equal sizes... ***');return;end

%%% raaicheck=find(ismember(raaien,jrkinfo.raai_id));
%%% if length(raaicheck)~=length(raaien);disp('*** ERROR: not enough jrkinfo for all raaien; check input ***');return;end

%%
for ir=1:length(raaien)
    rid     = find(jrkinfo.raai_id == raaien(ir));
    if isempty(rid)
        %%% disp('ERROR: something wrong with script...');return
        x_p(ir) = NaN;
        y_p(ir) = NaN;
        a_p(ir) = NaN;
    else
        x_p(ir) = jrkinfo.xRD(rid);
        y_p(ir) = jrkinfo.yRD(rid);
        a_p(ir) = jrkinfo.alpha(rid);
    end
end

%%
if length(raaien)~=size(raaien,1);raaien=raaien';end
if length(x_p) ~=size(x_p,1)    ;x_p=x_p'   ;end
if length(y_p) ~=size(y_p,1)    ;y_p=y_p'   ;end
if length(a_p) ~=size(a_p,1)    ;a_p=a_p'   ;end
if size(data,1)~=size(raaien,1) ;data=data' ;end

x_p = repmat(x_p,1,size(data,2));
y_p = repmat(y_p,1,size(data,2));
a_p = repmat(a_p,1,size(data,2));

%%
xRD = x_p + sin(a_p).*data;
yRD = y_p + cos(a_p).*data;

%%
[lon lat]=convertCoordinates(xRD,yRD,'CS1.code',28992,'CS2.code',4326);

%%
nanIDS = isnan(xRD) | isnan(yRD);
lon(nanIDS)=NaN;
lat(nanIDS)=NaN;







