示例#1
1
 /// <summary>
 /// Reads a <see cref="IMultiLineString"/> geometry.
 /// </summary>
 /// <param name="reader">The reader</param>
 /// <param name="cs">The coordinate system</param>
 ///<param name="srid">The spatial reference id for the geometry.</param>
 ///<returns>A <see cref="IMultiLineString"/> geometry</returns>
 protected IGeometry ReadMultiLineString(BinaryReader reader, CoordinateSystem cs, int srid)
 {
     IGeometryFactory factory = _geometryServices.CreateGeometryFactory(_precisionModel, srid, _sequenceFactory);
     int numGeometries = reader.ReadInt32();
     ILineString[] strings = new ILineString[numGeometries];
     for (int i = 0; i < numGeometries; i++)
     {
         ReadByteOrder(reader);
         CoordinateSystem cs2;
         int srid2;
         WKBGeometryTypes geometryType = ReadGeometryType(reader, out cs2, out srid2);//(WKBGeometryTypes) reader.ReadInt32();
         if (geometryType != WKBGeometryTypes.WKBLineString)
             throw new ArgumentException("ILineString feature expected");
         strings[i] = ReadLineString(reader, cs2, srid2) as ILineString;
     }
     return factory.CreateMultiLineString(strings);
 }
示例#2
0
		protected YuvPlanar(Buffer.Sized buffer, Geometry2D.Integer.Size size, CoordinateSystem coordinateSystem, Geometry2D.Integer.Shell crop) :
			base(buffer, size, coordinateSystem, crop)
		{
			this.Y = this.CreateY();
			this.U = this.CreateU();
			this.V = this.CreateV();
		}
示例#3
0
 /// <summary>Initializes a new instance of the <see cref="T:Microsoft.Spatial.Geometry" /> class.</summary>
 /// <param name="coordinateSystem">The coordinate system of this instance.</param>
 /// <param name="creator">The implementation that created this instance.</param>
 protected Geometry(CoordinateSystem coordinateSystem, SpatialImplementation creator)
 {
     Util.CheckArgumentNull(coordinateSystem, "coordinateSystem");
     Util.CheckArgumentNull(creator, "creator");
     this.coordinateSystem = coordinateSystem;
     this.creator = creator;
 }
示例#4
0
		AnnotationGraphic IDrawProtractor.Draw(CoordinateSystem coordinateSystem, string name, PointF point1, PointF vertex, PointF point2)
		{
			var image = Context.Viewer.SelectedPresentationImage;
			if (!CanStart(image))
				throw new InvalidOperationException("Can't draw a protractor at this time.");

			var imageGraphic = ((IImageGraphicProvider) image).ImageGraphic;
			if (coordinateSystem == CoordinateSystem.Destination)
			{
				point1 = imageGraphic.SpatialTransform.ConvertToSource(point1);
				vertex = imageGraphic.SpatialTransform.ConvertToSource(vertex);
				point2 = imageGraphic.SpatialTransform.ConvertToSource(point2);
			}

			var overlayProvider = (IOverlayGraphicsProvider) image;
			var roiGraphic = CreateRoiGraphic(false);
			roiGraphic.Name = name;
			AddRoiGraphic(image, roiGraphic, overlayProvider);

			var subject = (IPointsGraphic) roiGraphic.Subject;
			subject.Points.Add(point1);
			subject.Points.Add(vertex);
			subject.Points.Add(point2);

			roiGraphic.Callout.Update();
			roiGraphic.State = roiGraphic.CreateSelectedState();
			return roiGraphic;
		}
		public override bool CalculateCalloutLocation(out PointF location, out CoordinateSystem coordinateSystem)
		{
			// if the user has manually positioned the callout, we won't override it
			if (_manuallyPositionedCallout)
			{
				location = PointF.Empty;
				coordinateSystem = CoordinateSystem.Destination;
				return false;
			}

			Callout.CoordinateSystem = CoordinateSystem.Destination;
            AnnotationSubject.CoordinateSystem = CoordinateSystem.Destination;
			try
			{
                var roiBoundingBox = AnnotationSubject.BoundingBox;
                var clientRectangle = AnnotationSubject.ParentPresentationImage.ClientRectangle;

				var textSize = Callout.TextBoundingBox.Size;
				if (textSize.IsEmpty)
					textSize = new SizeF(100, 50);

				coordinateSystem = CoordinateSystem.Destination;
				location = new PointF(ComputeCalloutLocationX(textSize, clientRectangle, roiBoundingBox), ComputeCalloutLocationY(textSize, clientRectangle, roiBoundingBox));
			}
			finally
			{
				Callout.ResetCoordinateSystem();
                AnnotationSubject.ResetCoordinateSystem();
			}
			return true;
		}
示例#6
0
		protected Image(Geometry2D.Integer.Size size, CoordinateSystem coordinateSystem, Geometry2D.Integer.Shell crop) :
			base(size, coordinateSystem, crop)
		{
			this.LeftTop = new Geometry2D.Single.Point(0, 0);
			this.RightTop = new Geometry2D.Single.Point(1, 0);
			this.LeftBottom = new Geometry2D.Single.Point(0, 1);
			this.RightBottom = new Geometry2D.Single.Point(1, 1);
		}
示例#7
0
 public Linear(CoordinateSystem entity, Vector2 direction)
 {
     PathAwareEntity = entity as PathAware;
     Position = entity.Position;
     if (direction.X != 0 || direction.Y != 0)
     {
         direction.Normalize();
     }
     Direction = direction;
 }
        private static void ReadPointTest(SpatialFormatter<TextReader, TextWriter> formatter, TextReader input, PositionData expected, CoordinateSystem expectedCoordinateSystem = null)
        {
            var p = formatter.Read<Geography>(input);
            Assert.NotNull(p);
            p.VerifyAsPoint(expected);

            if (expectedCoordinateSystem != null)
            {
                Assert.Equal(p.CoordinateSystem, expectedCoordinateSystem);
            }
        }
        private void ReadPolygonTest(string input, CoordinateSystem expectedReference, params PositionData[][] expected)
        {
            var p = this.d4Formatter.Read<Geography>(new StringReader(input));
            Assert.NotNull(p);
            p.VerifyAsPolygon(expected);

            if (expectedReference != null)
            {
                Assert.Equal(p.CoordinateSystem, expectedReference);
            }
        }
示例#10
0
 public static GeometryPoint Create(CoordinateSystem coordinateSystem, double x, double y, double? z, double? m)
 {
     var builder = SpatialBuilder.Create();
     var pipeline = builder.GeometryPipeline;
     pipeline.SetCoordinateSystem(coordinateSystem);
     pipeline.BeginGeometry(SpatialType.Point);
     pipeline.BeginFigure(new GeometryPosition(x, y, z, m));
     pipeline.EndFigure();
     pipeline.EndGeometry();
     return (GeometryPoint)builder.ConstructedGeometry;
 }
示例#11
0
 public static GeographyPoint Create(CoordinateSystem coordinateSystem, double latitude, double longitude, double? z, double? m)
 {
     var builder = SpatialBuilder.Create();
     var pipeline = builder.GeographyPipeline;
     pipeline.SetCoordinateSystem(coordinateSystem);
     pipeline.BeginGeography(SpatialType.Point);
     pipeline.BeginFigure(new GeographyPosition(latitude, longitude, z, m));
     pipeline.EndFigure();
     pipeline.EndGeography();
     return (GeographyPoint)builder.ConstructedGeography;
 }
 public static void AreEqual(CoordinateSystem expected, CoordinateSystem actual, double tolerance = 1e-6, string message = "")
 {
     if (string.IsNullOrEmpty(message))
         message = string.Format("Expected {0} but was {1}", expected, actual);
     if (expected.Values.Length != actual.Values.Length)
         Assert.Fail();
     for (int i = 0; i < expected.Values.Length; i++)
     {
         Assert.AreEqual(expected.Values[i], actual.Values[i], tolerance);
     }
 }
        public static void AreEqual(CoordinateSystem coordinateSystem, Point3D origin, Vector3D xAxis, Vector3D yAxis, Vector3D zAxis, double tolerance = 1e-6)
        {
            AreEqual(xAxis, coordinateSystem.XAxis, tolerance);
            AreEqual(yAxis, coordinateSystem.YAxis, tolerance);
            AreEqual(zAxis, coordinateSystem.ZAxis, tolerance);
            AreEqual(origin, coordinateSystem.Origin, tolerance);

            AreEqual(new double[] { xAxis.X, xAxis.Y, xAxis.Z, 0 }, coordinateSystem.Column(0).ToArray(), tolerance);
            AreEqual(new double[] { yAxis.X, yAxis.Y, yAxis.Z, 0 }, coordinateSystem.Column(1).ToArray(), tolerance);
            AreEqual(new double[] { zAxis.X, zAxis.Y, zAxis.Z, 0 }, coordinateSystem.Column(2).ToArray(), tolerance);
            AreEqual(new double[] { origin.X, origin.Y, origin.Z, 1 }, coordinateSystem.Column(3).ToArray(), tolerance);
        }
