/********************************************************************** * main() * * This program is used to dump binary files (default behavior), and to * test some parts of the lib. during the development process. **********************************************************************/ int main(int argc, char *argv[]) { const char *pszFname; /*--------------------------------------------------------------------- * Read program arguments. *--------------------------------------------------------------------*/ if (argc<3) { printf("%s", TABTEST_USAGE); return 1; } else { pszFname = argv[2]; } /*--------------------------------------------------------------------- * With option -blocks <filename> * Open file, and dump each block sequentially. *--------------------------------------------------------------------*/ if (EQUALN(argv[1], "-blocks", 2)) { if (strstr(pszFname, ".map") != NULL || strstr(pszFname, ".MAP") != NULL) { DumpMapFileBlocks(pszFname); } else if (strstr(pszFname, ".ind") != NULL || strstr(pszFname, ".IND") != NULL) { DumpIndFileObjects(pszFname); } else if (strstr(pszFname, ".otherextension") != NULL) { ; } } /*--------------------------------------------------------------------- * With option -blocks <filename> * Open file, and dump each block sequentially. *--------------------------------------------------------------------*/ else if (EQUALN(argv[1], "-details", 2) && argc >= 4) { if (strstr(pszFname, ".map") != NULL || strstr(pszFname, ".MAP") != NULL) { DumpMapFileBlockDetails(pszFname, atoi(argv[3])); } else if (strstr(pszFname, ".otherextension") != NULL) { ; } } /*--------------------------------------------------------------------- * With option -objects <filename> * Open file, and all geogr. objects. *--------------------------------------------------------------------*/ else if (EQUALN(argv[1], "-objects", 2)) { if (strstr(pszFname, ".map") != NULL || strstr(pszFname, ".MAP") != NULL) { DumpMapFileObjects(pszFname); } else if (strstr(pszFname, ".tab") != NULL || strstr(pszFname, ".TAB") != NULL) { DumpTabFile(pszFname); } else if (strstr(pszFname, ".ind") != NULL || strstr(pszFname, ".IND") != NULL) { DumpIndFileObjects(pszFname); } } /*--------------------------------------------------------------------- * With option -spatialindex <filename> [maxdepth] * Dump Spatial Index Tree of .MAP file *--------------------------------------------------------------------*/ else if (EQUALN(argv[1], "-spatialindex", 2)) { if (strstr(pszFname, ".map") != NULL || strstr(pszFname, ".MAP") != NULL) { if (argc >= 4) DumpMapFileIndexTree2MIF(pszFname, atoi(argv[3])); else DumpMapFileIndexTree2MIF(pszFname, -1); } } /*--------------------------------------------------------------------- * With option -all <filename> * Dump the whole TAB dataset (all supported files) *--------------------------------------------------------------------*/ else if (EQUALN(argv[1], "-all", 2)) { if (strstr(pszFname, ".tab") != NULL || strstr(pszFname, ".TAB") != NULL || strstr(pszFname, ".mif") != NULL || strstr(pszFname, ".MIF") != NULL) { DumpTabFile(pszFname); } } /*--------------------------------------------------------------------- * With option -coordsys <filename> * Dump the dataset's projection string *--------------------------------------------------------------------*/ else if (EQUALN(argv[1], "-coordsys", 2)) { if (strstr(pszFname, ".tab") != NULL || strstr(pszFname, ".TAB") != NULL) { DumpCoordsys(pszFname); } } /*--------------------------------------------------------------------- * With option -Ccoordsys <filename> * Dump the dataset's coordsys and bounds info in a C struct format *--------------------------------------------------------------------*/ else if (EQUALN(argv[1], "-Ccoordsys", 3)) { if (strstr(pszFname, ".tab") != NULL || strstr(pszFname, ".TAB") != NULL) { DumpCoordsysStruct(pszFname); } } /*--------------------------------------------------------------------- * With option -index <filename> <indexno> <value> * Search specified index for a value. *--------------------------------------------------------------------*/ else if (EQUALN(argv[1], "-index", 2) && argc >=5) { SearchIndex(pszFname, atoi(argv[3]), argv[4]); } /*--------------------------------------------------------------------- * With option -envelope <filename> <xmin> <ymin> <ymax> <ymax> * Dump all objects that intersect the envelope. Scan via spatial index. *--------------------------------------------------------------------*/ else if (EQUALN(argv[1], "-envelope", 2) && argc >= 7) { if (strstr(pszFname, ".tab") != NULL || strstr(pszFname, ".TAB") != NULL) { DumpViaSpatialIndex(pszFname, atof(argv[3]), atof(argv[4]), atof(argv[5]), atof(argv[6])); } } /*--------------------------------------------------------------------- * With option -otheroption <filename> ... * ... do something else ... *--------------------------------------------------------------------*/ else if (EQUALN(argv[1], "-otheroption", 2)) { ; } else { printf("Cannot process file %s\n\n", pszFname); printf("%s", TABTEST_USAGE); return 1; } return 0; }
/********************************************************************** * main() * * This program is used to dump binary files (default behavior), and to * test some parts of the lib. during the development process. **********************************************************************/ int main(int argc, char *argv[]) { const char *pszFname; /*--------------------------------------------------------------------- * Read program arguments. *--------------------------------------------------------------------*/ if (argc<3) { printf("%s", TABTEST_USAGE); return 1; } else { pszFname = argv[2]; } /*--------------------------------------------------------------------- * With option -blocks <filename> * Open file, and dump each block sequentially. *--------------------------------------------------------------------*/ if (EQUALN(argv[1], "-blocks", 2)) { if (strstr(pszFname, ".map") != NULL || strstr(pszFname, ".MAP") != NULL) { DumpMapFileBlocks(pszFname); } else if (strstr(pszFname, ".ind") != NULL || strstr(pszFname, ".IND") != NULL) { DumpIndFileObjects(pszFname); } else if (strstr(pszFname, ".otherextension") != NULL) { ; } } /*--------------------------------------------------------------------- * With option -objects <filename> * Open file, and all geogr. objects. *--------------------------------------------------------------------*/ else if (EQUALN(argv[1], "-objects", 2)) { if (strstr(pszFname, ".map") != NULL || strstr(pszFname, ".MAP") != NULL) { DumpMapFileObjects(pszFname); } else if (strstr(pszFname, ".tab") != NULL || strstr(pszFname, ".TAB") != NULL) { DumpTabFile(pszFname); } else if (strstr(pszFname, ".ind") != NULL || strstr(pszFname, ".IND") != NULL) { DumpIndFileObjects(pszFname); } } /*--------------------------------------------------------------------- * With option -all <filename> * Dump the whole TAB dataset (all supported files) *--------------------------------------------------------------------*/ else if (EQUALN(argv[1], "-all", 2)) { if (strstr(pszFname, ".tab") != NULL || strstr(pszFname, ".TAB") != NULL) { DumpTabFile(pszFname); } } /*--------------------------------------------------------------------- * With option -coordsys <filename> * Dump the dataset's projection string *--------------------------------------------------------------------*/ else if (EQUALN(argv[1], "-coordsys", 2)) { if (strstr(pszFname, ".tab") != NULL || strstr(pszFname, ".TAB") != NULL) { DumpCoordsys(pszFname); } } /*--------------------------------------------------------------------- * With option -index <filename> <indexno> <value> * Search specified index for a value. *--------------------------------------------------------------------*/ else if (EQUALN(argv[1], "-index", 2) && argc >=5) { SearchIndex(pszFname, atoi(argv[3]), argv[4]); } /*--------------------------------------------------------------------- * With option -otheroption <filename> ... * ... do something else ... *--------------------------------------------------------------------*/ else if (EQUALN(argv[1], "-otheroption", 2)) { ; } else { printf("Cannot process file %s\n\n", pszFname); printf("%s", TABTEST_USAGE); return 1; } return 0; }