public static CATextLayer RenderLabel(Mapsui.Geometries.Point point, LabelStyle style, IFeature feature, IViewport viewport, string text) { // Offset stackOffset, Mapsui.Geometries.Point p = viewport.WorldToScreen(point); //var pointF = new xPointF((float)p.X, (float)p.Y); var label = new CATextLayer (); var aString = new Foundation.NSAttributedString (text, new CoreText.CTStringAttributes(){ Font = new CoreText.CTFont("ArialMT", 10) }); var frame = new CGRect(new CoreGraphics.CGPoint((int)p.X, (int)p.Y), GetSizeForText(0, aString)); //label.Frame = frame; //frame.Width = (float)(p2.X - p1.X);// + margin); //frame.Height = (float)(p1.Y - p2.Y); label.FontSize = 10; label.ForegroundColor = new CoreGraphics.CGColor (0, 0, 255, 150); label.BackgroundColor = new CoreGraphics.CGColor (255, 0, 2, 150); label.String = text; label.Frame = frame; Console.WriteLine ("Pos " + label.Frame.X + ":" + label.Frame.Y + " w " + label.Frame.Width + " h " + label.Frame.Height); // = MonoTouch.UIKit.UIScreen.MainScreen.Scale; // label.ContentsScale = scale; return label; }
/// <summary> /// This method is used for determining the color of country based on attributes. /// It is used as a delegate for the CustomTheme class. /// </summary> /// <param name="row"></param> /// <returns></returns> private VectorStyle GetCountryStyle(IFeature row) { VectorStyle style = new VectorStyle(); switch (row.Attributes["NAME"].ToString().ToLower()) { case "denmark": //If country name is Danmark, fill it with green style.Fill = Brushes.Green; return style; case "united states": //If country name is USA, fill it with Blue and add a red outline style.Fill = Brushes.Blue; style.Outline = Pens.Red; return style; case "china": //If country name is China, fill it with red style.Fill = Brushes.Red; return style; default: break; } //If country name starts with S make it yellow if (row.Attributes["NAME"].ToString().StartsWith("S")) { style.Fill = Brushes.Yellow; return style; } // If geometry is a (multi)polygon and the area of the polygon is less than 30, make it cyan else if (row.Geometry is IMultiPolygon && (row.Geometry as IMultiPolygon).Area < 30 || row.Geometry is IPolygon && (row.Geometry as IPolygon).Area < 30) { style.Fill = Brushes.Cyan; return style; } else //None of the above -> Use the default style return null; }
private IEnumerable<Coordinate[]> WriteFeature(JsonWriter writer, JsonSerializer serializer, IFeature feature) { if (writer == null) throw new ArgumentNullException("writer"); if (serializer == null) throw new ArgumentNullException("serializer"); if (feature == null) throw new ArgumentNullException("feature"); Coordinate[][] arcs; writer.WriteStartObject(); IGeometry geom = feature.Geometry; writer.WritePropertyName("type"); writer.WriteValue(geom.GeometryType); OgcGeometryType type = geom.OgcGeometryType; switch (type) { case OgcGeometryType.Point: WriteGeom(writer, serializer, (IPoint)geom); arcs = null; break; case OgcGeometryType.LineString: arcs = WriteGeom(writer, (ILineString)geom); break; case OgcGeometryType.Polygon: arcs = WriteGeom(writer, (IPolygon)geom); break; default: string err = String.Format("type unsupported: {0}", type); throw new ArgumentOutOfRangeException(err); } serializer.Serialize(writer, feature.Attributes); writer.WriteEndObject(); return arcs; }
public void IsDisabledShouldThrowWhenGivenNullFeatureContext(IFeature feature) { var exception = Assert.Throws<ArgumentNullException>(() => FeatureContextExtensions.IsDisabled(null, feature)); Assert.Contains("featureContext", exception.ParamName); }
public void Start(INode node, AddRelatedFeature addRelatedFeature, int level) { lastFeature = node; lastRelatedFeatureGeometries.Clear(); lastRelatedFeatures = new List<IFeature>(); lastRelatedNewFeatures = new List<IFeature>(); lastCoordinate = (ICoordinate)node.Geometry.Coordinates[0].Clone(); foreach (IBranch branch in node.IncomingBranches) { lastRelatedFeatures.Add(branch); var clone = (IBranch)branch.Clone(); lastRelatedNewFeatures.Add(clone); lastRelatedFeatureGeometries.Add((IGeometry)clone.Geometry.Clone()); if (null != addRelatedFeature) { activeInRules.Add(new List<IFeatureRelationInteractor>()); addRelatedFeature(activeInRules[activeInRules.Count - 1], branch, clone, level); } } foreach (var branch in node.OutgoingBranches) { lastRelatedFeatures.Add(branch); var clone = (IBranch) branch.Clone(); lastRelatedNewFeatures.Add(clone); lastRelatedFeatureGeometries.Add((IGeometry)clone.Geometry.Clone()); if (null != addRelatedFeature) { activeOutRules.Add(new List<IFeatureRelationInteractor>()); addRelatedFeature(activeOutRules[activeOutRules.Count - 1], branch, clone, level); } } }
public ConfigurationDrivenFeatureAdapter(IFeature feature, FeatureConfiguration configuration = null) { Require.Argument.NotNull(feature); _feature = feature; _configuration = configuration ?? FeatureConfiguration.Current; }
public void IsEnabledCallsAllToggles([Frozen] IFeatureToggleProvider toggleProvider, IFeature feature, Fixture fixture, FeatureContext sut) { var featureToggles = fixture.CreateMany<Fake<IFeatureToggle>>().ToList(); foreach (Fake<IFeatureToggle> fake in featureToggles) { fake.CallsTo(ft => ft.IsEnabled(feature)) .Returns(null); } var finalTogle = A.Fake<Fake<IFeatureToggle>>(); finalTogle.CallsTo(ft => ft.IsEnabled(feature)) .Returns(true); featureToggles.Add(finalTogle); A.CallTo(() => toggleProvider.GetFeatureToggles()) .Returns(featureToggles.Select(f => f.FakedObject)); sut.IsEnabled(feature); foreach (Fake<IFeatureToggle> fake in featureToggles) { fake.CallsTo(ft => ft.IsEnabled(feature)) .MustHaveHappened(); } }
/// <summary> /// Gets the stub header. /// </summary> /// <param name="feature">The feature.</param> /// <param name="count">The count.</param> /// <returns></returns> public static DbaseFileHeader GetHeader(IFeature feature, int count) { IAttributesTable attribs = feature.Attributes; string[] names = attribs.GetNames(); DbaseFileHeader header = new DbaseFileHeader(); header.NumRecords = count; foreach (string name in names) { Type type = attribs.GetType(name); if (type == typeof(double) || type == typeof(float)) header.AddColumn(name, 'N', DoubleLength, DoubleDecimals); else if (type == typeof(short) || type == typeof(ushort) || type == typeof(int) || type == typeof(uint) || type == typeof(long) || type == typeof(ulong)) header.AddColumn(name, 'N', IntLength, IntDecimals); else if (type == typeof(string)) header.AddColumn(name, 'C', StringLength, StringDecimals); else if (type == typeof(bool)) header.AddColumn(name, 'L', BoolLength, BoolDecimals); else if (type == typeof(DateTime)) header.AddColumn(name, 'D', DateLength, DateDecimals); else throw new ArgumentException("Type " + type.Name + " not supported"); } return header; }
// todo: // try to remove the feature argument. LabelStyle should already contain the feature specific text // The visible feature iterator should create this LabelStyle public static void Draw(SKCanvas canvas, IViewport viewport, IStyle style, IFeature feature, IGeometry geometry, IDictionary<int, SKBitmapInfo> symbolBitmapCache) { var point = geometry as Point; var destination = viewport.WorldToScreen(point); if (style is LabelStyle) // case 1) LabelStyle { LabelRenderer.Draw(canvas, (LabelStyle) style, feature, (float) destination.X, (float) destination.Y); } else if (style is SymbolStyle) { var symbolStyle = (SymbolStyle)style; if ( symbolStyle.BitmapId >= 0) // case 2) Bitmap Style { DrawPointWithBitmapStyle(canvas, symbolStyle, destination, symbolBitmapCache); } else // case 3) SymbolStyle without bitmap { DrawPointWithSymbolStyle(canvas, symbolStyle, destination, symbolStyle.SymbolType); } } else if (style is VectorStyle) // case 4) VectorStyle { DrawPointWithVectorStyle(canvas, (VectorStyle) style, destination); } else { throw new Exception($"Style of type '{style.GetType()}' is not supported for points"); } }
public Corridor(Position startingPosition, Direction direction, int maxLenght, IFeature spawningFeature) { Trail = new List<Floor>(); ConnectedFeatureA = spawningFeature; Direction = direction; InitTrail(startingPosition, maxLenght); }
/// <summary> /// Creates a Balloon Callout with the value from the given field name for the given feature. /// </summary> /// <param name="displayFieldName">The name of the field.</param> /// <param name="feature">The feature for which to create the callout.</param> /// <returns>Returns an element with a callout symbol.</returns> public static IElement CreateBalloonCalloutForFeature(string displayFieldName, IFeature feature) { string methodName = MethodBase.GetCurrentMethod().Name; object o = DatabaseUtil.GetFieldValue(feature, displayFieldName, true); string val = o != null ? o.ToString() : string.Empty; return CreateBalloonCalloutForFeature(feature, val); }
public static void Draw(SKCanvas canvas, IViewport viewport, IStyle style, IFeature feature, IDictionary<object, SKBitmapInfo> skBitmapCache, long currentIteration) { try { var raster = (IRaster)feature.Geometry; SKBitmapInfo textureInfo; if (!skBitmapCache.Keys.Contains(raster)) { textureInfo = BitmapHelper.LoadTexture(raster.Data); skBitmapCache[raster] = textureInfo; } else { textureInfo = skBitmapCache[raster]; } textureInfo.IterationUsed = currentIteration; skBitmapCache[raster] = textureInfo; var destination = WorldToScreen(viewport, feature.Geometry.GetBoundingBox()); BitmapHelper.RenderRaster(canvas, textureInfo.Bitmap, RoundToPixel(destination).ToSkia()); } catch (Exception ex) { Logger.Log(LogLevel.Error, ex.Message, ex); } }
public virtual bool Contains(IFeature feature) { if (Features.Count == 0) { return false; } // Since Features can be strongly collection typed we must prevent searching objects of an invalid type if (FeatureType != null) { // test if feature we are looking for is derived from FeatureType if (!FeatureType.IsAssignableFrom(feature.GetType())) { return false; } } else { // if FeatureType is not set use type of first object in collection. if (Features[0].GetType() != feature.GetType()) { return false; } } return Features.Contains(feature); }
public virtual IFeatureInteractor CreateInteractor(ILayer layer, IFeature feature) { if (null == feature) return null; var vectorLayer = layer as VectorLayer; var vectorStyle = (vectorLayer != null ? vectorLayer.Style : null); // most specific type should be first if (feature is RegularGridCoverageCell) return new LineStringInteractor(layer, feature, vectorStyle, null); if (feature is IGridFace || feature is IGridVertex) return new LineStringInteractor(layer, feature, vectorStyle, null); if (feature.Geometry is ILineString) return new LineStringInteractor(layer, feature, vectorStyle, null); if (feature.Geometry is IPoint) return new PointInteractor(layer, feature, vectorStyle, null); // todo implement custom mutator for Polygon and MultiPolygon // LineStringMutator will work as long as moving is not supported. if (feature.Geometry is IPolygon) return new LineStringInteractor(layer, feature, vectorStyle, null); if (feature.Geometry is IMultiPolygon) return new LineStringInteractor(layer, feature, vectorStyle, null); return null; //throw new ArgumentException("Unsupported type " + feature.Geometry); }
public override bool Render(IFeature feature, Graphics g, ILayer layer) { var segmentsLayer = (NetworkCoverageSegmentLayer) layer; var coverage = ((NetworkCoverageFeatureCollection)layer.DataSource).RenderedCoverage; IEnvelope mapExtents = layer.Map.Envelope; var sliceValues = coverage.GetValues(); // 1 find the segments withing the current extend var segments = coverage.Segments.Values;//.Where(seg => seg.Geometry.EnvelopeInternal.Intersects(mapExtents)).ToList(); for (int i = 0; i < segments.Count; i++) { INetworkSegment segment = segments[i]; if (segment.Geometry.EnvelopeInternal.Intersects(mapExtents) && sliceValues.Count > 0) { // 2 get the values for this segment // if SegmentGenerationMethod == SegmentGenerationMethod.RouteBetweenLocations the segments and // location do not have to match; return default value double value = coverage.SegmentGenerationMethod == SegmentGenerationMethod.RouteBetweenLocations ? 0 : (double) sliceValues[i]; // 3 use the Theme of the layer to draw var style = (VectorStyle)segmentsLayer.Theme.GetStyle(value); VectorRenderingHelper.RenderGeometry(g, layer.Map, segment.Geometry, style, null, true); } } return true; }
public ConditionalFeature(OverlayPlugin plugin, XmlNode node) { mPlugin = plugin; XmlNode featureNode = node.SelectSingleNode("child::Feature"); mStartActive = GetBool(node, false, "StartActive"); mMultiActivate = GetBool(node, false, "MultiActivate"); if (featureNode == null) throw new ArgumentException("Unable to load Conditional Feature. Unable to parse feature."); foreach (var child in GetChildrenOfChild(node, "ActiveTriggers")) { var trigger = plugin.GetTrigger(child, "conditional feature", null); mActiveTriggers.Add(trigger); trigger.Triggered += mActiveTrigger_Triggered; } foreach (var child in GetChildrenOfChild(node, "InactiveTriggers")) { var trigger = plugin.GetTrigger(child, "conditional feature", null); mInactiveTriggers.Add(trigger); trigger.Triggered += mInactiveTrigger_Triggered; } mFeature = mPlugin.GetFeature(featureNode, "conditional feature", null); if (node.SelectSingleNode("child::ActiveTriggers") == null) Logger.Info("No active trigger node found in conditional feature " + Name + "."); if (node.SelectSingleNode("child::InactiveTriggers") == null) Logger.Info("No inactive trigger node found in conditional feature."); if (mActiveTriggers.Count == 0) Logger.Info("No active triggers loaded in conditional feature " + Name + "."); if (mInactiveTriggers.Count == 0) Logger.Info("No inactive triggers loaded in conditional feature " + Name + "."); }
public void RenderGeometry(MultiPolygon multiPolygon, IStyle style, IFeature feature, IViewport viewport) { if (_bgWorker == null) _bgWorker = new BackgroundWorker(); /* while (_bgWorker.IsBusy) { Thread.Sleep (00001); } */ _bgWorker.RunWorkerCompleted += (sender, e) => { var layer = e.Result as CALayer; if (layer != null) { var styleKey = style.GetHashCode().ToString(); feature[styleKey] = layer; } }; _bgWorker.DoWork += delegate(object sender, DoWorkEventArgs e) { var layer = RenderImage(multiPolygon, style, viewport); e.Result = layer; }; _bgWorker.RunWorkerAsync(); }
/// <summary> /// Creates a shape based on the specified feature. This shape will be standing alone, /// all by itself. The fieldnames and field types will be null. /// </summary> /// <param name="feature"></param> public Shape(IFeature feature) { _shapeRange = new ShapeRange(feature.FeatureType); _attributes = feature.DataRow.ItemArray; IList<Coordinate> coords = feature.Coordinates; _vertices = new double[feature.NumPoints*2]; _z = new double[feature.NumPoints]; _m = new double[feature.NumPoints]; for (int i = 0; i < coords.Count; i++) { Coordinate c = coords[i]; _vertices[i*2] = c.X; _vertices[i*2 + 1] = c.Y; _z[i] = c.Z; _m[i] = c.M; } int offset = 0; for(int ig = 0; ig < feature.NumGeometries; ig++) { IBasicGeometry g = feature.GetBasicGeometryN(ig); PartRange prt = new PartRange(_vertices, 0, offset, feature.FeatureType); _shapeRange.Parts.Add(prt); offset += g.NumPoints; } }
private void Init(AxMapControl mc, int programID) { gp = new Geoprocessor(); mapControl = mc; UpdateMapLayerNameList(mapLayerNameList, mapControl); program = new Program(); program.id = programID; program.select(); project = new Project(); project.id = program.projectID; project.select(); netSize = program.getRelatedNetSize(); conditionList = program.getAllRelatedCondition(); baseFeature = GisUtil.GetBaseFeature(mapControl, project.baseMapIndex); mapFolder = System.IO.Path.GetDirectoryName(project.path); targetFolder = generateFolder(mapFolder); foreach (Condition condition in conditionList) { if (condition.type == C.CONFIG_TYPE_STANDARD) { totalStandardValue += condition.value; } } fishnetPolygonName = "polygon.shp"; fishnetName = "fishnet.shp"; fishnetWidth = netSize.width; fishnetHeight = netSize.height; featureList = new List<Feature>(); }
public static void Draw(IViewport viewport, IStyle style, IFeature feature) { var lineString = ((LineString)feature.Geometry).Vertices; float lineWidth = 1; var lineColor = Color.White; var vectorStyle = style as VectorStyle; if (vectorStyle != null) { lineWidth = (float)vectorStyle.Line.Width; lineColor = vectorStyle.Line.Color; } float[] points = ToOpenTK(lineString); WorldToScreen(viewport, points); GL.LineWidth(lineWidth); GL.Color4((byte)lineColor.R, (byte)lineColor.G, (byte)lineColor.B, (byte)lineColor.A); GL.EnableClientState(All.VertexArray); GL.VertexPointer(2, All.Float, 0, points); GL.DrawArrays(All.Lines, 0, points.Length / 2); GL.DisableClientState(All.VertexArray); }
public static void Draw(Canvas canvas, IViewport viewport, IStyle style, IFeature feature) { try { if (!feature.RenderedGeometry.ContainsKey(style)) feature.RenderedGeometry[style] = ToAndroidBitmap(feature.Geometry); var bitmap = (AndroidGraphics.Bitmap)feature.RenderedGeometry[style]; var dest = WorldToScreen(viewport, feature.Geometry.GetBoundingBox()); dest = new BoundingBox( dest.MinX, dest.MinY, dest.MaxX, dest.MaxY); var destination = RoundToPixel(dest); using (var paint = new Paint()) { canvas.DrawBitmap(bitmap, new Rect(0, 0, bitmap.Width, bitmap.Height), destination, paint); } DrawOutline(canvas, style, destination); } catch (Exception ex) { Trace.WriteLine(ex.Message); } }
public IStyle GetStyle(IFeature row) { IStyle style = StyleDelegate(row); if (style != null) return style; return DefaultStyle; }
public WeakClassifier(double Alpha, int Threshold, sbyte Parity, IFeature Feature) { this.Alpha = Alpha; this.Threshold = Threshold; this.Parity = Parity; this.Feature = Feature; }
public static void Draw(CALayer target, IViewport viewport, IStyle style, IFeature feature) { const string styleKey = "laag"; if(feature[styleKey] == null) feature[styleKey] = ToiOSBitmap(feature.Geometry); var bitmap = (UIImage)feature [styleKey]; var dest = WorldToScreen(viewport, feature.Geometry.GetBoundingBox()); dest = new BoundingBox( dest.MinX, dest.MinY, dest.MaxX, dest.MaxY); var destination = RoundToPixel(dest); var tile = new CALayer { Frame = destination, Contents = bitmap.CGImage, }; target.AddSublayer(tile); }
/// <summary> /// 获取选中要素的DataTable /// </summary> /// <param name="pSelection">IFeature</param> /// <returns>DataTable</returns> public static DataTable GetFeatureAttr(IFeature pFeature) { DataTable dt = new DataTable(); dt.Columns.Add("name", System.Type.GetType("System.String")); //名称 dt.Columns.Add("value", System.Type.GetType("System.String")); //值 try { if (pFeature == null) { return dt; } ITable table = pFeature.Table; IFields fields = table.Fields; for (int i = 0; i < fields.FieldCount; i++) { //获取数据 IField field = fields.get_Field(i); string aliasName = field.AliasName; //string name = GISConfig.ConvertFieldName(aliasName); if (aliasName != "XZQMC") { continue; } string value = Convert.ToString(pFeature.get_Value(i)); //写入数据 DataRow dr = dt.NewRow(); dr["name"] = aliasName; dr["value"] = value; dt.Rows.Add(dr); } } catch { } return dt; }
public static void Draw(IViewport viewport, IStyle style, IFeature feature) { var lineString = ((Polygon)feature.Geometry).ExteriorRing.Vertices; float lineWidth = 1; var lineColor = Color.Black; // default // todo: var fillColor = Color.Gray; // default var vectorStyle = style as VectorStyle; if (vectorStyle != null) { lineWidth = (float)vectorStyle.Outline.Width; lineColor = vectorStyle.Outline.Color; // todo: fillColor = vectorStyle.Fill.Color; } float[] points = ToOpenTK(lineString); WorldToScreen(viewport, points); // Fill // Not implemented. It might be hard to draw a concave polygon with holes. // Outline GL.LineWidth(lineWidth); GL.Color4(lineColor.R, lineColor.G, lineColor.B, lineColor.A); GL.EnableClientState(All.VertexArray); GL.VertexPointer(2, All.Float, 0, points); GL.DrawArrays(All.LineLoop, 0, points.Length / 2); GL.DisableClientState(All.VertexArray); }
public static void Draw(IViewport viewport, IStyle style, IFeature feature, IDictionary<object, TextureInfo> TextureCache, long currentIteration) { try { var raster = (IRaster)feature.Geometry; TextureInfo textureInfo; if (!TextureCache.Keys.Contains(raster)) { textureInfo = TextureHelper.LoadTexture(raster.Data); TextureCache[raster] = textureInfo; } else { textureInfo = TextureCache[raster]; } textureInfo.IterationUsed = currentIteration; TextureCache[raster] = textureInfo; var destination = WorldToScreen(viewport, feature.Geometry.GetBoundingBox()); TextureHelper.RenderTexture(textureInfo.TextureId, ToVertexArray(RoundToPixel(destination))); } catch (Exception ex) { Trace.WriteLine(ex.Message); } }
public RouteInvocation (IFeature feature, IRouteTarget target, IDictionary<string, string> data) { this.Feature = feature; this.Target = target; this.RouteData = data; }
/// <summary> /// Function to evaluate if a feature has an ID /// </summary> /// <param name="feature">The feature</param> /// <returns><value>true</value> if <paramref name="feature"/> has an identifier assigned, otherwise <value>false</value></returns> /// <exception cref="ArgumentNullException">Thrown, if <paramref name="feature"/> is <valu>null</valu></exception> public static bool HasID(IFeature feature) { if (feature == null) throw new ArgumentNullException("feature"); return feature.Attributes.Exists(IdAttributeName); }
public OperateForm(IFeatureClass FeatureClass, IFeature Feature) { this.FeatureClass = FeatureClass; this.Feature = Feature; this.FieldIndexDict = GISHelper.GetFieldIndexDict(FeatureClass); Init(); InitializeComponent(); }
private void OnSketchFinished() { ConfigUtil.type = "gas"; Keys ModKey = Control.ModifierKeys; // Send a shift-tab to hide the construction toolbar m_editor.StartOperation(); IFeature pFeat = null; returnFeatArray pRetVal = null; if (ModKey == Keys.Shift) { pFeat = Globals.CreateFeature(m_edSketch.Geometry, m_editor.CurrentTemplate, m_editor, ArcMap.Application, false, false, true); pRetVal = ConnectClosest.ConnectClosestFeatureAtPoint(ArcMap.Application, ConfigUtil.GetConnectClosestConfig(), m_edSketch.Geometry as IPoint, m_editor.CurrentTemplate.Layer.Name, true, ModKey); // pFeat.Store(); } else if (ModKey == (Keys.Control | Keys.Shift)) { pFeat = Globals.CreateFeature(m_edSketch.Geometry, m_editor.CurrentTemplate, m_editor, ArcMap.Application, false, false, true); pRetVal = ConnectClosest.ConnectClosestFeatureAtPoint(ArcMap.Application, ConfigUtil.GetConnectClosestConfig(), m_edSketch.Geometry as IPoint, m_editor.CurrentTemplate.Layer.Name, true, ModKey); // pFeat.Store(); } else if (ModKey == Keys.Control) { pFeat = Globals.CreateFeature(m_edSketch.Geometry, m_editor.CurrentTemplate, m_editor, ArcMap.Application, false, true, true); pRetVal = ConnectClosest.ConnectClosestFeatureAtPoint(ArcMap.Application, ConfigUtil.GetConnectClosestConfig(), m_edSketch.Geometry as IPoint, m_editor.CurrentTemplate.Layer.Name, true, ModKey); // pFeat.Store(); } else { pFeat = Globals.CreateFeature(m_edSketch.Geometry, m_editor.CurrentTemplate, m_editor, ArcMap.Application, false, true, true); pRetVal = ConnectClosest.ConnectClosestFeatureAtPoint(ArcMap.Application, ConfigUtil.GetConnectClosestConfig(), m_edSketch.Geometry as IPoint, m_editor.CurrentTemplate.Layer.Name, true, ModKey); } pFeat.Store(); foreach (IFeature featus in pRetVal.Features) { featus.Store(); } if (pRetVal.Options == "DIGITIZED") { Globals.GetCommand("A4GasUtilities_EstablishFlowDigitized", ArcMap.Application).Execute(); } else if (pRetVal.Options == "ROLE") { Globals.GetCommand("A4GasUtilities_EstablishFlowAncillary", ArcMap.Application).Execute(); } else if (pRetVal.Options == "Ancillary".ToUpper()) { Globals.GetCommand("A4GasUtilities_EstablishFlowAncillary", ArcMap.Application).Execute(); } else { } // addLat.AddLateralAtPoint(m_edSketch.Geometry as IPoint, m_editor.CurrentTemplate.Layer.Name); m_editor.StopOperation("Create asset and lateral"); //IEnvelope pEnv = pFeat.Shape.Envelope; //pEnv.Expand(8, 8, true); (ArcMap.Application.Document as IMxDocument).ActiveView.PartialRefresh(esriViewDrawPhase.esriViewAll, pFeat, null); //pEnv = null; pFeat = null; pRetVal = null; }
public FrmNewZHZZT(FrmZhzzt mFrmZhzzt, string BID) { InitializeComponent(); setcombox(); //设置窗体属性 LibCommon.FormDefaultPropertiesSetter.SetEnteringFormDefaultProperties(this, "修改柱状图"); frmZhzzt = mFrmZhzzt; bid = BID; isadd = false; IQueryFilter pFilter = new QueryFilterClass(); pFilter.WhereClause = "BID='" + BID + "' and strtype='1'"; IFeatureCursor pCursor = mFrmZhzzt.pFeatureClass.Search(pFilter, false); IFeature pFeature = pCursor.NextFeature(); if (pFeature != null) { string textstr = pFeature.get_Value(pFeature.Fields.FindField("textstr")).ToString(); string bilici = pFeature.get_Value(pFeature.Fields.FindField("bilici")).ToString(); txtname.Text = textstr; txtBlc.Text = bilici; } pFilter = new QueryFilterClass(); pFilter.WhereClause = "BID='" + BID + "' and xuhaoR>0"; int count = mFrmZhzzt.pFeatureClass.FeatureCount(pFilter); count = count / 6; if (count % 6 != 0) { count += 1; } if (count == 0) { return; } dgrdvZhzzt.RowCount = count; for (int i = 0; i < count; i++) { pCursor = MyMapHelp.FeatureSorting(mFrmZhzzt.pFeatureClass, "BID='" + BID + "' and xuhaoR=" + (i + 1) + "", "order by xuhaoC"); pFeature = pCursor.NextFeature(); while (pFeature != null) { string textstr = ""; if (pFeature.get_Value(pFeature.Fields.FindField("textstr")) != null) { textstr = pFeature.get_Value(pFeature.Fields.FindField("textstr")).ToString(); } string xuhaoC = pFeature.get_Value(pFeature.Fields.FindField("xuhaoC")).ToString(); if (xuhaoC.Equals("2")) { dgrdvZhzzt[0, i].Value = textstr; } if (xuhaoC.Equals("3")) { dgrdvZhzzt[1, i].Value = textstr; } if (xuhaoC.Equals("5")) { string zztype = pFeature.get_Value(pFeature.Fields.FindField("zztype")).ToString(); dgrdvZhzzt[2, i].Value = ZZCodeToStr(zztype); } if (xuhaoC.Equals("6")) { dgrdvZhzzt[3, i].Value = textstr; } pFeature = pCursor.NextFeature(); } } }
public void VerifySegmentsGroupContinuously() { var featureClassMock = new FeatureClassMock(1, "mock", esriGeometryType.esriGeometryMultiPatch); // make sure the table is known by the workspace const double nearAngle = 5; const double y = 10; var construction = new MultiPatchConstruction(); double xi = 0; double yi = y; construction.StartOuterRing(0, 0, 0) .Add(xi, yi, 0); double angleRad = 1.01 * MathUtils.ToRadians(nearAngle); for (int i = 1; i < 4; i++) { double currentAngle = i * angleRad; double dx = y * Math.Sin(currentAngle); double dy = y * Math.Cos(currentAngle); xi += dx; yi += dy; construction.Add(xi, yi, 0); } construction.Add(20, 0, 0); IFeature row1 = featureClassMock.CreateFeature(construction.MultiPatch); var test = new QaMpHorizontalAzimuths(featureClassMock, nearAngle, 0, 0, false); var runner = new QaTestRunner(test); runner.Execute(row1); Assert.AreEqual(0, runner.Errors.Count); construction = new MultiPatchConstruction(); xi = 0; yi = y; construction.StartOuterRing(0, 0, 0) .Add(xi, yi, 0); angleRad = 0.99 * MathUtils.ToRadians(nearAngle); for (int i = 1; i < 4; i++) { double currentAngle = i * angleRad; double dx = y * Math.Sin(currentAngle); double dy = y * Math.Cos(currentAngle); xi += dx; yi += dy; construction.Add(xi, yi, 0); } construction.Add(20, 0, 0); row1 = featureClassMock.CreateFeature(construction.MultiPatch); test = new QaMpHorizontalAzimuths(featureClassMock, nearAngle, 0, 0, false); runner = new QaTestRunner(test); runner.Execute(row1); Assert.AreEqual(1, runner.Errors.Count); }
/// <summary> /// Returns the next feature at worldPos. /// </summary> /// <param name="worldPos"></param> /// <param name="limit"></param> /// <param name="outLayer"></param> /// the layer containing the next feature; null if no next feature is found. /// <param name="feature"></param> /// <param name="condition"></param> /// <returns>the next feature at worldPos, null if there is no next feature.</returns> public IFeature GetNextFeatureAtPosition(ICoordinate worldPos, float limit, out Layer outLayer, IFeature feature, Func <ILayer, bool> condition) { IEnvelope envelope = GetEnvelope(worldPos, limit); IFeature nextFeature = null; bool featureFound = false; outLayer = null; foreach (ILayer mapLayer in Map.GetAllVisibleLayers(false)) { var vectorLayer = mapLayer as VectorLayer; IPoint point = GeometryFactory.CreatePoint(worldPos); if (vectorLayer == null || !vectorLayer.IsSelectable) { continue; } if ((null != condition) && (!condition(vectorLayer))) { continue; } if (vectorLayer.DataSource != null) { var objectsAt = vectorLayer.GetFeatures(envelope); foreach (IFeature featureAt in objectsAt) { // GetFeatures(envelope) uses the geometry bounds; this results in more // geometries than we actually are interested in (especially linestrings and polygons). double distance = featureAt.Geometry.Distance(point); if (distance >= limit) { continue; } if (featureFound) { nextFeature = featureAt; outLayer = vectorLayer; return(nextFeature); } if (featureAt == feature) { featureFound = true; continue; } if (null != nextFeature) { continue; } // If feature is last in collections objectsAt nextfeature is first nextFeature = featureAt; outLayer = vectorLayer; } } } return(nextFeature); }
public ILayer GetLayerByFeature(IFeature feature) { return(Map.GetLayerByFeature(feature)); }
private static void PositionGeometry(UIElement renderedGeometry, IViewport viewport, IStyle style, IFeature feature) { if (feature.Geometry is Geometries.Point) { GeometryRenderer.PositionPoint(renderedGeometry, feature.Geometry as Geometries.Point, style, viewport); } else if (feature.Geometry is MultiPoint) { GeometryRenderer.PositionGeometry(renderedGeometry, viewport); } else if (feature.Geometry is LineString) { GeometryRenderer.PositionGeometry(renderedGeometry, viewport); } else if (feature.Geometry is MultiLineString) { GeometryRenderer.PositionGeometry(renderedGeometry, viewport); } else if (feature.Geometry is Polygon) { GeometryRenderer.PositionGeometry(renderedGeometry, viewport); } else if (feature.Geometry is MultiPolygon) { GeometryRenderer.PositionGeometry(renderedGeometry, viewport); } else if (feature.Geometry is IRaster) { GeometryRenderer.PositionRaster(renderedGeometry, feature.Geometry.GetBoundingBox(), viewport); } }
/// <summary> /// Create a new install certificates features /// </summary> public InstallCertificatesTask(IFeature feature) { this.Feature = feature; }
public abstract bool Render(IFeature feature, Graphics g, ILayer layer);
public IGeometry GetRenderedFeatureGeometry(IFeature feature, ILayer layer) { return(feature.Geometry); //throw new NotImplementedException(); }
private bool CreateShpFile(List <ROIGeometry> geometryList, out string sShpFilePath) { bool result = false; string shpName = DateTime.Now.ToString("yyyyMMddhhmmss"); sShpFilePath = System.IO.Path.Combine(ConstDef.PATH_TEMP, shpName + ".shp"); try { if (!Directory.Exists(ConstDef.PATH_TEMP)) { Directory.CreateDirectory(ConstDef.PATH_TEMP); } IWorkspace workspace = EngineAPI.OpenWorkspace(ConstDef.PATH_TEMP, DataType.shp); if (workspace == null) { result = false; } else { IFields fields = this.CreateFields(); if (fields == null) { result = false; } IFeatureClass featureClass = this.CreateFeatureClass(workspace, shpName, fields, spatialReference); if (featureClass == null) { result = false; } try { int rowIndex = 0; foreach (ROIGeometry roi in geometryList) { IFeature pFeature = featureClass.CreateFeature(); pFeature.Shape = roi.geometry; pFeature.Store(); ITable pTable = pFeature.Table; if (pTable.RowCount(null) > 0) { IRow pRow = pTable.GetRow(rowIndex); pRow.set_Value(2, roi.name); pRow.set_Value(3, roi.id); Color color = ColorTranslator.FromOle(roi.color.RGB); pRow.set_Value(4, string.Format("{0},{1},{2}", color.R, color.G, color.B)); pRow.Store(); } rowIndex++; //IFieldEdit field = feature as IField; } } catch (Exception ex) { Log.WriteLog(typeof(HyperSpeClassification), ex); result = false; } finally { if (featureClass != null) { System.Runtime.InteropServices.Marshal.ReleaseComObject(featureClass); } } } result = true; } catch (Exception ex) { Log.WriteLog(typeof(HyperSpeClassification), ex); result = false; } return(result); }
private byte[] AnalGeomBufferHandler(NameValueCollection boundVariables, JsonObject operationInput, string outputFormat, string requestProperties, out string responseProperties) { responseProperties = null; long?paramOID; bool found = operationInput.TryGetAsLong("OBJECTID", out paramOID); if (!found || !paramOID.HasValue) { throw new ArgumentNullException("OBJECTID invalido!"); } long?paramBuffer1; found = operationInput.TryGetAsLong("bufferCerchio1", out paramBuffer1); if (!found || !paramBuffer1.HasValue) { throw new ArgumentNullException("Valore Buffer1 invalido!!"); } long?paramBuffer2; found = operationInput.TryGetAsLong("bufferCerchio2", out paramBuffer2); if (!found || !paramBuffer2.HasValue) { throw new ArgumentNullException("Valore Buffer2 invalido!!"); } long?paramBuffer3; found = operationInput.TryGetAsLong("bufferCerchio3", out paramBuffer3); if (!found || !paramBuffer3.HasValue) { throw new ArgumentNullException("Valore Buffer3 invalido!!"); } this.RicavaInfoFc(); IFeature feature = null; this.RicavaFeatureFiliare(paramOID.Value, out feature); Dictionary <long, IPolygon> dizGeometrieBuffer = this.CostruisciBuffer(feature, paramBuffer1.Value, paramBuffer2.Value, paramBuffer3.Value); List <IRecordSet2> listaRecordSet = this.AnalisiSpazialiBufferOper(dizGeometrieBuffer); JsonObject result = new JsonObject(); result.AddJsonObject("interno", new JsonObject(Encoding.UTF8.GetString(Conversion.ToJson(listaRecordSet[0])))); result.AddJsonObject("centrale", new JsonObject(Encoding.UTF8.GetString(Conversion.ToJson(listaRecordSet[1])))); result.AddJsonObject("superiore", new JsonObject(Encoding.UTF8.GetString(Conversion.ToJson(listaRecordSet[2])))); #region Mi occupo di tirare fuori le Geometrie dei Buffer circolari e serializzarle List <IGeometry> listaGeometrie = new List <IGeometry>(); foreach (KeyValuePair <long, IPolygon> coppia in dizGeometrieBuffer) { // ATTENZIONE!!! // GLI ARCOBJECTS (METODO CONVERSION - SOE_SUPPORT) NON GESTISCE L'INSERIMENTO DI CURVE NEL JSON. // UNA TRUE CURVE DEVE ESSERE SEMPLIFICATA - DENSIFICATA COME UN INSIEME DI SEGMENTI (es: shapefile) // PRIMA DI ESSERE RESTITUITA AL CLIENT!! IPolycurve polycurve = coppia.Value as IPolycurve; polycurve.Densify(5, 0); IGeometry geo = polycurve as IGeometry; geo.SpatialReference = ((IGeoDataset)fcClienti).SpatialReference; listaGeometrie.Add(geo); } object[] objArray = Helper.GetListJsonObjects(listaGeometrie); #endregion result.AddArray("geomBuffer", objArray); return(Encoding.UTF8.GetBytes(result.ToJson())); }
/// <summary> /// Returns whether <paramref name="feature"/> is a product of this factory. /// </summary> /// <param name="feature">Feature to test</param> /// <returns>True if it came from this factory, false otherwise.</returns> public bool IsProduct(IFeature <ImageDataPoint <float>, float[]> feature) { return(feature is HaarFeature); }
private void button1_Click(object sender, EventArgs e) { try { string saveString = comboBox1.Text; // 属性过滤 IQueryFilter pQueryFilter = new QueryFilter(); if (pItems.Count > 0) { pQueryFilter.WhereClause = saveString; } else { pQueryFilter.WhereClause = null; } // 要素游标 //启动编辑 IFeatureLayer pFeatureLayer = mLayer as IFeatureLayer; IFeatureClass pFeatureClass = pFeatureLayer.FeatureClass; IWorkspace workspace = null; IEngineEditor mEngineEditor = mEngineEditor = new EngineEditorClass(); if (pFeatureClass.FeatureDataset != null) { workspace = pFeatureClass.FeatureDataset.Workspace; IMap mMap = mAxMapControl1.Map; mEngineEditor.EditSessionMode = esriEngineEditSessionMode.esriEngineEditSessionModeVersioned; mEngineEditor.StartEditing(workspace, mMap); ((IEngineEditLayers)mEngineEditor).SetTargetLayer(pFeatureLayer, -1); mEngineEditor.StartOperation(); } IFeatureCursor pFCursor = pFeatureClass.Search(pQueryFilter, false); IFeature pFeature = pFCursor.NextFeature(); //todo string str = getQueryString(); pFeature.Shape = GetMergeGeometry(str); pFeature.Store(); //pFCursor.Flush(); //删除语句 pItems.Remove(saveString); for (int i = 0; i < pItems.Count; i++) { delectSelectedCells(pItems[i]); } this.Close(); if (workspace != null) { mEngineEditor.StopEditing(true); } XtraMessageBox.Show("合并成功", "提示信息", MessageBoxButtons.OK); mAxMapControl1.Refresh(); } catch (Exception ex) { XtraMessageBox.Show(ex.Message, "合并失败", MessageBoxButtons.OK); } }
public bool RemoveFeature(IFeature feature) { return(_features.Remove(feature)); }
private void TryTrim(IPoint point) { if (this.idisplayFeedback_0 != null) { IEnvelope ienvelope_ = (this.idisplayFeedback_0 as INewEnvelopeFeedback).Stop(); this.idisplayFeedback_0 = null; this.double_1 = point.X; //this.iapplication_0.ShowCommandString("找到" + _context.FocusMap.SelectionCount.ToString() + "个对象", CommandTipsType.CTTLog); double double_ = Common.ConvertPixelsToMapUnits(_context.FocusMap as IActiveView, 6.0); System.Collections.Generic.IList <IFeature> intersectsLineFeatures = Yutai.ArcGIS.Common.Editor.Editor.GetIntersectsLineFeatures(_context.FocusMap, ienvelope_); IWorkspaceEdit workspaceEdit = null; for (int i = 0; i < intersectsLineFeatures.Count; i++) { IWorkspaceEdit workspaceEdit2 = (intersectsLineFeatures[i].Class as IDataset).Workspace as IWorkspaceEdit; if (workspaceEdit2.IsBeingEdited()) { if (workspaceEdit == null) { workspaceEdit = workspaceEdit2; workspaceEdit.StartEditOperation(); } this.method_0(ienvelope_, double_, intersectsLineFeatures[i]); } } if (workspaceEdit != null) { workspaceEdit.StopEditOperation(); _context.ActiveView.Refresh(); } } else { double double_ = Common.ConvertPixelsToMapUnits(_context.FocusMap as IActiveView, 6.0); IFeatureLayer layer; IFeature hitLineFeature = Yutai.ArcGIS.Common.Editor.Editor.GetHitLineFeature(_context.FocusMap, point, double_, out layer); if (hitLineFeature != null) { IPolyline polyline = Yutai.ArcGIS.Common.Editor.Editor.TrimPolyLine(_context.FocusMap, hitLineFeature.Shape, point, double_); if (polyline != null && !polyline.IsEmpty && (polyline as IPointCollection).PointCount > 1) { (polyline as ITopologicalOperator).Simplify(); IWorkspaceEdit workspaceEdit = (hitLineFeature.Class as IDataset).Workspace as IWorkspaceEdit; workspaceEdit.StartEditOperation(); hitLineFeature.Shape = polyline; hitLineFeature.Store(); workspaceEdit.StopEditOperation(); _context.ActiveView.Refresh(); } // this.ShowCommandLine(); } else { this.idisplayFeedback_0 = new NewEnvelopeFeedback(); this.idisplayFeedback_0.Display = (_context.FocusMap as IActiveView).ScreenDisplay; (this.idisplayFeedback_0 as INewEnvelopeFeedback).Start(point); //this.double_0 = point.X; //this.iapplication_0.ShowCommandString("指定下一个角点:", CommandTipsType.CTTCommandTip); } } }
public bool UpdateRenderedFeatureGeometry(IFeature feature, ILayer layer) { throw new NotImplementedException(); }
public static void Draw(SKCanvas canvas, IReadOnlyViewport viewport, IStyle style, IFeature feature, MultiPolygon multiPolygon, float opacity, SymbolCache?symbolCache = null) { foreach (var geometry in multiPolygon.Geometries) { var polygon = (Polygon)geometry; PolygonRenderer.Draw(canvas, viewport, style, feature, polygon, opacity, symbolCache); } }
public int IndexOf(IFeature feature) { throw new System.NotImplementedException(); }
/// <summary> /// Finds the average slope in the given polygons. /// </summary> /// <param name="ras">The dem Raster(Grid file).</param> /// <param name="zFactor">The scaler factor.</param> /// <param name="poly">The flow poly shapefile path.</param> /// <param name="output">The resulting DEM of slopes.</param> /// <param name="cancelProgressHandler">The progress handler.</param> /// <returns>True, if executed successfully.</returns> public bool Execute(IRaster ras, double zFactor, IFeatureSet poly, IFeatureSet output, ICancelProgressHandler cancelProgressHandler) { // Validates the input and output data if (ras == null || poly == null || output == null) { return(false); } output.FeatureType = poly.FeatureType; foreach (IFeature f in poly.Features) { output.Features.Add(f); } output.DataTable.Columns.Add("FID", typeof(int)); output.DataTable.Columns.Add(TextStrings.AveSlope, typeof(double)); IRaster slopeGrid = new Raster { DataType = ras.DataType, Bounds = ras.Bounds }; // FeatureSet polyShape = new FeatureSet(); int previous = 0; if (Slope(ref ras, zFactor, false, ref slopeGrid, cancelProgressHandler) == false) { return(false); } int shapeCount = output.Features.Count; int[] areaCount = new int[shapeCount]; double[] areaTotal = new double[shapeCount]; double[] areaAve = new double[shapeCount]; double dxHalf = slopeGrid.CellWidth / 2; double dyHalf = slopeGrid.CellHeight / 2; // check whether those two envelope are intersect if (ras.Extent.Intersects(output.Extent) == false) { return(false); } RcIndex start = slopeGrid.ProjToCell(output.Extent.MinX, output.Extent.MaxY); RcIndex stop = slopeGrid.ProjToCell(output.Extent.MaxX, output.Extent.MinY); int rowStart = start.Row; int colStart = start.Column; int rowStop = stop.Row; int colStop = stop.Column; for (int row = rowStart - 1; row < rowStop + 1; row++) { int current = Convert.ToInt32((row - rowStart + 1) * 100.0 / (rowStop + 1 - rowStart + 1)); // only update when increment in percentage if (current > previous + 5) { cancelProgressHandler.Progress(current, current + TextStrings.progresscompleted); previous = current; } for (int col = colStart - 1; col < colStop + 1; col++) { Coordinate cent = slopeGrid.CellToProj(row, col); double xCent = cent.X; double yCent = cent.Y; for (int shpindx = 0; shpindx < output.Features.Count; shpindx++) { IFeature tempFeat = output.Features[shpindx]; NtsPoint pt1 = new(xCent, yCent); NtsPoint pt2 = new(xCent - dxHalf, yCent - dyHalf); NtsPoint pt3 = new(xCent + dxHalf, yCent - dyHalf); NtsPoint pt4 = new(xCent + dxHalf, yCent + dyHalf); NtsPoint pt5 = new(xCent - dxHalf, yCent + dyHalf); if ((((!tempFeat.Geometry.Covers(pt1) && !tempFeat.Geometry.Covers(pt2)) && !tempFeat.Geometry.Covers(pt3)) && !tempFeat.Geometry.Covers(pt4)) && !tempFeat.Geometry.Covers(pt5)) { continue; } areaCount[shpindx]++; areaTotal[shpindx] += slopeGrid.Value[row, col] / 100; if (cancelProgressHandler.Cancel) { return(false); } } } } for (int shpindx = 0; shpindx < output.Features.Count; shpindx++) { if (areaCount[shpindx] == 0) { areaAve[shpindx] = 0; } else { areaAve[shpindx] = areaTotal[shpindx] / areaCount[shpindx]; } output.Features[shpindx].DataRow["FID"] = shpindx; output.Features[shpindx].DataRow[TextStrings.AveSlope] = areaAve[shpindx]; } poly.Close(); slopeGrid.Close(); output.SaveAs(output.Filename, true); return(true); }
public bool Contains(IFeature feature) { throw new System.NotImplementedException(); }
/// <summary> /// Trigger and receive a concrete motionPlan from startFrame to goalFrame. /// Obstacles must be added to the motionPlanner instance of the robot before. /// </summary> /// <param name="robot"></param>The robot for which a motion should be planned. /// <param name="motionPlan"></param>The preconfigured motionPlan which should be used. /// <param name="startFrame"></param>The frame where the motion should start. /// <param name="goalFrame"></param>The frame where the motion should end. /// <returns></returns> public VectorOfDoubleVector planMotion(IRobot robot, MotionPlan motionPlan, String startFrame, String goalFrame) { MotionPlanRobotDescription description = motionPlan.getMotionPlanRobotDescription(); // we need the current position of the robot to enhance the result of the inverse kinematics VectorOfDouble currentPositionJointAngles = new VectorOfDouble(robot.RobotController.Joints.Count); if (robot.RobotController.Joints.Count == 7) { currentPositionJointAngles.Add(robot.RobotController.Joints[0].Value); currentPositionJointAngles.Add(robot.RobotController.Joints[1].Value); currentPositionJointAngles.Add(robot.RobotController.Joints[6].Value); currentPositionJointAngles.Add(robot.RobotController.Joints[2].Value); currentPositionJointAngles.Add(robot.RobotController.Joints[3].Value); currentPositionJointAngles.Add(robot.RobotController.Joints[4].Value); currentPositionJointAngles.Add(robot.RobotController.Joints[5].Value); } else { currentPositionJointAngles.Add(robot.RobotController.Joints[0].Value); currentPositionJointAngles.Add(robot.RobotController.Joints[1].Value); currentPositionJointAngles.Add(robot.RobotController.Joints[2].Value); currentPositionJointAngles.Add(robot.RobotController.Joints[3].Value); currentPositionJointAngles.Add(robot.RobotController.Joints[4].Value); currentPositionJointAngles.Add(robot.RobotController.Joints[5].Value); } //TODO: Make those frames global? IFeature startNode = robot.Component.FindFeature(startFrame); if (startNode == null) { IoC.Get <IMessageService>().AppendMessage("Start Frame \"" + startFrame + "\" was not found.", MessageLevel.Error); return(null); } IFeature goalNode = robot.Component.FindFeature(goalFrame); if (goalNode == null) { IoC.Get <IMessageService>().AppendMessage("Goal Frame \"" + goalFrame + "\" was not found.", MessageLevel.Error); return(null); } Matrix startPosition = robot.Component.RootNode.GetFeatureTransformationInWorld(startNode); Matrix goalPosition = robot.Component.RootNode.GetFeatureTransformationInWorld(goalNode); Vector3 startRotation = startPosition.GetWPR(); Vector3 goalRotation = goalPosition.GetWPR(); Vector3 robotPosition = robot.Component.TransformationInWorld.GetP(); VectorOfDouble startJointAngles = currentPositionJointAngles; //IoC.Get<IMessageService>().AppendMessage("Goal Frame \"" + goalFrame + "\": [" + String.Format("{0:0.000}", (goalPosition.GetP().X / 1000)) + ", " + String.Format("{0:0.000}", (goalPosition.GetP().Y / 1000)) + ", " + String.Format("{0:0.000}", (goalPosition.GetP().Z / 1000)) + "] ["+ String.Format("{0:0.000}", goalRotation.X)+" "+ String.Format("{0:0.000}", goalRotation.Y)+" "+ String.Format("{0:0.000}", goalRotation.Z) + "]", MessageLevel.Warning); VectorOfDouble goalJointAngles = description.getIK(goalPosition.GetP().X / 1000, goalPosition.GetP().Y / 1000, goalPosition.GetP().Z / 1000, goalRotation.X, goalRotation.Y, goalRotation.Z, startJointAngles, 0.5, "Distance"); motionPlan.setStartPosition(startJointAngles); motionPlan.setGoalPosition(goalJointAngles); String startOut = "[", goalOut = "["; for (int i = 0; i < startJointAngles.Count; i++) { startOut += String.Format("{0:0.000}", startJointAngles[i]) + " "; } for (int i = 0; i < goalJointAngles.Count; i++) { goalOut += String.Format("{0:0.000}", goalJointAngles[i]) + " "; } startOut += "]"; goalOut += "]"; motionPlan.setSolveTime(10.0); motionPlan.setStateValidityCheckingResolution(0.01); //motionPlan.setReportFirstExactSolution(true); motionPlan.setPlannerByString("RRTConnect"); if (motionPlan.plan() > 0) { //IoC.Get<IMessageService>().AppendMessage("Found motion from " + startFrame + "@" + startOut + " to " + goalFrame + "@" + goalOut + ": ", MessageLevel.Warning); VectorOfDoubleVector plan = motionPlan.getLastResult(); //motionPlan.showSetupInInspector(); foreach (VectorOfDouble jointConfiguration in plan) { String motionBuf = "[", sep = ""; foreach (double jointAngle in jointConfiguration) { motionBuf += sep + String.Format("{0:0.000}", jointAngle); sep = ","; } //IoC.Get<IMessageService>().AppendMessage(motionBuf + "]", MessageLevel.Warning); } //IoC.Get<IMessageService>().AppendMessage("Found motion END", MessageLevel.Warning); return(plan); } else { //motionPlan.showSetupInInspector(); IoC.Get <IMessageService>().AppendMessage("Failed to find motion from " + startOut + " to " + goalOut + ": " + motionPlan.getLastPlanningError(), MessageLevel.Warning); } return(null); }
private void M_DotMap_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e) { if (m_AddFeaType != FeaType.None) { Coordinate coord = m_DotMap.PixelToProj(e.Location);//点击的屏幕未知转换成坐标系中的点 switch (m_AddFeaType) { case FeaType.Point: { CreatePointDlg f = UCVectorDataEditing.m_CreatePointDlg; if (f == null) { return; } var layer = f.m_PointLayer; IFeatureSet PointF = (layer as FeatureLayer).FeatureSet; GeoAPI.Geometries.IPoint pPoint = new NetTopologySuite.Geometries.Point(coord); IFeature currentFeature = PointF.AddFeature(pPoint); PointF.InitializeVertices(); m_DotMap.ResetBuffer(); } break; case FeaType.Polyline: { CreatePolylineDlg f = UCVectorDataEditing.m_CreatePolylineDlg; if (f == null) { return; } var layer = f.m_PolylineLayer; IFeatureSet LineF = (layer as FeatureLayer).FeatureSet; if (e.Button == System.Windows.Forms.MouseButtons.Left) { if (f.IsFirstPoint) { //一开始就要加入至少两个点 f.CoordList.Add(coord); f.CoordList.Add(coord); LineString line = new LineString(f.CoordList.ToArray()); IFeature lineFeature = LineF.AddFeature(line); f.IsFirstPoint = false; } else { LineF.Features.RemoveAt(LineF.Features.Count - 1); if (f.CoordList[0] == f.CoordList[1]) { f.CoordList.RemoveAt(1); } f.CoordList.Add(coord); LineString line = new LineString(f.CoordList.ToArray()); IFeature lineFeature = LineF.AddFeature(line); m_DotMap.ResetBuffer(); } } else if (e.Button == System.Windows.Forms.MouseButtons.Right) { LineF.InitializeVertices(); f.IsFirstPoint = true; f.CoordList.Clear(); m_DotMap.ResetBuffer(); } } break; case FeaType.Polygon: { CreatePolygonDlg f = UCVectorDataEditing.m_CreatePolygonDlg; if (f == null) { return; } var layer = f.m_PolygonLayer; IFeatureSet PolygonF = (layer as FeatureLayer).FeatureSet; if (e.Button == System.Windows.Forms.MouseButtons.Left) { if (f.IsFirstPoint) { for (int i = 0; i < 4; i++) { f.CoordList.Add(coord); } ILinearRing LineRing = new LinearRing(f.CoordList.ToArray()); NetTopologySuite.Geometries.Polygon pPolygon = new NetTopologySuite.Geometries.Polygon(LineRing); IFeature polygonFeature = PolygonF.AddFeature(pPolygon); f.IsFirstPoint = false; } else { PolygonF.Features.RemoveAt(PolygonF.Features.Count - 1); if (f.CoordList[0] == f.CoordList[1]) { f.CoordList.RemoveAt(1); } //组成面的点必须形成一个闭环 因此要先把最新加入的点去掉,加入绘制点之后再加入第一个点 f.CoordList.RemoveAt(f.CoordList.Count - 1); f.CoordList.Add(coord); f.CoordList.Add(f.CoordList[0]); ILinearRing LineRing = new LinearRing(f.CoordList.ToArray()); NetTopologySuite.Geometries.Polygon pPolygon = new NetTopologySuite.Geometries.Polygon(LineRing); IFeature lineFeature = PolygonF.AddFeature(pPolygon); m_DotMap.ResetBuffer(); } } else if (e.Button == System.Windows.Forms.MouseButtons.Right) { PolygonF.InitializeVertices(); f.IsFirstPoint = true; f.CoordList.Clear(); m_DotMap.ResetBuffer(); } } break; } } }
public IFeature FindNearestFeature(ICoordinate worldPos, float limit, out ILayer outLayer, Func <ILayer, bool> condition) { IFeature nearestFeature = null; outLayer = null; // Since we are only interested in one geometry object start with the topmost trackersLayer and stop // searching the lower layers when an object is found. foreach (ILayer mapLayer in Map.GetAllVisibleLayers(true).OrderBy(l => l.RenderOrder)) { if (mapLayer is DiscreteGridPointCoverageLayer) { try { var curvilinearGridLayer = (DiscreteGridPointCoverageLayer)mapLayer; var coverage = (IDiscreteGridPointCoverage)curvilinearGridLayer.Coverage; var nearestFeatures = coverage.GetFeatures(worldPos.X, worldPos.Y, limit); if (nearestFeatures != null) { if (!curvilinearGridLayer.ShowFaces) { nearestFeatures = nearestFeatures.Where(f => !(f is IGridFace)); } if (!curvilinearGridLayer.ShowVertices) { nearestFeatures = nearestFeatures.Where(f => !(f is IGridVertex)); } } nearestFeature = nearestFeatures.FirstOrDefault(); outLayer = curvilinearGridLayer; } catch (Exception) { // GetCoordinateAtPosition will throw exception if x, y is not within the coverage } } if (mapLayer is VectorLayer) { var vectorLayer = mapLayer as VectorLayer; IEnvelope envelope; float localLimit = limit; if ((!vectorLayer.IsSelectable) || ((null != condition) && (!condition(vectorLayer)))) { continue; } // Adjust the marge limit for Layers with a symbol style and if the size of the symbol exceeds // the minimum limit. Ignore layers with custom renderers if ((vectorLayer.Style.Symbol != null) && (0 == vectorLayer.CustomRenderers.Count)) { ICoordinate size = MapHelper.ImageToWorld(MapControl.Map, vectorLayer.Style.Symbol.Width, vectorLayer.Style.Symbol.Height); if ((size.X > localLimit) || (size.Y > localLimit)) { envelope = MapHelper.GetEnvelope(worldPos, size.X, size.Y); localLimit = (float)Math.Max(envelope.Width, envelope.Height); } else { envelope = GetEnvelope(worldPos, localLimit); } } else { envelope = GetEnvelope(worldPos, localLimit); } if (vectorLayer.DataSource != null) { // Get features in the envelope var objectsAt = vectorLayer.GetFeatures(envelope).ToList(); // Mousedown at new position if (null != objectsAt) { IFeature feature = null; if (objectsAt.Count == 1) { feature = objectsAt.First(); } else if (objectsAt.Count > 1) { double localDistance; feature = FindNearestFeature(vectorLayer, objectsAt.Distinct(), worldPos, localLimit, out localDistance); } if (null != feature) { nearestFeature = feature; outLayer = vectorLayer; break; } } } } else if (mapLayer is IRegularGridCoverageLayer) { try { IRegularGridCoverageLayer regularGridCoverageLayer = (IRegularGridCoverageLayer)mapLayer; IRegularGridCoverage regularGridCoverage = (IRegularGridCoverage)regularGridCoverageLayer.Coverage; nearestFeature = regularGridCoverage.GetRegularGridCoverageCellAtPosition(worldPos.X, worldPos.Y); outLayer = regularGridCoverageLayer; } catch (Exception) { // GetCoordinateAtPosition will throw exception if x, y is not within the coverage } } } return(nearestFeature); }
/// <summary> /// 配置指定要素的字段 /// </summary> /// <param name="AnnotationFeatureClass"></param> /// <param name="AnnotationFeatureCursor"></param> /// <param name="AnnotationFeature"></param> public void ConfigFields(IFeatureClass AnnotationFeatureClass, IFeatureCursor AnnotationFeatureCursor, IFeature AnnotationFeature) { IWorkspace WorkSpace = ((IDataset)AnnotationFeatureClass).Workspace; IWorkspaceEdit edit = WorkSpace as IWorkspaceEdit; bool startEdit = edit.IsBeingEdited(); if (!startEdit) { edit.StartEditing(false); } edit.StartEditOperation(); try { int index = AnnotationFeature.Fields.FindField("Status"); AnnotationFeature.set_Value(index, esriAnnotationStatus.esriAnnoStatusPlaced); index = AnnotationFeature.Fields.FindField("Angle"); AnnotationFeature.set_Value(index, 90); index = AnnotationFeature.Fields.FindField("FontName"); AnnotationFeature.set_Value(index, "华文彩云"); }//先找到字段的索引值,再set_Value catch { } AnnotationFeature.Store(); System.Runtime.InteropServices.Marshal.ReleaseComObject(AnnotationFeature); AnnotationFeatureCursor.Flush(); System.Runtime.InteropServices.Marshal.ReleaseComObject(AnnotationFeatureCursor); edit.StopEditOperation(); startEdit = edit.IsBeingEdited(); if (startEdit) { edit.StopEditing(true); } }
public FeatureSet getRoseFeatureSet(double x1, double y1, DataTable solarTab, Int16 noonHour, double RoseScale) { // RoseShp = Nothing Feature f = new Feature(); FeatureSet fs = new FeatureSet(f.FeatureType); //--------------------------------------------------------- fs.DataTable.Columns.Add(new DataColumn("Azimuth", typeof(string))); fs.DataTable.Columns.Add(new DataColumn("Ele_Angle", typeof(string))); fs.DataTable.Columns.Add(new DataColumn("Magnitude", typeof(Int16))); fs.DataTable.Columns.Add(new DataColumn("Angle", typeof(double))); //--------------------------------------------------------- double dOut = 0; //out double dIn = 100; //In int iDirection = 0; // Todo: Dim SumHr As Integer = grdWaveH.Item(9, 17).Value int i = 0; int roseTyp = 1; string AzName = ""; int SumHr = noonHour; // foreach (DataRow row in solarTab.Rows) { double iniP = dIn; int j = 0; foreach (DataColumn column in solarTab.Columns) { if (j == 0) { AzName = row[column].ToString(); iDirection = AZNameID(AzName); } else { if (AzName.ToUpper() != "Sum".ToUpper()) { // % of solar Magnitude Int16 Magnitude = Convert.ToInt16(row[column]);// / (double)SumHr * 100; if (Magnitude > 0 & j <= 8) { double _Magnitude = (double)Magnitude / (double)SumHr * 100; if (roseTyp == 0) { Polygon poly = plotRose(x1, y1, iDirection, iniP, _Magnitude, AzName, getStrMagnitude(j), RoseScale); iniP += _Magnitude; IFeature ifea = fs.AddFeature(poly); //------------------------------------------------------ ifea.DataRow.BeginEdit(); ifea.DataRow["Azimuth"] = AzName; ifea.DataRow["Ele_Angle"] = getStrMagnitude(j); ifea.DataRow["Magnitude"] = Magnitude; ifea.DataRow["Angle"] = AzName2RCPAng(AzName); // ifea.DataRow.EndEdit(); //------------------------------------------------------ } if (roseTyp == 1) { double r1 = dIn + (20 + 0) * (j) * RoseScale; double r2 = dIn + (20 + 0) * (j + 1) * RoseScale; Polygon poly = plotRose(x1, y1, iDirection, r1, r2, RoseScale); IFeature ifea = fs.AddFeature(poly); //------------------------------------------------------ ifea.DataRow.BeginEdit(); ifea.DataRow["Azimuth"] = AzName; ifea.DataRow["Ele_Angle"] = getStrMagnitude(j); ifea.DataRow["Magnitude"] = Magnitude; ifea.DataRow["Angle"] = AzName2RCPAng(AzName); // ifea.DataRow.EndEdit(); //------------------------------------------------------ } } } } //Console.WriteLine(row[column]); //if(iniP > dOut){ dOut = iniP;} j++; } i++; } return(fs); }
protected override void OnClick() { IEnumLayer EnumLayer = ArcMap.Document.FocusMap.get_Layers(null, false); ILayer pLayer = EnumLayer.Next(); ProgressForm progressForm = new ProgressForm(); progressForm.Show(); while (null != pLayer) { //string b = pLayer.Name.Substring(pLayer.Name.LastIndexOf('_') + 1); if ("Point" == pLayer.Name.Substring(pLayer.Name.LastIndexOf('_') + 1) || "Line" == pLayer.Name.Substring(pLayer.Name.LastIndexOf('_') + 1) || "Polygon" == pLayer.Name.Substring(pLayer.Name.LastIndexOf('_') + 1) ) { break; } pLayer = EnumLayer.Next(); }//加入的图层中至少有点线面中的一个,点线面图层中有DWG字段,表明了shp的来源 progressForm.AddProgress(10); IFeatureLayer pFeatureLayer = pLayer as IFeatureLayer; IFeature pfeature = pFeatureLayer.Search(null, false).NextFeature(); IDataLayer DataLayer = pLayer as IDataLayer; IDatasetName tem_DatasetName = DataLayer.DataSourceName as IDatasetName; string PathName = tem_DatasetName.WorkspaceName.PathName; string DatasetName = pfeature.get_Value(pfeature.Fields.FindField("DWG")) as string;//获取生成shp的DWG文件名称 string MDB_FullName = PathName; //*******************************************开 始 拓 扑 检 查***************************************************** IWorkspaceFactory iwsf = new AccessWorkspaceFactoryClass(); IFeatureWorkspace ifws = (IFeatureWorkspace)iwsf.OpenFromFile(MDB_FullName, 0); IFeatureDataset topocheckDataset = ifws.OpenFeatureDataset(DatasetName); IFeatureClassContainer MyFeatureClassContainer = topocheckDataset as IFeatureClassContainer; #if true TopologyChecker topocheck = new TopologyChecker(topocheckDataset); topocheck.PUB_TopoBuild(DatasetName + "_TopoCheck");//创建拓扑层 progressForm.AddProgress(20); List <IFeatureClass> allFeatureClass_tem = topocheck.PUB_GetAllFeatureClass(); //List<IFeatureClass> TopoClass; List <IFeatureClass> allFeatureClass = new List <IFeatureClass>(); IFeatureClass topocheckFeatureClass_Point = null; IFeatureClass topocheckFeatureClass_Line = null; IFeatureClass topocheckFeatureClass_Polygon = null; foreach (IFeatureClass tem in allFeatureClass_tem) { switch (tem.AliasName.Substring(tem.AliasName.LastIndexOf('_') + 1)) { case "Point": allFeatureClass.Add(tem); topocheckFeatureClass_Point = tem; break; case "Line": allFeatureClass.Add(tem); topocheckFeatureClass_Line = tem; break; case "Polygon": allFeatureClass.Add(tem); topocheckFeatureClass_Polygon = tem; break; default: break; } }//只对点线面图层进行拓扑检查 topocheck.PUB_AddFeatureClass(allFeatureClass); progressForm.AddProgress(10); List <string> ErrorInfo = null; topocheck.PUB_AddRuleToTopology(TopologyChecker.TopoErroType.线要素不能自相交, topocheckFeatureClass_Line, out ErrorInfo); progressForm.AddProgress(10); topocheck.PUB_AddRuleToTopology(TopologyChecker.TopoErroType.线要素之间不能相交, topocheckFeatureClass_Line, out ErrorInfo); progressForm.AddProgress(10); topocheck.PUB_AddRuleToTopology(TopologyChecker.TopoErroType.点要素之间不相交, topocheckFeatureClass_Point, out ErrorInfo); progressForm.AddProgress(10); topocheck.PUB_AddRuleToTopology(TopologyChecker.TopoErroType.面要素间无重叠, topocheckFeatureClass_Polygon, out ErrorInfo); progressForm.AddProgress(10); System.IO.File.WriteAllLines(MDB_FullName.Substring(0, MDB_FullName.LastIndexOf('\\')) + "\\拓扑错误报告.txt", ErrorInfo.ToArray()); //生成检查报告 progressForm.AddProgress(10); //----------------------------------------------打 开 错 误 报 告 器------------------------------------------------------ EnumLayer = ArcMap.Document.FocusMap.get_Layers(null, false); ArcMap.Document.FocusMap.ClearLayers(); ArcMap.Document.FocusMap.AddLayers(EnumLayer, true); pLayer = EnumLayer.Next(); while (null != pLayer) { if ((DatasetName + "_Polygon") == pLayer.Name) { pLayer = EnumLayer.Next(); continue; } DirectRender(pLayer); pLayer = EnumLayer.Next(); } ESRI.ArcGIS.Framework.ICommandBars CommandBars = ArcMap.Application.Document.CommandBars; UID uid = new UIDClass(); uid.Value = "esriEditor.StartEditingCommand"; //bool isEditable = true; try { ESRI.ArcGIS.Framework.ICommandItem CommandItem = CommandBars.Find(uid, false, false); if (CommandItem != null) { CommandItem.Execute(); } uid.Value = "esriEditorExt.ErrorWindowCommand"; CommandItem = CommandBars.Find(uid, false, false); if (CommandItem != null) { CommandItem.Execute(); } } catch { //isEditable = false;//如果初次打开出现不可编辑的错误,下面将尝试重新添加图层并打开错误编辑器 } /* * if (!isEditable) * { * try * { * ESRI.ArcGIS.Framework.ICommandItem CommandItem = CommandBars.Find(uid, false, false); * if (CommandItem != null) * { * CommandItem.Execute(); * } * * uid.Value = "esriEditorExt.ErrorWindowCommand"; * CommandItem = CommandBars.Find(uid, false, false); * if (CommandItem != null) * { * CommandItem.Execute(); * } * * }catch{} * * * }*/ //------------------------------------------完成打开错误报告器--------------------------------------------- progressForm.Close(); #endif }
public void Add(IFeature feature) { _features.Add(feature); }
public static void Draw(SKCanvas canvas, IReadOnlyViewport viewport, IStyle style, IFeature feature, float opacity, IDictionary <object, BitmapInfo> tileCache, long currentIteration) { try { var raster = (IRaster)feature.Geometry; BitmapInfo bitmapInfo; if (!tileCache.Keys.Contains(raster)) { bitmapInfo = BitmapHelper.LoadBitmap(raster.Data); tileCache[raster] = bitmapInfo; } else { bitmapInfo = tileCache[raster]; } bitmapInfo.IterationUsed = currentIteration; tileCache[raster] = bitmapInfo; var boundingBox = feature.Geometry.BoundingBox; if (viewport.IsRotated) { var priorMatrix = canvas.TotalMatrix; var matrix = CreateRotationMatrix(viewport, boundingBox, priorMatrix); canvas.SetMatrix(matrix); var destination = new BoundingBox(0.0, 0.0, boundingBox.Width, boundingBox.Height); BitmapHelper.RenderRaster(canvas, bitmapInfo.Bitmap, destination.ToSkia(), opacity); canvas.SetMatrix(priorMatrix); } else { var destination = WorldToScreen(viewport, feature.Geometry.BoundingBox); BitmapHelper.RenderRaster(canvas, bitmapInfo.Bitmap, RoundToPixel(destination).ToSkia(), opacity); } } catch (Exception ex) { Logger.Log(LogLevel.Error, ex.Message, ex); } }
private void OnSketchFinished() { ConfigUtil.type = "gas"; IFeature pFeat = null; ISegmentCollection pSegColl = null; IEnumSegment pESeg = null; ISegment testSegment = null; ISegmentCollection segColTest = null; object Missing = null; try { // Send a shift-tab to hide the construction toolbar try { m_editor.StartOperation(); } catch { m_editor.AbortOperation(); m_editor.StartOperation(); } bool twoPoint = false; (ArcMap.Application.Document as IMxDocument).FocusMap.ClearSelection(); List <IFeature> pLstFeat = null; if (Control.ModifierKeys == Keys.Control) { twoPoint = CreateLineWithEndPoints.CreatePoints(ArcMap.Application, ConfigUtil.GetLinePointAtEndsConfig(), m_edSketch.Geometry as IPolyline, (IFeatureLayer)m_editor.CurrentTemplate.Layer, false, out pLstFeat); } else { twoPoint = CreateLineWithEndPoints.CreatePoints(ArcMap.Application, ConfigUtil.GetLinePointAtEndsConfig(), m_edSketch.Geometry as IPolyline, (IFeatureLayer)m_editor.CurrentTemplate.Layer, true, out pLstFeat); } if (twoPoint) { pSegColl = (ISegmentCollection)m_edSketch.Geometry; pESeg = pSegColl.EnumSegments; pESeg.Reset(); int partIndex = 0; int segmentIndex = 0; pESeg.Next(out testSegment, ref partIndex, ref segmentIndex); while (testSegment != null) { segColTest = new PolylineClass(); Missing = Type.Missing; segColTest.AddSegment(testSegment, ref Missing, ref Missing); pFeat = Globals.CreateFeature(segColTest as IGeometry, m_editor.CurrentTemplate, m_editor, ArcMap.Application, false, false, true); pFeat.Store(); pESeg.Next(out testSegment, ref partIndex, ref segmentIndex); } } else { pFeat = Globals.CreateFeature(m_edSketch.Geometry, m_editor.CurrentTemplate, m_editor, ArcMap.Application, false, false, true); pFeat.Store(); } foreach (IFeature pFt in pLstFeat) { pFt.Store(); } pLstFeat = null; m_editor.StopOperation("Create line with points"); } catch { } finally { pFeat = null; pSegColl = null; pESeg = null; testSegment = null; segColTest = null; Missing = null; } }
private void OnSketchFinished() { ConfigUtil.type = "gas"; //m_editor.UndoOperation(); IFeature pFeat = null; IEnvelope pEnv = null; try { m_editor.StartOperation(); Globals.ClearSelected(ArcMap.Application, false, new List <esriGeometryType>() { esriGeometryType.esriGeometryPoint }); pFeat = Globals.CreateFeature(m_edSketch.Geometry, m_editor.CurrentTemplate, m_editor, ArcMap.Application, false, false, true); //CreatePoint(m_edSketch.Geometry as IPoint, m_editor.CurrentTemplate); if (pFeat == null) { return; } // addLat.AddLateralAtPoint(m_edSketch.Geometry as IPoint, m_editor.CurrentTemplate.Layer.Name); //((IFeatureSelection)m_editor.CurrentTemplate.Layer).Clear(); m_editor.Map.SelectFeature(m_editor.CurrentTemplate.Layer as IFeatureLayer, pFeat); List <MergeSplitGeoNetFeatures> m_Config = null; m_Config = ConfigUtil.GetMergeSplitConfig(); string resetFlow = AddLateralsFromPoint.AddLateralsFromMainPoint(ArcMap.Application, ConfigUtil.GetAddLateralsFromMainConfig(), pFeat, false, true, false, m_Config[0]); // m_editor.Map.SelectFeature(m_editor.CurrentTemplate.Layer as IFeatureLayer, pFeat); m_editor.Display.Invalidate((ArcMap.Document as IMxDocument).ActiveView.Extent, true, (short)esriScreenCache.esriAllScreenCaches); pFeat.Store(); (ArcMap.Document as IMxDocument).ActiveView.PartialRefresh(esriViewDrawPhase.esriViewAll, null, (ArcMap.Document as IMxDocument).ActiveView.Extent.Envelope); if (resetFlow.ToUpper() == "DIGITIZED") { Globals.GetCommand("A4GasUtilities_EstablishFlowDigitized", ArcMap.Application).Execute(); } else if (resetFlow.ToUpper() == "ROLE") { Globals.GetCommand("A4GasUtilities_EstablishFlowAncillary", ArcMap.Application).Execute(); } else if (resetFlow.ToUpper() == "Ancillary".ToUpper()) { Globals.GetCommand("A4GasUtilities_EstablishFlowAncillary", ArcMap.Application).Execute(); } else { } m_editor.StopOperation("Create asset and lateral"); } catch (Exception ex) { MessageBox.Show("Error in the Add Lateral Tools: " + ex.ToString()); m_editor.AbortOperation(); } finally { pFeat = null; pEnv = null; } }