示例#14
0
        public void ShouldConvertPointsFromWgs84ToLambert93()
        {
            var wgs84=new CoordinateSystem(new DotGeo.World().WGS1984);
            var lam93=new CoordinateSystem(new DotPrj.NationalGrids().RGF1993Lambert93);

            var ct=new CoordinatesTransformer(wgs84, lam93);

            foreach (var coordinates in new double[][][] { _Paris, _NewYorkCity })
            {
                var input=coordinates[0];
                var expected=coordinates[1];
                var result=ct.Convert(input);

                Assert.Equal(expected, result, new CoordinateComparer(2));
            }
        }
		public override void CalculateCalloutEndPoint(out PointF endPoint, out CoordinateSystem coordinateSystem)
		{
			if (_userMovedCallout)
			{
				base.CalculateCalloutEndPoint(out endPoint, out coordinateSystem);
			}
			else
			{
                coordinateSystem = AnnotationSubject.CoordinateSystem;

				if (this.Roi.Points.Count < 3)
					endPoint = this.Roi.Points[0];
				else
					endPoint = this.Roi.Points[1];
			}
		}
		public override bool CalculateCalloutLocation(out PointF location, out CoordinateSystem coordinateSystem)
		{
			if (this.Roi.Points.Count < 3 || string.IsNullOrEmpty(this.Callout.Text))
				base.Callout.Visible = false;
			else
				base.Callout.Visible = true;

			if (!base.Callout.Visible || _userMovedCallout)
				return base.CalculateCalloutLocation(out location, out coordinateSystem);

			SizeF calloutOffsetDestination = GetCalloutOffsetDestination();

			coordinateSystem = CoordinateSystem.Destination;
			base.AnnotationGraphic.CoordinateSystem = coordinateSystem;

			// first, move the callout by the same amount the vertex moved (if it moved at all).
			location = base.Callout.TextLocation + calloutOffsetDestination;

			PointF start = this.Roi.Points[0];
			PointF vertex = this.Roi.Points[1];
			PointF end = this.Roi.Points[2];

			base.AnnotationGraphic.ResetCoordinateSystem();

			double vectorAngle = -Vector.SubtendedAngle(start, vertex, end) / 2 + 180;

			PointF[] points = new PointF[] { start, end };

			using (Matrix rotation = new Matrix())
			{
				rotation.Rotate((float) vectorAngle);
				rotation.Translate(-vertex.X, -vertex.Y);
				rotation.TransformPoints(points);
			}

			float calloutMagnitude = new Vector3D(location.X - vertex.X, location.Y - vertex.Y, 0).Magnitude;

			Vector3D startVector = new Vector3D(points[0].X, points[0].Y, 0);
			if (FloatComparer.AreEqual(startVector.Magnitude, 0F, 0.01F))
				startVector = new Vector3D(-1, 0, 0);

			startVector = startVector / startVector.Magnitude * calloutMagnitude;

			location = new PointF(startVector.X + vertex.X, startVector.Y + vertex.Y);

			return true;
		}
示例#17
0
    private void CreateNewCoordinateSystem(int id)
    {
        if((31 - m_coordinateSystems.Count) < 15)
        {
            throw new OverflowException("Too many coordinate systems in use.");
        }

        var coordSystem = new CoordinateSystem();
        coordSystem.objects = new List<GameObject>();
        coordSystem.layerNumber = (31 - m_coordinateSystems.Count);
        coordSystem.cullingMask =  1 << coordSystem.layerNumber;

        coordSystem.camera = Instantiate(m_cameraPrefab);
        // Add new camera under "Cameras"-entity.
        coordSystem.camera.transform.parent = transform.parent.FindChild("Cameras");
        coordSystem.camera.GetComponent<Camera>().cullingMask = coordSystem.cullingMask;
        m_coordinateSystems[id] = coordSystem;
    }
示例#18
0
        public Entity2D(Texture2D texture, CoordinateSystem parent)
        {
            SourceRectangle = null;

            Dirty = false;
            Texture = texture;

            Parent = parent;
            BoundingArea = new Sphere(new Vector2(0, 0), 1);
            Position = new Vector2(0, 0);
            Rotation = 0f;
            Scale = 1f;
            Tint = Color.White;

            Origin = new Vector2(0, 0);
            Layer = 0f;
            Opacity = 1f;
            Flip = SpriteEffects.None;
        }
		public override bool CalculateCalloutLocation(out PointF location, out CoordinateSystem coordinateSystem)
		{
			// if the user has manually positioned the callout, we won't override it
			if (_manuallyPositionedCallout || Roi.Points.Count == 0)
			{
				location = PointF.Empty;
				coordinateSystem = CoordinateSystem.Destination;
				return false;
			}

			Callout.CoordinateSystem = CoordinateSystem.Destination;
			Roi.CoordinateSystem = CoordinateSystem.Destination;
			try
			{
				var roiPoint1 = Roi.Points[0];
				var roiPoint2 = Roi.Points[Roi.Points.Count - 1];
				var clientRectangle = Roi.ParentPresentationImage.ClientRectangle;

				var textSize = Callout.TextBoundingBox.Size;
				if (textSize.IsEmpty)
					textSize = new SizeF(100, 50);

				var calloutLocation = new PointF();
				calloutLocation.Y = ComputeCalloutLocationY(textSize, clientRectangle, roiPoint1, roiPoint2);
				calloutLocation.X = ComputeCalloutLocationX(textSize, clientRectangle, roiPoint1, roiPoint2, calloutLocation.Y);

				coordinateSystem = CoordinateSystem.Destination;
				location = calloutLocation;
			}
			finally
			{
				Callout.ResetCoordinateSystem();
				Roi.ResetCoordinateSystem();
			}
			return true;
		}
示例#20
0
 /// <summary>
 /// Reads a <see cref="IPolygon"/> geometry.
 /// </summary>
 /// <param name="reader">The reader</param>
 /// <param name="cs">The coordinate system</param>
 ///<param name="srid">The spatial reference id for the geometry.</param>
 ///<returns>A <see cref="IPolygon"/> geometry</returns>
 protected IGeometry ReadPolygon(BinaryReader reader, CoordinateSystem cs, int srid)
 {
     IGeometryFactory factory = _geometryServices.CreateGeometryFactory(_precisionModel, srid, _sequenceFactory);
     ILinearRing exteriorRing = null;
     ILinearRing[] interiorRings = null;
     int numRings = reader.ReadInt32();
     if (numRings > 0)
     {
         exteriorRing = ReadLinearRing(reader, cs, srid);
         interiorRings = new ILinearRing[numRings - 1];
         for (int i = 0; i < numRings - 1; i++)
             interiorRings[i] = ReadLinearRing(reader, cs, srid);
     }
     return factory.CreatePolygon(exteriorRing, interiorRings);
 }
示例#21
0
 /// <summary>
 /// Reads a <see cref="IMultiPolygon"/> geometry.
 /// </summary>
 /// <param name="reader">The reader</param>
 /// <param name="cs">The coordinate system</param>
 ///<param name="srid">The spatial reference id for the geometry.</param>
 ///<returns>A <see cref="IMultiPolygon"/> geometry</returns>
 protected IGeometry ReadMultiPolygon(BinaryReader reader, CoordinateSystem cs, int srid)
 {
     IGeometryFactory factory = _geometryServices.CreateGeometryFactory(_precisionModel, srid, _sequenceFactory);
     int numGeometries = reader.ReadInt32();
     IPolygon[] polygons = new IPolygon[numGeometries];
     for (int i = 0; i < numGeometries; i++)
     {
         ReadByteOrder(reader);
         CoordinateSystem cs2;
         int srid2;
         WKBGeometryTypes geometryType = ReadGeometryType(reader, out cs2, out srid2);//(WKBGeometryTypes) reader.ReadInt32();
         if (geometryType != WKBGeometryTypes.WKBPolygon)
             throw new ArgumentException("IPolygon feature expected");
         polygons[i] = ReadPolygon(reader, cs2, srid2) as IPolygon;
     }
     return factory.CreateMultiPolygon(polygons);
 }
