当前位置: 首页>>代码示例>>C#>>正文


C# System.Coordinate类代码示例

本文整理汇总了C#中System.Coordinate的典型用法代码示例。如果您正苦于以下问题:C# Coordinate类的具体用法?C# Coordinate怎么用?C# Coordinate使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Coordinate类属于System命名空间,在下文中一共展示了Coordinate类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: square_at

        public Square square_at(Coordinate coordinate)
        {
            return contains_token_at(coordinate) ? (Square) 
                new PlayingSquare(_squares[coordinate.X, coordinate.Y]) :
                new EmptyPlayingSquare();

        }
开发者ID:elbandit,项目名称:Tic-Tac-Toe,代码行数:7,代码来源:NineSquareGrid.cs

示例2: Reproject

 public Coordinate Reproject(Coordinate coordinate, ISpatialReference @from, ISpatialReference to)
 {
     double[] xy, z;
     ToDotSpatial(coordinate, out xy, out z);
     DotSpatial.Projections.Reproject.ReprojectPoints(xy, z, GetProjectionInfo(@from), GetProjectionInfo(to), 0, 1);
     return ToGeoAPI(xy, z);
 }
开发者ID:geobabbler,项目名称:SharpMap,代码行数:7,代码来源:DotSpatialReprojector.cs

示例3: Normalize

 /// <summary>
 /// Normalizes the vector <param name="v"></param>
 /// </summary>
 /// <param name="v">The normalized <paramref name="v"/></param>
 public static void Normalize(Coordinate v)
 {
     double absVal = Math.Sqrt(v.X * v.X + v.Y * v.Y + v.Z * v.Z);
     v.X /= absVal;
     v.Y /= absVal;
     v.Z /= absVal;
 }
开发者ID:Walt-D-Cat,项目名称:NetTopologySuite,代码行数:11,代码来源:VectorMath.cs

示例4: IsPointInRing

        /// <summary>
        ///
        /// </summary>
        /// <param name="p"></param>
        /// <param name="ring"></param>
        /// <returns></returns>
        public static bool IsPointInRing(Coordinate p, Coordinate[] ring)
        {
            int i;		    // point index; i1 = i-1 mod n
            int crossings = 0;	// number of edge/ray crossings
            int nPts = ring.Length;

            /* For each line edge l = (i-1, i), see if it crosses ray from test point in positive x direction. */
            for (i = 1; i < nPts; i++)
            {
                int i1 = i - 1;		    // point index; i1 = i-1 mod n
                Coordinate p1 = ring[i];
                Coordinate p2 = ring[i1];
                double x1 = p1.X - p.X;
                double y1 = p1.Y - p.Y;
                double x2 = p2.X - p.X;
                double y2 = p2.Y - p.Y;

                if (((y1 > 0) && (y2 <= 0)) || ((y2 > 0) && (y1 <= 0)))
                {
                    /* e straddles x axis, so compute intersection. */
                    double xInt = (x1 * y2 - x2 * y1) / (y2 - y1);		    // x intersection of e with ray
                    /* crosses ray if strictly positive intersection. */
                    if (0.0 < xInt) crossings++;
                }
            }

            /* p is inside if an odd number of crossings. */
            return (crossings % 2) == 1;
        }
开发者ID:ExRam,项目名称:DotSpatial-PCL,代码行数:35,代码来源:NonRobustCGAlgorithms.cs

