/// <summary>
 /// 拷贝构造函数。
 /// </summary>
 /// <param name="interpolationParameter">插值通用参数设置类。</param>
 /// <exception cref="ArgumentNullException">插值通用参数设置类为 null 时抛出异常。</exception>
 public InterpolationParameter(InterpolationParameter interpolationParameter)
 {
     if (interpolationParameter == null)
     {
         throw new ArgumentNullException("interpolationParameter");
     }
     if (interpolationParameter.Bounds != null)
     {
         this.Bounds = new Rectangle2D(interpolationParameter.Bounds);
     }
     this.ExpectedCount = interpolationParameter.ExpectedCount;
     if (interpolationParameter.FilterQueryParameter != null)
     {
         this.FilterQueryParameter = new QueryParameter(interpolationParameter.FilterQueryParameter);
     }
     this.MaxPointCountForInterpolation = interpolationParameter.MaxPointCountForInterpolation;
     this.MaxPointCountInNode = interpolationParameter.MaxPointCountInNode;
     this.OutputDatasetName = interpolationParameter.OutputDatasetName;
     this.OutputDatasourceName = interpolationParameter.OutputDatasourceName;
     this.PixelFormat = interpolationParameter.PixelFormat;
     this.Resolution = interpolationParameter.Resolution;
     this.SearchMode = interpolationParameter.SearchMode;
     this.SearchRadius = interpolationParameter.SearchRadius;
     this.ZValueFieldName = interpolationParameter.ZValueFieldName;
     this.ZValueScale = interpolationParameter.ZValueScale;
 }
Example #2
0
 public ImageProcess(ImageIO sourceImage,
                     int targetWidth, int targetHeight,
                     Interpolation interpolation, double bicubicFactor = -0.5)
 {
     _imageParameter = new ImageParameter(sourceImage, null, sourceImage.Path, null);
     sourceImage.LockBits();
     _processOption          = new ProcessOption(Transform.None, interpolation);
     _distortionParameter    = null;
     _warpParameter          = null;
     _faceTransformation     = null;
     _interpolationParameter = new InterpolationParameter(targetWidth, targetHeight, bicubicFactor);
     _processResult          = new ProcessResult(this.InterpolationFunction(), null, null);
     sourceImage.UnlockBits();
 }
Example #3
0
 public ImageProcess(ImageIO sourceImage, ImageIO faceImage,
                     int targetWidth, int targetHeight,
                     Interpolation interpolation, double bicubicFactor = -0.5)
 {
     _imageParameter = new ImageParameter(sourceImage, faceImage, sourceImage.Path, faceImage.Path);
     sourceImage.LockBits();
     faceImage.LockBits();
     _processOption          = new ProcessOption(Transform.TPS, interpolation);
     _distortionParameter    = null;
     _warpParameter          = null;
     _faceTransformation     = new FaceTransformation(this.ImageParameter.SourcePath, this.ImageParameter.FacePath);
     _interpolationParameter = new InterpolationParameter(targetWidth, targetHeight, bicubicFactor);
     _processResult          = new ProcessResult(this.InterpolationFunction(), this.FaceTransformation.Source_marked, this.FaceTransformation.Face_marked);
     sourceImage.UnlockBits();
     faceImage.UnlockBits();
 }
