private Feature GetFeature(IceFreeCurveInfoLayer.InfoItem item, int oid) { ShapePoint pt = new ShapePoint(item.Longitude, item.Latitude); //ShapePoint[] pts =new ShapePoint[]{pt}; //ShapeMultiPoint mpt = new ShapeMultiPoint(pts); Feature fet = new Feature(oid, pt, new string[] { "No", "Temp" }, new string[] { item.No.ToString(), item.Temperature.ToString("f2") }, null); return(fet); }
private void InitInfoLayer() { if (_infoLayer == null) { _infoLayer = new IceFreeCurveInfoLayer(); if (!_canvas.LayerContainer.Layers.Contains(_infoLayer)) { _canvas.LayerContainer.Layers.Add(_infoLayer); } } else { _infoLayer.InfoItems.Clear(); if (!_canvas.LayerContainer.Layers.Contains(_infoLayer)) { _canvas.LayerContainer.Layers.Add(_infoLayer); } } _iceFeatures.Clear(); IPencilToolLayer toolLayer = new PencilToolLayer(); toolLayer.PencilType = enumPencilType.ControlFreeCurve; _canvas.CurrentViewControl = toolLayer; toolLayer.PencilIsFinished = new Action <GeometryOfDrawed> ( (geo) => { //增加冰缘线 Feature feature = GetIceLineFeature(ref _iceLineFeatureOid, geo); //增加冰缘线拐点 List <IceFreeCurveInfoLayer.InfoItem> infoList = new List <IceFreeCurveInfoLayer.InfoItem>(); foreach (PointF rasterPoint in geo.ControlRasterPoints) { double geoX, geoY; double temp; _canvas.CoordTransform.Raster2Geo((int)rasterPoint.Y, (int)rasterPoint.X, out geoX, out geoY); temp = GetPixelTemperature(_canvas, rasterPoint.X, rasterPoint.Y); // IceFreeCurveInfoLayer.InfoItem info = new IceFreeCurveInfoLayer.InfoItem(); info.No = ++_iceControlPointNo; info.Longitude = geoX; info.Latitude = geoY; info.Temperature = temp; infoList.Add(info); } //if the last point is same to the one before it ,remove one int count = infoList.Count; if (count >= 2) { IceFreeCurveInfoLayer.InfoItem info = infoList.Last(); int firstNo = infoList[0].No; for (int i = count - 2; i >= 0; i--) { if ((infoList[i].Latitude == info.Latitude) && (infoList[i].Longitude == info.Longitude)) { infoList.RemoveAt(infoList.Count - 2); } else { break; } } for (int i = 0; i < infoList.Count; i++) { infoList[i].No = firstNo + i; } _iceControlPointNo = infoList.Last().No; } IceFreeCurveInfoLayer.InfoItem[] infos = infoList.ToArray(); _infoLayer.InfoItems.AddRange(infos); _iceFeatures.Add(feature, infos); UpdateLayer(feature); } ); }