fit_map.c 635 B

123456789101112131415161718192021222324252627
  1. /* Function: fit_map_to_box
  2. **
  3. ** Author: Paul W. Carlson 5/92
  4. */
  5. #include "ps_info.h"
  6. int fit_map_to_box(void)
  7. {
  8. /* make map fit in bounding box */
  9. PS.ew_to_x = PS.map_width * 72.0 / (PS.w.east - PS.w.west);
  10. PS.ns_to_y = PS.map_height * 72.0 / (PS.w.north - PS.w.south);
  11. if (PS.ew_to_x < PS.ns_to_y) {
  12. PS.map_pix_wide = 72.0 * PS.map_width;
  13. PS.map_pix_high = 72.0 * PS.map_height * PS.ew_to_x / PS.ns_to_y;
  14. PS.ns_to_y = PS.ew_to_x;
  15. }
  16. else {
  17. PS.map_pix_wide = 72.0 * PS.map_width * PS.ns_to_y / PS.ew_to_x;
  18. PS.map_pix_high = 72.0 * PS.map_height;
  19. PS.ew_to_x = PS.ns_to_y;
  20. }
  21. return 0;
  22. }