C2011mar16.cc

From TORI
Jump to: navigation, search

// This is generator of the image at right side.

C2011mar16c.jpg


// It requires the input file c2010mar16.txt that should be saved as c2010mar16.txt
// This generator can be saved as c2010mar16.cc
// and compiled with command make c2010mar16
// and executed with command ./c2010mar16
// Unfortunately, neither eps not pdf files are supported here;
// for the uploading of the updated image, you have to convert the result to JPG,
// indicating the appropriate resolution.
// The addition of letter "c" in the filename indicates the third attempt to find the appropriate conversion.
// Copyleft 2011 by Dmitrii Kouznetsov. Let me know if any problem with the compiling or executing.

#include<stdio.h>
#include<math.h>
#include<stdlib.h>
#define DB double
#define DO(x,y) for(x=0; x<y; x++)
void ado(FILE *O, int X, int Y)
{      fprintf(O,"%c!PS-Adobe-2.0 EPSF-2.0\n",'%');
       fprintf(O,"%c%cBoundingBox: 0 0 %d %d\n",'%','%',X,Y);
       fprintf(O,"/M {moveto} bind def\n");
       fprintf(O,"/L {lineto} bind def\n");
       fprintf(O,"/S {stroke} bind def\n");
       fprintf(O,"/s {show newpath} bind def\n");
       fprintf(O,"/C {closepath} bind def\n");
       fprintf(O,"/F {fill} bind def\n");
       fprintf(O,"/o {.01 0 360 arc C S} bind def\n");
       fprintf(O,"/O {.01 0 360 arc C F} bind def\n");
       fprintf(O,"/times-Roman findfont .25 scalefont setfont\n");
       fprintf(O,"/W {setlinewidth} bind def\n");
       fprintf(O,"/RGB {setrgbcolor} bind def\n");}
main(){ int m,n,k; DB x,y,z, X[49],Y[49], Z[49][17]; char c,d, namae[32];
       //char city[16];
       //char City[49][16];
       char CITY[49][16];
       FILE *i,*o;
       i=fopen("c2011mar16.txt","r");
DO(m,900) { fscanf(i,"%c",&c); printf("%c",c); if(c==64) goto end; }
end: printf("m=%7d\n",m);
for(n=1; n<48; n++)
{ fscanf(i,"%d", &m);  printf("%2d ",n);
 fscanf(i,"%s", namae);// printf("%24s ",namae);
 fscanf(i,"%s", CITY[n]);
printf("%12s ",CITY[n]);
 fscanf(i,"%lf%lf",&y,&x);     printf("% 5.2lf %6.2lf ",y,x);          X[n]=x; Y[n]=y;
 for(k=1;k<16;k++){ fscanf(i,"%lf",&z); if(z==0) z=1.; printf(" %5.3lf",z);    Z[n][k]=z;}
 printf("\n");
}
fclose(i);
o=fopen("c2011mar16.eps", "w"); ado(o,114,140);
#define o(x,y) fprintf(o,"%4.3f %4.3f o\n",(x-130.)*.88,(y-30.)*1.15);
#define O(x,y) fprintf(o,"%4.3f %4.3f O\n",(x-130.)*.88,(y-30.)*1.15);
#define M(x,y) fprintf(o,"%4.3f %4.3f M\n",(x-130.)*.88,(y-30.)*1.15);
fprintf(o,"2 -15 translate\n");
fprintf(o,"10 10 scale\n");
fprintf(o,".4 W\n");
for(n=1;n<48;n++)
       {
       DB s=0; for(k=1;k<16;k++) s+=Z[n][k]; s/=16.;
       if(s<0.05){ fprintf(o,"0 1 0 RGB\n"); goto fin;}
       if(s<0.1) { fprintf(o,".5 .5 0 RGB\n"); goto fin;}
       if(s<0.2) { fprintf(o,"1 0 0 RGB\n"); goto fin;}
       if(s<0.4) {fprintf(o,".7 0 .8 RGB\n"); goto fin;}
                     fprintf(o,"0 0 .4 RGB\n");
fin:    M(X[n],Y[n])   fprintf(o,"(%2d %s) show newpath\n", n, CITY[n]);
o(X[n],Y[n]);
}
fprintf(o,"0 1 1 RGB\n");
//o(138.252924,36.204824)
//141.0125, 37.449167 futaba
o(141.032917, 37.422972)
fprintf(o,"/times-Roman findfont .4 scalefont setfont\n");
fprintf(o,"newpath 0  0  0 RGB 0 14.8 M (level, measured in  microZv/h :) show\n");
fprintf(o,"0  .8  0 RGB 0 14.4 M (less than 0.05    : rgb 0 1 0) show\n");
fprintf(o,".4 .4 0 RGB 0 14.0 M (from 0.05 to 0.1 : rgb .5 .5 0) show\n");
fprintf(o,".8  0  0 RGB 0 13.6 M (from 0.1 to 0.2  : rgb 1 0 0) show\n");
fprintf(o,".6 0 .7 RGB 0 13.2 M (from 0.2 to 0.4   : rgb .7 0 .8) show\n");
fprintf(o,"0  0  .4 RGB 0 12.8 M (more than 0.4    : rgb  0 0 .4) show\n");
fprintf(o,"/times-Roman findfont .25 scalefont setfont\n");
fprintf(o,"0 10.7 M 0 0 0 RGB (Interpretation of data from) show\n");
fprintf(o,"0 10.4 M (http://www.mext.go.jp/component/a_menu/other/detail/__icsFiles/afieldfile/2011/03/17/1303724_6_3.pdf) show\n");
fprintf(o,"/times-Roman findfont .3 scalefont setfont\n");
fprintf(o,"0 10 M 0 0 0 RGB (Map of contamination for 2010 March 16) show\n");
fprintf(o,"0 9.6 M 0 0 0 RGB (Copyleft 2011 by Dmitrii Kouznetsov) show\n");
 fprintf(o,"showpage\n");
fprintf(o,"%cTrailer\n",'%');
fclose(o);
system("epstopdf c2011mar16.eps");
system(    "open c2011mar16.pdf");
//system("convert c2011mar16.eps c2011mar16.jpg");
}
// End of egnerator

// // //