function  s_data=get_sdata(db_file,S)
    conn=sqlite(db_file);
    res=fetch(conn,"SELECT name FROM sqlite_schema WHERE name='tmp';");
    if ~ isempty(res)
        execute(conn,"DROP TABLE tmp;")
    end
    sql="CREATE TABLE tmp("+ table_images_desc()+");";
    sql_insert="INSERT INTO tmp SELECT * FROM images WHERE %d <= cnt_id AND cnt_id<%d;";
    sql_get_path="SELECT time,lat,lon,yaw,rota FROM images WHERE %d <= cnt_id AND cnt_id<%d;";
    execute(conn,sql);
    s_data=[];
    rota=[];
    for idx=1:size(S,1)
        execute(conn,sprintf(sql_insert,S(idx,2),S(idx,3)));
        res=fetch(conn,sprintf(sql_get_path,S(idx,2),S(idx,3)));
        lat=cell2mat(arrayfun(@(x) str2num(x),res.lat,'UniformOutput',false));
        lon=cell2mat(arrayfun(@(x) str2num(x),res.lon,'UniformOutput',false));
        yaw=cell2mat(arrayfun(@(x) str2num(x),res.yaw,'UniformOutput',false));
        tim=cell2mat(arrayfun(@(x) str2num(x),res.time,'UniformOutput',false));
        la=[];
        lo=[];
        ya=[];
        ti=[];
        for kdx=1:size(res,1)
            rota=str2num(res.rota(idx));
            notrota=setdiff(1:size(res,2),rota);
            if ~isempty(rota)
                ti=[ti,tim(kdx,:)];
                la=[la,lat(kdx,:)];
                lo=[lo,lon(kdx,:)];
                ya=[ya,yaw(kdx,:)];
            else
                ti=[ti,tim(kdx,notrota)];
                la=[la,lat(kdx,notrota)];
                lo=[lo,lon(kdx,notrota)];
                ya=[ya,yaw(kdx,notrota)];
            end
        end
        %[~,idxs]=sort(reshape(tim,length(tim(:)),1));
        [~,idxs]=sort(ti);
        s_data=[s_data,struct("lat",la(idxs),"lon",lo(idxs),...
                             "idx1",S(idx,2),"idx2",S(idx,3))];
    end    
    close(conn);
end