private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) { TopoPolygon SelectedTopoPolygon = sTopoPolygonSet.TopoPolygonList[comboBox1.SelectedIndex]; textBox1.Text = string.Format("PID:\t{0}\r\n弧段数:\t{1}\r\n周长:\t{2}\r\n面积:\t{3}", SelectedTopoPolygon.PID, SelectedTopoPolygon.TopologyArcs.Count, SelectedTopoPolygon.GetPerimeter().ToString("0.00"), SelectedTopoPolygon.GetArea().ToString("0.00")); }
public TopoObject Build() { TopoObject obj; switch (_type) { case "Point": obj = new TopoPoint(_type, _coordinates); break; case "LineString": obj = new TopoLineString(_type, _arcs); break; case "Polygon": obj = new TopoPolygon(_type, _arcs); break; case "MultiPoint": obj = new TopoMultiPoint(_type, _coordinates); break; case "MultiLineString": obj = new TopoMultiLineString(_type, _arcs); break; case "MultiPolygon": obj = new TopoMultiPolygon(_type, _arcs); break; case "GeometryCollection": obj = new TopoCollection(_type, _geometries); break; default: throw new ArgumentOutOfRangeException("unhandled type: " + _type); } obj.Id = _id; obj.Properties = _properties; return(obj); }
void RenderTopoObject(TopoJson topo, TopoObject obj) { int geometryIndex = 0; foreach (var geometry in obj.geometries) { geometryIndex++; string name = null; if (geometry.properties != null) { name = (string)geometry.properties.GetOrNull("nam"); } if (name == null) { name = geometryIndex.ToString(); } if (geometry.IsMultiPolygon()) { var parentObject = this.NewGameObject(this.transform, name); int[][] arcIndexesSet = geometry.AsMultiPolygon().arcs.Flatten().ToArray(); foreach (int[] arcIndexes in arcIndexesSet) { var verts = TopoPolygon.CreateVerts(arcIndexes, topo); this.RenderGameObject(parentObject.transform, name, verts); } } else if (geometry.IsPolygon()) { var parentObject = this.gameObject.transform; int[] arcIndexes = geometry.AsPolygon().arcs.Flatten().ToArray(); var verts = TopoPolygon.CreateVerts(arcIndexes, topo); this.RenderGameObject(parentObject.transform, name, verts); } } }
private void agisControl_MouseDoubleClick(object sender, MouseEventArgs e) { MouseLocation = e.Location; GridDivisionScreenRefresh(); if (this.UserOperation != UserOperationType.DisplayInGrid || GridDivisionCount_X * EachGridDivisionCount_X < 1 || GridDivisionCount_Y * EachGridDivisionCount_Y < 1 || this.IsGridVisible == false) { return; } if (e.Clicks == 2 && this.IsQueryIntersection == true && this.ShowTopology == false && this.IsGridVisible == true) { SelectPointX = SelectPointY = -1; int gridScreen_AxisX_count = GridScreen_AxisX.Count; for (int i = 0; i < gridScreen_AxisX_count; i++) { if (Math.Abs(GridScreen_AxisX[i] - this.MouseLocation.X) < this.SelectPixelThreshold) { SelectPointX = this.agisControl.GetRealWorldLocX((float)GridScreen_AxisX[i]); } } int gridScreen_AxisY_count = GridScreen_AxisY.Count; for (int i = 0; i < gridScreen_AxisY_count; i++) { if (Math.Abs(GridScreen_AxisY[i] - this.MouseLocation.Y) < this.SelectPixelThreshold) { SelectPointY = this.agisControl.GetRealWorldLocY((float)GridScreen_AxisY[i]); } } //选中了格网点 if (SelectPointX != -1 && SelectPointY != -1 && agisControl.GridIntMethod != Mehtod.GridInterpolationMehtod.None) { this.agisControl.Refresh(); string MethodName = ""; string Para = ""; if (agisControl.GridIntMethod == Mehtod.GridInterpolationMehtod.方位加权平均法) { if (agisControl.方位加权平均法SectorNum < 0) { MessageBox.Show("按方位加权平均法 参数尚未设置", "错误"); return; } MethodName = "按方位加权平均法"; Para = string.Format("{0}:{1}", "每个象限等分扇区数N0", agisControl.方位加权平均法SectorNum / 4); } else if (agisControl.GridIntMethod == Mehtod.GridInterpolationMehtod.距离平方倒数法) { if (agisControl.距离平方倒数法NearPts < 0) { MessageBox.Show("距离平方倒数法 参数尚未设置", "错误"); return; } MethodName = "距离平方倒数法"; Para = string.Format("{0}:{1}", "选取距插值点最近的N个点", agisControl.距离平方倒数法NearPts); } MessageBox.Show(string.Format("{0}\t\r\nX:{1}\t\nY:{2}\t\r\nValue:{3}\r\n\r\n{4}\r\n{5}", "格网点属性信息:", SelectPointX.ToString("0.00"), SelectPointY.ToString("0.00"), agisControl.GetGridInterpolationValue(SelectPointX, SelectPointY).ToString("0.000"), "插值方法:" + MethodName, Para ), "属性查询"); } } if (e.Clicks == 2 && this.IsQueryTopoPolygon == true && this.ShowTopology == true && this.ShowTopoPolygon == true) { TopoPoint clickLoc = new TopoPoint(agisControl.GetRealWorldLocX(e.X), agisControl.GetRealWorldLocX(e.Y), 0, false); this.SelectedTopoPolygon = this.mTopoPolygonSet.GetClickPointInsidePolygon(clickLoc); this.agisControl.Refresh(); if (SelectedTopoPolygon != null) { MessageBox.Show(string.Format("PID:{0}\r\n弧段数:{1}\r\n周长:{2}\r\n面积:{3}", SelectedTopoPolygon.PID, SelectedTopoPolygon.TopologyArcs.Count, SelectedTopoPolygon.GetPerimeter().ToString("0.00"), SelectedTopoPolygon.GetArea().ToString("0.00")), "多边形信息"); } } }
GameObject RenderGameObject(Transform parentTransform, string name, Vector2[] verts) { return(TopoPolygon.CreatePolygon(this.MeshPrefab.gameObject, parentTransform, verts, name)); }
public FeatureCollection Create(TopoObject data) { if (data == null) { throw new ArgumentNullException("data"); } string type = data.Type; if (String.IsNullOrEmpty(type)) { throw new ArgumentException("type undefined", "data"); } if (String.Equals("GeometryCollection", type)) { // a TopoJSON "GeometryCollection" actually is an IFeature array // so we handle this stuff as a special case TopoCollection coll = (TopoCollection)data; return(CreateCollection(coll.Geometries)); } IGeometry geometry; switch (type) { case "Point": TopoPoint point = (TopoPoint)data; geometry = CreatePoint(point.Coordinates); break; case "MultiPoint": TopoMultiPoint mpoint = (TopoMultiPoint)data; geometry = CreateMultiPoint(mpoint.Coordinates); break; case "LineString": TopoLineString lstring = (TopoLineString)data; geometry = CreateLineString(lstring.Arcs); break; case "MultiLineString": TopoMultiLineString mlstring = (TopoMultiLineString)data; geometry = CreateMultiLineString(mlstring.Arcs); break; case "Polygon": TopoPolygon poly = (TopoPolygon)data; geometry = CreatePolygon(poly.Arcs); break; case "MultiPolygon": TopoMultiPolygon mpoly = (TopoMultiPolygon)data; geometry = CreateMultiPolygon(mpoly.Arcs); break; default: string s = string.Format("type unsupported: {0}", type); throw new NotSupportedException(s); } IAttributesTable properties = data.Properties; Feature feature = new Feature(geometry, properties); Collection <IFeature> collection = new Collection <IFeature> { feature }; return(new FeatureCollection(collection)); }