Example #4
0
 public ImageProcess(ImageIO sourceImage,
                     double warpFactor, int warpCenter_x, int warpCenter_y,
                     int targetWidth, int targetHeight,
                     Interpolation interpolation, double bicubicFactor = -0.5)
 {
     _stretch        = false;
     _imageParameter = new ImageParameter(sourceImage, null, sourceImage.Path, null);
     sourceImage.LockBits();
     _processOption          = new ProcessOption(Transform.Warp, interpolation);
     _distortionParameter    = null;
     _warpParameter          = new WarpParameter(sourceImage.Width * sourceImage.Height, warpFactor, warpCenter_x, warpCenter_y);
     _faceTransformation     = null;
     _interpolationParameter = new InterpolationParameter(targetWidth, targetHeight, bicubicFactor);
     _processResult          = new ProcessResult(this.InterpolationFunction(), null, null);
     sourceImage.UnlockBits();
 }
        public override void Deserialize(MoDeserializer archive)
        {
            var first  = new InterpolationParameter();
            var second = new InterpolationParameter();

            first.X  = archive.ReadByte();
            second.X = archive.ReadByte();
            first.Y  = archive.ReadByte();
            second.Y = archive.ReadByte();
            X.First  = first;
            X.Second = second;

            first.X  = archive.ReadByte();
            second.X = archive.ReadByte();
            first.Y  = archive.ReadByte();
            second.Y = archive.ReadByte();
            Y.First  = first;
            Y.Second = second;

            first.X  = archive.ReadByte();
            second.X = archive.ReadByte();
            first.Y  = archive.ReadByte();
            second.Y = archive.ReadByte();
            Z.First  = first;
            Z.Second = second;

            first.X  = archive.ReadByte();
            second.X = archive.ReadByte();
            first.Y  = archive.ReadByte();
            second.Y = archive.ReadByte();
            R.First  = first;
            R.Second = second;

            first.X  = archive.ReadByte();
            second.X = archive.ReadByte();
            first.Y  = archive.ReadByte();
            second.Y = archive.ReadByte();
            D.First  = first;
            D.Second = second;

            first.X  = archive.ReadByte();
            second.X = archive.ReadByte();
            first.Y  = archive.ReadByte();
            second.Y = archive.ReadByte();
            V.First  = first;
            V.Second = second;
        }
