void IOrbitProjectionTransformControl.Free() { if (_orbitProjectionTransform != null) { _orbitProjectionTransform.Dispose(); _orbitProjectionTransform = null; } }
void BuildOrbitPrjTransoform(object sender, EventArgs e) { IRasterBand lonBand, latBand; IRasterBand[] bs = _bandProvider.GetBands("Longitude"); if (bs == null) { return; } lonBand = bs[0]; bs = _bandProvider.GetBands("Latitude"); if (bs == null) { return; } latBand = bs[0]; float[] lonBuffer = null; float[] latBuffer = null; // switch (lonBand.DataType) { case enumDataType.Float: lonBuffer = new float[lonBand.Width * lonBand.Height]; latBuffer = new float[latBand.Width * latBand.Height]; fixed(float *lonPtr = lonBuffer, latPtr = latBuffer) { IntPtr lonIntPtr = new IntPtr(lonPtr); IntPtr latIntPtr = new IntPtr(latPtr); lonBand.Read(0, 0, lonBand.Width, lonBand.Height, lonIntPtr, enumDataType.Float, lonBand.Width, latBand.Height); latBand.Read(0, 0, latBand.Width, latBand.Height, latIntPtr, enumDataType.Float, latBand.Width, latBand.Height); } break; case enumDataType.Double: double[] lonBufferDouble = new double[lonBand.Width * lonBand.Height]; double[] latBufferDouble = new double[latBand.Width * latBand.Height]; fixed(double *lonPtrd = lonBufferDouble, latPtrd = latBufferDouble) { IntPtr lonIntPtr = new IntPtr(lonPtrd); IntPtr latIntPtr = new IntPtr(latPtrd); lonBand.Read(0, 0, lonBand.Width, lonBand.Height, lonIntPtr, enumDataType.Double, lonBand.Width, latBand.Height); latBand.Read(0, 0, latBand.Width, latBand.Height, latIntPtr, enumDataType.Double, latBand.Width, latBand.Height); } lonBuffer = new float[lonBand.Width * lonBand.Height]; latBuffer = new float[latBand.Width * latBand.Height]; for (int i = 0; i < lonBuffer.Length; i++) { lonBuffer[i] = (float)lonBufferDouble[i]; latBuffer[i] = (float)latBufferDouble[i]; } break; } if (lonBuffer != null && latBuffer != null) { int lonsWidth = lonBand.Width; int latsHeight = latBand.Height; float[] retLonBuffer, retLatBuffer; int retWidth, retHeight; int sample = 4;//经纬度数据集缩小4倍 SampleMatrix(sample, lonBuffer, latBuffer, lonsWidth, latsHeight, out retLonBuffer, out retLatBuffer, out retWidth, out retHeight); _orbitProjectionTransform = new OrbitProjectionTransform(retLonBuffer, retLatBuffer, new Size(retWidth, retHeight), _width / retWidth); } }