RESULTCODE GetDataSourceResponse::Write(WebWriter* pWriter)
	{
		if(pWriter==NULL)
		{
			return AG_FAILURE;
		}

		GLogger* pLogger = augeGetLoggerInstance();

		Workspace* pWorkspace = NULL;
		ConnectionManager* pConnManager = augeGetConnectionManagerInstance();

		XDocument	*pxDoc = new XDocument();
		XElement	*pxRoot = pxDoc->CreateRootNode("IMS_DataSources", NULL, NULL);

		const char* name = m_pRequest->GetName();
		if(name==NULL)
		{
			g_uint count = pConnManager->GetCount();
			for(g_uint i=0; i<count; i++)
			{
				pWorkspace = pConnManager->GetWorkspace(i);
				AddDataSourceNode(pxRoot, pWorkspace);
			}
		}
		else
		{
			pWorkspace = pConnManager->GetWorkspace(name);
			if(pWorkspace!=NULL)
			{
				AddDataSourceNode(pxRoot, pWorkspace);
			}
		}

		int len = 0;
		g_uchar* buffer = NULL;
		pxDoc->WriteToString(&buffer, len, "GBK",0);

		pWriter->WriteHead(m_pRequest->GetMimeType());
		pWriter->Write(buffer, len);
		pWriter->WriteTail();

		pLogger->Info((g_char*)buffer);

		pxDoc->Close();
		AUGE_SAFE_RELEASE(pxDoc);
		return AG_SUCCESS;
	}
	FeatureClass* DescribeFeatureTypeHandler::GetFeatureClassBySource(WebRequest* pWebRequest, WebContext* pWebContext, User* pUser)
	{
		const char* typeName = NULL;
		Layer* pLayer = NULL;
		GLogger *pLogger = augeGetLoggerInstance();
		DescribeFeatureTypeRequest* pRequest = static_cast<DescribeFeatureTypeRequest*>(pWebRequest);
		typeName = pRequest->GetTypeName();

		const char* sourceName = pRequest->GetSourceName();
		if(sourceName==NULL)
		{
			GError* pError = augeGetErrorInstance();
			pError->SetError("No Source is attached");
			return NULL;
		}

		ConnectionManager* pConnManager = augeGetConnectionManagerInstance();
		Workspace* pWorkspace = pConnManager->GetWorkspace(pUser->GetID(), sourceName);
		if(pWorkspace==NULL)
		{
			char msg[AUGE_MSG_MAX];
			g_sprintf(msg, "No DataSource Named [%s]", sourceName);
			GError* pError = augeGetErrorInstance();
			pError->SetError(msg);
			return NULL;
		}

		FeatureWorkspace* pFeatureWorkspace = dynamic_cast<FeatureWorkspace*>(pWorkspace);
		FeatureClass* pFeatureClass = pFeatureWorkspace->OpenFeatureClass(typeName);
		if(pFeatureClass==NULL)
		{
			char msg[AUGE_MSG_MAX];
			g_sprintf(msg, "Cannot Get FeatureType %s",typeName);
			pLogger->Error(msg, __FILE__, __LINE__);
			GError* pError = augeGetErrorInstance();
			pError->SetError(msg);
			return NULL;
		}
		return pFeatureClass;
	}
