home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD2.mdf / c / worldmap / demo / grid.c < prev    next >
Encoding:
Text File  |  1986-01-21  |  1.5 KB  |  70 lines

  1. /*  grid  -  Display the lat/long lines for the Alaska demo.
  2.  
  3.         Copyright 1986 John B. Allison                */
  4.  
  5. struct {        /*  To draw latitude lines in Mercator projection  */
  6.   float    mercaty;    /*  the Mercator y value of this latitude    */
  7.   char    *degree;    /*  this latitude in degrees  */
  8. } lat1[] = {
  9.      1.125, " 54",
  10.      1.185, " 56",
  11.      1.250, " 58",
  12.      1.317, " 60",
  13.      1.389, " 62",
  14.      1.466, " 64",
  15.      1.548, " 66",
  16.      1.637, " 68",
  17.      1.788, " 70"
  18.     };
  19.  
  20. grid(){
  21.  
  22. #define LEFT    -200        /*  left limit of screen        */
  23. #define RIGHT    -115        /*  right limit of screen        */
  24. #define INC    5        /*  increment of lines across screen    */
  25.  
  26.   float x, y, ytop, ybot, xsidetext, ybottext, nx, ny;
  27.   int   i, height, width, path = 0, mode = 0;
  28.   char  tstring[10];
  29.  
  30.  
  31.  
  32.  
  33.     /*  Map normalized co-ordinate near bottom right of screen to
  34.         world co-ordinates for locating text.            */
  35.  
  36.     nx = ny = 0.9;
  37.     mapntow(&nx, &ny, &xsidetext, &ybottext);
  38.  
  39.     height = width = 1;
  40.     settext(&height, &width, &path, &mode);
  41.  
  42.     /*  draw lines of longitude  */
  43.  
  44.     ytop = 1.85;
  45.     ybot = 1.1;
  46.  
  47.     for(i = LEFT; i <= RIGHT; i += INC){
  48.         x = i;
  49.         movabs(&x, &ytop);
  50.         lnabs(&x, &ybot);
  51.  
  52.         sprintf(tstring, "%d", i);
  53.         movtcurabs(&x, &ybottext);
  54.         text(tstring);
  55.     }
  56.  
  57.     /*  draw lines of latitude.  */
  58.  
  59.     for(i = 0; i <= 9; i++){
  60.         y = lat1[i].mercaty;
  61.         x = LEFT;
  62.         movabs(&x, &y);
  63.         x = RIGHT;
  64.         lnabs(&x, &y);
  65.  
  66.         movtcurabs(&xsidetext, &y);
  67.         text(lat1[i].degree);
  68.     }
  69. }
  70.