示例5: Multipg

        public void Multipg()
        {
            Random rnd = new Random();
            Polygon[] pg = new Polygon[50];
            GeoAPI.Geometries.IPolygon[] pgcheck = new GeoAPI.Geometries.IPolygon[50];
            GisSharpBlog.NetTopologySuite.Geometries.GeometryFactory gf = new GisSharpBlog.NetTopologySuite.Geometries.GeometryFactory();
            for (int i = 0; i < 50; i++)
            {
                Coordinate center = new Coordinate((rnd.NextDouble() * 360) - 180, (rnd.NextDouble() * 180) - 90);
                Coordinate[] coord = new Coordinate[36];
                GeoAPI.Geometries.ICoordinate[] coordscheck = new GeoAPI.Geometries.ICoordinate[36];
                for (int ii = 0; ii < 36; ii++)
                {
                    coord[ii] = new Coordinate(center.X + Math.Cos((ii * 10) * Math.PI / 10), center.Y + (ii * 10) * Math.PI / 10);
                    double x = coord[ii].X;
                    double y = coord[ii].Y;
                    GisSharpBlog.NetTopologySuite.Geometries.Coordinate c = new GisSharpBlog.NetTopologySuite.Geometries.Coordinate(x, y);
                    coordscheck[ii] = c;
                }
                coord[35] = new Coordinate(coord[0].X, coord[0].Y);
                coordscheck[35] = new GisSharpBlog.NetTopologySuite.Geometries.Coordinate(coordscheck[0].X, coordscheck[0].Y);
                GeoAPI.Geometries.ILinearRing ring = gf.CreateLinearRing(coordscheck);
                pgcheck[i] = gf.CreatePolygon(ring, null);
                pg[i] = new Polygon(coord);

            }
            MultiPolygon mpg = new MultiPolygon(pg);
            GeoAPI.Geometries.IMultiPolygon mpgcheck = gf.CreateMultiPolygon(pgcheck);
            for (int ii = 0; ii < mpg.Coordinates.Count; ii++)
            {
                Assert.AreEqual(mpg.Coordinates[ii].X, mpgcheck.Coordinates[ii].X);
                Assert.AreEqual(mpg.Coordinates[ii].Y, mpgcheck.Coordinates[ii].Y);
            }
        }
开发者ID:ExRam,项目名称:DotSpatial-PCL,代码行数:34,代码来源:MultiShape.cs

示例6: PointInformation

 private static string PointInformation()
 {
     StringBuilder text = new StringBuilder();
     Window window = Window.GetWindowAtCursor();
     Coordinate pt = new Coordinate(CoordinateType.Absolute, new WindowEntity.Point() { X = Cursor.Position.X, Y = Cursor.Position.Y });
     Color color = Desktop.Primary.GetPixelColor(pt);
     if(window != null)
     {
         WindowEntity.Point rel = pt.ToRelative(window);
         StretchedPoint st = pt.ToStretched(window);
         text.Append("<b>Window</b>: ");
         text.AppendFormat("[{0}, {1}] ", window.Width, window.Height);
         text.AppendFormat("\"{0}\"", window.Title);
         text.AppendLine();
         text.Append("<br><b>Color</b>: ");
         text.AppendLine(color.ToString());
         text.Append("<br><b>Coordinate</b>: Absolute: ");
         text.AppendFormat("X = {0}, Y = {1}", pt.X, pt.Y);
         text.Append("; Relative: ");
         text.AppendFormat("X = {0}, Y = {1}", rel.X, rel.Y);
         text.Append("; Stretched: ");
         text.AppendFormat(CultureInfo.InvariantCulture, "X = {0}, Y = {1}", st.X, st.Y);
     }
     else
     {
         text.Append("<b>Color</b>: ");
         text.AppendLine(color.ToString());
         text.Append("<br><b>Coordinate</b>: Absolute: ");
         text.AppendFormat("{0}, {1}", pt.X, pt.Y);
     }
     return text.ToString();
 }
开发者ID:antgraf,项目名称:BA,代码行数:32,代码来源:HtmlRecorder.cs

示例7: Vector

 /// <summary>
 /// Creates a new instance of a vector where the X, Y and Z terms are the same as the
 /// specified coordinate.
 /// </summary>
 /// <param name="coord">The ICoordinate to use</param>
 public Vector(Coordinate coord)
 {
     X = coord.X;
     Y = coord.Y;
     Z = coord.Z;
     RemoveNan();
 }
开发者ID:DIVEROVIEDO,项目名称:DotSpatial,代码行数:12,代码来源:Vector.cs

