! . */
| 11678 | |
| 11679 | /*! . */ |
| 11680 | int gmt_contlabel_prep (struct GMT_CTRL *GMT, struct GMT_CONTOUR *G, double xyz[2][3]) { |
| 11681 | /* G is pointer to the LABELED CONTOUR structure |
| 11682 | * xyz, if not NULL, have the (x,y,z) min and max values for a grid |
| 11683 | */ |
| 11684 | |
| 11685 | /* Prepares contour labeling machinery as needed */ |
| 11686 | |
| 11687 | unsigned int error = 0, dummy; |
| 11688 | uint64_t k, i, seg, row, rec; |
| 11689 | double x, y; |
| 11690 | |
| 11691 | gmt_contlabel_free (GMT, G); /* In case we've been here before */ |
| 11692 | |
| 11693 | if (G->clearance_flag) { /* Gave a percentage of fontsize as clearance */ |
| 11694 | G->clearance[GMT_X] = 0.01 * G->clearance[GMT_X] * G->font_label.size * GMT->session.u2u[GMT_PT][GMT_INCH]; |
| 11695 | G->clearance[GMT_Y] = 0.01 * G->clearance[GMT_Y] * G->font_label.size * GMT->session.u2u[GMT_PT][GMT_INCH]; |
| 11696 | } |
| 11697 | if (G->label_type == GMT_LABEL_IS_FFILE && !G->fixed) { /* Requires fixed file */ |
| 11698 | error++; |
| 11699 | GMT_Report (GMT->parent, GMT_MSG_ERROR, "Option -%c: Labeling option +Lf requires the fixed label location setting\n", G->flag); |
| 11700 | } |
| 11701 | if (G->label_type == GMT_LABEL_IS_XFILE && G->crossing != GMT_CONTOUR_XCURVE) { /* Requires cross file */ |
| 11702 | error++; |
| 11703 | GMT_Report (GMT->parent, GMT_MSG_ERROR, "Option -%c: Labeling option +Lx requires the crossing lines setting\n", G->flag); |
| 11704 | } |
| 11705 | if (G->spacing && G->dist_kind == 1 && G->label_type == GMT_LABEL_IS_MDIST && G->dist_unit == 0) { /* Did not specify unit - use same as in -G */ |
| 11706 | GMT->current.map.dist[GMT_LABEL_DIST].func = GMT->current.map.dist[GMT_CONT_DIST].func; |
| 11707 | GMT->current.map.dist[GMT_LABEL_DIST].scale = GMT->current.map.dist[GMT_CONT_DIST].scale; |
| 11708 | } |
| 11709 | if ((G->dist_kind == 1 || G->label_type == GMT_LABEL_IS_MDIST) && gmt_M_is_cartesian (GMT, GMT_IN)) { |
| 11710 | GMT_Report (GMT->parent, GMT_MSG_ERROR, "Option -%c: Map distance options requires a map projection.\n", G->flag); |
| 11711 | error++; |
| 11712 | } |
| 11713 | if (G->angle_type == GMT_ANGLE_LINE_PARALLEL) |
| 11714 | G->no_gap = (G->just < 5 || G->just > 7); /* Don't clip contour if label is not in the way */ |
| 11715 | else if (G->angle_type == GMT_ANGLE_LINE_NORMAL) |
| 11716 | G->no_gap = ((G->just + 2)%4 != 0); /* Don't clip contour if label is not in the way */ |
| 11717 | |
| 11718 | if (G->crossing == GMT_CONTOUR_XLINE) { |
| 11719 | G->X = gmt_make_profiles (GMT, G->flag, G->option, G->do_interpolate, true, false, 0.0, GMT_TRACK_FILL, xyz, &dummy); |
| 11720 | } |
| 11721 | else if (G->crossing == GMT_CONTOUR_XCURVE) { |
| 11722 | unsigned int first = 0; |
| 11723 | if (gmt_file_is_cache (GMT->parent, G->file)) { /* Must be a cache file */ |
| 11724 | first = gmt_download_file_if_not_found (GMT, G->file, 0); |
| 11725 | } |
| 11726 | if ((G->X = GMT_Read_Data (GMT->parent, GMT_IS_DATASET, GMT_IS_FILE, GMT_IS_LINE, GMT_READ_NORMAL, NULL, &G->file[first], NULL)) == NULL) { /* Failure to read the file */ |
| 11727 | GMT_Report (GMT->parent, GMT_MSG_ERROR, "Option -%c: Crossing file %s does not exist or had no data records\n", G->flag, G->file); |
| 11728 | error++; |
| 11729 | } |
| 11730 | else if (G->X->n_columns < 2 || G->X->n_records < 2) { |
| 11731 | GMT_Report (GMT->parent, GMT_MSG_ERROR, "Option -%c: Crossing file %s does not have enough columns or records\n", G->flag, G->file); |
| 11732 | GMT_Destroy_Data (GMT, &(G->X)); |
| 11733 | error++; |
| 11734 | } |
| 11735 | else { /* Should be OK to use; note there is only one table here */ |
| 11736 | struct GMT_DATASEGMENT *S = NULL; |
| 11737 | for (k = 0; k < G->X->table[0]->n_segments; k++) { |
no test coverage detected