center.c 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #include <string.h>
  2. #include <grass/gis.h>
  3. #include <grass/display.h>
  4. #include "local_proto.h"
  5. int make_window_center(struct Cell_head *window, double magnify, double east,
  6. double north)
  7. {
  8. char buffer[64];
  9. double east_west, north_south;
  10. int len_n, len_e;
  11. len_n = len_e = 0;
  12. if (east < 0.0 && north < 0.0) {
  13. east = (window->east + window->west) / 2.;
  14. north = (window->north + window->south) / 2.;
  15. }
  16. east_west = (window->east - window->west) / magnify;
  17. window->east = east + east_west / 2;
  18. window->west = east - east_west / 2;
  19. if (window->proj == PROJECTION_LL) {
  20. if (east_west > 360) {
  21. window->east = east + 180;
  22. window->west = east - 180;
  23. }
  24. window->east = G_adjust_easting(window->east, window);
  25. }
  26. north_south = (window->north - window->south) / magnify;
  27. window->north = north + north_south / 2;
  28. window->south = north - north_south / 2;
  29. G_limit_south(&window->south, window->proj);
  30. G_limit_north(&window->north, window->proj);
  31. G_format_easting(window->east, buffer, window->proj);
  32. G_format_easting(window->west, buffer, window->proj);
  33. G_format_northing(window->north, buffer, window->proj);
  34. G_format_northing(window->south, buffer, window->proj);
  35. return 0;
  36. }