示例8: TestWriteZMValuesShapeFile

        private void TestWriteZMValuesShapeFile(bool testM)
        {
            var points = new Coordinate[3];
            points[0] = new Coordinate(0, 0);
            points[1] = new Coordinate(1, 0);
            points[2] = new Coordinate(1, 1);

            var csFactory = DotSpatialAffineCoordinateSequenceFactory.Instance;
            var sequence = csFactory.Create(3, Ordinates.XYZM);
            for (var i = 0; i < 3; i++)
            {
                sequence.SetOrdinate(i, Ordinate.X, points[i].X);
                sequence.SetOrdinate(i, Ordinate.Y, points[i].Y);
                sequence.SetOrdinate(i, Ordinate.Z, 1 + i);
                if (testM)
                    sequence.SetOrdinate(i, Ordinate.M, 11 + i);
            }
            var lineString = Factory.CreateLineString(sequence);

            var attributes = new AttributesTable();
            attributes.AddAttribute("FOO", "Trond");

            var feature = new Feature(Factory.CreateMultiLineString(new[] { lineString }), attributes);
            var features = new Feature[1];
            features[0] = feature;

            var shpWriter = new ShapefileDataWriter("ZMtest", Factory)
            {
                Header = ShapefileDataWriter.GetHeader(features[0], features.Length)
            };
            shpWriter.Write(features);

            // Now let's read the file and verify that we got Z and M back
            var factory = new GeometryFactory(DotSpatialAffineCoordinateSequenceFactory.Instance);

            using (var reader = new ShapefileDataReader("ZMtest", factory))
            {
                reader.Read();
                var geom = reader.Geometry;

                for (var i = 0; i < 3; i++)
                {
                    var c = geom.Coordinates[i];
                    Assert.AreEqual(i + 1, c.Z);
                }

                if (testM)
                {
                    sequence = ((ILineString)geom).CoordinateSequence;
                    for (var i = 0; i < 3; i++)
                    {
                        Assert.AreEqual(sequence.GetOrdinate(i, Ordinate.M), 11 + i);
                    }
                }

                // Run a simple attribute test too
                var v = reader.GetString(0);
                Assert.AreEqual(v, "Trond");
            }
        }
开发者ID:Walt-D-Cat,项目名称:NetTopologySuite,代码行数:60,代码来源:ShapefileWriteTest.cs

示例9: RollForEngagement

        /// <summary>
        /// Finds number of players for each team at a coordinate at rolls to find a winner
        /// 
        /// </summary>
        public void RollForEngagement(Coordinate coordinate, Match match)
        {
            List<Player> homePlayersAtCoordinate = new List<Player>();
            List<Player> awayPlayerAtCoordinate = new List<Player>();

            foreach (Player somePlayer in match.GetPlayersAtCoordinate(coordinate, match))
            {
                if (somePlayer.Team.TeamName == match.HomeTeam.TeamName)
                {
                    homePlayersAtCoordinate.Add(somePlayer);
                }
                else
                {
                    awayPlayerAtCoordinate.Add(somePlayer);
                }
            }

            Console.WriteLine(match.HomeTeam.TeamName + " has " + homePlayersAtCoordinate.Count + " players at coordinate 2,2");
            Console.WriteLine(match.AwayTeam.TeamName + " has " + awayPlayerAtCoordinate.Count + " players at coordinate 2,2");

            //roll for greek players at coordinate
            Random rnd = new Random();

            int rollHome = rnd.Next(1, 7);
            int rollAway = rnd.Next(1, 7);

            Console.WriteLine(match.HomeTeam.TeamName + " rolls " + rollHome);
            Console.WriteLine(match.AwayTeam.TeamName + " rolls " + rollAway);

            //+2 til roll pr. player at coordinate.
            int modifiedGreekRoll = rollHome + homePlayersAtCoordinate.Count * 2;
            int modifiedOlsenRoll = rollAway + awayPlayerAtCoordinate.Count * 2;

            Console.WriteLine("greek modified roll is" + modifiedGreekRoll);
            Console.WriteLine("Olsen modified roll is" + modifiedOlsenRoll);

            ResultOfEngagement engagementResult = FindWinner(match, modifiedGreekRoll, modifiedOlsenRoll);

            var downedPlayer = new Player();
            //add effect (down player, equals half a player next round and can't move.
            if (engagementResult != ResultOfEngagement.Tie)
            {
                downedPlayer = EffectOfEngangement(engagementResult, homePlayersAtCoordinate, awayPlayerAtCoordinate);
            }
            else
            {
                Console.WriteLine("Its was a tie, no player downed");
            }

            if (downedPlayer != null)
            {
                if (match.MatchBall.PlayerWithBall == downedPlayer)
                {
                    //give player to another player at that coordinate
                }
                Console.WriteLine(downedPlayer.Name + " " + downedPlayer.State);
            }

            Console.WriteLine(engagementResult.ToString());
        }
