Raster* DemAspectProcessorImpl::Aspect(Raster* pinRaster)
	{
		Raster* poutRaster = NULL;
		RasterFactory* pRasterFactory = augeGetRasterFactoryInstance();
		//poutRaster = pRasterFactory->CreateRaster("", augePixelDouble, 1, pinRaster->GetExtent(), pinRaster->GetWidth(), pinRaster->GetHeight(), pinRaster->GetSpatialReference());
		poutRaster = pRasterFactory->CreateRaster("", augePixelFloat32, 1, pinRaster->GetExtent(), pinRaster->GetWidth(), pinRaster->GetHeight(), pinRaster->GetSpatialReference());
		if(poutRaster==NULL)
		{
			return NULL;
		}

		RESULTCODE rc = AG_SUCCESS;
		augePixelType type = pinRaster->GetPixelType();

		RasterBand* pinBand = NULL;
		RasterBand* poutBand = NULL;
		g_uint band_count = pinRaster->GetBandCount();
		for(g_uint i=0; i<band_count; i++)
		{
			pinBand  = pinRaster->GetBand(i);
			poutBand = poutRaster->GetBand(i);

			switch(type)
			{
			case augePixelByte:
				rc = Aspect_Byte(pinBand, poutBand);
				break;
			case augePixelUInt16:
			case augePixelInt16:
				Aspect_Short(pinBand, poutBand);
				break;
			case augePixelUInt32:
			case augePixelInt32:
				break;
			case augePixelFloat32:
				Aspect_Float(pinBand, poutBand);
				break;
			case augePixelDouble:
				Aspect_Double(pinBand, poutBand);
				break;
			}

			if(rc!=AG_SUCCESS)
			{
				break;
			}
		}

		if(rc!=AG_SUCCESS)
		{
			poutRaster->Release();
			poutRaster = NULL;
		}

		return poutRaster;
	}
	Raster*	RasterMosiacProcessorImpl::Mosiac(char** rasters, g_uint count, const char* poutRasterPath)
	{
		if(count==0)
		{
			return NULL;
		}

		Raster* pinRaster = NULL;
		Raster* pinRaster0 = NULL;
		Raster* poutRaster = NULL;
		Raster** ppinRasters = new Raster*[count];
		memset(ppinRasters, 0, sizeof(Raster*)*count);

		RasterIO* io = augeGetRasterIOInstance();
		const char* rpath = NULL;
		for(g_uint i=0; i<count; i++)
		{
			rpath = rasters[i];
			if(rpath!=NULL)
			{
				pinRaster = io->Read(rpath);
				ppinRasters[i] = pinRaster;
			}
		}

		if(!MosiacCheck(ppinRasters, count))
		{
			CleanupRasters(ppinRasters, count);
			return NULL;
		}

		pinRaster0 = GetRaster0(ppinRasters, count);
		if(pinRaster0==NULL)
		{
			CleanupRasters(ppinRasters, count);
			return NULL;
		}

		char uuid[AUGE_NAME_MAX];
		auge_generate_uuid(uuid, AUGE_NAME_MAX);
		g_uint srid  = pinRaster0->GetSRID();
		g_uint bands = pinRaster0->GetBandCount();
		const char* format = pinRaster0->GetFormat();
		double resolution_x = pinRaster0->GetResolution_X();
		double resolution_y = pinRaster0->GetResolution_Y();
		augePixelType pixelType = pinRaster0->GetPixelType();
		const char* spatialref = pinRaster0->GetSpatialReference();

		GEnvelope extent;
		if(!ComputeMosiacExtent(extent, ppinRasters, count))
		{
			CleanupRasters(ppinRasters, count);
			return NULL;
		}

		g_uint width, height;
		width = ceil(extent.GetWidth() / fabs(resolution_x));
		height= ceil(extent.GetHeight() / fabs(resolution_y));

		RasterFactory* pRasterFactory = augeGetRasterFactoryInstance();

		{
			poutRaster = pRasterFactory->CreateRaster("", pixelType, bands, extent, width, height,spatialref);

			g_uint64 pixelSize = (g_uint64)(pinRaster0->GetPixelSize());
			g_uint64 buffer_size = width * height * pixelSize;
			void* buffer = malloc(buffer_size);

			g_uint bands = poutRaster->GetBandCount();
			for(g_uint i=0; i<bands;i++)
			{	
				memset(buffer, 0, buffer_size);

				RasterBand* poutBand = poutRaster->GetBand(i);
				//for(int j=0; j<count; j++)
				for(int j=0; j<1; j++)
				{
					pinRaster = ppinRasters[j];

					RasterBand* pinBand = pinRaster->GetBand(i);
					CopyBandMem(poutBand, pinBand, poutRaster, buffer);
				}
				poutBand->SetData(buffer);
			}

			poutRaster->Save(poutRasterPath);

			free(buffer);
		}
		

		{
		//	//·Ö¿éMosiac
		//	poutRaster = pRasterFactory->CreateRaster("", poutRasterPath,"gtiff", pixelType, bands, extent, width, height,spatialref);
		//	//CreateRaster(const char* name, const char* path, const char* format, augePixelType pixelType, g_uint bands, GEnvelope& extent, g_uint width, g_uint height, const char*  spatialRef);
		//	if(poutRaster==NULL)
		//	{
		//		CleanupRasters(ppinRasters, count);
		//		return NULL;
		//	}
		//	for(g_uint i=0; i<count;i++)
		//		//for(g_uint i=0; i<1;i++)
		//		//for(g_uint i=1; i<2;i++)
		//	{
		//		pinRaster = ppinRasters[i];
		//		Mosiac(poutRaster, pinRaster);
		//	}
		}
		
		
		CleanupRasters(ppinRasters, count);

		return poutRaster;
	}