Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

kml2gmt, add KEYS for reading #183

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/gmt_core_module.c
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ static struct Gmt_moduleinfo g_core_module[] = {
{"grdvolume", "core", "Calculate grid volume and area constrained by a contour", "<G{,>D}"},
{"greenspline", "core", "Interpolate using Green's functions for splines in 1-3 dimensions", "<D{,AD(=,ED),ND(,TG(,CD)=f,G?},GDN"},
{"inset", "core", "Manage modern mode figure inset design and completion", ">X}"},
{"kml2gmt", "core", "Extract GMT table data from Google Earth KML files", ">D}"},
{"kml2gmt", "core", "Extract GMT table data from Google Earth KML files", "<D{,>D}"},
{"makecpt", "core", "Make GMT color palette tables", ">C},ED(,SD(,TD("},
{"mapproject", "core", "Forward and inverse map transformations, datum conversions and geodesy", "<D{,LD(=,>D},W-("},
{"movie", "core", "Create animation sequences and movies", ""},
Expand Down Expand Up @@ -198,7 +198,7 @@ static struct Gmt_moduleinfo g_core_module[] = {
{"grdvolume", "core", "Calculate grid volume and area constrained by a contour", "<G{,>D}", &GMT_grdvolume},
{"greenspline", "core", "Interpolate using Green's functions for splines in 1-3 dimensions", "<D{,AD(=,ED),ND(,TG(,CD)=f,G?},GDN", &GMT_greenspline},
{"inset", "core", "Manage modern mode figure inset design and completion", ">X}", &GMT_inset},
{"kml2gmt", "core", "Extract GMT table data from Google Earth KML files", ">D}", &GMT_kml2gmt},
{"kml2gmt", "core", "Extract GMT table data from Google Earth KML files", "<D{,>D}", &GMT_kml2gmt},
{"makecpt", "core", "Make GMT color palette tables", ">C},ED(,SD(,TD(", &GMT_makecpt},
{"mapproject", "core", "Forward and inverse map transformations, datum conversions and geodesy", "<D{,LD(=,>D},W-(", &GMT_mapproject},
{"movie", "core", "Create animation sequences and movies", "", &GMT_movie},
Expand Down
13 changes: 7 additions & 6 deletions src/kml2gmt.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
#define THIS_MODULE_NAME "kml2gmt"
#define THIS_MODULE_LIB "core"
#define THIS_MODULE_PURPOSE "Extract GMT table data from Google Earth KML files"
#define THIS_MODULE_KEYS ">D}"
#define THIS_MODULE_KEYS "<D{,>D}"
#define THIS_MODULE_NEEDS ""
#define THIS_MODULE_OPTIONS "-:Vbdh" GMT_OPT("HMm")

Expand All @@ -37,16 +37,16 @@
#define POLYGON 2

struct KML2GMT_CTRL {
struct In { /* in file */
struct KML2GMT_In { /* in file */
bool active;
char *file;
} In;
struct F { /* -F */
struct KML2GMT_F { /* -F */
bool active;
unsigned int mode;
unsigned int geometry;
} F;
struct Z { /* -Z */
struct KML2GMT_Z { /* -Z */
bool active;
} Z;
};
Expand Down Expand Up @@ -144,7 +144,8 @@ GMT_LOCAL int parse (struct GMT_CTRL *GMT, struct KML2GMT_CTRL *Ctrl, struct GMT

if (GMT->common.b.active[GMT_IN] && GMT->common.b.ncol[GMT_IN] == 0) GMT->common.b.ncol[GMT_IN] = 2;
n_errors += gmt_M_check_condition (GMT, n_files > 1, "Syntax error: Only one file can be processed at the time\n");
n_errors += gmt_M_check_condition (GMT, Ctrl->In.active && access (Ctrl->In.file, R_OK), "Syntax error: Cannot read file %s\n", Ctrl->In.file);
n_errors += gmt_M_check_condition (GMT, !GMT->parent->external && Ctrl->In.active && access (Ctrl->In.file, R_OK),
"Syntax error: Cannot read file %s\n", Ctrl->In.file);

return (n_errors ? GMT_PARSE_ERROR : GMT_NOERROR);
}
Expand Down Expand Up @@ -212,7 +213,7 @@ int GMT_kml2gmt (void *V_API, int mode, void *args) {
* P. Wessel, April 2013. */

if (Ctrl->In.active) {
if ((fp = gmt_fopen (GMT, Ctrl->In.file, "r")) == NULL) {
if (!GMT->parent->external && (fp = gmt_fopen (GMT, Ctrl->In.file, "r")) == NULL) {
GMT_Report (API, GMT_MSG_NORMAL, "Cannot open file %s\n", Ctrl->In.file);
Return (GMT_ERROR_ON_FOPEN);
}
Expand Down