Пример #1
0
        private void UpdateGridStructure()
        {
            grid       = new GeoCircle[numRows, numCols];
            enabled    = new bool[numRows, numCols];
            numCircles = numRows * numCols;

            int width  = floatPanelVis.Width;
            int height = floatPanelVis.Height;

            int stepX = (int)((width - numCols * CircleRadius) / (numCols + 1));
            int stepY = (int)((height - numRows * CircleRadius) / (numRows + 1));

            int firstX = (int)(stepX + CircleRadius);
            int firstY = (int)(stepY + CircleRadius);

            for (int y = 0; y < numRows; y++)
            {
                int posY = firstY + y * stepY;
                for (int x = 0; x < numCols; x++)
                {
                    int posX = firstX + x * stepX;
                    grid[y, x]           = new GeoCircle(Color.Red, new Point(posX, posY), CircleRadius, 1f, floatPanelVis.CurrentImageToScreenTransform);
                    grid[y, x].FillColor = Color.White;
                }
            }

            RenderGrid();
        }
Пример #2
0
        public void GeoCircle_Serialize()
        {
            var circle1 = new GeoCircle(GeoCoordinate.Origin, 10, GeoHelper.EarthRadiusMiles);
            var circle2 = (GeoCircle)GeoRegion.Parse(circle1.ToString());

            Assert.AreEqual(circle1, circle2);
        }
Пример #3
0
    private void RemoveCircle(GeoCircle geoCircle)
    {
        CircleBehaviour circleBehaviour = circleMap[geoCircle];

        Destroy(circleBehaviour.gameObject);
        circleMap.Remove(geoCircle);
    }
Пример #4
0
        public void GeoCircle_Contains()
        {
            var circle = new GeoCircle(GeoCoordinate.Origin, 10, GeoHelper.EarthRadiusMiles);

            Assert.IsTrue(circle.Contains(circle.Center));
            Assert.IsTrue(circle.Contains(GeoHelper.Plot(circle.Center, 0.45, 5, GeoHelper.EarthRadiusMiles)));
            Assert.IsFalse(circle.Contains(GeoHelper.Plot(circle.Center, 0.45, 15, GeoHelper.EarthRadiusMiles)));
        }
Пример #5
0
        public void GeoCircle_Basic()
        {
            var circle = new GeoCircle(new GeoCoordinate(10, 20), 10.5, GeoHelper.EarthRadiusKilometers);

            Assert.AreEqual(new GeoCoordinate(10, 20), circle.Center);
            Assert.AreEqual(10.5, circle.Radius);
            Assert.AreEqual(GeoHelper.EarthRadiusKilometers, circle.PlanetRadius);
        }
Пример #6
0
        /// <summary>
        /// A method for computing the two points created by circle intersection. returns null if no intersection occurs and returns the same Point if circles are tangent.
        /// </summary>
        /// <param name="c1"></param>
        /// <param name="c2"></param>
        /// <returns>If the list has only one element it means the circles are tangent. if the list is null, it means no points were found, therefore no intersection. returns the points in degrees.</returns>
        public static GeoPoint[] CirclesIntersection(GeoCircle c1, GeoCircle c2)
        {
            // See reference image: https://i.stack.imgur.com/aUXMY.gif
            // See reference URL: https://stackoverflow.com/questions/3349125/circle-circle-intersection-points
http:       //paulbourke.net/geometry/circlesphere/

            // First we check to see if Circles really intersect
            if (!AreCirclesIntersecting(c1, c2))
            {
                return(null);
            }
            // We rearrange, to make c1 the circle with the bigger radius
            if (c2.R > c1.R)
            {
                GeoCircle c3 = new GeoCircle(c2);
                c2 = c1;
                c1 = c3;
            }

            GeoPoint[] points = new GeoPoint[2];                                         // symbolize the points of intersection

            float d = GetGeoDistance(c1.Midpoint, c2.Midpoint);                          // Distance from centers
            float a = (float)((c1.R.Power(2) - (c2.R.Power(2)) + d.Power(2)) / (2 * d)); // distance from center of circle1 to intersection mid-point
            float b;                                                                     // distance from center of circle2 to intersection mid-point
            float h = (float)Math.Sqrt(c1.R.Power(2) - (a.Power(2)));                    // (half) height of the lens created from intersection

            d = (float)ConvertDistanceUnit(d, DistanceUnits.NauticalMiles, DistanceUnits.Degrees);
            a = (float)ConvertDistanceUnit(a, DistanceUnits.NauticalMiles, DistanceUnits.Degrees);
            h = (float)ConvertDistanceUnit(h, DistanceUnits.NauticalMiles, DistanceUnits.Degrees);

            GeoPoint p = new GeoPoint() // Midpoint of lens (created by intersection)
            {
                Lat = c1.Midpoint.Lat + a * (c2.Midpoint.Lat - c1.Midpoint.Lat) / d,
                Lon = c1.Midpoint.Lon + a * (c2.Midpoint.Lon - c1.Midpoint.Lon) / d,
                Alt = c1.Midpoint.Alt,
            };

            //DrawUI.instance.DrawIcon(DrawUI.instance.defaultIcon, p, 32);

            // Since Altitude is given with feet, we must first convert it to NM.
            points[0] = new GeoPoint()
            {
                Lat = p.Lat + h * (c2.Midpoint.Lon - c1.Midpoint.Lon) / d,
                Lon = p.Lon - h * (c2.Midpoint.Lat - c1.Midpoint.Lat) / d,
                Alt = p.Alt
            };
            points[1] = new GeoPoint()
            {
                Lat = p.Lat - h * (c2.Midpoint.Lon - c1.Midpoint.Lon) / d,
                Lon = p.Lon + h * (c2.Midpoint.Lat - c1.Midpoint.Lat) / d,
                Alt = p.Alt
            };

            return(points);
        }