示例#3
0
	WebResponse* TransactionHandler::ExecuteBySource(WebRequest* pWebRequest, WebContext* pWebContext, User* pUser)
	{
		GLogger *pLogger = augeGetLoggerInstance();

		TransactionRequest* pRequest = static_cast<TransactionRequest*>(pWebRequest);

		const char* sourceName = pRequest->GetSourceName();
		if(sourceName==NULL)
		{
			char msg[AUGE_MSG_MAX];
			WebExceptionResponse* pExpResponse = augeCreateWebExceptionResponse();
			g_sprintf(msg, "No DataSource is Defined");
			pExpResponse->SetMessage(msg);
			return pExpResponse;
		}

		ConnectionManager* pConnManager = augeGetConnectionManagerInstance();
		FeatureWorkspace* pWorkspace = dynamic_cast<FeatureWorkspace*>(pConnManager->GetWorkspace(pUser->GetID(), sourceName));
		if(pWorkspace==NULL)
		{
			char msg[AUGE_MSG_MAX];
			g_sprintf(msg, "No DataSource Named [%s]", sourceName);
			GError* pError = augeGetErrorInstance();
			pError->SetError(msg);
			WebExceptionResponse* pExpResponse = augeCreateWebExceptionResponse();
			pExpResponse->SetMessage(msg);
			return pExpResponse;
		}

		const char* typeName = NULL;
		Layer* pLayer = NULL;

		XDocument* pxDoc = NULL;
		pxDoc = pRequest->GetXmlDoc();
		if(pxDoc==NULL)
		{
			WebExceptionResponse* pExpResponse = augeCreateWebExceptionResponse();
			pExpResponse->SetMessage("transaction xml parse error");
			return pExpResponse;
		}


		XNodeSet	*pxNodeSet = NULL;
		XElement	*pxRoot = pxDoc->GetRootNode();
		pxNodeSet = pxRoot->GetChildren("Insert");
		g_uint num_insert = Insert(pxNodeSet, pWebContext, pWorkspace);
		pxNodeSet->Release();

		pxNodeSet = pxRoot->GetChildren("Update");
		g_uint num_update = Update(pxNodeSet, pWebContext, pWorkspace);
		pxNodeSet->Release();

		pxNodeSet = pxRoot->GetChildren("Delete");
		g_uint num_delete = Delete(pxNodeSet, pWebContext, pWorkspace);
		pxNodeSet->Release();

		TransactionResponse *pResponse = new TransactionResponse(pRequest);	
		pResponse->SetInsertCount(num_insert);
		pResponse->SetUpdateCount(num_update);
		pResponse->SetDeleteCount(num_delete);

		return pResponse;
	}
	RESULTCODE PolygonToLineProcessorImpl::Execute()
	{
		GError	*pError  = augeGetErrorInstance();
		GLogger	*pLogger = augeGetLoggerInstance();

		const char* sourceName_in = GetInputSource();
		const char* className_in  = GetInputFatureClass();

		const char* sourceName_out= GetOutputSource();
		const char* className_out = GetOutputFatureClass();

		if(sourceName_in==NULL)
		{
			return AG_FAILURE;
		}

		if(className_in==NULL)
		{
			return AG_FAILURE;
		}

		if(sourceName_out==NULL)
		{
			return AG_FAILURE;
		}

		if(className_out==NULL)
		{
			return AG_FAILURE;
		}
		
		FeatureClass		*pinFeatureClass = NULL;
		FeatureClass		*poutFeatureClass= NULL;
		FeatureWorkspace	*pinWorkspace = NULL;
		FeatureWorkspace	*poutWorkspace= NULL;
		ConnectionManager	*pConnManager = augeGetConnectionManagerInstance();
		
		pinWorkspace = dynamic_cast<FeatureWorkspace*>(pConnManager->GetWorkspace(m_user, sourceName_in));
		if(pinWorkspace==NULL)
		{
			return AG_FAILURE;
		}

		poutWorkspace = dynamic_cast<FeatureWorkspace*>(pConnManager->NewWorkspace(m_user, sourceName_out));
		if(poutWorkspace==NULL)
		{
			return AG_FAILURE;
		}

		pinFeatureClass = pinWorkspace->OpenFeatureClass(className_in);
		if(pinFeatureClass==NULL)
		{
			poutWorkspace->Release();
			return AG_FAILURE;
		}

		GField* pField = pinFeatureClass->GetFields()->GetGeometryField();
		if(pField==NULL)
		{
			pinFeatureClass->Release();
			poutWorkspace->Release();
			return AG_FAILURE;
		}
		augeGeometryType type = pField->GetGeometryDef()->GeometryType();
		if(type!=augeGTPolygon&&type!=augeGTMultiPolygon)
		{
			const char* msg = "输入数据集几何类型必须是多边形类型";
			pError->SetError(msg);
			pinFeatureClass->Release();
			poutWorkspace->Release();
			return AG_FAILURE;
		}


		poutFeatureClass = CreateOutputFeatureClass(className_out, poutWorkspace, pinFeatureClass);
		if(poutFeatureClass==NULL)
		{
			poutWorkspace->Release();
			return AG_FAILURE;
		}

		RESULTCODE rc = AG_FAILURE;
		rc = Process(pinFeatureClass, poutFeatureClass);
		poutFeatureClass->Refresh();
		poutFeatureClass->Release();

		if(rc!=AG_SUCCESS)
		{
			poutWorkspace->RemoveFeatureClass(className_out);
		}

		pinFeatureClass->Release();
		poutWorkspace->Release();
		
		return AG_SUCCESS;
	}
