Esempio n. 1
0
int main(int argc, char *argv[]) {
    int i, verbose = false;
    char *ghaasMetaDB = (char *) NULL, metaFileName[DBDataFileNameLen];
    DBObjData *dbData;
    DBDataset *dbDataset;
    DBObjectLIST<DBObjMetaEntry> *metaList;
    DBObjMetaEntry *metaEntry;

    if (argc < 2) {
        Usage(argv[0]);
        return (0);
    }

    for (i = 1; i < argc; ++i) {
        if ((strcmp(argv[i], "-h") == 0) || (strcmp(argv[i], "--help") == 0)) {
            Usage(argv[0]);
            return (0);
        }
        else if ((strcmp(argv[i], "-V") == 0) || (strcmp(argv[i], "--verbose") == 0)) verbose = true;
        else if (((strcmp(argv[i], "-m") == 0) || (strcmp(argv[i], "--MetaDB") == 0)) && (argc > i + 1)) {
            if (++i < argc) {
                ghaasMetaDB = argv[i];
                break;
            } else {
                Usage(argv[0]);
                return (0);
            }
        }
    }
    if (i == argc) i = 0;
    if (verbose) RGlibPauseOpen(argv[0]);

    if (ghaasMetaDB == (char *) NULL) {
        sprintf(metaFileName, "%s/GHAASMetadb", getenv("GHAAS_DIR") == NULL ? getenv("HOME") : getenv("GHAAS_DIR"));
        ghaasMetaDB = metaFileName;
    }
    dbDataset = new DBDataset((char *) "GHAASmetadb", ghaasMetaDB);
    metaList = dbDataset->MetaList();

    for (; i < argc - 1; ++i) {
        dbData = new DBObjData();
        if (dbData->Read(argv[i + 1]) == DBSuccess) {
            dbData->FileName(argv[i + 1]);
            dbDataset->Data(dbData);
            printf("%s\n", dbData->Name());
            metaEntry = metaList->Item(dbData->Name());
            metaEntry->FileName(dbData->FileName());
            dbDataset->RemoveData(dbData);
        }
        delete dbData;
    }
    delete dbDataset;
    if (verbose) RGlibPauseClose();
    return (0);
}
Esempio n. 2
0
void RGISAnalysePointInterStationTSCBK (Widget widget, RGISWorkspace *workspace,XmAnyCallbackStruct *callData)

	{
	char *selection;
	DBDataset *dataset = UIDataset ();
	DBObjMetaEntry *metaEntry;
	DBObjData *pntData = dataset->Data (), *tsData;
	DBObjTable *relateTBL = pntData->Table (DBrNRelations);
	DBObjRecord *relateRec;
	DBObjTableField *relDataFLD;
	DBObjTableField *relateFLD;
	DBObjTableField *joinFLD;
	static Widget selectWidget = (Widget) NULL;

	if (selectWidget == (Widget) NULL) selectWidget = UISelectionCreate ((char *) "Select Time Series");

	if ((selection = UISelectObject (selectWidget,(DBObjectLIST<DBObject> *) relateTBL)) == (char *) NULL) return;
	if ((relateRec = relateTBL->Item (selection)) == (DBObjRecord *) NULL)
		{ CMmsgPrint (CMmsgAppError, "Relate Record Error in: %s %d",__FILE__,__LINE__); return; }

	relDataFLD = relateTBL->Field (DBrNRelateData);
	relateFLD = relateTBL->Field (DBrNRelateField);
	joinFLD	= relateTBL->Field (DBrNRelateJoinField);

	if ((tsData = dataset->Data (relDataFLD->String (relateRec))) == (DBObjData *) NULL)
		{
		if ((metaEntry = dataset->Meta (relDataFLD->String (relateRec))) == (DBObjMetaEntry *) NULL)
			{ CMmsgPrint (CMmsgAppError, "Meta Enrty Finding Error in: %s %d",__FILE__,__LINE__); return; }
		tsData = new DBObjData ();
		if (tsData->Read (metaEntry->FileName ()) != DBSuccess) return;
		}
	workspace->CurrentData (tsData);

	UIPauseDialogOpen ((char *) "Calculating");
	RGlibPointInterStationTS (pntData,tsData,relateFLD->String (relateRec),joinFLD->String (relateRec));
	UIPauseDialogClose ();
	}
