int Raster<T>::Copy(Raster& otherRaster) { //delete existing memory DeleteExistingData(); m_nRows = otherRaster.GetNumberOfRows(); m_nCols = otherRaster.GetNumberofColumns(); m_xllCenter = otherRaster.GetXllCenter(); m_yllCenter = otherRaster.GetYllCenter(); m_dx = otherRaster.GetXCellSize(); m_dy = otherRaster.GetYCellSize(); m_noDataValue = otherRaster.GetNoDataValue(); m_srs = otherRaster.GetSRS(); //allocate memory m_data = new T*[m_nRows]; for (int i = 0; i < m_nRows; ++i) { m_data[i] = new T[m_nCols]; for (int j = 0; j < m_nCols; ++j) { m_data[i][j] = otherRaster.At(i, j); } } return 0; }
int Raster<T>::CopyMask(Raster<int> &otherRaster) { m_nRows = otherRaster.GetNumberOfRows(); m_nCols = otherRaster.GetNumberofColumns(); m_xMin = otherRaster.GetXMin(); m_yMax = otherRaster.GetYMax(); m_dx = otherRaster.GetXCellSize(); m_dy = otherRaster.GetYCellSize(); //m_noDataValue = otherRaster.GetNoDataValue(); m_nAll = m_nRows * m_nCols; m_proj = otherRaster.GetProjection(); //allocate memory if(m_data != NULL) CPLFree(m_data); m_data = (T*) CPLMalloc(sizeof(T)*m_nAll); return 0; }