zoukankan      html  css  js  c++  java
  • [地图投影之C实现]主程序

      1 #include                               /* Mercator Projection */
      2 #include
      3 #include
      4 #include
      5 #include"a:\2023\ex6\parameter.h"
      6 #include"a:\2023\ex6\basic_function.c"
      7 main()
      8 {
      9  FILE *fp;
     10  double latitude[300],longitude[300];             /* the boundary */
     11  int i,j;
     12  int gdriver=VGA,gmode=VGAHI;
     13  char s[6],*min=s;
     14  double x[25][17],y[25][17],p;                    /* latitude and longitude web */
     15  double a[300],b[300];                            /* value changed from boundary */
     16  double m0=2.6E8,alpha=Parallel_radius(0);
     17  for(j=0;j<=16;j++)
     18     {
     19   double x0;
     20   x0=U(Radiam(-80+10*j));
     21   x0=log(x0)*alpha*100/m0;
     22   if(j==0) p=x0;
     23   for(i=0;i<=24;i++)
     24   {
     25    x[i][j]=x0-p;
     26   }
     27     }
     28     for(i=0;i<=24;i++)
     29     {
     30         double y0;
     31   y0=alpha*Radiam(-180+15*i)*100/m0;
     32   for(j=0;j<=16;j++)
     33         {
     34     y[i][j]=y0;
     35         }
     36     }
     37  initgraph(&gdriver,&gmode,"");
     38  setbkcolor(15);
     39  setcolor(7);
     40  for(j=0;j<=16;j++)
     41     {
     42   outtextxy(y[0][j]*35+300,460-x[0][j]*35,itoa(abs(-80+10*j),min,10));
     43   moveto(y[0][j]*35+320,460-x[0][j]*35);
     44         for(i=0;i<=24;i++)
     45         {
     46    lineto(y[i][j]*35+320,460-x[i][j]*35);
     47         }
     48     }
     49     for(i=0;i<=24;i++)
     50     {
     51   outtextxy(y[i][0]*35+320,470-x[i][0]*35,itoa(abs(-180+15*i),min,10));
     52   moveto(y[i][0]*35+320,460-x[i][0]*35);
     53   for(j=0;j<=16;j++)
     54         {
     55    lineto(y[i][j]*35+320,460-x[i][j]*35);
     56         }
     57  }
     58  fp=fopen("a:\\2023\\ex6\\Globe.txt","rb");
     59  if(fp==NULL)
     60  {
     61   printf("Can't open the file!");
     62   exit(1);
     63  }
     64  setcolor(4);
     65  while(!feof(fp))                     /* every time, one group of datas */
     66  {
     67   for(i=0;i<300;i++)
     68   {
     69    fscanf(fp,"%lf %lf",&longitude[i],&latitude[i]);
     70    if(latitude[i]==-1000)
     71    {
     72     break;
     73    }                                   /* stop */
     74   }
     75   for(j=0;j  {
     76    double u;
     77    u=U(Radiam(latitude[j]));
     78    a[j]=alpha*log(fabs(u));
     79    a[j]=a[j]*100/m0-p;
     80    b[j]=alpha*Radiam(longitude[j]);
     81    b[j]=b[j]*100/m0;                  /* map projection */
     82   }
     83   for(j=0;j  {
     84    line(320+b[j]*35,460-a[j]*35,320+b[j+1]*35,460-a[j+1]*35);
     85   }                                           /* drawing map */
     86  }
     87  fclose(fp);
     88  setcolor(7);
     89  outtextxy(180,5,"Mercator Projection Of The Globe");
     90  outtextxy(400,20,"Disigned by DICK");
     91  outtextxy(400,30,"Proportation 1:");
     92  outtextxy(520,30,ltoa(m0,min,10));
     93  setcolor(1);
     94  outtextxy(450,195,"INDIA");
     95  outtextxy(380,180,"SADI");
     96  outtextxy(370,190,"ARABIA");
     97  outtextxy(330,155,"FRANCE");
     98  outtextxy(280,195,"SPAIN");
     99  outtextxy(350,310,"SOUTH");
    100  outtextxy(345,320,"AFRICA");
    101  outtextxy(240,235,"BRAZIL");
    102  outtextxy(370,245,"CANGO");
    103  outtextxy(480,245,"INDUNISIA");
    104  outtextxy(175,290,"BOLIVIA");
    105  getchar();
    106 }


    e-mail:shisong.zhu@gmail.com
    GISer in China, for engineering
  • 相关阅读:
    【zookpeer】Failed to check the status of the service com.xxx.UserSerivce. No provider available for
    【solr】Spring data solr Document is missing mandatory uniqueKey field: id 解决
    【ssm】springmvc-spring-mybatis框架的搭建
    【jdbc】jdbc连接池理解
    【java基础】接口的理解
    【java基础】private protect的理解
    Single Number II
    Single Number I
    Candy
    Gas Station
  • 原文地址:https://www.cnblogs.com/columbus2/p/2867167.html
Copyright © 2011-2022 走看看