Esempio n. 3
0
int main (int argc,char **argv)

	{
	int argPos, argNum = argc;
	char *metaDB = (char *) NULL;
	int spin = true, progress = true;
	const char *modes [] = { (char *) "yes", (char *) "no", NULL };
	int codes [] = { true, false };
	Widget mainForm;
	RGISWorkspace *workspace;

	for (argPos = 1;argPos < argNum; )
		{
		if (CMargTest (argv [argPos],"-m","--metadb"))
			{
			if ((argNum = CMargShiftLeft (argPos,argv,argc)) <= argPos)
				{ CMmsgPrint (CMmsgUsrError, "Missing metadb argument!"); return (CMfailed); }
			metaDB = argv [argPos];
			if ((argNum = CMargShiftLeft (argPos,argv,argc)) <= argPos) break;
			continue;
			}
		if (CMargTest (argv [argPos],"-p","--progress"))
			{
			if ((argNum = CMargShiftLeft (argPos,argv,argc)) <= argPos)
				{ CMmsgPrint (CMmsgUsrError,"Missing progress mode!");   return (CMfailed); }
			if ((progress = CMoptLookup (modes,argv [argPos],true)) == DBFault)
				{ CMmsgPrint (CMmsgUsrError,"Invalid progress mode!");   return (CMfailed); }
			progress = codes [progress];
			if ((argNum = CMargShiftLeft (argPos,argv,argc)) <= argPos) break;
			continue;
			}
		if (CMargTest (argv [argPos],"-s","--spin"))
			{
			if ((argNum = CMargShiftLeft (argPos,argv,argc)) <= argPos)
				{ CMmsgPrint (CMmsgUsrError,"Missing spin mode!");       return (CMfailed); }
			if ((spin = CMoptLookup (modes,argv [argPos],true)) == DBFault)
				{ CMmsgPrint (CMmsgUsrError,"Invalid spin mode!");	     return (CMfailed); }
			spin = codes [spin];
			if ((argNum = CMargShiftLeft (argPos,argv,argc)) <= argPos) break;
			continue;
			}
		if (CMargTest (argv [argPos],"-P","--planet"))
			{
			int planet;
			const char *planets [] = { "Earth", "Mars", "Venus", NULL };
			DBFloat radius [] = { 6371.2213, 6371.2213 * 0.53264, 6371.2213 * 0.94886 };

			if ((argNum = CMargShiftLeft (argPos,argv,argc)) <= argPos)
				{ CMmsgPrint (CMmsgUsrError,"Missing planet!");	       return (CMfailed); }
			if ((planet = CMoptLookup (planets,argv [argPos],true)) == DBFault)
				{
				if (sscanf (argv [argPos],"%lf",radius) != 1)
					{ CMmsgPrint (CMmsgUsrError,"Invalid planet!");      return (CMfailed); }
				planet = 0;
				}
			DBMathSetGlobeRadius (radius [planet]);
			if ((argNum = CMargShiftLeft (argPos,argv,argc)) <= argPos) break;
			continue;
			}
		if (CMargTest (argv [argPos],"-h","--help"))
			{
			CMmsgPrint (CMmsgInfo, "rgis [options]");
			CMmsgPrint (CMmsgInfo, "     -m, --metadb   [meta database]");
			CMmsgPrint (CMmsgInfo, "     -p, --progress [yes|no]");
			CMmsgPrint (CMmsgInfo, "     -s, --spin     [yes|no]");
			CMmsgPrint (CMmsgInfo, "     -P, --planet   [Earth|Mars|Venus|radius]");
			CMmsgPrint (CMmsgInfo, "     -h, --help");
			return (DBSuccess);
			}
		if ((argv [argPos][0] == '-') && (strlen (argv [argPos]) > 1))
			{ CMmsgPrint (CMmsgUsrError, "Unknown option: %s!",argv [argPos]); return (DBFault); }
		argPos++;
		}

	workspace = new RGISWorkspace;
	mainForm = UIInitialize ((char *) "GHAAS V2.2 - RiverGIS",(char *) "GHAASrgis",(char *) "RGISMain.html",
									 RGISMainMenu,(void *) workspace,&argc,argv,720,500,(bool) spin,(bool) progress);

	UIDataset ((char *) "GHAASrgis",metaDB);

	XtVaSetValues (mainForm,XmNkeyboardFocusPolicy,		XmPOINTER, NULL);

	workspace->Initialize (mainForm);

	if (argNum > 1)
		{
		DBDataset *dataset;
		DBObjData *data;
		DBObjectLIST<DBObjMetaEntry> *metaList;
		DBObjMetaEntry *metaEntry;

		dataset  = UIDataset ();
		metaList = dataset->MetaList ();

		for (argPos = 1;argPos < argNum; ++argPos)
			{
			data = new DBObjData ();
			if (data->Read (argv [argPos]) == DBSuccess)
				{
				workspace->CurrentData (data);
				metaEntry = metaList->Item (data->Name ());
				metaEntry->FileName (data->FileName ());
				}
			else delete data;
			}
		}
	while (UILoop ());
	delete UIDataset ();
	return (DBSuccess);
	}