示例#5
0
	WebResponse* ListHandler::Execute(WebRequest* pWebRequest, WebContext* pWebContext, User* pUser)
	{
		GLogger* pLogger = augeGetLoggerInstance();
		ListRequest* pRequest = static_cast<ListRequest*>(pWebRequest);

		const char* sourceName = pRequest->GetSourceName();
		const char* path = pRequest->GetPath();

		if(sourceName==NULL)
		{
			const char* msg = "Parameter [sourceName] is NULL";
			GLogger* pLogger = augeGetLoggerInstance();
			pLogger->Error(msg, __FILE__, __LINE__);
			WebExceptionResponse* pExpResponse = augeCreateWebExceptionResponse();
			pExpResponse->SetMessage(msg);
			return pExpResponse;
		}

		Workspace* pWorkspace = NULL;
		RasterWorkspace* pRasterWorkspace = NULL;
		ConnectionManager* pConnManager = augeGetConnectionManagerInstance();

		pWorkspace = pConnManager->GetWorkspace(pUser->GetID(), sourceName);
		if(pWorkspace==NULL)
		{
			char msg[AUGE_MSG_MAX];
			g_sprintf(msg, "Cannot Get DataSource [%s]", sourceName);
			GLogger* pLogger = augeGetLoggerInstance();
			pLogger->Error(msg, __FILE__, __LINE__);
			WebExceptionResponse* pExpResponse = augeCreateWebExceptionResponse();
			pExpResponse->SetMessage(msg);
			return pExpResponse;
		}
		if(!pWorkspace->IsOpen())
		{
			char msg[AUGE_MSG_MAX];
			g_sprintf(msg, "Cannot Connect to DataSource [%s]", sourceName);
			GLogger* pLogger = augeGetLoggerInstance();
			pLogger->Error(msg, __FILE__, __LINE__);
			WebExceptionResponse* pExpResponse = augeCreateWebExceptionResponse();
			pExpResponse->SetMessage(msg);
			return pExpResponse;
		}

		pRasterWorkspace = dynamic_cast<RasterWorkspace*>(pWorkspace);

		RasterFolder* pFolder = pRasterWorkspace->GetFolder(path);
		if(pFolder==NULL)
		{
			char msg[AUGE_MSG_MAX];
			g_sprintf(msg, "Path [%s] does not exist.", path);
			GLogger* pLogger = augeGetLoggerInstance();
			pLogger->Error(msg, __FILE__, __LINE__);
			WebExceptionResponse* pExpResponse = augeCreateWebExceptionResponse();
			pExpResponse->SetMessage(msg);
			return pExpResponse;
		}

		ListResponse* pResponse = new ListResponse(pRequest);
		pResponse->SetFolder(pFolder);

		return pResponse;
	}
	RESULTCODE DemAspectProcessorImpl::Execute()
	{
		const char* inSourceName = GetInputDataSource();
		const char* inRasterName = GetInputRaster();
		const char* inRasterPath = GetInputRasterPath();
		const char* outSourceName = GetOutputDataSource();
		const char* outRasterName = GetOutputRaster();
		const char* outRasterPath = GetOutputRasterPath();

		Workspace* pWorkspace = NULL;
		RasterWorkspace* pinRasterWorkspace = NULL;
		RasterWorkspace* poutRasterWorkspace = NULL;

		GError* pError = augeGetErrorInstance();
		GLogger* pLogger = augeGetLoggerInstance();
		ConnectionManager* pConnManager = augeGetConnectionManagerInstance();

		pWorkspace = pConnManager->GetWorkspace(m_user, inSourceName);
		if(pWorkspace==NULL)
		{
			return AG_FAILURE;
		}
		pinRasterWorkspace = dynamic_cast<RasterWorkspace*>(pWorkspace);

		pWorkspace = pConnManager->GetWorkspace(m_user, outSourceName);
		if(pWorkspace==NULL)
		{
			return AG_FAILURE;
		}
		poutRasterWorkspace = dynamic_cast<RasterWorkspace*>(pWorkspace);

		Raster* pinRaster = NULL;
		RasterFolder* pinFolder = NULL;

		Raster* poutRaster = NULL;
		RasterFolder* poutFolder = NULL;

		pinFolder = pinRasterWorkspace->GetFolder(inRasterPath);
		if(pinFolder==NULL)
		{
			return AG_FAILURE;
		}
		pinRaster = pinFolder->GetRasterDataset()->GetRaster(inRasterName);
		if(pinRaster==NULL)
		{
			const char* msg = "无法打开输入栅格数据";
			pError->SetError(msg);
			pinFolder->Release();
			return AG_FAILURE;
		}

		g_uint band_count = pinRaster->GetBandCount();
		if(band_count!=1)
		{
			const char* msg = "Dem坡向计算仅支持单波段Dem数据";
			pError->SetError(msg);
			pinFolder->Release();
			return AG_FAILURE;
		}
		
		poutRaster = Aspect(pinRaster);

		if(poutRaster!=NULL)
		{
			poutRaster->SetName(outRasterName);
		}
		poutFolder = poutRasterWorkspace->GetFolder(outRasterPath);
		if(poutFolder==NULL)
		{
			pinFolder->Release();
			poutRaster->Release();
			return AG_FAILURE;
		}
		RESULTCODE rc = poutFolder->GetRasterDataset()->AddRaster(outRasterName, poutRaster);
		poutRaster->Release();
		pinFolder->Release();
		poutFolder->Release();

		return rc;
	}
