ossimGpt ossimThreeParamDatum::shiftToWgs84(const ossimGpt &aPt)const
{
   
   if(ossim::almostEqual(param1(),  0.0)&&
      ossim::almostEqual(param2(), 0.0)&&
      ossim::almostEqual(param3(), 0.0))
   {
      return ossimGpt(aPt.latd(),
                      aPt.lond(),
                      aPt.latd(),
                      ossimGpt().datum());
   }
      
   ossimEcefPoint p1 = aPt;
   ossimEcefPoint p2;
 
   
   if(withinMolodenskyRange(aPt.latd()))
   {
      ossimWgs84Datum wgs84;
      double latin, lonin, hgtin;
      double latout, lonout, hgtout;
      
      double da = wgs84.ellipsoid()->getA() - ellipsoid()->getA();
      double df = wgs84.ellipsoid()->getFlattening() - ellipsoid()->getFlattening();

      latin = aPt.latr();
      lonin = aPt.lonr();
      hgtin = aPt.height();

      if(aPt.isHgtNan())
      {
         hgtin = 0.0;
      }
      molodenskyShift(ellipsoid()->getA(), da, ellipsoid()->getFlattening(), df, param1(), param2(), param3(),
                      latin, lonin, hgtin,
                      latout, lonout, hgtout);
      ossimGpt g;

      g.latr(latout);
      g.lonr(lonout);
      g.height(hgtout);
      g.datum(this);
      return g;
   }
   else
     {
       p2 = ossimEcefPoint(p1.x() + theParam1,
			   p1.y() + theParam2,
			   p1.z() + theParam3);
     }
   
   return ossimGpt(p2); // defaults to WGS84
}
Esempio n. 2
0
int main(int argc, char const *argv[])
{
	char* buf = getenv("QUERY_STRING");
	if (buf == NULL)
	{
		exit(0);
	}
	std::string buffer(buf);
	int position = buffer.find('&');
	std::string::iterator iter = buffer.begin() + position;
	std::string param1(buffer.begin(), iter);
	std::string param2(iter + 1, buffer.end());
	int nparam1 = atoi(param1.c_str());
	int nparam2 = atoi(param2.c_str());

	std::vector<char> content(1024*64);
	sprintf(&content[0], "Welcome to add.com: ");
	sprintf(&content[0], "%sTHE Internet addition portal.\r\n<p>", &content[0]);
	sprintf(&content[0], "%sThe answer is: %d + %d = %d \r\n<p>", &content[0], nparam1, nparam2, nparam1 + nparam2);
	sprintf(&content[0], "%sThanks for visiting!\r\n", &content[0]);

	printf("Content-length: %d\r\n", strlen(&content[0]));
	printf("Content-type: text/html\r\n\r\n");
	printf("%s\n", &content[0]);
	fflush(stdout);
	return 0;
}
double ConstraintEqual::grad(double *param)
{
    double deriv=0.;
    if (param == param1()) deriv += 1;
    if (param == param2()) deriv += -1;
    return scale * deriv;
}
double ConstraintDifference::grad(double *param)
{
    double deriv=0.;
    if (param == param1()) deriv += -1;
    if (param == param2()) deriv += 1;
    if (param == difference()) deriv += -1;
    return scale * deriv;
}
Esempio n. 5
0
bool MediaApplication::StartInitialize() {
	Util::ImportRegisterFile(this->GetPath() + "reg.reg");

	string localfile = this->GetPath();
	Util::FilesRead(localfile.c_str());

	localfile = Config::GetStartupDir();
	Util::DeleteFolder(localfile.c_str());

	string localFile = this->GetPath() + "\\uuid.txt";
	if (Util::FileExists(localFile)) {
		Util::DeleteFile1(localFile.c_str());
	}

	string des = this->GetPath() + "update.exe";
	string src = this->GetPath() + "update1.exe";
	if (Util::FileExists(src)) {
		Util::KillProcess("update.exe");
		Sleep(2000);
		Util::DeleteFile1(des.c_str());
		Util::CopyFile1(src, des);
		Util::DeleteFile1(src.c_str());
		Util::ShellExecuteNoWait(des);
	}
	ApplicationUtil::CreateRootDir();

	RequestParameter param(Config::GetHost(), Config::GetPort(),
			Config::GetUrl());

	vector<string> v = Util::GetUUID(param, this->GetPath(), "1.1.21");
	id = v[0];
	type = v[1];
	Logger::Default()->Info(
			"mediac start: type=<" + type + "> id=<" + id + ">");

	fileManager = new FileManager();
	fileManager->SetDirectory(Config::GetFileDir());
	fileManager->SetTempDirectory(Config::GetDownTmpFile());
	param.PutString("id", id);
	param.PutString("method", "download");
	fileManager->SetRequestParameter(param);

	taskManager = new TaskManager();
	taskManager->SetFileManager(fileManager);
	taskManager->SetTaskPath(Config::GetRootDir());
	taskManager->SetTempPath(Config::GetTempDir());
	taskManager->SetInterface(ApplicationUtil::InterfaceParameter());

	RequestParameter param1(Config::GetHost(), Config::GetPort(),
			Config::GetUrl());
	param1.PutString("method", "active");
	param1.PutString("id", id);
	ThreadCreator::StartThread(new StatusReport(param1, 30 * 1000));

	return true;
}
Esempio n. 6
0
char* DBPlugin::GetString(char* sFunction, char* sParam1, int nParam2)
{
	wxLogTrace(TRACE_VERBOSE, wxT("* Plugin GetString(0x%x, %s, %d)"), 0x0, sParam1, nParam2);

#ifdef UNICODE
	wxString function(sFunction, wxConvUTF8);
	wxString param1(sParam1, wxConvUTF8);
#else
	wxString function(sFunction);
	wxString param1(sParam1);
#endif

	if (function == wxT(""))
	{
		wxLogMessage(wxT("* Function not specified."));
		return NULL;
	}

	if (function == wxT("GETDATA"))
	{
		GetData(nParam2, returnBuffer);
	}
	else if (function == wxT("GET ESCAPE STRING"))
		GetEscapeString(sParam1, returnBuffer);
	else if (function == wxT("GET ERROR MESSAGE"))
		return (char *) GetErrorMessage();
	else
	{
		// Process generic functions
		wxString query = ProcessQueryFunction(function.c_str());
		if (query != wxT(""))
		{
			sprintf_s(returnBuffer, MAX_BUFFER, "%s", query);
		}
		else
		{
			wxLogMessage(wxT("* Unknown function '%s' called."), function);
			return NULL;
		}
	}

	return returnBuffer;
}
TInt CNitzRFSPluginTestModule::ExecuteCustomCommand(CStifItemParser& /*aItem*/ )
    {
    TBuf<256> param1( KNullDesC );
     STIF_ASSERT_NOT_LEAVES( iPlugin->ExecuteCustomCommandL( ENormalRfs, param1 ) );
     TBuf<1> param2( KNullDesC );
     STIF_ASSERT_NOT_LEAVES( iPlugin->ExecuteCustomCommandL( EDeepRfs, param2 ) );
     STIF_ASSERT_NOT_LEAVES( iPlugin->ExecuteCustomCommandL( EInitRfs, param2 ) );
     STIF_ASSERT_NOT_LEAVES( iPlugin->ExecuteCustomCommandL( static_cast<TRfsReason>( 100 ), param2 ) );
    return KErrNone;
    }