示例#22
0
文件: Operators.cs 项目: sandrist/psi
 /// <summary>
 /// Transforms a point cloud by a coordinate system.
 /// </summary>
 /// <param name="coordinateSystem">The coordinate system.</param>
 /// <param name="pointCloud3D">The point cloud.</param>
 /// <returns>The transformed point cloud.</returns>
 public static PointCloud3D Transform(this CoordinateSystem coordinateSystem, PointCloud3D pointCloud3D)
 => pointCloud3D.TransformBy(coordinateSystem);
示例#23
0
 /// <summary>
 /// Sets the CoordinateSystem for Geography and Geometry shapes.
 /// </summary>
 /// <param name="coordinateSystem">CoordinateSystem value to set.</param>
 private void SetCoordinateSystem(CoordinateSystem coordinateSystem)
 {
     this.currentCoordinateSystem = coordinateSystem;
 }
示例#24
0
        public void Hull2dCommand()
        {
            Editor editor = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;

            try
            {
                //LicenseManager.CheckValid("FULL");
                ObjectId[] idArray = CommandLineQuerries.SelectPoints(false);
                CMD_Hull2d.string_0 = CommandLineQuerries.SpecifyProjectionDirection(CMD_Hull2d.string_0);
                ngeometry.VectorGeometry.Vector3d vector3d = new ngeometry.VectorGeometry.Vector3d(0.0, 0.0, 1.0);
                string a;
                if ((a = CMD_Hull2d.string_0.ToUpper()) != null)
                {
                    if (!(a == "X"))
                    {
                        if (!(a == "Y"))
                        {
                            if (!(a == "Z"))
                            {
                                if (!(a == "U"))
                                {
                                    if (!(a == "2P"))
                                    {
                                        goto IL_150;
                                    }
                                    vector3d = CommandLineQuerries.Specify2PDirection().BasisVector[2];
                                    vector3d = vector3d.Normalize();
                                }
                                else
                                {
                                    vector3d = Conversions.GetUCS().BasisVector[2].Normalize();
                                }
                            }
                            else
                            {
                                vector3d = new ngeometry.VectorGeometry.Vector3d(0.0, 0.0, 1.0);
                            }
                        }
                        else
                        {
                            vector3d = new ngeometry.VectorGeometry.Vector3d(0.0, 1.0, 0.0);
                        }
                    }
                    else
                    {
                        vector3d = new ngeometry.VectorGeometry.Vector3d(1.0, 0.0, 0.0);
                    }
                    Point point = new Point(0.0, 0.0, 0.0);
                    ngeometry.VectorGeometry.Plane plane = new ngeometry.VectorGeometry.Plane(point, vector3d);
                    CoordinateSystem actualCS            = new CoordinateSystem(plane);
                    CMD_Hull2d.Compute2dHull(idArray, actualCS);
                    return;
                }
IL_150:
                throw new System.Exception("Invalid option keyword.");
            }
            catch (System.Exception ex)
            {
                editor.WriteMessage("\n" + ex.Message);
            }
        }
 /// <summary>
 /// Returns a collection with items matching a specified coordinate system.
 /// </summary>
 /// <param name="coordinateSystem">The coordinate system.</param>
 /// <returns>A collection containing the items that match the specified coordinate system.</returns>
 public IEnumerable <VerticalCoordinateReferenceSystem> WithCoordinateSystem(CoordinateSystem coordinateSystem)
 {
     return(this.GetReferences().Where(referenceSystem => referenceSystem.CoordinateSystem.Equals(coordinateSystem)));
 }
示例#26
0
        private void button3_Click(object sender, EventArgs e)
        {
            CoordinateSystem coordinateSystem = new CoordinateSystem(this.comboBox1.Text);

            coordinateSystem.Show();
        }
示例#27
0
        private void drawAufgabeFromDot(object sender, MouseEventArgs e)
        {
            float  iX, iY;
            string strIFS = "";

            iX = (e.X * (_coord.MaxX - _coord.MinX)) / (float)ImageWidth + _coord.MinX;
            iY = (e.Y * (_coord.MaxY - _coord.MinY)) / (float)ImageHeight + _coord.MinY;

            // IFS laden
            switch (iKlicks)
            {
            case 0:
                strIFS = "IFS_TEST.IFS";
                break;

            case 1:
                strIFS = "Bigbang.IFS";
                break;

            case 2:
                strIFS = "Filmstreifen.IFS";
                break;

            case 3:
                strIFS = "Strauch.IFS";
                break;

            case 4:
                strIFS = "Swirl.IFS";
                break;

            case 5:
                strIFS = "Wirbel_blatt.IFS";
                break;

            case 6:
                Logger.Instance.LogInfo("\n" + "!!! Jetzt kommt Aufgabe 4 !!!");
                strIFS = "IFS_TEST.IFS";
                break;

            default:
                strIFS  = "Farn_1.IFS";
                iKlicks = 0;
                break;
            }
            iKlicks++;
            _ifs = GLabReader.ReadIfsFromFile("..\\..\\IFS2\\" + strIFS);
            Logger.Instance.LogInfo("IFS:\t" + strIFS);
            readIfsProbabilities();

            // Create a new raster image for drawing
            _image = new Image <Rgb, byte>(MAX_COORDINATE, MAX_COORDINATE, new Rgb(Color.Black));

            // Painter initialisieren mit neuem Koordinatensystem
            _coord   = new CoordinateSystem(_ifs.CoordinateSystem.MinX, _ifs.CoordinateSystem.MaxX, _ifs.CoordinateSystem.MinY, _ifs.CoordinateSystem.MaxY);
            _painter = new Painter(ref _image, _coord);
            _frame.SetImage(_image);
            _painter.PaintCoordinateSystem(16, Color.Red);

            // Punkt zeichnen
            Aufgabe(getFixPoint());
        }
 private static Autodesk.DesignScript.Geometry.Geometry Transform(Autodesk.DesignScript.Geometry.Geometry geom, CoordinateSystem coordinateSystem)
 {
     if (coordinateSystem == null)
     {
         return(geom);
     }
     return(geom.Transform(coordinateSystem));
 }
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="coordinateSystem">The CoordinateSystem</param>
 /// <param name="creator">The implementation that created this instance.</param>
 internal GeographyFullGlobeImplementation(CoordinateSystem coordinateSystem, SpatialImplementation creator)
     : base(coordinateSystem, creator)
 {
 }
 private static IEnumerable <Autodesk.DesignScript.Geometry.Geometry> Transform(IEnumerable <Autodesk.DesignScript.Geometry.Geometry> geom, CoordinateSystem coordinateSystem)
 {
     if (coordinateSystem == null)
     {
         return(geom);
     }
     return(geom.Select(x => Transform(x, coordinateSystem)).ToList());
 }
 private static object Transform(object geom, CoordinateSystem coordinateSystem)
 {
     return(geom);
 }
示例#32
0
文件: Operators.cs 项目: sandrist/psi
 /// <summary>
 /// Transforms a box by a coordinate system.
 /// </summary>
 /// <param name="coordinateSystem">The coordinate system.</param>
 /// <param name="box3D">The box.</param>
 /// <returns>The transformed box.</returns>
 public static Box3D Transform(this CoordinateSystem coordinateSystem, Box3D box3D)
 => box3D.TransformBy(coordinateSystem);
示例#33
0
        private WKBGeometryTypes ReadGeometryType(BinaryReader reader, out CoordinateSystem coordinateSystem, out int srid)
        {
            uint type = reader.ReadUInt32();
            //Determine coordinate system
            if ((type & (0x80000000 | 0x40000000)) == (0x80000000 | 0x40000000))
                coordinateSystem = CoordinateSystem.XYZM;
            else if ((type & 0x80000000) == 0x80000000)
                coordinateSystem = CoordinateSystem.XYZ;
            else if ((type & 0x40000000) == 0x40000000)
                coordinateSystem = CoordinateSystem.XYM;
            else
                coordinateSystem = CoordinateSystem.XY;

            //Has SRID
            if ((type & 0x20000000) != 0)
                srid = reader.ReadInt32();
            else
                srid = -1;

            if (!HandleSRID) srid = -1;

            //Get cs from prefix
            uint ordinate = (type & 0xffff) / 1000;
            switch (ordinate)
            {
                case 1:
                    coordinateSystem = CoordinateSystem.XYZ;
                    break;
                case 2:
                    coordinateSystem = CoordinateSystem.XYM;
                    break;
                case 3:
                    coordinateSystem = CoordinateSystem.XYZM;
                    break;
            }

            return (WKBGeometryTypes)((type & 0xffff) % 1000);
        }
示例#34
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="coordinateSystem">The CoordinateSystem</param>
 /// <param name="creator">The implementation that created this instance.</param>
 /// <param name="rings">The rings of this polygon</param>
 internal GeographyPolygonImplementation(CoordinateSystem coordinateSystem, SpatialImplementation creator, params GeographyLineString[] rings)
     : base(coordinateSystem, creator)
 {
     this.rings = rings ?? new GeographyLineString[0];
 }