示例#7
0
	WebResponse* AddRasterHandler::Execute(WebRequest* pWebRequest, WebContext* pWebContext, User* pUser)
	{
		GLogger* pLogger = augeGetLoggerInstance();
		AddRasterRequest* pRequest = static_cast<AddRasterRequest*>(pWebRequest);

		const char* raster_name = pRequest->GetRasterName();
		const char* folder_path = pRequest->GetRasterPath();
		const char* file_path   = pRequest->GetFilePath();

		if(raster_name==NULL)
		{
			const char* msg = "Parameter [Name] is NULL";
			WebExceptionResponse* pExpResponse = augeCreateWebExceptionResponse();
			pExpResponse->SetMessage(msg);
			pLogger->Error(msg,__FILE__,__LINE__);

			return pExpResponse;
		}
		const char* sourceName = pRequest->GetSourceName();
		if(sourceName==NULL)
		{
			const char* msg = "Parameter [SourceName] is NULL";
			WebExceptionResponse* pExpResponse = augeCreateWebExceptionResponse();
			pExpResponse->SetMessage(msg);
			pLogger->Error(msg,__FILE__,__LINE__);

			return pExpResponse;
		}
		if(file_path==NULL)
		{
			const char* msg = "Parameter [filePath] is NULL";
			WebExceptionResponse* pExpResponse = augeCreateWebExceptionResponse();
			pExpResponse->SetMessage(msg);
			pLogger->Error(msg,__FILE__,__LINE__);

			return pExpResponse;
		}

		Workspace* pWorkspace = NULL;
		RasterWorkspace* pRasterWorkspace = NULL;
		ConnectionManager* pConnectionManager = NULL;
		pConnectionManager = augeGetConnectionManagerInstance();
		pWorkspace = pConnectionManager->GetWorkspace(pUser->GetID(), sourceName);
		if(pWorkspace==NULL)
		{
			char msg[AUGE_MSG_MAX];
			memset(msg,0,AUGE_MSG_MAX);
			g_sprintf(msg,"Cannot Get DataSource [%s]", sourceName);
			WebExceptionResponse* pExpResponse = augeCreateWebExceptionResponse();
			pExpResponse->SetMessage(msg);
			pLogger->Error(msg,__FILE__,__LINE__);

			return pExpResponse;
		}

		pRasterWorkspace = dynamic_cast<RasterWorkspace*>(pWorkspace);
		//if(pRasterWorkspace==NULL)
		//{
		//	char msg[AUGE_MSG_MAX];
		//	memset(msg,0,AUGE_MSG_MAX);
		//	g_sprintf(msg,"Cannot Get DataSource [%s]", sourceName);
		//	WebExceptionResponse* pExpResponse = augeCreateWebExceptionResponse();
		//	pExpResponse->SetMessage(msg);
		//	pLogger->Error(msg,__FILE__,__LINE__);

		//	return pExpResponse;
		//}

		RasterFolder* pFolder = pRasterWorkspace->GetFolder(folder_path);
		if(pFolder==NULL)
		{
			char msg[AUGE_MSG_MAX];
			g_sprintf(msg, "Path [%s] does not exist.", folder_path);
			GLogger* pLogger = augeGetLoggerInstance();
			pLogger->Error(msg, __FILE__, __LINE__);
			WebExceptionResponse* pExpResponse = augeCreateWebExceptionResponse();
			pExpResponse->SetMessage(msg);
			return pExpResponse;
		}

		char user_file_root[AUGE_PATH_MAX];
		auge_make_user_file_root(user_file_root, AUGE_PATH_MAX, pWebContext->GetUserRoot(), pUser->GetName());

		char file_local_path[AUGE_PATH_MAX];
		memset(file_local_path, 0, AUGE_PATH_MAX);
		auge_make_path(file_local_path,  NULL, user_file_root, file_path+1, NULL);
		if(g_access(file_local_path,4))
		{
			char msg[AUGE_MSG_MAX];
			g_snprintf(msg, AUGE_MSG_MAX, "File [%s] does not exist", file_path);
			GLogger* pLogger = augeGetLoggerInstance();
			pLogger->Error(msg, __FILE__, __LINE__);
			WebExceptionResponse* pExpResponse = augeCreateWebExceptionResponse();
			pExpResponse->SetMessage(msg);
			return pExpResponse;
		}

		char uuid[AUGE_PATH_MAX] = {0};
		auge_generate_uuid(uuid, AUGE_PATH_MAX);

		RESULTCODE rc = AG_FAILURE;
		RasterDataset* pRasterDataset = pFolder->GetRasterDataset();
		rc = pRasterDataset->AddRaster(raster_name, file_local_path, uuid);
		if(rc != AG_SUCCESS )
		{
			pFolder->Release();

			GError* pError = augeGetErrorInstance();			
			GLogger* pLogger = augeGetLoggerInstance();
			pLogger->Error(pError->GetLastError(), __FILE__, __LINE__);
			WebExceptionResponse* pExpResponse = augeCreateWebExceptionResponse();
			pExpResponse->SetMessage(pError->GetLastError());
			return pExpResponse;
		}

		pFolder->Release();

		//生成thumbnail
		//char thumbnail_path[AUGE_PATH_MAX];
		//memset(thumbnail_path, 0, AUGE_PATH_MAX);
		//auge_make_path(thumbnail_path, NULL, pWebContext->GetThumbnailPath(), uuid, AUGE_THUMBNAIL_SUFFIX);

		//RasterThumbnailProcessor* pProcessor = NULL;
		//GProcessorFactory* pFactory = augeGetGeoProcessorFactoryInstance();
		//pProcessor = pFactory->CreateRasterThumbnailProcessor();
		//pProcessor->SetInputRaster(file_local_path);
		//pProcessor->SetOutputRaster(thumbnail_path);
		//pProcessor->SetThumbSize(512);
		//pProcessor->Execute();
		//pProcessor->Release();

		////计算raster的根目录
		//char raster_repository[AUGE_PATH_MAX];
		//memset(raster_repository, 0, AUGE_PATH_MAX);
		//rds_get_raster_repository(raster_repository, AUGE_PATH_MAX, pUser->GetName(), pWebContext);
		////计算导入后的raster的路径
		//char raster_local_folder[AUGE_PATH_MAX];
		//auge_make_path(raster_local_folder, NULL, raster_repository, raster_path+1, NULL);
		//char raster_local_path[AUGE_PATH_MAX];
		//auge_make_path(raster_local_path, NULL, raster_local_folder, raster_name, NULL);

		//if(g_access(raster_local_folder,4))
		//{
		//	char msg[AUGE_MSG_MAX];
		//	memset(msg,0,AUGE_MSG_MAX);
		//	g_sprintf(msg,"raster path [%s] does not exist.", raster_path);
		//	WebExceptionResponse* pExpResponse = augeCreateWebExceptionResponse();
		//	pExpResponse->SetMessage(msg);
		//	pLogger->Error(msg,__FILE__,__LINE__);

		//	return pExpResponse;
		//}

		////计算待导入的raster文件的本地路径
		//char file_local_path[AUGE_PATH_MAX];
		//memset(file_local_path,0,AUGE_PATH_MAX);
		//auge_make_path(file_local_path,NULL,pWebContext->GetUploadPath(), file_path+1,NULL);

		//// whether file exists.
		//if(g_access(file_local_path,4))
		//{
		//	char msg[AUGE_MSG_MAX];
		//	memset(msg,0,AUGE_MSG_MAX);
		//	g_sprintf(msg,"raster [%s] does not exist.", file_path);
		//	WebExceptionResponse* pExpResponse = augeCreateWebExceptionResponse();
		//	pExpResponse->SetMessage(msg);
		//	pLogger->Error(msg,__FILE__,__LINE__);

		//	return pExpResponse;
		//}

		//RESULTCODE rc = AG_FAILURE;
		//Raster* pRaster = NULL;
		//RasterIO* rio = augeGetRasterIOInstance();
		//pRaster = rio->Read(file_local_path);
		//if(pRaster==NULL)
		//{
		//	char msg[AUGE_MSG_MAX];
		//	memset(msg,0,AUGE_MSG_MAX);
		//	g_sprintf(msg,"Fail to read raster [%s]", file_path);
		//	WebExceptionResponse* pExpResponse = augeCreateWebExceptionResponse();
		//	pExpResponse->SetMessage(msg);
		//	pLogger->Error(msg,__FILE__,__LINE__);

		//	return pExpResponse;
		//}
		//pRaster->SetName(raster_name);
		//pRaster->SetAlias(raster_name);
		//pRaster->SetPath(raster_path);
		////rc = pRasterWorkspace->AddRaster(pRaster);
		//pRaster->Release();

		//if(rc!=AG_SUCCESS)
		//{
		//	GError* pError = augeGetErrorInstance();
		//	WebExceptionResponse* pExpResponse = augeCreateWebExceptionResponse();
		//	pExpResponse->SetMessage(pError->GetLastError());
		//	pLogger->Error(pError->GetLastError(),__FILE__,__LINE__);

		//	return pExpResponse;
		//}

		//auge_move(file_local_path, raster_local_path);

		WebSuccessResponse* pSusResponse = augeCreateWebSuccessResponse();
		pSusResponse->SetRequest(pRequest->GetRequest());
		return pSusResponse;
	}
	RESULTCODE CsvImportProcessorImpl::Execute()
	{
		GError	*pError  = augeGetErrorInstance();
		GLogger	*pLogger = augeGetLoggerInstance();

		char csvDrv[AUGE_DRV_MAX];
		char csvDir[AUGE_PATH_MAX];
		char csvName[AUGE_NAME_MAX];
		char csvPath[AUGE_PATH_MAX];
		char constr[AUGE_PATH_MAX];
		memset(csvDrv, 0, AUGE_DRV_MAX);
		memset(csvDir, 0, AUGE_PATH_MAX);
		memset(csvName, 0, AUGE_NAME_MAX);
		memset(csvPath, 0, AUGE_PATH_MAX);
		memset(constr,0,AUGE_PATH_MAX);

		auge_split_path(m_csv_path.c_str(), csvDrv, csvDir,csvName,NULL);
		auge_make_path(csvPath, csvDrv,csvDir,NULL,NULL);
		g_sprintf(constr,"DATABASE=%s",csvPath);

		DataEngine* pDataEngine = NULL;
		DataEngineManager* pDataEngineManager = augeGetDataEngineManagerInstance();
		pDataEngine = pDataEngineManager->GetEngine("CsvFile");
		if(pDataEngine==NULL)
		{
			pLogger->Error(pError->GetLastError(),__FILE__,__LINE__);
			return AG_FAILURE;
		}
		
		RESULTCODE rc = AG_FAILURE;
		Workspace* pcsvWorkspace = pDataEngine->CreateWorkspace();
		pcsvWorkspace->SetConnectionString(constr);
		rc = pcsvWorkspace->Open();
		if(rc!=AG_SUCCESS)
		{
			pLogger->Error(pError->GetLastError(),__FILE__,__LINE__);

			pcsvWorkspace->Release();
			return AG_FAILURE;
		}

		FeatureWorkspace* pobjWorkspace = NULL;
		ConnectionManager* pConnectionManager = augeGetConnectionManagerInstance();
		pobjWorkspace = dynamic_cast<FeatureWorkspace*>(pConnectionManager->GetWorkspace(m_user, m_source_name.c_str()));
		if(pobjWorkspace==NULL)
		{
			pLogger->Error(pError->GetLastError(),__FILE__,__LINE__);

			pcsvWorkspace->Release();
			return AG_FAILURE;
		}

		FeatureClass* pFeatureClass = NULL;
		pFeatureClass = pobjWorkspace->OpenFeatureClass(m_dataset_name.c_str());
		if(pFeatureClass==NULL)
		{
			pLogger->Error(pError->GetLastError(),__FILE__,__LINE__);
			pcsvWorkspace->Release();
			return AG_FAILURE;
		}

		AttributeDataSet* pcsvDataset = static_cast<AttributeDataSet*>(pcsvWorkspace->OpenDataSet(csvName));
		GFields* pcsvFields = pcsvDataset->GetFields();
		GFields* pobjFields = pFeatureClass->GetFields();
		if(!IsMatch(pcsvFields,pobjFields))
		{
			const char* msg = "Field is not matched";
			pError->SetError(msg);
			pLogger->Error(msg, __FILE__, __LINE__);

			pFeatureClass->Release();
			pcsvDataset->Release();
			pcsvWorkspace->Release();
			return AG_FAILURE;
		}

		FeatureInsertCommand* cmd = pFeatureClass->CreateInsertCommand();

		Row* pRow = NULL;
		Cursor* pCursor = pcsvDataset->GetRows();
		while((pRow=pCursor->NextRow())!=NULL)
		{
			AddFeature(pRow, pFeatureClass,cmd);

			pRow->Release();
		}
		cmd->Commit();
		cmd->Release();
		pCursor->Release();		

		pFeatureClass->Refresh();
		pFeatureClass->Release();
		pcsvDataset->Release();
		pcsvWorkspace->Release();

		return AG_SUCCESS;
	}
	RESULTCODE RasterHistogramEqualizationProcessorImpl::Execute()
	{
		const char* inSourceName = GetInputDataSource();
		const char* inRasterName = GetInputRaster();
		const char* inRasterPath = GetInputRasterPath();
		const char* outSourceName = GetOutputDataSource();
		const char* outRasterName = GetOutputRaster();
		const char* outRasterPath = GetOutputRasterPath();

		Workspace* pWorkspace = NULL;
		RasterWorkspace* pinRasterWorkspace = NULL;
		RasterWorkspace* poutRasterWorkspace = NULL;

		GError* pError = augeGetErrorInstance();
		GLogger* pLogger = augeGetLoggerInstance();
		ConnectionManager* pConnManager = augeGetConnectionManagerInstance();

		pWorkspace = pConnManager->GetWorkspace(m_user, inSourceName);
		if(pWorkspace==NULL)
		{
			return AG_FAILURE;
		}
		pinRasterWorkspace = dynamic_cast<RasterWorkspace*>(pWorkspace);

		pWorkspace = pConnManager->GetWorkspace(m_user, outSourceName);
		if(pWorkspace==NULL)
		{
			return AG_FAILURE;
		}

		poutRasterWorkspace = dynamic_cast<RasterWorkspace*>(pWorkspace);

		Raster* pinRaster = NULL;
		RasterFolder* pinFolder = NULL;

		//Raster* poutRaster = NULL;
		RasterFolder* poutFolder = NULL;

		pinFolder = pinRasterWorkspace->GetFolder(inRasterPath);
		if(pinFolder==NULL)
		{
			return AG_FAILURE;
		}
		pinRaster = pinFolder->GetRasterDataset()->GetRaster(inRasterName);
		if(pinRaster==NULL)
		{
			pinFolder->Release();
			return AG_FAILURE;
		}

		augePixelType pixelType = pinRaster->GetPixelType();
		if(pixelType != augePixelByte)
		{
			char msg[AUGE_MSG_MAX];
			g_sprintf(msg, "直方图均衡化仅支持Byte类型像元栅格数据,当前栅格数据像元宽度为%dByte", pinRaster->GetPixelSize());
			pError->SetError(msg);
			pinFolder->Release();
			return AG_FAILURE;
		}

		//g_uint band_count = pinRaster->GetBandCount();
		//if(band_count<3||band_count>4)
		//{
		//	pinFolder->Release();
		//	return AG_FAILURE;
		//}


		if(!HistogramEqualize(pinRaster))
		{
			pinFolder->Release();
			return AG_FAILURE;
		}
		
		poutFolder = poutRasterWorkspace->GetFolder(outRasterPath);
		if(poutFolder==NULL)
		{
			pinFolder->Release();
			return AG_FAILURE;
		}
		RESULTCODE rc = poutFolder->GetRasterDataset()->AddRaster(outRasterName, pinRaster);

		pinRaster->Release();
		poutFolder->Release();
		pinFolder->Release();

		return rc;
	}