Пример #7
0
    private void SpreadCone()
    {
        float Radius    = circular.radius1;
        float height    = circular.Vertices[0].y - circular.Vertices[1].y;
        float width     = circular.Vertices[2].z - circular.Vertices[1].z;
        float fanRadius = Mathf.Sqrt(height * height + width * width);

        positionZ = fanRadius / 2;
        geoCamera.TriggerMoveZAnimation(270, 0, positionZ);

        VertexSpace u0             = new VertexSpace(circular.Vertices[0]);
        VertexSpace u1             = new VertexSpace(circular.Vertices[2]);
        VertexSpace u2             = new VertexSpace(circular.Vertices[1]);
        int         segments       = 60;
        float       angleRad       = Mathf.Deg2Rad * (360 * Radius / fanRadius);
        float       angleCur       = Mathf.Deg2Rad * (180 - Mathf.Acos(height / fanRadius) * 180 / Mathf.PI - 360 * Radius / fanRadius);
        float       angledelta     = angleRad / segments;
        int         vertices_count = segments + 1;
        VertexSpace v1;
        VertexSpace v2;
        GeoFace     f;

        Vector3[] vertices = new Vector3[vertices_count];
        for (int i = 0; i < vertices_count; i++)
        {
            float cosA = Mathf.Cos(angleCur);
            float sinA = Mathf.Sin(angleCur);
            vertices[i] = new Vector3(u0.Position().x + 0, u0.Position().y + fanRadius * cosA, u0.Position().x + fanRadius * sinA);
            angleCur   += angledelta;
        }
        VertexSpace[] vertexs = new VertexSpace[vertices_count + 1];
        vertexs[0] = u0;
        for (int i = 0; i < vertices_count - 1; i++)
        {
            v1             = new VertexSpace(vertices[i]);
            v2             = new VertexSpace(vertices[i + 1]);
            vertexs[i + 1] = v1;
            vertexs[i + 2] = v2;
            geometryBehaviour.AddElement(new GeoEdge(v1, v2, false));
        }
        f = new GeoFace(vertexs, false, FaceType.SpreadFan);
        geometryBehaviour.AddElement(f);
        GeoEdge e1 = new GeoEdge(u0, new VertexSpace(vertices[0]), false);
        GeoEdge e2 = new GeoEdge(u0, new VertexSpace(vertices[vertices_count - 1]), false);

        geometryBehaviour.AddElement(e1);
        geometryBehaviour.AddElement(e2);


        VertexSpace u3 = new VertexSpace(0, circular.Vertices[0].y, fanRadius + Radius);
        GeoCircle   c2 = new GeoCircle(u3, Radius, CircleDirection.X, true, FaceType.SpreadConeCircle);

        geometryBehaviour.AddElement(c2);
    }
Пример #8
0
    private void AddCircle(GeoCircle geoCircle)
    {
        GameObject planeObject = new GameObject(geoCircle.ToString());

        planeObject.transform.SetParent(faceWrapper.transform);

        CircleBehaviour circleBehaviour = planeObject.AddComponent <CircleBehaviour>();

        circleBehaviour.Init(geoCircle);

        circleBehaviour.SetData(geometry.Circle(geoCircle));

        circleMap.Add(geoCircle, circleBehaviour);
        elementMap.Add(geoCircle, circleBehaviour);
    }