示例#35
0
		internal static float ConvertStartAngle(float angle, SpatialTransform transform, CoordinateSystem targetSystem)
		{
			PointF xVector = new PointF(100, 0);

			Matrix rotation = new Matrix();
			PointF[] angleVector = new PointF[] { xVector };
			rotation.Rotate(angle);
			rotation.TransformVectors(angleVector);
			rotation.Dispose();

			SizeF xVectorTransformed, angleVectorTransformed;
			if (targetSystem == Graphics.CoordinateSystem.Destination)
			{
				xVectorTransformed = transform.ConvertToDestination(new SizeF(xVector));
				angleVectorTransformed = transform.ConvertToDestination(new SizeF(angleVector[0]));
			}
			else
			{
				xVectorTransformed = transform.ConvertToSource(new SizeF(xVector));
				angleVectorTransformed = transform.ConvertToSource(new SizeF(angleVector[0]));
			}

			float xRotationOffset =
				(int)Math.Round(Vector.SubtendedAngle(xVectorTransformed.ToPointF(), PointF.Empty, xVector));

			float angleTransformed =
				(int)Math.Round(Vector.SubtendedAngle(angleVectorTransformed.ToPointF(), PointF.Empty, xVectorTransformed.ToPointF()));

			// have to figure out where x-axis moved to and then return the difference between the angle
			// and the x-axis, where both are in 'target' coordinates.
			float returnAngle = angleTransformed + xRotationOffset;
			if (returnAngle < 0)
				returnAngle += 360;

			return returnAngle;
		}
 internal GeographyMultiLineStringImplementation(CoordinateSystem coordinateSystem, SpatialImplementation creator, params GeographyLineString[] lineStrings) : base(coordinateSystem, creator)
 {
     this.lineStrings = lineStrings ?? new GeographyLineString[0];
 }
示例#37
0
        /// <summary>
        /// Calculates the geocentric ecliptic coordinates of the planet at a specified time.
        /// </summary>
        /// <param name="time">Local time.</param>
        /// <param name="isApparent">Is it the apparent ecliptic coordinates.</param>
        /// <returns>Geocentric ecliptic coordinates.</returns>
        public virtual Ecliptic GetEclipticCoordinate(DateTime time, bool isApparent = false)
        {
            Earth e = new Earth();

            var    earth = e.GetHeliocentricEclipticCoordinate(time);
            double r0    = e.GetToSunDistance(time);
            var    e1    = GetHeliocentricEclipticCoordinate(time);
            double r1    = GetToSunDistance(time);

            double x1 = r1 * Math.Cos(e1.Latitude * (Math.PI / 180.0)) * Math.Cos(e1.Longitude * (Math.PI / 180.0)) - r0 * Math.Cos(earth.Latitude * (Math.PI / 180.0)) * Math.Cos(earth.Longitude * (Math.PI / 180.0));
            double y1 = r1 * Math.Cos(e1.Latitude * (Math.PI / 180.0)) * Math.Sin(e1.Longitude * (Math.PI / 180.0)) - r0 * Math.Cos(earth.Latitude * (Math.PI / 180.0)) * Math.Sin(earth.Longitude * (Math.PI / 180.0));
            double z1 = r1 * Math.Sin(e1.Latitude * (Math.PI / 180.0)) - r0 * Math.Sin(earth.Latitude * (Math.PI / 180.0));

            if (isApparent)
            {
                double t = 0.0057755183 * Math.Sqrt(x1 * x1 + y1 * y1 + z1 * z1);

                var    e2 = GetHeliocentricEclipticCoordinate(time, t);
                double r2 = GetToSunDistance(time, t);

                double x2       = r2 * Math.Cos(e2.Latitude * (Math.PI / 180.0)) * Math.Cos(e2.Longitude * (Math.PI / 180.0)) - r0 * Math.Cos(earth.Latitude * (Math.PI / 180.0)) * Math.Cos(earth.Longitude * (Math.PI / 180.0));
                double y2       = r2 * Math.Cos(e2.Latitude * (Math.PI / 180.0)) * Math.Sin(e2.Longitude * (Math.PI / 180.0)) - r0 * Math.Cos(earth.Latitude * (Math.PI / 180.0)) * Math.Sin(earth.Longitude * (Math.PI / 180.0));
                double z2       = r2 * Math.Sin(e2.Latitude * (Math.PI / 180.0)) - r0 * Math.Sin(earth.Latitude * (Math.PI / 180.0));
                var    nutation = CoordinateSystem.GetNutation(time);
                // Uncorrected annual aberration
                // Corrected the light time and nutation of ecliptic longitude.
                double latitude  = Math.Atan2(z2, Math.Sqrt(x2 * x2 + y2 * y2)) * (180 / Math.PI);
                double longitude = Math.Atan2(y2, x2) * (180 / Math.PI) + nutation.Longitude;

                if (longitude < 0)
                {
                    return(new Ecliptic
                    {
                        Latitude = latitude,
                        Longitude = longitude + 360
                    });
                }
                else
                {
                    return(new Ecliptic
                    {
                        Latitude = latitude,
                        Longitude = longitude
                    });
                }
            }
            else
            {
                double latitude  = Math.Atan2(z1, Math.Sqrt(x1 * x1 + y1 * y1)) * (180 / Math.PI);
                double longitude = Math.Atan2(y1, x1) * (180 / Math.PI);

                if (longitude < 0)
                {
                    return(new Ecliptic
                    {
                        Latitude = latitude,
                        Longitude = longitude + 360
                    });
                }
                else
                {
                    return(new Ecliptic
                    {
                        Latitude = latitude,
                        Longitude = longitude
                    });
                }
            }
        }
示例#38
0
		public Yuv444(Geometry2D.Integer.Size size, CoordinateSystem coordinateSystem, Geometry2D.Integer.Shell crop) :
			this(new Buffer.Vector<byte>(3 * Packed.CalculateLength(size, 1)), size, coordinateSystem, crop) { }
示例#39
0
 /// <summary>Initializes a new instance of the <see cref="T:Microsoft.Spatial.GeometryPoint" /> class. Empty Point constructor.</summary>
 /// <param name="coordinateSystem">The CoordinateSystem.</param>
 /// <param name="creator">The implementation that created this instance.</param>
 protected GeometryPoint(CoordinateSystem coordinateSystem, SpatialImplementation creator)
     : base(coordinateSystem, creator)
 {
 }
示例#40
0
 /// <summary>
 /// Set the coordinate system
 /// </summary>
 /// <param name="coordinateSystem">The CoordinateSystem</param>
 /// <returns>
 /// the coordinate system to be passed down the pipeline
 /// </returns>
 protected override CoordinateSystem OnSetCoordinateSystem(CoordinateSystem coordinateSystem)
 {
     SetCoordinateSystem(coordinateSystem);
     return(coordinateSystem);
 }
示例#41
0
 /// <summary>
 /// Setup the pipeline for reuse
 /// </summary>
 protected virtual void Reset()
 {
     this.stack.Clear();
     this.currentCoordinateSystem = default(CoordinateSystem);
 }
示例#42
0
 /// <summary>
 /// Reads a <see cref="ILineString"/> geometry.
 /// </summary>
 /// <param name="reader">The reader</param>
 /// <param name="cs">The coordinate system</param>
 ///<param name="srid">The spatial reference id for the geometry.</param>
 ///<returns>A <see cref="ILineString"/> geometry</returns>
 protected IGeometry ReadLineString(BinaryReader reader, CoordinateSystem cs, int srid)
 {
     IGeometryFactory factory = _geometryServices.CreateGeometryFactory(_precisionModel, srid, _sequenceFactory);
     int numPoints = reader.ReadInt32();
     ICoordinateSequence sequence = ReadCoordinateSequenceLineString(reader, numPoints, cs);
     return factory.CreateLineString(sequence);
 }
