Graph_Set.c 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  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. struct html_state html;
  20. int HTML_Graph_set(void)
  21. {
  22. char *file_name;
  23. char *p;
  24. G_gisinit("HTMLMAP driver");
  25. NCOLORS = 256;
  26. /*
  27. * set the minimum bounding box dimensions
  28. */
  29. if (NULL != (p = getenv("GRASS_HTMLMINBBOX"))) {
  30. html.BBOX_MINIMUM = atoi(p);
  31. if (html.BBOX_MINIMUM <= 0) {
  32. html.BBOX_MINIMUM = DEF_MINBBOX;
  33. }
  34. }
  35. else {
  36. html.BBOX_MINIMUM = DEF_MINBBOX;
  37. }
  38. /*
  39. * set the maximum number of points
  40. */
  41. if (NULL != (p = getenv("GRASS_HTMLMAXPOINTS"))) {
  42. html.MAX_POINTS = atoi(p);
  43. if (html.MAX_POINTS <= 0) {
  44. html.MAX_POINTS = DEF_MAXPTS;
  45. }
  46. }
  47. else {
  48. html.MAX_POINTS = DEF_MAXPTS;
  49. }
  50. /*
  51. * set the minimum difference to keep a point
  52. */
  53. if (NULL != (p = getenv("GRASS_HTMLMINDIST"))) {
  54. html.MINIMUM_DIST = atoi(p);
  55. if (html.MINIMUM_DIST <= 0) {
  56. html.MINIMUM_DIST = DEF_MINDIST;
  57. }
  58. }
  59. else {
  60. html.MINIMUM_DIST = DEF_MINDIST;
  61. }
  62. /*
  63. * open the output file
  64. */
  65. if (NULL != (p = getenv("GRASS_HTMLFILE"))) {
  66. if (strlen(p) == 0) {
  67. p = FILE_NAME;
  68. }
  69. }
  70. else {
  71. p = FILE_NAME;
  72. }
  73. file_name = p;
  74. html.output = fopen(file_name, "w");
  75. if (html.output == NULL) {
  76. G_fatal_error("HTMLMAP: couldn't open output file %s", file_name);
  77. exit(EXIT_FAILURE);
  78. }
  79. G_message("HTMLMAP: collecting to file: %s\n width = %d, height = %d, ",
  80. file_name, screen_width, screen_height);
  81. /*
  82. * check type of map wanted
  83. */
  84. if (NULL == (p = getenv("GRASS_HTMLTYPE"))) {
  85. p = "CLIENT";
  86. }
  87. if (strcmp(p, "APACHE") == 0) {
  88. html.type = APACHE;
  89. fprintf(stdout, "type = APACHE\n");
  90. }
  91. else if (strcmp(p, "RAW") == 0) {
  92. html.type = RAW;
  93. fprintf(stdout, "type = RAW\n");
  94. }
  95. else {
  96. html.type = CLIENT;
  97. fprintf(stdout, "type = CLIENT\n");
  98. }
  99. /*
  100. * initialize text memory and list pointers
  101. */
  102. html.last_text = (char *)G_malloc(INITIAL_TEXT + 1);
  103. html.last_text[0] = '\0';
  104. html.last_text_len = INITIAL_TEXT;
  105. html.head = NULL;
  106. html.tail = &html.head;
  107. return 0;
  108. }