Пример #9
0
        public void GeoCircle_Bounds()
        {
            var circle = new GeoCircle(GeoCoordinate.Origin, 10, GeoHelper.EarthRadiusMiles);
            var r      = circle.Bounds;

            Assert.IsTrue(Math.Abs(r.Southwest.Longitude - GeoHelper.Plot(circle.Center, 270, circle.Radius, GeoHelper.EarthRadiusMiles).Longitude) < 0.01);
            Assert.IsTrue(Math.Abs(r.Northeast.Longitude - GeoHelper.Plot(circle.Center, 90, circle.Radius, GeoHelper.EarthRadiusMiles).Longitude) < 0.01);
            Assert.IsTrue(Math.Abs(r.Southwest.Latitude - GeoHelper.Plot(circle.Center, 180, circle.Radius, GeoHelper.EarthRadiusMiles).Latitude) < 0.01);
            Assert.IsTrue(Math.Abs(r.Northeast.Latitude - GeoHelper.Plot(circle.Center, 0, circle.Radius, GeoHelper.EarthRadiusMiles).Latitude) < 0.01);

            // Make sure that bounds are restored after serialization.

            circle = new GeoCircle(circle.ToString());

            Assert.AreEqual(r, circle.Bounds);
        }
Пример #10
0
        /// <summary>
        /// A method to determine wether two circles intersect
        /// </summary>
        /// <param name="c1"></param>
        /// <param name="c2"></param>
        /// <returns>returb true if intersection occurs</returns>
        public static bool AreCirclesIntersecting(GeoCircle c1, GeoCircle c2)
        {
            double distance = GetGeoDistance(c1.Midpoint, c2.Midpoint);

            if (distance < Math.Abs(c1.R - c2.R)) // circle contains another circle. This will be dealt in phase 2.
            {
                return(false);
            }
            else if (distance > c1.R + c2.R || distance == 0 && c1.R == c2.R) // circles are too far || circles are on top each other and have same radius
            {
                return(false);
            }
            else
            {
                return(true);
            }
        }
Пример #11
0
    private void SpreadCylinder()
    {
        float Radius = circular.radius1;
        float height = circular.Vertices[0].y - circular.Vertices[1].y;
        float width  = 2 * Mathf.PI * Radius;

        positionZ = width / 2;
        geoCamera.TriggerMoveZAnimation(270, 0, positionZ);

        VertexSpace u0 = new VertexSpace(0, height / 2, Radius);
        VertexSpace u1 = new VertexSpace(0, -height / 2, Radius);
        VertexSpace u2 = new VertexSpace(0, -height / 2, Radius + width);
        VertexSpace u3 = new VertexSpace(0, height / 2, Radius + width);

        GeoEdge e0 = new GeoEdge(u0, u1, false);
        GeoEdge e1 = new GeoEdge(u1, u2, false);
        GeoEdge e2 = new GeoEdge(u2, u3, false);
        GeoEdge e3 = new GeoEdge(u0, u3, false);

        geometryBehaviour.AddElement(e0);
        geometryBehaviour.AddElement(e1);
        geometryBehaviour.AddElement(e2);
        geometryBehaviour.AddElement(e3);

        GeoFace f = new GeoFace(new VertexSpace[] { u0, u1, u2, u3 }, false, FaceType.SpreadRectangle);

        geometryBehaviour.AddElement(f);

        VertexSpace u4 = new VertexSpace(0, height / 2 + Radius, width / 2 + Radius);
        GeoCircle   c1 = new GeoCircle(u4, Radius, CircleDirection.X, true, FaceType.SpreadCylinderCircle);

        geometryBehaviour.AddElement(c1);
        VertexSpace u5 = new VertexSpace(0, -height / 2 - Radius, width / 2 + Radius);
        GeoCircle   c2 = new GeoCircle(u5, Radius, CircleDirection.X, true, FaceType.SpreadCylinderCircle);

        geometryBehaviour.AddElement(c2);
    }
Пример #12
0
    private void UpdateCircle(GeoCircle geoCircle)
    {
        CircleBehaviour circleBehaviour = circleMap[geoCircle];

        circleBehaviour.SetData(geometry.Circle(geoCircle));
    }
