Nippon02.cc

From TORI
Revision as of 14:25, 20 June 2013 by Maintenance script (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

// Generator of image nippon02.jpg (clickable at right).

Nippon02.jpg

// The input with the coastal lines is required, // the following files should be downoaded for the compilation:

//

// russia.txt,
// chinaa.txt,
// koreano.txt,
// koreasua.txt,
// sakhalin.txt,
// hokkaido.txt,
// honshu.txt,
// kyushu.txt,
// shikoku.txt,
// habomai.txt,
// shikotan.txt,
// kunashiri.txt,
// etorofu.txt,
// urupu.txt .

//


 #include<math.h>
 #include<stdio.h>
 #include<stdlib.h>
 #define DB double
 #define DO(x,y) for(x=0;x<y;x++)
//<br>
void ado(FILE *O, int X, int Y) //<br>
{ fprintf(O,"%c!PS-Adobe-2.0 EPSF-2.0\n",'%'); //<br>
fprintf(O,"%c%cBoundingBox: 0 0 %d %d\n",'%','%',X,Y); //<br>
fprintf(O,"/M {moveto} bind def\n"); //<br>
fprintf(O,"/L {lineto} bind def\n"); //<br>
fprintf(O,"/S {stroke} bind def\n"); //<br>
fprintf(O,"/s {show newpath} bind def\n"); //<br>
fprintf(O,"/C {closepath} bind def\n"); //<br>
fprintf(O,"/F {fill} bind def\n"); //<br>
fprintf(O,"/times-Roman findfont 90 scalefont setfont\n"); //<br>
fprintf(O,"/W {setlinewidth} bind def\n"); //<br>
fprintf(O,"/RGB {setrgbcolor} bind def\n");} //<br>
#include "russia.txt" //<br>
#include "chinaa.txt" //<br>
#include "koreano.txt" //<br>
#include "koreasua.txt" //<br>
#include "sakhalin.txt" //<br>
#include "hokkaido.txt" //<br>
#include "honshu.txt" //<br>
#include "kyushu.txt" //<br>
#include "shikoku.txt" //<br>
#include "habomai.txt" //<br>
#include "shikotan.txt" //<br>
#include "kunashiri.txt" //<br>
#include "etorofu.txt" //<br>
#include "urupu.txt" //<br>

DB R=6400.; //kilometers , unity at the map//<br>
DB GR=M_PI/180.; // gradus //<br>
#define ADn(array) {a=array[n][0];d=array[n][1]; if(d<1.) d+=360.;} //<br>

DB A0=40; //<br>
DB D0=140.; //<br>
DB C0=cos(A0*GR); //<br>
DB R0=cos(A0*GR)/sin(A0*GR); //<br>
DB r, f; //<br>
#define XY { r=R0-GR*(a-A0); f=GR*C0*(d-D0)/R0; x=r*sin(f); y=R0-r*cos(f); x*=R; y*=R;} //<br>
#define MLn {if(n==0)M(x,y)else L(x,y)} //<br>

main(){ int n,j,k; DB a,d,x,y,c; //<br>
FILE *o; o=fopen("nippon02.eps","w"); ado(o,2040,2440); //<br>
#define M(x,y) fprintf(o,"%5.2f %5.2f M\n",0.+x,0.+y); //<br>
#define L(x,y) fprintf(o,"%5.2f %5.2f L\n",0.+x,0.+y); //<br>
M(0,0)L(2040,0)L(2040,2440)L(0,2440) fprintf(o,".88 .95 1 RGB C F\n"); // Blue sea //<br>
//fprintf(o,"120 112 translate .1 .1 scale\n"); //for the low resolution version//<br>
fprintf(o,"1200 1120 translate\n"); //<br>

DO(n,RussiaN){ADn(Russia); XY; MLn} fprintf(o,"C .95 .95 .95 RGB F\n"); //<br>
DO(n,RussiaN){ADn(Russia); XY; MLn} fprintf(o,"C 0 0 0 RGB S\n"); //<br>

DO(n,ChinaaN){ADn(Chinaa); XY; MLn} fprintf(o,"C 1 1 .9 RGB F\n"); //<br>
DO(n,ChinaaN){ADn(Chinaa); XY; MLn} fprintf(o,"C 0 0 0 RGB S\n"); //<br>

DO(n,KoreanoN){ADn(Koreano); XY; MLn} fprintf(o,"C 1 .9 .9 RGB F\n"); //<br>
DO(n,KoreanoN){ADn(Koreano); XY; MLn} fprintf(o,"C 0 0 0 RGB S\n"); //<br>

DO(n,KoreasuaN){ADn(Koreasua); XY; MLn} fprintf(o,"C 1 .94 1 RGB F\n"); //<br>
DO(n,KoreasuaN){ADn(Koreasua); XY; MLn} fprintf(o,"C 0 0 0 RGB S\n"); //<br>

DO(n,SakhalinN){ADn(Sakhalin); XY; MLn} fprintf(o,"C 1 1 1 RGB F\n"); //<br>
DO(n,SakhalinN){ADn(Sakhalin); XY; MLn} fprintf(o,"C 0 0 0 RGB S\n"); //<br>

DO(n,HokkaidoN){ADn(Hokkaido); XY; MLn} fprintf(o,"C 1 1 1 RGB F\n"); //<br>
DO(n,HokkaidoN){ADn(Hokkaido); XY; MLn} fprintf(o,"C 0 0 0 RGB S\n"); //<br>

DO(n,HonshuN){ADn(Honshu); XY; MLn} fprintf(o,"C 1 1 1 RGB F\n"); //<br>
DO(n,HonshuN){ADn(Honshu); XY; MLn} fprintf(o,"C 0 0 0 RGB S\n"); //<br>

DO(n,KyushuN){ADn(Kyushu); XY; MLn} fprintf(o,"C 1 1 1 RGB F\n"); //<br>
DO(n,KyushuN){ADn(Kyushu); XY; MLn} fprintf(o,"C 0 0 0 RGB S\n"); //<br>

DO(n,ShikokuN){ADn(Shikoku); XY; MLn} fprintf(o,"C 1 1 1 RGB F\n"); //<br>
DO(n,ShikokuN){ADn(Shikoku); XY; MLn} fprintf(o,"C 0 0 0 RGB S\n"); //<br>

DO(n,HabomaiN){ADn(Habomai); XY; MLn} fprintf(o,"C 1 1 1 RGB F\n"); //<br>
DO(n,HabomaiN){ADn(Habomai); XY; MLn} fprintf(o,"C 0 0 0 RGB S\n"); //<br>

DO(n,ShikotanN){ADn(Shikotan); XY; MLn} fprintf(o,"C 1 1 1 RGB F\n"); //<br>
DO(n,ShikotanN){ADn(Shikotan); XY; MLn} fprintf(o,"C 0 0 0 RGB S\n"); //<br>

DO(n,KunashiriN){ADn(Kunashiri); XY; MLn} fprintf(o,"C 1 1 1 RGB F\n"); //<br>
DO(n,KunashiriN){ADn(Kunashiri); XY; MLn} fprintf(o,"C 0 0 0 RGB S\n"); //<br>

DO(n,EtorofuN){ADn(Etorofu); XY; MLn} fprintf(o,"C 1 1 1 RGB F\n"); //<br>
DO(n,EtorofuN){ADn(Etorofu); XY; MLn} fprintf(o,"C 0 0 0 RGB S\n"); //<br>

DO(n,UrupuN){ADn(Urupu); XY; MLn} fprintf(o,"C 1 1 1 RGB F\n"); //<br>
DO(n,UrupuN){ADn(Urupu); XY; MLn} fprintf(o,"C 0 0 0 RGB S\n"); //<br>

for(j= 0;j< 81;j+=2){a=j; //<br>
for(k=28;k<181;k+=2){d=k; XY; if(k==28)M(x,y) else L(x,y)}} //<br>
for(j=28;j<181;j+=2) {d=j; a= 0.; XY; M(x,y) a= 80.; XY; L(x,y)} //<br>
fprintf(o,"0.2 W 0 0 1 RGB S\n"); //<br>

d=133; for(a=0;a< 80; a+=10){XY; M(x-60,y-20.); fprintf(o,"(%2.0f) show\n",a); } //<br>
a= 31; for(d=90;d<189; d+=10){XY; M( x-90.,y-80.); fprintf(o,"(%3.0f) show\n",d); } //<br>

fprintf(o,"showpage\n%cTrailer\n",'%'); fclose(o); //<br>
//system("epstopdf nippon02.eps"); //<br>
//system( "open nippon02.pdf"); // This is specific for Macintosh; //<br>
system("convert nippon02.eps nippon02.jpg"); //<br>
system( "open nippon02.jpg"); // This is specific for Macintosh; //<br>
//system("convert nippon02.eps nippon02.png"); //<br>
//system("convert nippon02.eps nippon02.gif"); //<br>
}
//

// Copyleft 2011 by Dmitrii Kouznetsov // // //