graph_set.c 2.8 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 <grass/glocale.h>
  17. #include "driverlib.h"
  18. #include "driver.h"
  19. #include "htmlmap.h"
  20. struct html_state html;
  21. int HTML_Graph_set(void)
  22. {
  23. char *file_name;
  24. char *p;
  25. G_gisinit("HTMLMAP driver");
  26. /*
  27. * set the minimum bounding box dimensions
  28. */
  29. if (NULL != (p = getenv("GRASS_RENDER_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_RENDER_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_RENDER_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_RENDER_FILE"))) {
  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_verbose_message(_("html: collecting to file '%s'"), file_name);
  80. G_verbose_message(_("html: image size %dx%d"),
  81. screen_width, screen_height);
  82. /*
  83. * check type of map wanted
  84. */
  85. if (NULL == (p = getenv("GRASS_RENDER_HTMLTYPE"))) {
  86. p = "CLIENT";
  87. }
  88. if (strcmp(p, "APACHE") == 0) {
  89. html.type = APACHE;
  90. G_verbose_message(_("html: type '%s'"), "apache");
  91. }
  92. else if (strcmp(p, "RAW") == 0) {
  93. html.type = RAW;
  94. G_verbose_message(_("html: type '%s'"), "raw");
  95. }
  96. else {
  97. html.type = CLIENT;
  98. G_verbose_message(_("html: type '%s'"), "client");
  99. }
  100. /*
  101. * initialize text memory and list pointers
  102. */
  103. html.last_text = (char *)G_malloc(INITIAL_TEXT + 1);
  104. html.last_text[0] = '\0';
  105. html.last_text_len = INITIAL_TEXT;
  106. html.head = NULL;
  107. html.tail = &html.head;
  108. return 0;
  109. }