Пример #13
0
		/// <summary>
		/// 在查询结果面板上初始化查询结果列表
		/// </summary>
		/// <param name="type">查询方式,默认为属性查询-Attribute,空间查询-Spatial</param>
		private void ExecuteQueryListBox(string type, Point3Ds TempPoints3Ds=null, string actionStr=null)
		{
			string layerName = "";
			if (this.QueryLayerList.Items.Count > 0)
			{
				layerName = this.QueryLayerList.SelectedValue.ToString();
			}
			
			if (layerName != "")//关键字为空时查询全部要素
			{
				string queryTxt = this.QueryNameTxt.Text.Trim();
				Workspace ws = MainWindow.m_workspace;
				if (ws != null)
				{
					string sourceName = ConfigurationManager.AppSettings.Get(queryDataSource);
					Datasource dSource = ws.Datasources[sourceName];
					if (dSource != null)
					{
						DatasetVector dSetV = (DatasetVector)dSource.Datasets[layerName];
						if (dSetV != null)
						{
							string fieldName = ConfigurationManager.AppSettings.Get(queryNameField);
							string fieldCode = ConfigurationManager.AppSettings.Get(queryCodeField);
							Recordset recordset = null;

							if (type != ATTRIBUTE_QUERY)
							{
								double queryBuffer = 0.0;
								SuperMap.Data.Geometry queryGeometry = null;
								
								switch (actionStr)
								{
									case "createpoint":
                                        queryBuffer = 0.01;
										if (TempPoints3Ds.Count == 1)
										{
											GeoPoint geoPoint = new GeoPoint(TempPoints3Ds[0].X, TempPoints3Ds[0].Y);
											queryGeometry = geoPoint;
										}
										break;
									case "createline":
										if (TempPoints3Ds.Count == 2)
										{
											Point2D point2D = new Point2D(TempPoints3Ds[0].X, TempPoints3Ds[0].Y);
                                            Point2D point2D1 = new Point2D(TempPoints3Ds[1].X, TempPoints3Ds[1].Y);
                                            double radius = Geometrist.Distance(new GeoPoint(point2D), new GeoPoint(point2D1));
                                            GeoCircle geoCircle = new GeoCircle(point2D, radius);
                                            GeoRegion geoRegion = geoCircle.ConvertToRegion(72);
                                            queryGeometry = geoRegion;
										}
										break;
									case "createpolygon":
										if (TempPoints3Ds.Count > 2)
										{
											Point2Ds tempPoint2Ds = new Point2Ds();
											for (int i = 0; i < TempPoints3Ds.Count; i++)
											{
												tempPoint2Ds.Add(new Point2D(TempPoints3Ds[i].X, TempPoints3Ds[i].Y));
											}
											GeoRegion geoRegion = new GeoRegion(tempPoint2Ds);
											queryGeometry = geoRegion;
										}
										break;
									default:
										break;
								}
                                if (queryGeometry != null)
                                {
                                    recordset = dSetV.Query(queryGeometry, queryBuffer, SuperMap.Data.CursorType.Static);
                                }
							}
							else
							{
								QueryParameter queryParameter = new QueryParameter();
								queryParameter.CursorType = SuperMap.Data.CursorType.Static;
								queryParameter.HasGeometry = true;
								if (this.QueryNameTxt.Text.Trim() != "")
								{
									queryParameter.AttributeFilter = fieldName + " like '%" + queryTxt + "%'";
								}

								recordset = dSetV.Query(queryParameter);
							}
							
							if (recordset != null && recordset.RecordCount > 0)
							{
								ObservableCollection<QueryRecordVO> recordList = SysModelLocator.getInstance().recordList;
								recordList.Clear();
								bool isExist = false;
								FieldInfos fis = recordset.GetFieldInfos();
								for (int j = 0; j < fis.Count; j++)
								{
									FieldInfo fi = fis[j];
									if (fi != null)
									{
										if (fi.Name.ToString().ToUpper() == fieldName)
										{
											isExist = true;
											break;
										}
										continue;
									}
								}

								if (isExist)
								{
									for (recordset.MoveFirst(); recordset.IsEOF == false; recordset.MoveNext())
									{
										QueryRecordVO qVO = new QueryRecordVO();
										qVO.RecordLayerId = layerName;
										qVO.RecordName = recordset.GetFieldValue(fieldName).ToString();
										qVO.RecordIndex = recordset.GetFieldValue(fieldCode).ToString();
										qVO.RecordCenterX = recordset.GetGeometry().InnerPoint.X.ToString();
										qVO.RecordCenterY = recordset.GetGeometry().InnerPoint.Y.ToString();
										recordList.Add(qVO);
									}
									this.QueryListBox.ItemsSource = recordList;
									this.QueryInfo.Text = "查询结果合计:" + recordList.Count + "条";
								}
								else
								{
									this.QueryListBox.ItemsSource = null;
									this.QueryInfo.Text = "";
								}
							}
							else
							{
                                SysModelLocator.getInstance().recordList.Clear();
								this.QueryListBox.ItemsSource = null;
								this.QueryInfo.Text = "查询结果合计:0条";
							}
						}
					}
				}
			}
		}
Пример #14
0
 public void RemoveGeoCircle(GeoCircle circle)
 {
     geoCircles.Remove(circle);
     circle.RemoveObserveElements();
 }
Пример #15
0
 public Circle Circle(GeoCircle circle)
 {
     return(circle.Circle());
 }
Пример #16
0
 public void Init(GeoCircle geoCircle)
 {
     this.geoCircle    = geoCircle;
     visiable          = true;
     geometryBehaviour = GameObject.Find("/3D/Geometry").GetComponent <GeometryBehaviour>();
 }
Пример #17
0
 public void AddGeoCircle(GeoCircle circle)
 {
     geoCircles.Add(circle);
     circle.AddObserveElements();
 }