source: issm/oecreview/Archive/25834-26739/ISSM-26630-26631.diff@ 28275

Last change on this file since 28275 was 26740, checked in by Mathieu Morlighem, 3 years ago

CHG: added 25834-26739

File size: 1.3 KB
  • ../trunk-jpl/src/m/shp/shp2exp.m

     
    4747                end
    4848        elseif strcmpi(shp(i).Geometry,'Point'),
    4949                x=shp(i).X; y=shp(i).Y;
    50                 expstruct(end+1).x=x;
    51                 expstruct(end).y=y;
    52                 expstruct(end).nods=length(x);
    53                 expstruct(end).density=1;
    54                 expstruct(end).closed=0;
    55                 %exp(end).name=num2str(shp(i).id);
     50                if ~isnan(x) && ~isnan(y)
     51                        expstruct(end+1).x=x;
     52                        expstruct(end).y=y;
     53                        expstruct(end).nods=length(x);
     54                        expstruct(end).density=1;
     55                        expstruct(end).closed=0;
     56                        %exp(end).name=num2str(shp(i).id);
     57                end
     58        elseif strcmpi(shp(i).Geometry,'PointZ'),
     59                shp(i)
    5660        elseif strcmpi(shp(i).Geometry,'Line'),
    57                 x=shp(i).X; y=shp(i).Y;
    58                 expstruct(end+1).x=x;
    59                 expstruct(end).y=y;
    60                 expstruct(end).nods=length(x);
    61                 expstruct(end).density=1;
    62                 expstruct(end).closed=0;
     61                x=shp(i).X(:); y=shp(i).Y(:);
     62                pos = find(~isnan(x) & ~isnan(y));
     63                idx=find(diff(pos)~=1);
     64                A=[idx(1);diff(idx);numel(pos)-idx(end)];
     65                Cx=mat2cell(x(pos),A,1);
     66                Cy=mat2cell(y(pos),A,1);
     67                for i=1:numel(Cx)
     68                        expstruct(end+1).x=Cx{i};
     69                        expstruct(end).y=Cy{i};
     70                        expstruct(end).nods=length(Cx{i});
     71                        expstruct(end).density=1;
     72                        expstruct(end).closed=0;
     73                end
    6374        end
    6475end
    6576
Note: See TracBrowser for help on using the repository browser.