开发者ID:runelippert,项目名称:TestGame,代码行数:64,代码来源:Rolls.cs

示例10: Build

 public Build(BlockTemplate BlockType, Coordinate Location)
     : base(Location)
 {
     this.BlockType = BlockType;
     MarkerTile = TileNames.TaskIconBlank;
     GnomeIcon = TileNames.TaskIconBuild;
 }
开发者ID:Blecki,项目名称:GnomeColony,代码行数:7,代码来源:Build.cs

示例11: Pixel

 public Pixel(Coordinate position, int r, int g, int b)
     : this(position)
 {
     this.R = r;
     this.G = g;
     this.B = b;
 }
开发者ID:rerezz,项目名称:Digitale-Bildbearbeitung,代码行数:7,代码来源:Pixel.cs

示例12: CompareOriented

        /// <summary>
        /// 
        /// </summary>
        /// <param name="pts1"></param>
        /// <param name="orientation1"></param>
        /// <param name="pts2"></param>
        /// <param name="orientation2"></param>
        /// <returns></returns>
        private static int CompareOriented(Coordinate[] pts1, bool orientation1, Coordinate[] pts2, bool orientation2)
        {
            int dir1 = orientation1 ? 1 : -1;
            int dir2 = orientation2 ? 1 : -1;
            int limit1 = orientation1 ? pts1.Length : -1;
            int limit2 = orientation2 ? pts2.Length : -1;

            int i1 = orientation1 ? 0 : pts1.Length - 1;
            int i2 = orientation2 ? 0 : pts2.Length - 1;
            while (true)
            {
                int compPt = pts1[i1].CompareTo(pts2[i2]);
                if (compPt != 0)
                    return compPt;

                i1 += dir1;
                i2 += dir2;
                bool done1 = i1 == limit1;
                bool done2 = i2 == limit2;
                if(done1 && !done2)
                    return -1;
                if(!done1 && done2)
                    return 1;
                if(done1 && done2)
                    return 0;
            }
        }
开发者ID:Walt-D-Cat,项目名称:NetTopologySuite,代码行数:35,代码来源:OrientedCoordinateArray.cs

示例13: Add

 /// <summary>
 /// Adds a point to the current line.
 /// </summary>
 /// <param name="pt">The <see cref="Coordinate" /> to add.</param>
 /// <param name="allowRepeatedPoints">If <c>true</c>, allows the insertions of repeated points.</param>
 public void Add(Coordinate pt, bool allowRepeatedPoints)
 {
     if (_coordList == null)
         _coordList = new CoordinateList();
     _coordList.Add(pt, allowRepeatedPoints);
     _lastPt = pt;
 }
开发者ID:ste10k41,项目名称:nettopologysuite,代码行数:12,代码来源:LinearGeometryBuilder.cs

示例14: is_square_at

 public bool is_square_at(Coordinate coordinate)
 {
     if (coordinate.Y > 2 || coordinate.X > 2)
         return false;
     else
         return true;
 }
开发者ID:elbandit,项目名称:Tic-Tac-Toe,代码行数:7,代码来源:NineSquareGrid.cs

示例15: GPGLL

        /// <summary>
        /// Initializes the NMEA Geographic position, Latitude and Longitude and parses an NMEA sentence
        /// </summary>
        /// <param name="NMEAsentence"></param>
        public GPGLL(string NMEAsentence)
        {
            try
            {
                //Split into an array of strings.
                string[] split = NMEAsentence.Split(new Char[] { ',' });

                try
                {
                    _position = new Coordinate(GPSHandler.GPSToDecimalDegrees(split[3], split[4]),
                                                GPSHandler.GPSToDecimalDegrees(split[1], split[2]));
                }
                catch { _position = null; }

                try
                {
                    _timeOfSolution = new TimeSpan(int.Parse(split[5].Substring(0, 2)),
                                                    int.Parse(split[5].Substring(2, 2)),
                                                    int.Parse(split[5].Substring(4)));
                }
                catch
                {
                    _timeOfSolution = null; // TimeSpan.Zero;
                }
                _dataValid = (split[6] == "A");
            }
            catch { }
        }
开发者ID:siegelpeter,项目名称:UAV-NET,代码行数:32,代码来源:GPGLL.cs


注:本文中的System.Coordinate类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。