示例#10
0
	WebResponse* GetPreviewHandler::Execute(WebRequest* pWebRequest, User* pUser)
	{
		GetPreviewRequest* pRequest = static_cast<GetPreviewRequest*>(pWebRequest);

		const char* sourceName = pRequest->GetSourceName();
		const char* dataSetName= pRequest->GetDataSetName();

		if(sourceName==NULL)
		{
			const char* msg = "Parameter [sourceName] is NULL";
			GLogger* pLogger = augeGetLoggerInstance();
			pLogger->Error(msg, __FILE__, __LINE__);
			WebExceptionResponse* pExpResponse = augeCreateWebExceptionResponse();
			pExpResponse->SetMessage(msg);
			return pExpResponse;
		}

		Workspace* pWorkspace = NULL;
		ConnectionManager* pConnectionManager = augeGetConnectionManagerInstance();
		pWorkspace = pConnectionManager->GetWorkspace(pUser->GetID(), sourceName);
		if( pWorkspace==NULL )
		{
			char msg[AUGE_PATH_MAX] = {0};
			g_sprintf(msg, "Cannot load datasource [%s].", sourceName);
			GLogger* pLogger = augeGetLoggerInstance();
			pLogger->Error(msg, __FILE__, __LINE__);
			WebExceptionResponse* pExpResponse = augeCreateWebExceptionResponse();
			pExpResponse->SetMessage(msg);
			return pExpResponse;
		}

		DataSet* pDataSet = pWorkspace->OpenDataSet(dataSetName);
		if(pDataSet==NULL)
		{
			char msg[AUGE_PATH_MAX] = {0};
			g_sprintf(msg, "Cannot load data set [%s].", dataSetName);
			GLogger* pLogger = augeGetLoggerInstance();
			pLogger->Error(msg, __FILE__, __LINE__);
			WebExceptionResponse* pExpResponse = augeCreateWebExceptionResponse();
			pExpResponse->SetMessage(msg);
			return pExpResponse;
		}

		WebResponse* pWebResponse = NULL;
		switch(pDataSet->GetType())
		{
		case augeDataSetFeature:
			{
				FeatureClass* pFeatureClass = static_cast<FeatureClass*>(pDataSet);
				char img_sfix[AUGE_EXT_MAX] = {0};
				char img_path[AUGE_PATH_MAX] = {0};
				auge_get_image_suffix(pRequest->GetMimeType(), img_sfix, AUGE_EXT_MAX);
				WebContext* pWebContext = augeGetWebContextInstance();
				auge_make_path(img_path, NULL, pWebContext->GetCacheMapPath(), pFeatureClass->GetUUID(), img_sfix);
				if(!g_access(img_path, 4))
				{
					GetPreviewResponse* pMapResponse = new GetPreviewResponse(pRequest);
					pMapResponse->SetPath(img_path);
					pWebResponse = pMapResponse;
				}
				else
				{
					pWebResponse = DrawFeature(pFeatureClass,pRequest);
				}
			}			
			break;
		case augeDataSetRaster:
			break;
		}

		return pWebResponse;
	}