Graph_Set.c 2.6 KB

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