示例#43
0
        public static void Compute2dHull(ObjectId[] idArray, CoordinateSystem actualCS)
        {
            Editor        editor          = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;
            Database      workingDatabase = HostApplicationServices.WorkingDatabase;
            ProgressMeter progressMeter   = new ProgressMeter();
            MessageFilter value           = new MessageFilter();

            System.Windows.Forms.Application.AddMessageFilter(value);
            try
            {
                using (Transaction transaction = workingDatabase.TransactionManager.StartTransaction())
                {
                    progressMeter.SetLimit(idArray.Length);
                    if ((double)idArray.Length > 10000.0)
                    {
                        progressMeter.Start("Computing 2d hull...");
                    }
                    CoordinateTransformator coordinateTransformator = new CoordinateTransformator(CoordinateSystem.Global(), actualCS);
                    CoordinateTransformator inverseTransformation   = coordinateTransformator.GetInverseTransformation();
                    BlockTable       blockTable       = (BlockTable)transaction.GetObject(workingDatabase.BlockTableId, (OpenMode)1);
                    BlockTableRecord blockTableRecord = (BlockTableRecord)transaction.GetObject(blockTable[BlockTableRecord.ModelSpace], (OpenMode)1);
                    ObjectId         layerId          = DBManager.CurrentLayerId();
                    DBManager.CurrentLayerName();
                    PointSet pointSet = new PointSet();
                    for (int i = 0; i < idArray.Length; i++)
                    {
                        DBPoint dBPoint = (DBPoint)transaction.GetObject(idArray[i], (OpenMode)0, true);
                        Point   point   = new Point(dBPoint.Position.X, dBPoint.Position.Y, dBPoint.Position.Z);
                        coordinateTransformator.Transform(point);
                        pointSet.Add(point);
                    }
                    ConvexHull2d convexHull2d = new ConvexHull2d();
                    convexHull2d.InitialPoints = pointSet;
                    convexHull2d.ComputeHull();
                    PointSet vertices = convexHull2d.Vertices;
                    double   z        = vertices[0].Z;
                    for (int j = 0; j < vertices.Count; j++)
                    {
                        vertices[j].Z = z;
                    }
                    double areaXY = convexHull2d.AreaXY;
                    for (int k = 0; k < vertices.Count; k++)
                    {
                        inverseTransformation.Transform(vertices[k]);
                    }
                    Point3dCollection point3dCollection = Conversions.ToPoint3dCollection(vertices.ToList());
                    Polyline3d        polyline3d        = new Polyline3d(0, point3dCollection, true);
                    polyline3d.LayerId = (layerId);
                    blockTableRecord.AppendEntity(polyline3d);
                    transaction.AddNewlyCreatedDBObject(polyline3d, true);
                    editor.WriteMessage("\n2d convex hull properties:");
                    editor.WriteMessage("\nNumber of vertices on hull : " + convexHull2d.Vertices.Count);
                    editor.WriteMessage("\nHull perimeter length      : " + convexHull2d.PerimeterLength.ToString(DBManager.GetFormatFromLUPREC()));
                    editor.WriteMessage("\nEnclosed area in hull plane: " + areaXY.ToString(DBManager.GetFormatFromLUPREC()));
                    transaction.Commit();
                }
                progressMeter.Stop();
            }
            catch (System.Exception ex)
            {
                progressMeter.Stop();
                throw;
            }
        }
