Graph_Set.c 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. /*
  2. * Start up graphics processing. Anything that needs to be assigned, set up,
  3. * started-up, or otherwise initialized happens here. This is called only at
  4. * the startup of the graphics driver.
  5. *
  6. * The external variables define the pixle limits of the graphics surface. The
  7. * coordinate system used by the applications programs has the (0,0) origin
  8. * in the upper left-hand corner. Hence,
  9. * screen_left < screen_right
  10. * screen_top < screen_bottom
  11. *
  12. */
  13. #include <string.h>
  14. #include <stdlib.h>
  15. #include <grass/gis.h>
  16. #include "driverlib.h"
  17. #include "driver.h"
  18. #include "htmlmap.h"
  19. char *last_text;
  20. int last_text_len;
  21. char *file_name;
  22. int html_type;
  23. FILE *output;
  24. struct MapPoly *head;
  25. struct MapPoly **tail;
  26. int BBOX_MINIMUM;
  27. int MAX_POINTS;
  28. int MINIMUM_DIST;
  29. int HTML_Graph_set(void)
  30. {
  31. char *p;
  32. G_gisinit("HTMLMAP driver");
  33. NCOLORS = 256;
  34. /*
  35. * set the minimum bounding box dimensions
  36. */
  37. if (NULL != (p = getenv("GRASS_HTMLMINBBOX"))) {
  38. BBOX_MINIMUM = atoi(p);
  39. if (BBOX_MINIMUM <= 0) {
  40. BBOX_MINIMUM = DEF_MINBBOX;
  41. }
  42. }
  43. else {
  44. BBOX_MINIMUM = DEF_MINBBOX;
  45. }
  46. /*
  47. * set the maximum number of points
  48. */
  49. if (NULL != (p = getenv("GRASS_HTMLMAXPOINTS"))) {
  50. MAX_POINTS = atoi(p);
  51. if (MAX_POINTS <= 0) {
  52. MAX_POINTS = DEF_MAXPTS;
  53. }
  54. }
  55. else {
  56. MAX_POINTS = DEF_MAXPTS;
  57. }
  58. /*
  59. * set the minimum difference to keep a point
  60. */
  61. if (NULL != (p = getenv("GRASS_HTMLMINDIST"))) {
  62. MINIMUM_DIST = atoi(p);
  63. if (MINIMUM_DIST <= 0) {
  64. MINIMUM_DIST = DEF_MINDIST;
  65. }
  66. }
  67. else {
  68. MINIMUM_DIST = DEF_MINDIST;
  69. }
  70. /*
  71. * open the output file
  72. */
  73. if (NULL != (p = getenv("GRASS_HTMLFILE"))) {
  74. if (strlen(p) == 0) {
  75. p = FILE_NAME;
  76. }
  77. }
  78. else {
  79. p = FILE_NAME;
  80. }
  81. file_name = p;
  82. output = fopen(file_name, "w");
  83. if (output == NULL) {
  84. G_fatal_error("HTMLMAP: couldn't open output file %s", file_name);
  85. exit(EXIT_FAILURE);
  86. }
  87. G_message("HTMLMAP: collecting to file: %s\n width = %d, height = %d, ",
  88. file_name, screen_right, screen_bottom);
  89. /*
  90. * check type of map wanted
  91. */
  92. if (NULL == (p = getenv("GRASS_HTMLTYPE"))) {
  93. p = "CLIENT";
  94. }
  95. if (strcmp(p, "APACHE") == 0) {
  96. html_type = APACHE;
  97. fprintf(stdout, "type = APACHE\n");
  98. }
  99. else if (strcmp(p, "RAW") == 0) {
  100. html_type = RAW;
  101. fprintf(stdout, "type = RAW\n");
  102. }
  103. else {
  104. html_type = CLIENT;
  105. fprintf(stdout, "type = CLIENT\n");
  106. }
  107. /*
  108. * initialize text memory and list pointers
  109. */
  110. last_text = (char *)G_malloc(INITIAL_TEXT + 1);
  111. last_text[0] = '\0';
  112. last_text_len = INITIAL_TEXT;
  113. head = NULL;
  114. tail = &head;
  115. return 0;
  116. }