Handle SVG sprite file with flutter_svg - flutter

I have SVG file on server side named sprite-icons.svg:
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<symbol id="icon-1" viewBox="0 0 826800 826800">
<path fill="#222222" d="M201379 197582l31452 0 0 432178 -31452 0 0 -432178zm122701 72034l33469 0 0 282159 -33469 0 0 -282159zm138450 74734l31666 0 0 135933 -31666 0 0 -135933zm131388 -147310l31503 0 0 432178 -31503 0 0 -432178z"/>
</symbol>
<symbol id="icon-2" viewBox="0 0 826800 826800">
<path fill="#aaaaaa" d="M201379 197582l31452 0 0 432178 -31452 0 0 -432178zm122701 72034l33469 0 0 282159 -33469 0 0 -282159zm138450 74734l31666 0 0 135933 -31666 0 0 -135933zm131388 -147310l31503 0 0 432178 -31503 0 0 -432178z"/>
</symbol>
</svg>
I have url to get it, but when I try do it with flutter_svg this way:
SvgPicture.network('https://some-domain.com/img/sprite-icons.svg')
// or
SvgPicture.network('https://some-domain.com/img/sprite-icons.svg#icon-1')
I'm getting an error:
StateError (Bad state: SVG did not specify dimensions
The SVG library looks for a `viewBox` or `width` and `height` attribute to determine the viewport boundary of the SVG. Note that these attributes, as with all SVG attributes, are case sensitive.
Is it possible to get such SVG sprite file and render included svgs (icon-1 and icon-2) with flutter_svg? Or any other way? Thanks.

Related

Is there a difference between WKB and the hex value returned in PostGIS

I've been doing some experimenting with PostGIS, and here's what I've noticed:
Suppose I have a table defined as follows:
CREATE TABLE IF NOT EXISTS geomtest (
id SERIAL PRIMARY KEY,
name TEXT NOT NULL,
geom geometry(POLYGON, 4326) NOT NULL
);
And I add the following polygon:
SRID=4326;POLYGON((0 0,0 10,10 10,10 0,0 0))
If I query the geom column on its own, I get a Hex representation of the geometry. If I instead call ST_AsBinary(geom), I get a binary representation.
However, when I convert both the hex and binary representations to an array of bytes, the results I get are slightly different. The first comment is the result I get by converting the hex into binary, and the next is straight from ST_AsBinary()
//[1 3 0 0 32 230 16 0 0 1 0 0 0 5 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 36 64 0 0 0 0 0 0 36 64 0 0 0 0 0 0 36 64 0 0 0 0 0 0 36 64 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]
//[1 3 0 0 0 1 0 0 0 5 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 36 64 0 0 0 0 0 0 36 64 0 0 0 0 0 0 36 64 0 0 0 0 0 0 36 64 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]
As you can see, the first 4 bytes are identical; representing whether it's in big or little endian, and the type of geometry (3, in this case a Polygon). The rest of the bytes are the same too. The only difference is there are a few extra bytes added after the first 4.
I wondered if this had to do with representing the projection (SRID=4326), but I haven't found any evidence to that.
If someone could shed some light on this, I'd greatly appreciate it.
I didn't examine the bytes, but I am sure that the difference is the SRID that's not included in the WKB format.
Try st_asewkb instead.

How can i count number of particles in each grid box in this code?

how can i count number of particles in each grid box in this code
here is my code below:
xyRange=[1,5];
P=3;
vx=0.6;
vy=0.4;
X=[];
Y=[];
for day=1:5
X=[X;randi(xyRange,P,1)];
Y=[Y;randi(xyRange,P,1)];
X=X+vx;
Y=Y+vy;
end
plot(X,Y,'kd');
grid on;
axis([1,50,1,50]);
j = floor(X/5)+1;
k = floor(Y/5);
box = k*10+j;
If you have the Statistics Toolbox, the easiest way is to use hist3.
In your case, when I plotted the grid, it looks like each box was separated in units of 5. As such, the command is very simply this:
cnt = hist3([X,Y], {0:5:50 - 2.5, 0:5:50 - 2.5});
X and Y are your 2D data points, and the second element is a cell array of X and Y values which denote the centres of each of the points in each grid. Take note that the points that are defined are with respect to the origin being at the top left corner. If you want to make sure that the origin is at the bottom left corner, you would actually need to do this:
cnt = flipud(cnt.');
On my run I get this:
cnt =
0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0
0 1 6 0 0 0 0 0 0 0 0
0 5 3 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0
When producing your plot, I get this:
If you compare the counts in comparison to the grid produced at the top, you'll see that the match. However, because of the way I specified the centre of the bins, the first and last row, and the first and last column are meaningless, so you can safely eliminate these from your analysis.
If you want a nice pictorial example of this, call hist3 without any output arguments:
%// Plot 2D histogram with some transparency
hist3([X,Y], {(0:5:50) - 2.5, (0:5:50) - 2.5}, 'FaceAlpha', 0.65);
%// Set height of each bar coloured according to height
set(get(gca,'child'),'FaceColor','interp','CDataMode','auto');
view(-34,68); %// Change camera view for better look
We get this:

matlab running a video, .txt and .mat

I want to run a video in matlab but I got some problems while doing so. I tried to run the video while using 'load' and then 'implay'. But I got this problem. My movie file is a textfile which constains mostly of zeros, arranged diagonally.
When I load this file in matlab I get different values. Here a snippet:
0 0 0 0 0 0 0 0 0 0 0
0 0 -5 0 0 -5.00097609500000 0 0 0 0 0
0 0 -10 0 0 -10.0019423800000 0 0 0 0 0
0 0 -15 0 0 -15.0028988550000 0 0 0 0 0
0 0 -20 0 0 -20.0038455200000 0 0 0 0 0
0 0 -25 0 0 -25.0047823750000 0 0 0 0 0
0 0 -30 0 0 -30.0057094200000 0 0 0 0 0
0 0 -35 0 0 -35.0066266550000 0 0 0 0 0
0 0 -40 0 0 -40.0075340800000 0 0 0 0 0
0 0 -45 0 0 -45.0084316950000 0 0 0 0 0
I dont know why I get a mat.file with different values and why my movie does not run. I wanted to upload the original textfile but this not possible.
When I try to run I receive following message: There is not enough memory to open 'filename' in the Editor.
I hope you guys can help me!

a command to view result on matlab for the tarjan algorithm

I'm working on an implementation of the Tarjan algorithm in Matlab.
I use this source code to determine the strongly connected components.
This is the result I got, how can I view the result with Matlab (a figure that determines the colored strongly connected components)?
What is the appropriate command?
G=[0 0 1 1 0 0 0;
1 0 0 0 0 0 0;
0 0 0 0 0 1 0;
0 0 0 0 1 0 0;
0 0 0 0 0 0 1;
0 0 0 1 0 0 0;
0 0 0 0 0 1 0];
tarjan(G)
ans =
7 5 4 6 0 0 0
3 0 0 0 0 0 0
1 0 0 0 0 0 0
2 0 0 0 0 0 0
There is already an examle using coloring, all nodes listed in the first row are colored with the first color, all nodes listed in the second row are colored with the second color etc...

Applying Threshold mask

i am making image compression in matlab.
After i applied DCT on image and i had img matrix, i want to apply a threshold mask on that matrix.
mask = [1 1 1 1 0 0 0 0
1 1 1 0 0 0 0 0
1 1 0 0 0 0 0 0
1 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0];
maskedImg = blkproc(img,[8 8],mask );
I used that function but it didnt work and i get error message:
Error in ==> blkproc at 67
[a, block, border, fun, params, padval] = parse_inputs(varargin{:});
According to latest Matlab documentation; closest blockproc syntax (for your case) is B = blockproc(A,[M N],fun). So apparently your mask really should be a function!
However, I recall that blkproc has been a valid Matlab function for a while ago, thus double check the proper way to call it by typing (in the command line) > help blkproc. (Al tough I'm quite confident that it will share the calling signature with blockproc [in this case]).