Example #6
0
        public override void Deserialize(MoDeserializer archive)
        {
            X = new Interpolation();
            Y = new Interpolation();
            Z = new Interpolation();
            R = new Interpolation();
            var x  = new InterpolationParameter();
            var y  = new InterpolationParameter();
            var z1 = new InterpolationParameter();
            var r1 = new InterpolationParameter();
            var z2 = new InterpolationParameter();
            var r2 = new InterpolationParameter();

            x.X = archive.ReadByte();
            y.X = archive.ReadByte();
            archive.ReadByte();
            archive.ReadByte();
            x.Y     = archive.ReadByte();
            y.Y     = archive.ReadByte();
            X.First = x;
            Y.First = y;

            z1.Y = archive.ReadByte();
            r1.Y = archive.ReadByte();
            x.X  = archive.ReadByte();
            y.X  = archive.ReadByte();
            z2.X = archive.ReadByte();
            r2.X = archive.ReadByte();
            x.Y  = archive.ReadByte();
            y.Y  = archive.ReadByte();
            z2.Y = archive.ReadByte();
            r2.Y = archive.ReadByte();
            archive.ReadByte();
            z1.X     = archive.ReadByte();
            r1.X     = archive.ReadByte();
            X.Second = x;
            Y.Second = y;
            Z.First  = z1;
            Z.Second = z2;
            R.First  = r1;
            R.Second = r2;

            for (int i = 0; i < 64 - 19; i++)
            {
                archive.ReadByte();
            }
        }
        /// <summary>
        /// <para>用于对离散的点数据进行插值得到栅格数据集。插值分析可以将有限的采样点数据,通过插值对采样点周围的数值情况进行预测,
        /// 从而掌握研究区域内数据的总体分布状况,而使采样的离散点不仅仅反映其所在位置的数值情况,而且可以反映区域的数值分布。</para>
        /// </summary>
        /// <param name="pointDataset">进行插值分析的点数据集名称,如SamplesP@Interpolation。</param>
        /// <param name="parameter">插值参数对象。</param>
        /// <returns>返回插值分析得到的栅格数据集。</returns>
        /// <remarks>
        /// <para>插值分析支持的算法类型:点密度、径向基函数、距离反比权值、普通克吕金、简单克吕金、泛克吕金共6种插值法。</para>
        /// <para>(1)点密度(Density)插值法。插值分析时只需要将parameter参数定义为<see cref="InterpolationDensityParameter"/>类型,即可进行点密度插值法。</para>
        /// <para>(2)径向基函数(Radial Basis Function)插值法。该方法假设变化是平滑的,它有两个特点:表面必须精确通过数据点;表面必须有最小曲率。该插值在创建有视觉要求的曲线和等高线方面有优势。插值分析时只需要将parameter参数定义为<see cref="InterpolationRBFParameter"/>类型,即可进行径向基函数插值法。</para>
        /// <para>(3)距离反比权值(Inverse Distance Weighted)插值法。该方法通过计算附近区域离散点群的平均值来估算单元格的值,生成格网数据集。
        /// 这是一种简单有效的数据内插方法,运算速度相对较快。距离离散中心越近的点,其估算值越受影响。插值分析时只需要将parameter参数定义为<see cref="InterpolationIDWParameter"/>类型,即可进行距离反比权值插值法。</para>
        /// <para>(4)克吕金插值法。克吕金插值法又分成3种类型(参考<see cref="KrigingAlgorithmType"/>):普通克吕金插值法;简单克吕金插值法;泛克吕金插值法。插值分析时需要将parameter参数定义为<see cref="InterpolationKrigingParameter"/>类型,并且在InterpolationKrigingParameter.Type参数中设置克吕金插值法的类型,即可进行克吕金插值法。</para>
        /// </remarks>
        /// <exception cref="ArgumentNullException">参数 parameter 为空时抛出异常。</exception>
        /// <exception cref="SuperMap.Connector.Utility.ServiceException">服务端处理错误时抛出异常。</exception>
        /// <example>
        /// 以下示范代码演示如何进行插值分析操作。
        /// <code>
        /// using System;
        /// using System.Collections.Generic;
        /// using System.Text;
        /// using SuperMap.Connector;
        /// using SuperMap.Connector.Utility;
        /// 
        /// class Program
        /// {
        ///     static void Main(string[] args)
        ///     {
        ///          //根据服务组件地址初始化一个SpatialAnalyst对象
        ///          SpatialAnalyst spatialAnalyst = new SpatialAnalyst("http://*****:*****@Interpolation",param);
        ///           Console.WriteLine("返回的数据集名称是:{0}", actualResult.Dataset);
        ///           Console.ReadLine();
        ///      }
        /// }
        /// </code>
        /// </example>
        public DatasetSpatialAnalystResult Interpolate(string pointDataset, InterpolationParameter parameter)
        {
            if (parameter == null)
            {
                throw new ArgumentNullException("parameter", Resources.ArgumentIsNotNull);
            }
            if (pointDataset == null)
            {
                throw new ArgumentNullException("pointDataset", Resources.ArgumentIsNotNull);
            }

            return _spatialAnalystProvier.Interpolate(pointDataset, parameter);
        }
Example #8
0
        public void CalculateInterpolatedValueTest(InterpolationParameter first, InterpolationParameter second, float t, float y)
        {
            var interpolation = new Interpolation(first, second);

            Assert.AreEqual(y, interpolation.GetInterpolatedValue(t), 1e-5);
        }
        public DatasetSpatialAnalystResult Interpolate(string pointDataset, InterpolationParameter parameter)
        {
            string baseUrl = "";
            string resourceType = "";
            System.Type parameterType = parameter.GetType();
            switch (parameterType.Name)
            {
                case "InterpolationDensityParameter":
                    resourceType = "density";
                    break;
                case "InterpolationIDWParameter":
                    resourceType = "idw";
                    break;
                case "InterpolationRBFParameter":
                    resourceType = "rbf";
                    break;
                case "InterpolationKrigingParameter":
                    resourceType = "kriging";
                    break;
                default:
                    break;
            }
            baseUrl = string.Format("{0}/spatialanalyst/datasets/{1}/interpolation/{2}.json?returnContent=true", this._serviceUrl, HttpUtility.HtmlEncode(pointDataset), resourceType);
            string json = string.Empty;
            json = JsonConvert.SerializeObject(parameter);

            string interpolateResult = SynchHttpRequest.GetRequestString(baseUrl, HttpRequestMethod.POST, json);

            return JsonConvert.DeserializeObject<DatasetSpatialAnalystResult>(interpolateResult);
        }