示例#44
0
文件: Operators.cs 项目: sandrist/psi
 /// <summary>
 /// Convert a <see cref="CoordinateSystem"/> to the equivalent <see cref="Matrix4x4"/>.
 /// </summary>
 /// <param name="coordinateSystem">The <see cref="CoordinateSystem"/> to convert.</param>
 /// <returns>The equivalent <see cref="Matrix4x4"/>.</returns>
 public static Matrix4x4 ToSystemNumericsMatrix(this CoordinateSystem coordinateSystem)
 => new ((float)coordinateSystem.Values[0],
示例#45
0
 /// <summary>Initializes a new instance of the <see cref="T:Microsoft.Spatial.GeometryMultiCurve" /> class.</summary>
 /// <param name="coordinateSystem">The coordinate system of this instance.</param>
 /// <param name="creator">The implementation that created this instance.</param>
 protected GeometryMultiCurve(CoordinateSystem coordinateSystem, SpatialImplementation creator)
     : base(coordinateSystem, creator)
 {
 }
示例#46
0
        /// <summary>
        /// Transforms a point list between coordinate systems.
        /// </summary>
        /// <param name="points">Points to transform.</param>
        /// <param name="zAxis">Object normal vector.</param>
        /// <param name="from">Points coordinate system.</param>
        /// <param name="to">Coordinate system of the transformed points.</param>
        /// <returns>Transormed point list.</returns>
        public static List <Vector3> Transform(List <Vector3> points, Vector3 zAxis, CoordinateSystem from, CoordinateSystem to)
        {
            if (zAxis.Equals(Vector3.UnitZ))
            {
                return(points);
            }

            Matrix3        trans = ArbitraryAxis(zAxis);
            List <Vector3> transPoints;

            if (from == CoordinateSystem.World && to == CoordinateSystem.Object)
            {
                transPoints = new List <Vector3>();
                trans       = trans.Traspose();
                foreach (Vector3 p in points)
                {
                    transPoints.Add(trans * p);
                }
                return(transPoints);
            }
            if (from == CoordinateSystem.Object && to == CoordinateSystem.World)
            {
                transPoints = new List <Vector3>();
                foreach (Vector3 p in points)
                {
                    transPoints.Add(trans * p);
                }
                return(transPoints);
            }
            return(points);
        }
 /// <summary>
 /// Calculates the callout endpoint using the <see cref="IGraphic.GetClosestPoint"/> method.
 /// </summary>
 public virtual void CalculateCalloutEndPoint(out PointF endPoint, out CoordinateSystem coordinateSystem)
 {
     coordinateSystem = AnnotationGraphic.CoordinateSystem;
     endPoint         = AnnotationGraphic.Subject.GetClosestPoint(AnnotationGraphic.Callout.TextLocation);
 }
示例#48
0
        /// <summary>
        /// Transforms a point between coordinate systems.
        /// </summary>
        /// <param name="point">Point to transform.</param>
        /// <param name="zAxis">Object normal vector.</param>
        /// <param name="from">Point coordinate system.</param>
        /// <param name="to">Coordinate system of the transformed point.</param>
        /// <returns>Transormed point.</returns>
        public static Vector3 Transform(Vector3 point, Vector3 zAxis, CoordinateSystem from, CoordinateSystem to)
        {
            // if the normal is (0,0,1) no transformation is needed the transformation matrix is the identity
            if (zAxis.Equals(Vector3.UnitZ))
            {
                return(point);
            }

            Matrix3 trans = ArbitraryAxis(zAxis);

            if (from == CoordinateSystem.World && to == CoordinateSystem.Object)
            {
                trans = trans.Traspose();
                return(trans * point);
            }
            if (from == CoordinateSystem.Object && to == CoordinateSystem.World)
            {
                return(trans * point);
            }
            return(point);
        }
示例#49
0
 /// <summary>
 /// Reads a <see cref="IPoint"/> geometry.
 /// </summary>
 /// <param name="reader">The reader</param>
 /// <param name="cs">The coordinate system</param>
 ///<param name="srid">The spatial reference id for the geometry.</param>
 ///<returns>A <see cref="IPoint"/> geometry</returns>
 protected IGeometry ReadPoint(BinaryReader reader, CoordinateSystem cs, int srid)
 {
     IGeometryFactory factory = _geometryServices.CreateGeometryFactory(_precisionModel, srid, _sequenceFactory);
     return factory.CreatePoint(ReadCoordinateSequence(reader, 1, cs));
 }
示例#50
0
        /// <summary>
        /// Transforms a point between coordinate systems.
        /// </summary>
        /// <param name="point">Point to transform.</param>
        /// <param name="rotation">Rotation angle in radians.</param>
        /// <param name="from">Point coordinate system.</param>
        /// <param name="to">Coordinate system of the transformed point.</param>
        /// <returns>Transormed point.</returns>
        public static Vector2 Transform(Vector2 point, double rotation, CoordinateSystem from, CoordinateSystem to)
        {
            // if the rotation is 0 no transformation is needed the transformation matrix is the identity
            if (IsZero(rotation))
            {
                return(point);
            }

            double sin = Math.Sin(rotation);
            double cos = Math.Cos(rotation);

            if (from == CoordinateSystem.World && to == CoordinateSystem.Object)
            {
                return(new Vector2(point.X * cos + point.Y * sin, -point.X * sin + point.Y * cos));
            }
            if (from == CoordinateSystem.Object && to == CoordinateSystem.World)
            {
                return(new Vector2(point.X * cos - point.Y * sin, point.X * sin + point.Y * cos));
            }
            return(point);
        }
示例#51
0
 /// <summary>
 /// Function to convert from <see cref="CoordinateSystem"/> to <see cref="Ordinates"/>
 /// </summary>
 /// <param name="cs">The coordinate system</param>
 /// <returns>The corresponding <see cref="Ordinates"/></returns>
 private static Ordinates ToOrdinates(CoordinateSystem cs)
 {
     Ordinates res = Ordinates.XY;
     if (cs == CoordinateSystem.XYM)
         res |= Ordinates.M;
     if (cs == CoordinateSystem.XYZ)
         res |= Ordinates.Z;
     if (cs == CoordinateSystem.XYZM)
         res |= (Ordinates.M | Ordinates.Z);
     return res;
 }
示例#52
0
        public static void InitializeThreeDimensionController(
            CoordinateSystem coordinateSystem,
            GroupBox groupbox,
            Button buttonSquareLeft,
            Button buttonSquareRight,
            Button buttonSquareUp,
            Button buttonSquareDown,
            Button buttonSquareUpLeft,
            Button buttonSquareDownLeft,
            Button buttonSquareUpRight,
            Button buttonSquareDownRight,
            Button buttonLineUp,
            Button buttonLineDown,
            TextBox textboxSquare,
            TextBox textboxLine,
            CheckBox checkbox,
            Action <float, float, float, bool> actionMove)
        {
            Action <int, int> actionSquare = (int hSign, int vSign) =>
            {
                float value;
                if (!float.TryParse(textboxSquare.Text, out value))
                {
                    return;
                }
                actionMove(hSign * value, vSign * value, 0, checkbox?.Checked ?? false);
            };

            Action <int> actionLine = (int nSign) =>
            {
                float value;
                if (!float.TryParse(textboxLine.Text, out value))
                {
                    return;
                }
                actionMove(0, 0, nSign * value, checkbox?.Checked ?? false);
            };

            Action setEulerNames = () =>
            {
                buttonSquareLeft.Text      = "X-";
                buttonSquareRight.Text     = "X+";
                buttonSquareUp.Text        = "Z-";
                buttonSquareDown.Text      = "Z+";
                buttonSquareUpLeft.Text    = "X-Z-";
                buttonSquareDownLeft.Text  = "X-Z+";
                buttonSquareUpRight.Text   = "X+Z-";
                buttonSquareDownRight.Text = "X+Z+";
                buttonLineUp.Text          = "Y+";
                buttonLineDown.Text        = "Y-";
            };

            Action setRelativeNames = () =>
            {
                buttonSquareLeft.Text      = "L";
                buttonSquareRight.Text     = "R";
                buttonSquareUp.Text        = "F";
                buttonSquareDown.Text      = "B";
                buttonSquareUpLeft.Text    = "FL";
                buttonSquareDownLeft.Text  = "BL";
                buttonSquareUpRight.Text   = "FR";
                buttonSquareDownRight.Text = "BR";
                buttonLineUp.Text          = "U";
                buttonLineDown.Text        = "D";
            };

            Action actionCheckedChanged = () =>
            {
                if (checkbox.Checked)
                {
                    setRelativeNames();
                }
                else
                {
                    setEulerNames();
                }
            };

            buttonSquareLeft.Click      += (sender, e) => actionSquare(-1, 0);
            buttonSquareRight.Click     += (sender, e) => actionSquare(1, 0);
            buttonSquareUp.Click        += (sender, e) => actionSquare(0, 1);
            buttonSquareDown.Click      += (sender, e) => actionSquare(0, -1);
            buttonSquareUpLeft.Click    += (sender, e) => actionSquare(-1, 1);
            buttonSquareDownLeft.Click  += (sender, e) => actionSquare(-1, -1);
            buttonSquareUpRight.Click   += (sender, e) => actionSquare(1, 1);
            buttonSquareDownRight.Click += (sender, e) => actionSquare(1, -1);
            buttonLineUp.Click          += (sender, e) => actionLine(1);
            buttonLineDown.Click        += (sender, e) => actionLine(-1);
            if (coordinateSystem == CoordinateSystem.Euler)
            {
                checkbox.CheckedChanged += (sender, e) => actionCheckedChanged();
            }

            // Implement ToolStripMenu

            List <Button> buttonList = new List <Button>()
            {
                buttonSquareUp,
                buttonSquareUpRight,
                buttonSquareRight,
                buttonSquareDownRight,
                buttonSquareDown,
                buttonSquareDownLeft,
                buttonSquareLeft,
                buttonSquareUpLeft,
            };

            List <Point> positionList = buttonList.ConvertAll(
                button => new Point(button.Location.X, button.Location.Y));

            ToolStripMenuItem itemLeft      = new ToolStripMenuItem("Face Left");
            ToolStripMenuItem itemRight     = new ToolStripMenuItem("Face Right");
            ToolStripMenuItem itemUp        = new ToolStripMenuItem("Face Up");
            ToolStripMenuItem itemDown      = new ToolStripMenuItem("Face Down");
            ToolStripMenuItem itemUpLeft    = new ToolStripMenuItem("Face Up-Left");
            ToolStripMenuItem itemDownLeft  = new ToolStripMenuItem("Face Down-Left");
            ToolStripMenuItem itemUpRight   = new ToolStripMenuItem("Face Up-Right");
            ToolStripMenuItem itemDownRight = new ToolStripMenuItem("Face Down-Right");

            Action <FacingDirection, int> SetFacingDirection = (FacingDirection facingDirection, int direction) =>
            {
                itemLeft.Checked      = facingDirection == FacingDirection.Left;
                itemRight.Checked     = facingDirection == FacingDirection.Right;
                itemUp.Checked        = facingDirection == FacingDirection.Up;
                itemDown.Checked      = facingDirection == FacingDirection.Down;
                itemUpLeft.Checked    = facingDirection == FacingDirection.UpLeft;
                itemDownLeft.Checked  = facingDirection == FacingDirection.DownLeft;
                itemUpRight.Checked   = facingDirection == FacingDirection.UpRight;
                itemDownRight.Checked = facingDirection == FacingDirection.DownRight;

                for (int i = 0; i < buttonList.Count; i++)
                {
                    int    newDirection = (direction + i) % buttonList.Count;
                    Point  newPoint     = positionList[newDirection];
                    Button button       = buttonList[i];
                    button.Location = newPoint;
                }
            };

            itemLeft.Click      += (sender, e) => SetFacingDirection(FacingDirection.Left, 6);
            itemRight.Click     += (sender, e) => SetFacingDirection(FacingDirection.Right, 2);
            itemUp.Click        += (sender, e) => SetFacingDirection(FacingDirection.Up, 0);
            itemDown.Click      += (sender, e) => SetFacingDirection(FacingDirection.Down, 4);
            itemUpLeft.Click    += (sender, e) => SetFacingDirection(FacingDirection.UpLeft, 7);
            itemDownLeft.Click  += (sender, e) => SetFacingDirection(FacingDirection.DownLeft, 5);
            itemUpRight.Click   += (sender, e) => SetFacingDirection(FacingDirection.UpRight, 1);
            itemDownRight.Click += (sender, e) => SetFacingDirection(FacingDirection.DownRight, 3);

            ContextMenuStrip contextMenuStrip = new ContextMenuStrip();

            contextMenuStrip.Items.Add(itemLeft);
            contextMenuStrip.Items.Add(itemRight);
            contextMenuStrip.Items.Add(itemUp);
            contextMenuStrip.Items.Add(itemDown);
            contextMenuStrip.Items.Add(itemUpLeft);
            contextMenuStrip.Items.Add(itemDownLeft);
            contextMenuStrip.Items.Add(itemUpRight);
            contextMenuStrip.Items.Add(itemDownRight);
            groupbox.ContextMenuStrip = contextMenuStrip;

            AddInversionContextMenuStrip(buttonLineUp, buttonLineDown);

            itemUp.Checked = true;
        }
示例#53
0
 /// <summary>Initializes a new instance of the <see cref="T:Microsoft.Spatial.GeographyMultiCurve" /> class.</summary>
 /// <param name="coordinateSystem">The coordinate system of this instance.</param>
 /// <param name="creator">The implementation that created this instance.</param>
 protected GeographyMultiCurve(CoordinateSystem coordinateSystem, SpatialImplementation creator)
     : base(coordinateSystem, creator)
 {
 }
示例#54
0
        public Dictionary <string, object> GetStationOffsetElevationByPoint(Point point)
        {
            Utils.Log(string.Format("Featureline.GetStationOffsetElevationByPoint started...", ""));

            Utils.Log(string.Format("Point: X: {0} Y: {1} Z: {2}", point.X, point.Y, point.Z));

            Point flatPt = Point.ByCoordinates(point.X, point.Y);

            Curve flatPC = this.Curve.PullOntoPlane(Plane.XY());

            AeccAlignment alignment = this._baseline.Alignment.InternalElement as AeccAlignment;

            double station   = 0;
            double offset    = 0;
            double elevation = 0;

            double alStation = 0;
            double alOffset  = 0;

            //Point start = null; //  c.PointAtParameter(0);
            //Point end = null; // c.PointAtParameter(1);

            //Vector dir = null; // Vector.ByTwoPoints(start, end).Normalized();

            //Vector test = null;

            Point ortho = null;

            //Line l = null;

            CoordinateSystem cs = null;

            Point result = null;

            alignment.StationOffset(point.X, point.Y, out alStation, out alOffset);

            Utils.Log(string.Format("The point is at station {0}", alStation));

            // 20190414 -- START

            if (Math.Abs(alStation - this.Start) <= 0.00001)
            {
                alStation = this.Start;
                Utils.Log(string.Format("Station rounded to {0}", alStation));
            }

            if (Math.Abs(alStation - this.End) <= 0.00001)
            {
                alStation = this.End;
                Utils.Log(string.Format("Station rounded to {0}", alStation));
            }

            // 20190414 -- END

            if (this.Start <= Math.Round(alStation, 5) && Math.Round(alStation, 5) <= this.End ||
                Math.Abs(this.Start - alStation) < 0.0001 ||
                Math.Abs(this.End - alStation) < 0.0001)
            {
                // the point is in the featureline range

                Utils.Log(string.Format("The point is inside the featureline station range.", ""));

                // 20190205 -- START

                ortho = flatPC.ClosestPointTo(flatPt);

                Utils.Log(string.Format("Orthogonal Point at Z = 0: {0}", ortho));

                double orStation = 0;
                double orOffset  = 0;
                double error     = 0;

                alignment.StationOffset(ortho.X, ortho.Y, out orStation, out orOffset);

                cs = this.CoordinateSystemByStation(orStation, false).Inverse();

                Utils.Log(string.Format("CoordinateSystem: {0}", cs));

                result = point.Transform(cs) as Point;

                Utils.Log(string.Format("Result: {0}", result));

                station   = orStation;
                offset    = result.X;
                elevation = result.Z;
                error     = result.Y;

                // 20190205 -- END

                #region UNDER REVIEW
                //Dictionary<double, Point> cpts = new Dictionary<double, Point>();

                //foreach (Curve c in this._polycurve.Curves())
                //{
                //    start = c.PointAtParameter(0);
                //    end = c.PointAtParameter(1);

                //    start = Point.ByCoordinates(start.X, start.Y, 0);
                //    end = Point.ByCoordinates(end.X, end.Y, 0);

                //    Point q = Point.ByCoordinates(point.X, point.Y, 0);

                //    // Utils.Log(string.Format("Curve Start: {0} End: {1}", start, end));

                //    dir = Vector.ByTwoPoints(start, end).Normalized();

                //    test = null;

                //    ortho = null;

                //    if (start.DistanceTo(q) > 0)
                //    {
                //        test = Vector.ByTwoPoints(start, q);

                //        ortho = start.Translate(dir, test.Dot(dir)) as Point;
                //    }
                //    else
                //    {
                //        test = Vector.ByTwoPoints(end, q);

                //        ortho = end.Translate(dir.Reverse(), test.Dot(dir)) as Point;
                //    }

                //    if (ortho != null)
                //    {
                //        l = Line.ByStartPointEndPoint(start, end);

                //        double par = l.ParameterAtPoint(ortho);

                //        if (par >= 0 && par <= 1)
                //        {
                //            double orStation = 0;
                //            double orOffset = 0;

                //            alignment.StationOffset(ortho.X, ortho.Y, out orStation, out orOffset);

                //            CoordinateSystem cs = this.CoordinateSystemByStation(orStation, false).Inverse();

                //            Point result = point.Transform(cs) as Point;

                //            //Utils.Log(string.Format("OrStation: {0}", orStation));

                //            cpts[orStation] = result;
                //        }
                //    }
                //    else
                //    {
                //        Utils.Log(string.Format("No projection was found", ""));
                //    }
                //}

                //double error = double.MaxValue;

                //foreach (double s in cpts.Keys)
                //{
                //    double margin = cpts[s].Y;

                //    if (margin < error)
                //    {
                //        station = s;
                //        offset = cpts[s].X;
                //        elevation = cpts[s].Z;
                //        error = margin;
                //    }
                //}
                #endregion

                Utils.Log(string.Format("Final Margin: {0}", error));

                #region TEST CODE
                //Point projection = this._polycurve.ClosestPointTo(point);

                //int count = 0;

                ////while (true)
                ////{
                //    // The station and offset from the alignment of the point sitting on the featureline
                //double flStation = 0;
                //double flOffset = 0;

                //    // The X and Y from the alignment of the point on the featureline at station and offset
                //    double x = 0;
                //    double y = 0;

                //alignment.StationOffset(projection.X, projection.Y, out flStation, out flOffset);

                //    alignment.PointLocation(flStation, flOffset, out x, out y);

                //CoordinateSystem cs = this.CoordinateSystemByStation(flStation).Inverse();

                //Point result = point.Transform(cs) as Point;

                //station = flStation;
                //offset = result.X;
                //elevation = result.Z;

                //    Utils.Log(string.Format("Station: {0}", station));

                //    Utils.Log(string.Format("Margin: {0}", result.Y));

                //    Utils.Log(string.Format("X: {0} Y: {1}", x, y));

                //    // tolerance
                //    if (Math.Abs(result.Y) > 0.0001 && count < 10)
                //    {
                //        projection = projection.Translate(cs.YAxis, -result.Y) as Point;
                //    }
                //    else
                //    {
                //        cs.Dispose();
                //        result.Dispose();

                //        //break;
                //    }

                //    ++count;
                ////}
                #endregion
            }
            else
            {
                Utils.Log(string.Format("The point is outside the featureline station range.", ""));

                station   = alStation;
                offset    = alOffset;                                                                  // offset from alignment
                elevation = point.Z - this._baseline.PointByStationOffsetElevation(alStation, 0, 0).Z; // Absolute elevation
            }

            Utils.Log(string.Format("Station: {0} Offset: {1} Elevation: {2}", station, offset, elevation));

            //start.Dispose();
            //end.Dispose();
            //dir.Dispose();
            //test.Dispose();
            if (ortho != null)
            {
                ortho.Dispose();
            }
            //l.Dispose();
            if (cs != null)
            {
                cs.Dispose();
            }
            if (result != null)
            {
                result.Dispose();
            }
            if (flatPt != null)
            {
                flatPt.Dispose();
            }
            if (flatPC != null)
            {
                flatPC.Dispose();
            }

            #region OLD CODE
            //double[] soe = this._baseline.GetStationOffsetElevationByPoint(point);

            //double station = soe[0];
            //double offset = soe[1] - this._baseline.GetStationOffsetElevationByPoint(PointAtStation(station))[1];
            //double elevation = point.Z - PointAtStation(station).Z;
            #endregion

            Utils.Log(string.Format("Featureline.GetStationOffsetElevationByPoint completed.", ""));

            return(new Dictionary <string, object>
            {
                { "Station", Math.Round(station, 5) },
                { "Offset", Math.Round(offset, 5) },
                { "Elevation", Math.Round(elevation, 5) }
            });
        }
示例#55
0
		internal static float ConvertSweepAngle(float sweepAngle, float startAngle, SpatialTransform transform, CoordinateSystem targetSystem)
		{
			PointF x = new PointF(100, 0);

			PointF[] startVector = new PointF[] { x };
			Matrix rotation = new Matrix();
			rotation.Rotate(startAngle);
			rotation.TransformVectors(startVector);

			PointF[] sweepVector = (PointF[])startVector.Clone();
			rotation.Reset();
			rotation.Rotate(sweepAngle);
			rotation.TransformVectors(sweepVector);
			rotation.Dispose();

			SizeF startVectorTransformed, sweepVectorTransformed;
			if (targetSystem == Graphics.CoordinateSystem.Destination)
			{
				startVectorTransformed = transform.ConvertToDestination(new SizeF(startVector[0]));
				sweepVectorTransformed = transform.ConvertToDestination(new SizeF(sweepVector[0]));
			}
			else
			{
				startVectorTransformed = transform.ConvertToSource(new SizeF(startVector[0]));
				sweepVectorTransformed = transform.ConvertToSource(new SizeF(sweepVector[0]));
			}

			// simply return the angle between the start and sweep angle, in the target system.
			return (int)Math.Round(Vector.SubtendedAngle(sweepVectorTransformed.ToPointF(), PointF.Empty, startVectorTransformed.ToPointF()));
		}
示例#56
0
        // TODO: Define Coordinate System when the featurelines returns on itslef like a U
        // Minimum distance from baseline
        /// <summary>
        /// CoordinateSystem by station.
        /// </summary>
        /// <param name="station">The station.</param>
        /// <param name="vertical">if set to <c>true</c> the ZAxis is [vertical].</param>
        /// <returns></returns>
        public CoordinateSystem CoordinateSystemByStation(double station, bool vertical = true)
        {
            Utils.Log(string.Format("Featureline.CoordinateSystemByStation started...", ""));

            CoordinateSystem cs     = null;
            CoordinateSystem output = null;

            if (Math.Abs(station - this.Start) < 0.00001)
            {
                station = this.Start;
            }

            if (Math.Abs(station - this.End) < 0.00001)
            {
                station = this.End;
            }

            //bool findIntersection = true;

            if (station < this.Start || station > this.End)
            {
                var message = "The Station value is not compatible with the Featureline.";

                Utils.Log(string.Format("ERROR: {0}", message));

                //findIntersection = false;
                //return null;
            }

            cs = this._baseline.CoordinateSystemByStation(station);

            Utils.Log(string.Format("CoordinateSystem: {0}", cs));

            if (cs != null)
            {
                Plane plane = cs.ZXPlane;

                PolyCurve pc = this._polycurve;

                Point  p = null;
                double d = double.MaxValue;

                try
                {
                    var intersections = pc.Intersect(plane);

                    Utils.Log(string.Format("Intersections: {0}", intersections.Length));

                    // Get the closest point on the Feature Line
                    foreach (var result in intersections)
                    {
                        if (result is Point)
                        {
                            Point r = result as Point;

                            double dist = cs.Origin.DistanceTo(r);

                            if (dist < d)
                            {
                                p = r;
                                d = dist;
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    Utils.Log(string.Format("ERROR: {0}", ex.Message));

                    throw new Exception(ex.Message);
                }

                Utils.Log(string.Format("Distance: {0}", d));

                // 20190415  -- START
                if (p == null)
                {
                    if (Math.Abs(station - this.Start) < 0.0001)
                    {
                        p = pc.StartPoint;
                        Utils.Log(string.Format("Point forced on Featureline start.", ""));
                    }
                    if (Math.Abs(station - this.End) < 0.0001)
                    {
                        p = pc.EndPoint;
                        Utils.Log(string.Format("Point forced on Featureline end.", ""));
                    }
                }

                // 20190415  -- END

                Utils.Log(string.Format("Point: {0}", p));

                if (null != p)
                {
                    output = pc.CoordinateSystemAtParameter(pc.ParameterAtPoint(p));

                    output = CoordinateSystem.ByOriginVectors(output.Origin, output.YAxis.Cross(Vector.ZAxis()), output.YAxis, Vector.ZAxis());

                    if (vertical)
                    {
                        output = CoordinateSystem.ByOriginVectors(output.Origin,
                                                                  Vector.ByCoordinates(output.XAxis.X, output.XAxis.Y, 0, true),
                                                                  Vector.ByCoordinates(output.YAxis.X, output.YAxis.Y, 0, true),
                                                                  Vector.ZAxis());
                    }
                }
                else
                {
                    Utils.Log(string.Format("ERROR: Point is null.", ""));
                    // use the Baseline
                    output = CoordinateSystem.ByOriginVectors(cs.Origin, cs.XAxis, cs.YAxis, cs.ZAxis);

                    Utils.Log(string.Format("Baseline is used: {0}", output));
                }

                Utils.Log(string.Format("Featureline.CoordinateSystemByStation completed.", ""));

                if (plane != null)
                {
                    plane.Dispose();
                }
                //if (pc != null)
                //{
                //    pc.Dispose();
                //}
                if (p != null)
                {
                    p.Dispose();
                }
            }
            else
            {
                var message = "The Station value is not compatible with the Featureline and its Baseline.";

                Utils.Log(string.Format("ERROR: {0}", message));

                throw new Exception(message);
            }

            if (cs != null)
            {
                cs.Dispose();
            }

            return(output);
        }
示例#57
0
        public static void ComputeMinEnclosingCircle(ObjectId[] idArray, CoordinateSystem actualCS)
        {
            Editor        editor          = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;
            Database      workingDatabase = HostApplicationServices.WorkingDatabase;
            ProgressMeter progressMeter   = new ProgressMeter();
            MessageFilter value           = new MessageFilter();

            System.Windows.Forms.Application.AddMessageFilter(value);
            try
            {
                using (Transaction transaction = workingDatabase.TransactionManager.StartTransaction())
                {
                    progressMeter.SetLimit(idArray.Length);
                    if ((double)idArray.Length > 10000.0)
                    {
                        progressMeter.Start("Computing min. enclosing circle...");
                    }
                    CoordinateTransformator coordinateTransformator = new CoordinateTransformator(CoordinateSystem.Global(), actualCS);
                    CoordinateTransformator inverseTransformation   = coordinateTransformator.GetInverseTransformation();
                    BlockTable       blockTable       = (BlockTable)transaction.GetObject(workingDatabase.BlockTableId, (OpenMode)1);
                    BlockTableRecord blockTableRecord = (BlockTableRecord)transaction.GetObject(blockTable[BlockTableRecord.ModelSpace], (OpenMode)1);
                    ObjectId         layerId          = DBManager.CurrentLayerId();
                    DBManager.CurrentLayerName();
                    PointSet pointSet = new PointSet();
                    for (int i = 0; i < idArray.Length; i++)
                    {
                        progressMeter.MeterProgress();
                        DBPoint dBPoint = (DBPoint)transaction.GetObject(idArray[i], (OpenMode)0, true);
                        Point   point   = new Point(dBPoint.Position.X, dBPoint.Position.Y, dBPoint.Position.Z);
                        coordinateTransformator.Transform(point);
                        pointSet.Add(point);
                    }
                    ConvexHull2d convexHull2d = new ConvexHull2d();
                    convexHull2d.InitialPoints = pointSet;
                    convexHull2d.ComputeHull();
                    PointSet vertices = convexHull2d.Vertices;
                    double   z        = vertices[0].Z;
                    for (int j = 0; j < vertices.Count; j++)
                    {
                        vertices[j].Z = z;
                    }
                    SmallestEnclosingCircle         smallestEnclosingCircle = new SmallestEnclosingCircle(vertices);
                    ngeometry.VectorGeometry.Circle circle = smallestEnclosingCircle.ComputeCircle();
                    Point center = circle.Center;
                    Point point2 = circle.NormalVector.ToPoint();
                    inverseTransformation.Transform(center);
                    inverseTransformation.Transform(point2);
                    Autodesk.AutoCAD.DatabaseServices.Circle circle2 = new Autodesk.AutoCAD.DatabaseServices.Circle(new Autodesk.AutoCAD.Geometry.Point3d(center.X, center.Y, center.Z), new Autodesk.AutoCAD.Geometry.Vector3d(point2.X, point2.Y, point2.Z), circle.Radius);
                    circle2.LayerId = (layerId);
                    blockTableRecord.AppendEntity(circle2);
                    transaction.AddNewlyCreatedDBObject(circle2, true);
                    editor.WriteMessage("\nMinimum enclosing circle properties:");
                    editor.WriteMessage("\n------------------------------------");
                    editor.WriteMessage("\nRadius          : " + circle.Radius.ToString(DBManager.GetFormatFromLUPREC()));
                    editor.WriteMessage("\nArea            : " + circle.Area.ToString(DBManager.GetFormatFromLUPREC()));
                    editor.WriteMessage("\nPerimeter length: " + circle.Circumference.ToString(DBManager.GetFormatFromLUPREC()));
                    transaction.Commit();
                }
                progressMeter.Stop();
            }
            catch (System.Exception ex)
            {
                progressMeter.Stop();
                throw;
            }
        }
示例#58
0
        /// <summary>
        /// Calculates the equator coordinates of the star at a specified time.
        /// </summary>
        /// <param name="time">Local time.</param>
        /// <param name="isApparent">Is it the apparent equator coordinates.</param>
        /// <returns>Equator coordinates.</returns>
        public virtual Equator GetEquatorCoordinate(DateTime time, bool isApparent = false)
        {
            var e = GetEclipticCoordinate(time, isApparent);

            return(CoordinateSystem.Ecliptic2Equator(e, time, isApparent));
        }
示例#59
0
		public Yuv444(Buffer.Sized buffer, Geometry2D.Integer.Size size, CoordinateSystem coordinateSystem, Geometry2D.Integer.Shell crop) :
			base(buffer, size, coordinateSystem, crop)
		{ }
示例#60
0
 public static CoordinateSystem ToCoordinateSystem(this Transform t, bool convertUnits = true)
 {
     return(CoordinateSystem.ByOriginVectors(t.Origin.ToPoint(convertUnits), t.BasisX.ToVector(), t.BasisY.ToVector()));
 }