Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
function [] = createXMLShape(

...

 filename, varargin)

...


% function [] = createXMLShape(

...

filename , shape1, shape2, ...)

...


% The Function createXMLShape creates XML shape for SWIP5 maps

...


% It creates only one shape

...


%

...


% Input parameters:

...

%   d - the structure with two fields of tables:

%     Lat are latitudes of pollyline points od border of the shape .

%     Long are longitudes of pollyline points od border of the shape.

%     Number of pointd in Lat and Log must be the same.

%   filename - the name of file whre the shape will be written

%     The extension of the file name should be '.xml'

% Optional parameters

%   'Contour' the RGB color of the contour of the shape

...


%   shape* - structures with two fields of shapes:
%     Lat are latitudes of pollyline points od border of the shape .
%     Long are longitudes of pollyline points od border of the shape.
%       Number of pointd in Lat and Log must be the same.
%     Pen the RGB color of the contour of the shape
%       in  the table [r,g,b,w] where: r - red, g - green,

...


%       b - blue, and w - width of the line. Default value is [0,0,0,1]

...

%      (black)      

%   'Face' the RGB color of the face of the shape

...


%       (black)
%     Brush the RGB color of the face of the shape
%      in the table [r,g,b,a] where a - translucency.

...


%      Default value is [1,1,1,1] (white)

...

Pen = arparameters('Contour',[0,0,0,1],varargin{:});

Brush = arparameters('Face',[1,1,1,1],varargin{:});

...


%   filename - the name of file whre the shape will be written
%     The extension of the file name should be '.xml'
%
    N = numel(varargin); 
    if N == 0
        error('missing shapes')
    end
    fileID = fopen(filename,'w');

...


    fprintf(fileID,'<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>\r\n');

...


    fprintf(fileID,'<!DOCTYPE boost_serialization>\r\n');

...


    fprintf(fileID,'<boost_serialization signature="serialization::archive" version="12">\r\n');

...


    fprintf(fileID,'<Shapes class_id="0" tracking_level="0" version="0">\r\n');

...


    fprintf(fileID,'\

...

t<count>%d</count>\r\n', N);

...


    fprintf(fileID,'\t<item_version>0</item_version>\r\n')

...

;
    for sidx = 1:N
        d = varargin{sidx};
        fprintf(fileID,'\t<item class_id="1" tracking_level="0" version="0">\r\n');

...


        fprintf(fileID,'\t\t<penRed>%d</penRed>\r\n', d.Pen(1)*128);

...


        fprintf(fileID,'\t\t<penGreen>%d</penGreen>\r\n', d.Pen(2)*128);

...


        fprintf(fileID,'\t\t<penBlue>%d</penBlue>\r\n', d.Pen(3)*128);

...


        fprintf(fileID,'\t\t<penWidth>%d</penWidth>\r\n', d.Pen(4));

...


        fprintf(fileID,'\t\t<brushRed>%d</brushRed>\r\n',d.Brush(1)*128);

...


        fprintf(fileID,'\t\t<brushGreen>%d</brushGreen>\r\n',d.Brush(2)*128);

...


        fprintf(fileID,'\t\t<brushBlue>%d</brushBlue>\r\n',d.Brush(3)*128);

...


        fprintf(fileID,'\t\t<fill>%f</fill>\r\n',d.Brush(4));

...


        fprintf(fileID,'\t\t<coords class_id="2" tracking_level="0" version="0">\r\n');

...


        fprintf(fileID,'\t\t\t<count>%d</count>\r\n',numel(d.Lat));

...


        fprintf(fileID,'\t\t\t<item_version>0</item_version>\r\n');

...


        for i = 1:numel(d.Lat)

...

                if i == 1

...


            if i == 1
            fprintf(fileID,'\t\t\t<item class_id="3" tracking_level="0" version="0">\r\n');

...

                else

...


            else
            fprintf(fileID,'\t\t\t<item>\r\n');

...

                end

...


            end
            fprintf(fileID,'\t\t\t\t<latitude>%f</latitude>\r\n\t\t\t\t<longitude>%f</longitude>\r\n',d.Lat(i),d.Long(i));

...


            fprintf(fileID,'\t\t\t</item>\r\n');

...

            end

...


        end
        fprintf(fileID,'\t\t</coords>\r\n');

...


        fprintf(fileID,'\t</item>\r\n');

...


    end
    fprintf(fileID,'</Shapes>\r\n');

...


    fprintf(fileID,'</boost_serialization>\r\n');

...


    fclose(fileID);

...


end