當前位置: 首頁>>代碼示例>>C#>>正文


C# Point.Project方法代碼示例

本文整理匯總了C#中System.Point.Project方法的典型用法代碼示例。如果您正苦於以下問題:C# Point.Project方法的具體用法?C# Point.Project怎麽用?C# Point.Project使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.Point的用法示例。


在下文中一共展示了Point.Project方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: ProjectTest1

        public void ProjectTest1()
        {
            var p1 = new Point (1, 1);
            var p2 = new Point (2, 1);

            var p3 = new Point (100, 0);

            var pp = p3.Project (p1, p2);

            Assert.AreEqual (pp.X, 100);
            Assert.AreEqual (pp.Y, 1);
        }
開發者ID:magerate,項目名稱:Geometries,代碼行數:12,代碼來源:PointTests.cs

示例2: Handler

        /// <summary>
        ///     Handles the incoming rest requests
        /// </summary>
        /// <param name="boundVariables"> The bound variables. </param>
        /// <param name="operationInput"> The operation input. </param>
        /// <param name="outputFormat"> The output format. </param>
        /// <param name="requestProperties"> The request properties. </param>
        /// <param name="responseProperties"> The response properties. </param>
        /// <returns> </returns>
        /// <exception cref="System.ArgumentNullException"></exception>
        public static byte[] Handler(NameValueCollection boundVariables, JsonObject operationInput,
                                     string outputFormat, string requestProperties,
                                     out string responseProperties)
        {
            responseProperties = null;
            var errors = new ErrorContainer(400);
            var wkid = 26912;
            const string featureClass = "SGID10.TRANSPORTATION.UDOTRoutes_LRS";

            //pull out all the variables
            var x = operationInput.GetNumberValue("x");
            var y = operationInput.GetNumberValue("y");
            var wkidInput = operationInput.GetNumberValue("wkid", nullable: true);
            var bufferInput = operationInput.GetNumberValue("buffer", nullable: true);
            var includeRamps = operationInput.GetNumberValue("includeRamps", nullable: true);

            ISpatialReference newSpatialRefefence = null;
            ISpatialReferenceFactory srFactory = new SpatialReferenceEnvironment();

            if (wkidInput > 0)
            {
                wkid = Convert.ToInt32(wkidInput);
            }

            if (bufferInput < 1 || bufferInput > 200)
            {
                bufferInput = 100;
            }

            //reproject to our data's spatial reference
            if (wkid != 26912)
            {
                var isProjected = true;
                try
                {
                    newSpatialRefefence = srFactory.CreateProjectedCoordinateSystem(wkid);
                }
                catch (ArgumentException)
                {
                    isProjected = false;
                }

                if (!isProjected)
                {
                    newSpatialRefefence = srFactory.CreateGeographicCoordinateSystem(wkid);
                }
            }

            var utm = srFactory.CreateProjectedCoordinateSystem(26912);

            IPoint point = new Point
                {
                    X = x,
                    Y = y,
                    SpatialReference = utm
                };

            //input is in different projection - reproject it
            if (wkid != 26912)
            {
                point = new Point
                    {
                        X = x,
                        Y = y,
                        SpatialReference = newSpatialRefefence
                    };

                point.Project(utm);
            }

            var bufferGeometry = CommandExecutor.ExecuteCommand(
                new BufferGeometryCommand(new GeometryContainer
                    {
                        Geometry = point
                    }, bufferInput));

            var sdeConnector = SdeConnectorFactory.Create(featureClass);

            if (sdeConnector == null)
            {
                errors.Add("{0} was not found in our database. ".With(featureClass) +
                           "A valid example would be SGID10.BOUNDARIES.Counties.");
            }

            if (errors.HasErrors)
            {
                return Json(errors);
            }

// ReSharper disable PossibleNullReferenceException because of returning errors if null
//.........這裏部分代碼省略.........
開發者ID:agrc,項目名稱:api.mapserv.utah.gov,代碼行數:101,代碼來源:ReverseMilepost.cs


注:本文中的System.Point.Project方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。