! . */
| 9924 | |
| 9925 | /*! . */ |
| 9926 | int gmt_map_setup (struct GMT_CTRL *GMT, double wesn[]) { |
| 9927 | unsigned int i; |
| 9928 | int error; |
| 9929 | bool search, double_auto[6]; |
| 9930 | bool test_pole[2] = {true, true}, separate_intervals = false; |
| 9931 | double scale, i_scale; |
| 9932 | |
| 9933 | if ((error = gmt_proj_setup (GMT, wesn)) != GMT_NOERROR) goto gmt_map_setup_end; |
| 9934 | |
| 9935 | gmt_set_undefined_defaults (GMT, sqrt (GMT->current.map.width * GMT->current.map.height), false); /* We must change any undefined defaults given max plot dimension */ |
| 9936 | |
| 9937 | search = GMT->current.proj.search; |
| 9938 | |
| 9939 | /* If intervals are not set specifically, round them to some "nice" values |
| 9940 | * Remember whether frame items in both directions were automatically set */ |
| 9941 | for (i = 0; i < 6; i++) |
| 9942 | double_auto[i] = gmt_M_is_geographic (GMT, GMT_IN) && GMT->current.map.frame.set_both && |
| 9943 | GMT->current.map.frame.axis[GMT_X].item[i].active && GMT->current.map.frame.axis[GMT_X].item[i].interval == 0.0 && |
| 9944 | GMT->current.map.frame.axis[GMT_Y].item[i].active && GMT->current.map.frame.axis[GMT_Y].item[i].interval == 0.0; |
| 9945 | |
| 9946 | gmt_auto_frame_interval (GMT, GMT_X, GMT_ANNOT_UPPER); |
| 9947 | gmt_auto_frame_interval (GMT, GMT_Y, GMT_ANNOT_UPPER); |
| 9948 | gmt_auto_frame_interval (GMT, GMT_Z, GMT_ANNOT_UPPER); |
| 9949 | gmt_auto_frame_interval (GMT, GMT_X, GMT_ANNOT_LOWER); |
| 9950 | gmt_auto_frame_interval (GMT, GMT_Y, GMT_ANNOT_LOWER); |
| 9951 | gmt_auto_frame_interval (GMT, GMT_Z, GMT_ANNOT_LOWER); |
| 9952 | |
| 9953 | /* Then check if one or both poles are inside map. If they are then the longitude range will be 360 |
| 9954 | * and depending on the latitude extent it may not make sense to use the coarse longitude-spacing determined |
| 9955 | * also for the latitude spacing. We check this and if a pole is inside and if the latitude range is < 1/4 |
| 9956 | * of that of the longitude (e.g., 90 degrees for a 0-360 global map) we go separate. */ |
| 9957 | |
| 9958 | if (GMT->current.proj.projection_GMT == GMT_AZ_EQDIST) { /* Must be careful since if a pole equals an antipode we get NaNs as coordinates */ |
| 9959 | double x, y; |
| 9960 | gmt_geo_to_xy (GMT, GMT->current.proj.central_meridian, -90.0, &x, &y); |
| 9961 | if (gmt_M_is_dnan (x) && gmt_M_is_dnan (y)) test_pole[0] = false; |
| 9962 | gmt_geo_to_xy (GMT, GMT->current.proj.central_meridian, +90.0, &x, &y); |
| 9963 | if (gmt_M_is_dnan (x) && gmt_M_is_dnan (y)) test_pole[1] = false; |
| 9964 | } |
| 9965 | if (test_pole[0] && !gmt_map_outside (GMT, GMT->current.proj.central_meridian, -90.0)) GMT->current.proj.pole_in_map[0] = separate_intervals = true; |
| 9966 | if (test_pole[1] && !gmt_map_outside (GMT, GMT->current.proj.central_meridian, +90.0)) GMT->current.proj.pole_in_map[1] = separate_intervals = true; |
| 9967 | if (separate_intervals && (GMT->common.R.wesn[YHI] - GMT->common.R.wesn[YLO]) / (GMT->common.R.wesn[XHI] - GMT->common.R.wesn[XLO]) > 0.25) |
| 9968 | separate_intervals = false; /* E.g, for a whole global hemisphere we keep them the same, else we adjust individually */ |
| 9969 | |
| 9970 | /* Now set the pairs of automatically set intervals to be the same in both x- and y-direction, except when a geographic pole is inside an oblique map frame */ |
| 9971 | for (i = 0; i < 6; i++) { |
| 9972 | if (double_auto[i] && !separate_intervals) GMT->current.map.frame.axis[GMT_X].item[i].interval = GMT->current.map.frame.axis[GMT_Y].item[i].interval = |
| 9973 | MAX (GMT->current.map.frame.axis[GMT_X].item[i].interval, GMT->current.map.frame.axis[GMT_Y].item[i].interval); |
| 9974 | } |
| 9975 | |
| 9976 | if (!GMT->current.map.n_lon_nodes) GMT->current.map.n_lon_nodes = urint (GMT->current.map.width / GMT->current.setting.map_line_step); |
| 9977 | if (!GMT->current.map.n_lat_nodes) GMT->current.map.n_lat_nodes = urint (GMT->current.map.height / GMT->current.setting.map_line_step); |
| 9978 | |
| 9979 | GMT->current.map.dlon = (GMT->common.R.wesn[XHI] - GMT->common.R.wesn[XLO]) / GMT->current.map.n_lon_nodes; |
| 9980 | GMT->current.map.dlat = (GMT->common.R.wesn[YHI] - GMT->common.R.wesn[YLO]) / GMT->current.map.n_lat_nodes; |
| 9981 | |
| 9982 | if (GMT->current.map.width > 400.0 && gmt_M_is_grdmapproject (GMT)) { /* ***project calling with true scale, probably */ |
| 9983 | search = false; /* Safe-guard that prevents region search below for (map|grd)project and others (400 inch = ~> 10 meters) */ |
no test coverage detected