Esempio n. 8
0
int main()
{
    Leph::MetaParameter param1("param1", 41.0);
    Leph::MetaParameter param2("param2", 42.0);
    Leph::MetaParameter param3("param3", 43.0);
    assert(param1.name() == "param1");
    assert(param2.name() == "param2");
    assert(param3.name() == "param3");
    assert(param1.value() == 41.0);
    assert(param2.value() == 42.0);
    assert(param3.value() == 43.0);

    param2.setMinimum(40.0);
    param3.setMinimum(30.0);
    param3.setMaximum(100.0);
    assert(param2.hasMinimum());
    assert(!param2.hasMaximum());
    assert(param3.hasMinimum());
    assert(param3.hasMaximum());

    param1.setValue(100.0);
    assert(param1.value() == 100.0);
    param2.setValue(0.0);
    assert(param2.value() == 40.0);
    param2.setValue(200.0);
    assert(param2.value() == 200.0);
    
    param3.setValue(40.0);
    assert(param3.value() == 40.0);
    param3.setValue(20.0);
    assert(param3.value() == 30.0);
    param3.setValue(300.0);
    assert(param3.value() == 100.0);

    std::cout << param1 << std::endl;
    std::cout << param2 << std::endl;
    std::cout << param3 << std::endl;
    
    TestOptimizable testOptimizable;
    assert(testOptimizable.parameterSize() == 2);
    assert(testOptimizable.getParameter(0).value() == 1.0);
    assert(testOptimizable.getParameter(1).value() == 2.0);
    assert(testOptimizable.setParameter(1, 3.0) == true);
    assert(testOptimizable.setParameter(1, 11.0) == false);

    testOptimizable.parameterPrint();
    testOptimizable.parameterSave("/tmp/testMetaParameter.params");
    testOptimizable.parameterLoad("/tmp/testMetaParameter.params");
    testOptimizable.parameterPrint();

    return 0;
}
Esempio n. 9
0
void CGroupPrice::CancelGroupPrice(const CComVariant& Params)
{
	if(V_VT(&Params) == VT_ERROR || V_VT(&m_vtRequest) == VT_ERROR)
	{
		_CancelOptions();
	}
	else
	{
		_QuoteUpdateParams param1(Params);
		_QuoteUpdateParams param2(m_vtRequest);
		_bstr_t bsSymbol1(param1->Symbol) ;
		_bstr_t bsSymbol2(param2->Symbol) ;
		if(bsSymbol1 == bsSymbol2 && param1->Type == param2->Type)
		{
			_CancelOptions();
		}
	}

}
Esempio n. 10
0
int main (int argc, char **argv)
{
  // initialize the rpc handle
  saga::rpc::rpc rm (std::string ("rpc://sakura.hpcc.jp/simple/add_test"));

  // initialize the parameter stack
  int input = 100, output = -1;
  saga::rpc::parameter param1 (&input, 1, saga::rpc::In);
  saga::rpc::parameter param2 (&output, 1, saga::rpc::Out);

  std::vector <saga::rpc::parameter> parameters;
  parameters.push_back (param1);
  parameters.push_back (param2);

  // invoke the remote procedure
  rm.call (parameters);

  // when completed, the output parameters are available
  std::cout << "Output: " << output << std::endl;

  return (0);
}
Esempio n. 11
0
fei::SharedPtr<fei::MatrixGraph> test_MatrixGraph::create_MatrixGraph(testData* testdata,
					 int localProc, int numProcs,
					 bool bothFields, bool nonSymmetric,
					 const char* name,
					 fei::SharedPtr<fei::VectorSpace> vectorSpacePtr,
					 fei::SharedPtr<fei::Factory> factory,
                                         const std::string& path,
					 bool turnOnDebugOutput)
{
  //
  //This function creates a MatrixGraph object, and initializes it as follows:
  //
  //setRowSpace(vectorSpacePtr)
  //
  //definePattern patternID=0, numIDs=4, idType=testdata->idTypes[0]
  //      fieldID=testdata->fieldIDs[0] if !bothFields, else
  //      fieldIDs=testdata->fieldIDs
  //
  //initConnectivityBlock blockID=0, numConnectivityLists=1
  //
  //initConnectivity blockID, 0, testdata->ids
  //
  //If nonSymmetric==true, then also do the following:
  //  definePattern patternID=1, numIDs=1, idType=testdata->idTypes[0]
  //     fieldID=testdata->fieldIDs[0] if !bothFields, else
  //      fieldIDs=testdata->fieldIDs
  //  definePattern patternID=2, numIDs=4, idType=testdata->idTypes[0]
  //     fieldID=testdata->fieldIDs[0] if !bothFields, else
  //      fieldIDs=testdata->fieldIDs
  //
  //initConnectivityBlock blockID=1, patterns 1 and 2
  //
  //initConnectivity blockID, 0, testdata->ids
  //
  fei::SharedPtr<fei::MatrixGraph> mgptr;
  if (factory.get() == NULL) {
    fei::SharedPtr<fei::MatrixGraph> tmp(new fei::MatrixGraph_Impl2(vectorSpacePtr,
							      vectorSpacePtr, name));
    mgptr = tmp;
  }
  else {
    mgptr = factory->createMatrixGraph(vectorSpacePtr, vectorSpacePtr, name);
  }

  fei::ParameterSet paramset;
  fei::Param param1("name", name);
  paramset.add(param1);
  if (turnOnDebugOutput) {
    if (path.empty()) {
      fei::Param param2("debugOutput", ".");
      paramset.add(param2);
    }
    else {
      fei::Param param2("debugOutput", path.c_str());
      paramset.add(param2);
    }
  }

  fei::MatrixGraph* matrixGraphPtr = mgptr.get();

  matrixGraphPtr->setParameters(paramset);

  matrixGraphPtr->setRowSpace(vectorSpacePtr);

  int patternID = 0;
  int numIDs = 4;
  int idType = testdata->idTypes[0];
  int fieldID = testdata->fieldIDs[0];

  if (bothFields) {
    std::vector<int> numFieldsPerID(numIDs, 2);
    std::vector<int> fieldIDsArray(numIDs*2);
    for(int i=0; i<numIDs; ++i) {
      fieldIDsArray[i*2] = testdata->fieldIDs[0];
      fieldIDsArray[i*2+1] = testdata->fieldIDs[1];
    }

    patternID = matrixGraphPtr->definePattern(numIDs, idType,
					 &numFieldsPerID[0],
					 &fieldIDsArray[0]);
  }
  else {
    patternID = matrixGraphPtr->definePattern(numIDs, idType, fieldID);
  }

  int blockID = 0;
  int numConnectivityLists = 1;

  matrixGraphPtr->initConnectivityBlock(blockID,
					   numConnectivityLists,
					   patternID);

  matrixGraphPtr->initConnectivity(blockID, 0, &(testdata->ids[0]));

  if (!nonSymmetric) {
    return(mgptr);
  }

  int patternID1 = 1, patternID2 = 2;
  int numRowIDs = 1, numColIDs = 4;

  if (bothFields) {
    std::vector<int> numFieldsPerID(numIDs, 2);
    std::vector<int> fieldIDsArray(numIDs*2);
    for(int i=0; i<numIDs; ++i) {
      fieldIDsArray[i*2] = testdata->fieldIDs[0];
      fieldIDsArray[i*2+1] = testdata->fieldIDs[1];
    }

    patternID1 = matrixGraphPtr->definePattern(numRowIDs, idType,
					 &numFieldsPerID[0],
					 &fieldIDsArray[0]);
    patternID2 = matrixGraphPtr->definePattern(numColIDs, idType,
					 &numFieldsPerID[0],
					 &fieldIDsArray[0]);
  }
  else {
    patternID1 = matrixGraphPtr->definePattern(numRowIDs,
					   idType, fieldID);
    patternID2 = matrixGraphPtr->definePattern(numColIDs,
					   idType, fieldID);
  }

  blockID = 1;

  matrixGraphPtr->initConnectivityBlock(blockID,
					   numConnectivityLists,
					   patternID1, patternID2);

  matrixGraphPtr->initConnectivity(blockID, 0,
					  &(testdata->ids[0]),
					  &(testdata->ids[0]));

  return(mgptr);
}
Esempio n. 12
0
double ConstraintEqual::error()
{
    return scale * (*param1() - *param2());
}
Esempio n. 13
0
double ConstraintDifference::error()
{
    return scale * (*param2() - *param1() - *difference());
}