internal override void OnNewMapPointEvent(object obj) { base.OnNewMapPointEvent(obj); if (!IsActiveTab) { return; } var point = obj as MapPoint; if (point == null || !IsValidPoint(point)) { return; } if (ToolMode == MapPointToolMode.Target) { //TODO square symbol, add symbol to parameter list, etc AddGraphicToMap(point, ColorFactory.Red, true, 5.0); var addInPoint = new AddInPoint() { Point = point }; Application.Current.Dispatcher.Invoke(() => { TargetAddInPoints.Insert(0, addInPoint); }); } }
/// <summary> /// Method override to handle new map points /// Here we must take of targets in addition to observers /// </summary> /// <param name="obj">MapPoint</param> internal override async void OnNewMapPointEvent(object obj) { base.OnNewMapPointEvent(obj); if (!IsActiveTab) { return; } var point = obj as MapPoint; if (point == null || !(await IsValidPoint(point))) { return; } if (ToolMode == MapPointToolMode.Target) { var guid = await AddGraphicToMap(point, ColorFactory.Instance.RedRGB, true, 5.0, markerStyle : SimpleMarkerStyle.Square, tag : "target"); var addInPoint = new AddInPoint() { Point = point, GUID = guid }; Application.Current.Dispatcher.Invoke(() => { TargetAddInPoints.Insert(0, addInPoint); }); } }
/// <summary> /// Override this event to collect observer points based on tool mode /// </summary> /// <param name="obj">MapPointToolMode</param> internal override void OnNewMapPointEvent(object obj) { if (!IsActiveTab) { return; } var point = obj as IPoint; if (point == null || !IsValidPoint(point, true)) { return; } // ok, we have a point if (ToolMode == MapPointToolMode.Observer) { // in tool mode "Observer" we add observer points // otherwise ignore var color = new RgbColorClass() { Blue = 255 } as IColor; var guid = AddGraphicToMap(point, color, true); var addInPoint = new AddInPoint() { Point = point, GUID = guid }; ObserverAddInPoints.Insert(0, addInPoint); } }
public override async void OnMapPointSelection(object obj) { var mp = obj as MapPoint; var dblSrchDis = MapView.Active.Extent.Width / 200; var poly = GeometryEngine.Instance.Buffer(mp, dblSrchDis); AddInPoint closestPoint = null; Double distance = 0; foreach (var item in ProCollectTabViewModel.CoordinateAddInPoints) { if (item.Point.SpatialReference != MapView.Active.Map.SpatialReference) { item.Point = GeometryEngine.Instance.Project(item.Point, MapView.Active.Map.SpatialReference) as MapPoint; } var isWithinExtent = await IsPointWithinExtent(item.Point, poly.Extent); if (isWithinExtent) { double resultDistance = GeometryEngine.Instance.Distance(item.Point, mp); distance = (distance < resultDistance && distance > 0) ? distance : resultDistance; if (resultDistance == distance) { closestPoint = item; distance = resultDistance; } } } if (closestPoint != null) { closestPoint.IsSelected = true; ListBoxSelectedItem = closestPoint; } RaisePropertyChanged(() => ListBoxSelectedItem); }
/// <summary> /// Override this event to collect observer points based on tool mode /// </summary> /// <param name="obj">MapPointToolMode</param> internal override async void OnNewMapPointEvent(object obj) { if (!IsActiveTab) { return; } var point = obj as MapPoint; if (point == null || !(await IsValidPoint(point, true))) { return; } // ok, we have a point if (ToolMode == MapPointToolMode.Observer) { // in tool mode "Observer" we add observer points // otherwise ignore var guid = await AddGraphicToMap(point, ColorFactory.Blue, true, 5.0); var addInPoint = new AddInPoint() { Point = point, GUID = guid }; Application.Current.Dispatcher.Invoke(() => { ObserverAddInPoints.Insert(0, addInPoint); }); } }
internal override void OnNewMapPointEvent(object obj) { base.OnNewMapPointEvent(obj); if (!IsActiveTab) { return; } var point = obj as IPoint; if (point == null || !IsValidPoint(point)) { return; } if (ToolMode == MapPointToolMode.Target) { var color = new RgbColorClass() { Red = 255 } as IColor; var guid = AddGraphicToMap(point, color, true, esriSimpleMarkerStyle.esriSMSSquare); var addInPoint = new AddInPoint() { Point = point, GUID = guid }; TargetAddInPoints.Insert(0, addInPoint); } }
private async void AddCollectionPoint(MapPoint point) { var guid = await AddGraphicToMap(point, ColorFactory.RedRGB, true, 7); var addInPoint = new AddInPoint() { Point = point, GUID = guid }; CoordinateAddInPoints.Add(addInPoint); }
private async void AddCollectionPoint(MapPoint point, Dictionary <string, Tuple <object, bool> > fieldsDictionary = null) { var guid = await AddGraphicToMap(point, ColorFactory.Instance.RedRGB, true, 7); var addInPoint = new AddInPoint() { Point = point, GUID = guid, FieldsDictionary = fieldsDictionary }; //Add point to the top of the list CoordinateAddInPoints.Add(addInPoint); }
private async void AddCollectionPoint(MapPoint point) { var guid = await AddGraphicToMap(point, ColorFactory.Instance.RedRGB, true, 7); var addInPoint = new AddInPoint() { Point = point, GUID = guid }; //Add point to the top of the list CoordinateAddInPoints.Insert(0, addInPoint); }
internal async void ReadPointFromLayer(Envelope surfaceEnvelope, ObservableCollection <AddInPointObject> inExtentPoints, ObservableCollection <AddInPointObject> outOfExtentPoints, string selectedLayerName, List <long> selectedFeaturesCollections, string tag = "") { if (selectedLayerName != EnterManullyOption && !string.IsNullOrWhiteSpace(selectedLayerName)) { var layer = MapView.Active.Map.GetLayersAsFlattenedList().OfType <FeatureLayer>() .Where(lyr => lyr.Name == selectedLayerName && lyr.ShapeType == esriGeometryType.esriGeometryPoint).FirstOrDefault(); var cursor = layer.GetFeatureClass().Search(); while (cursor.MoveNext()) { var point = (MapPoint)cursor.Current["Shape"]; var addInPoint = new AddInPoint { Point = point, GUID = Guid.NewGuid().ToString() }; var objectId = -1; var FID = -1; try { objectId = Convert.ToInt32(cursor.Current["ObjectId"]); } catch (Exception) { } try { FID = Convert.ToInt32(cursor.Current["FID"]); } catch (Exception) { } var ID = objectId != -1 ? objectId : FID; var isWithinEntent = await IsPointWithinExtent(point, surfaceEnvelope); if (selectedFeaturesCollections == null || !selectedFeaturesCollections.Any() || (selectedFeaturesCollections.Any() && selectedFeaturesCollections.Where(x => Convert.ToInt32(x) == ID).Any())) { if (isWithinEntent) { inExtentPoints.Add(new AddInPointObject() { ID = ID, AddInPoint = addInPoint }); } else { outOfExtentPoints.Add(new AddInPointObject() { ID = ID, AddInPoint = addInPoint }); } } } } }
public void ProCreateAddInPointTest() { MapPoint point = MapPointBuilder.CreateMapPoint(1300757, 554219); Assert.IsNotNull(point); AddInPoint addinPoint = new AddInPoint(); addinPoint.Point = point; string output = addinPoint.Text; Assert.IsFalse(output.Equals("NA")); }
internal override void OnNewMapPointEvent(object obj) { base.OnNewMapPointEvent(obj); if (!IsActiveTab) { return; } var point = obj as IPoint; if (point != null && ToolMode == MapPointToolMode.Target) { if (IsMapClick) { if (!(IsValidPoint(point, true))) { IsMapClick = false; return; } } var color = new RgbColorClass() { Red = 255 } as IColor; var guid = AddGraphicToMap(point, color, true, esriSimpleMarkerStyle.esriSMSSquare); var addInPoint = new AddInPoint() { Point = point, GUID = guid }; bool isValid = IsValidPoint(point, false); if (!isValid) { TargetOutExtentPoints.Insert(0, addInPoint); } else { TargetInExtentPoints.Insert(0, addInPoint); } TargetAddInPoints.Insert(0, addInPoint); IsMapClick = false; } ValidateLLOS_LayerSelection(); }
private async void AddCollectionPoint(MapPoint point) { if (point != null) { var guid = await AddGraphicToMap(point, ColorFactory.Instance.RedRGB, true, 7); var addInPoint = new AddInPoint() { Point = point, GUID = guid }; //Add point to the top of the list (using main thread) ArcGIS.Desktop.Framework.FrameworkApplication.Current.Dispatcher.Invoke(() => ProCollectTabViewModel.CoordinateAddInPoints.Add(addInPoint)); } }
private void AddCollectionPoint(IPoint point) { var color = new RgbColorClass() { Red = 255 } as IColor; var guid = ArcMapHelpers.AddGraphicToMap(point, color, true, esriSimpleMarkerStyle.esriSMSCircle, 7); var addInPoint = new AddInPoint() { Point = point, GUID = guid }; CoordinateAddInPoints.Add(addInPoint); GraphicsList.Add(new AMGraphic(guid, point, true)); }
/// <summary> /// Override this event to collect observer points based on tool mode /// </summary> /// <param name="obj">MapPointToolMode</param> internal override async void OnNewMapPointEvent(object obj) { if (!IsActiveTab) { return; } var point = obj as MapPoint; // ok, we have a point if (point != null && ToolMode == MapPointToolMode.Observer) { if (IsMapClick) { if (!(await IsValidPoint(point, true))) { IsMapClick = false; return; } } // in tool mode "Observer" we add observer points // otherwise ignore var guid = await AddGraphicToMap(point, ColorFactory.Instance.BlueRGB, true, 5.0); var addInPoint = new AddInPoint() { Point = point, GUID = guid }; bool isValid = await IsValidPoint(point, false); Application.Current.Dispatcher.Invoke(() => { if (!isValid) { ObserverOutExtentPoints.Insert(0, addInPoint); } else { ObserverInExtentPoints.Insert(0, addInPoint); } ObserverAddInPoints.Insert(0, addInPoint); }); IsMapClick = false; } }
public override void OnMapPointSelection(object obj) { var mapPoint = obj as IPoint; double dblSrchDis = 0; AddInPoint closestPoint = null; Double distance = 0; var mxdoc = ArcMap.Application.Document as IMxDocument; var av = mxdoc.FocusMap as IActiveView; var m_graphicsCont = (IGraphicsContainer)av; dblSrchDis = av.Extent.Width / 200; mapPoint.Project(ArcMap.Document.FocusMap.SpatialReference); ITopologicalOperator topoOp = (ITopologicalOperator)mapPoint; IGeometry p2Bufferd = topoOp.Buffer(dblSrchDis); if (p2Bufferd == null) { return; } foreach (var item in CollectTabViewModel.CoordinateAddInPoints) { if (item.Point.SpatialReference != ArcMap.Document.FocusMap.SpatialReference) { item.Point.Project(ArcMap.Document.FocusMap.SpatialReference); } IRelationalOperator rel1 = (IRelationalOperator)item.Point; if (rel1.Within(p2Bufferd)) { var resultDistance = ((IProximityOperator)mapPoint).ReturnDistance((IGeometry)item.Point); distance = (distance < resultDistance && distance > 0) ? distance : resultDistance; if (resultDistance == distance) { closestPoint = item; distance = resultDistance; } } } if (closestPoint != null) { closestPoint.IsSelected = true; ListBoxSelectedItem = closestPoint; } RaisePropertyChanged(() => ListBoxSelectedItem); }
/// <summary> /// Method override to handle new map points /// Here we must take of targets in addition to observers /// </summary> /// <param name="obj">MapPoint</param> internal override async void OnNewMapPointEvent(object obj) { base.OnNewMapPointEvent(obj); if (!IsActiveTab) { return; } var point = obj as MapPoint; if (point != null && ToolMode == MapPointToolMode.Target) { if (IsMapClick) { if (!(await IsValidPoint(point, true))) { IsMapClick = false; return; } } var guid = await AddGraphicToMap(point, ColorFactory.Instance.RedRGB, true, 5.0, markerStyle : SimpleMarkerStyle.Square, tag : "target"); var addInPoint = new AddInPoint() { Point = point, GUID = guid }; bool isValid = await IsValidPoint(point, false); Application.Current.Dispatcher.Invoke(() => { if (!isValid) { TargetOutExtentPoints.Insert(0, addInPoint); } else { TargetInExtentPoints.Insert(0, addInPoint); } TargetAddInPoints.Insert(0, addInPoint); }); IsMapClick = false; } ValidateLLOS_LayerSelection(); }
/// <summary> /// Override this event to collect observer points based on tool mode /// </summary> /// <param name="obj">MapPointToolMode</param> internal override void OnNewMapPointEvent(object obj) { if (!IsActiveTab) { return; } var point = obj as IPoint; // ok, we have a point if (ToolMode == MapPointToolMode.Observer) { if (IsMapClick) { if (!(IsValidPoint(point, true))) { IsMapClick = false; return; } } // in tool mode "Observer" we add observer points // otherwise ignore var color = new RgbColorClass() { Blue = 255 } as IColor; var guid = AddGraphicToMap(point, color, true); var addInPoint = new AddInPoint() { Point = point, GUID = guid }; bool isValid = IsValidPoint(point, false); if (!isValid) { ObserverOutExtentPoints.Insert(0, addInPoint); } else { ObserverInExtentPoints.Insert(0, addInPoint); } ObserverAddInPoints.Insert(0, addInPoint); IsMapClick = false; } }
private void AddCollectionPoint(IPoint point, Dictionary <string, Tuple <object, bool> > fieldsDictionary = null) { if (point != null && !point.IsEmpty) { var color = (IColor) new RgbColorClass() { Red = 255 }; var guid = ArcMapHelpers.AddGraphicToMap(point, color, true, esriSimpleMarkerStyle.esriSMSCircle, ArcMapHelpers.DefaultMarkerSize); var addInPoint = new AddInPoint() { Point = point, GUID = guid, FieldsDictionary = fieldsDictionary }; //Add point to the top of the list CoordinateAddInPoints.Add(addInPoint); GraphicsList.Add(new AMGraphic(guid, point, true, fieldsDictionary)); } }
private void ShowPopUp(AddInPoint addinPoint) { var dictionary = addinPoint.FieldsDictionary; FieldsCollection = new ObservableCollection <FieldsCollection>(); if (dictionary != null) { var valOutput = dictionary.Where(x => x.Key == PointFieldName).Select(x => x.Value.Item1).FirstOrDefault(); IPointToStringConverter pointConverter = new IPointToStringConverter(); ViewDetailsTitle = pointConverter.Convert(valOutput, typeof(string), null, null) as string; foreach (var item in dictionary) { if (item.Value.Item2) { FieldsCollection.Add(new FieldsCollection() { FieldName = item.Key, FieldValue = Convert.ToString(item.Value.Item1) }); } } } else { ViewDetailsTitle = addinPoint.Text; } IsWarningVisible = FieldsCollection.Any() ? Visibility.Collapsed : Visibility.Visible; if (!IsDialogViewOpen) { IsDialogViewOpen = true; PageNumber = 1; DialogView = new AdditionalFieldsView(); DialogView.DataContext = this; DialogView.Closed += diagView_Closed; DialogView.Show(); } else { DialogView.DataContext = this; RaisePropertyChanged(() => FieldsCollection); RaisePropertyChanged(() => ViewDetailsTitle); } }
private void AddCollectionPoint(IPoint point) { if (point != null && !point.IsEmpty) { var color = new RgbColorClass() { Red = 255 } as IColor; var guid = ArcMapHelpers.AddGraphicToMap(point, color, true, esriSimpleMarkerStyle.esriSMSCircle, ArcMapHelpers.DefaultMarkerSize); var addInPoint = new AddInPoint() { Point = point, GUID = guid }; //Add point to the top of the list CollectTabViewModel.CoordinateAddInPoints.Add(addInPoint); CollectTabViewModel.GraphicsList.Add(new AMGraphic(guid, point, true)); } }
private void AddCollectionPoint(IPoint point) { if (!point.IsEmpty && point != null) { var color = new RgbColorClass() { Red = 255 } as IColor; var guid = ArcMapHelpers.AddGraphicToMap(point, color, true, esriSimpleMarkerStyle.esriSMSCircle, 7); var addInPoint = new AddInPoint() { Point = point, GUID = guid }; //Add point to the top of the list CoordinateAddInPoints.Insert(0, addInPoint); GraphicsList.Add(new AMGraphic(guid, point, true)); } }
/// <summary> /// Override this event to collect observer points based on tool mode /// </summary> /// <param name="obj">MapPointToolMode</param> internal override async void OnNewMapPointEvent(object obj) { if (!IsActiveTab) { return; } //if (string.IsNullOrEmpty(SelectedSurfaceName)) //{ // MessageBox.Show(VisibilityLibrary.Properties.Resources.MsgSurfaceLayerNotFound, // VisibilityLibrary.Properties.Resources.CaptionError, MessageBoxButton.OK); // return; //} //IsElevationSurfaceValid = ValidateElevationSurface(MapView.Active.Map, SelectedSurfaceName); //if (!await IsElevationSurfaceValid) //{ // MessageBox.Show(VisibilityLibrary.Properties.Resources.LOSDataFrameMatch, VisibilityLibrary.Properties.Resources.LOSSpatialReferenceCaption); // SelectedSurfaceTooltip = VisibilityLibrary.Properties.Resources.LOSDataFrameMatch; // SetErrorTemplate(false); // return; //} var point = obj as MapPoint; // ok, we have a point if (point != null && ToolMode == MapPointToolMode.Observer) { if (IsMapClick) { if (!(await IsValidPoint(point, true))) { IsMapClick = false; return; } } // in tool mode "Observer" we add observer points // otherwise ignore var guid = await AddGraphicToMap(point, ColorFactory.Instance.BlueRGB, true, 5.0); var addInPoint = new AddInPoint() { Point = point, GUID = guid }; bool isValid = await IsValidPoint(point, false); Application.Current.Dispatcher.Invoke(() => { if (!isValid) { ObserverOutExtentPoints.Insert(0, addInPoint); } else { ObserverInExtentPoints.Insert(0, addInPoint); } ObserverAddInPoints.Insert(0, addInPoint); }); IsMapClick = false; } }
internal void ReadSelectedLyrPoints(ObservableCollection <AddInPointObject> inExtentPoints, ObservableCollection <AddInPointObject> outOfExtentPoints, string selectedLyrName, IColor color) { var map = ArcMap.Document.FocusMap; if (map == null) { return; } var layers = map.get_Layers(); if (layers == null) { return; } var layer = layers.Next(); while (layer != null) { if (layer.Name == selectedLyrName) { IFeature feature = null; IFeatureLayer FLayer = (IFeatureLayer)layer; var cursor = FLayer.FeatureClass.Search(null, false); var surface = GetSurfaceFromMapByName(ArcMap.Document.FocusMap, SelectedSurfaceName); double finalObserverOffset = GetOffsetInZUnits(ObserverOffset.Value, surface.ZFactor, OffsetUnitType); var selectedFeaturesCollections = GetSelectedFeaturesCollections(layer); while ((feature = cursor.NextFeature()) != null) { var value = feature.get_Value(FLayer.FeatureClass.FindField("Shape")); var point = (IPoint)value; var objectId = FLayer.FeatureClass.FindField("ObjectId"); var FID = FLayer.FeatureClass.FindField("FID"); var idIndex = objectId != -1 ? objectId : FID; var id = Convert.ToInt32(feature.get_Value(idIndex)); var z1 = surface.GetElevation(point) + finalObserverOffset; if ((point.SpatialReference != null) && (ArcMap.Document.FocusMap != null) && (ArcMap.Document.FocusMap.SpatialReference != null)) { if (point.SpatialReference != ArcMap.Document.FocusMap.SpatialReference) { point.Project(ArcMap.Document.FocusMap.SpatialReference); } } var addInPoint = new AddInPoint() { Point = point, GUID = Guid.NewGuid().ToString() }; if (selectedFeaturesCollections == null || !selectedFeaturesCollections.Any() || (selectedFeaturesCollections.Any() && selectedFeaturesCollections.Where(x => x == id).Any())) { if (double.IsNaN(z1)) { outOfExtentPoints.Add(new AddInPointObject() { AddInPoint = addInPoint, ID = id }); } else { inExtentPoints.Add(new AddInPointObject() { AddInPoint = addInPoint, ID = id }); } } } } layer = layers.Next(); } }
public Dictionary <string, string> GetOutputFormats(AddInPoint input) { var results = new Dictionary <string, string>(); IPoint point; var inputText = input.Point.Y + " " + input.Point.X; var ctype = GetCoordinateType(inputText, out point); if (point != null) { ArcMapCoordinateGet arcMapCoordinateGetter = new ArcMapCoordinateGet(); arcMapCoordinateGetter.Point = point; CoordinateGetBase coordinateGetter = arcMapCoordinateGetter as CoordinateGetBase; results.Add(CoordinateFieldName, input.Text); CoordinateBase.IsOutputInProcess = true; foreach (var output in CoordinateConversionLibraryConfig.AddInConfig.OutputCoordinateList) { var props = new Dictionary <string, string>(); string coord = string.Empty; switch (output.CType) { case CoordinateType.DD: CoordinateDD cdd; if (coordinateGetter.CanGetDD(output.SRFactoryCode, out coord) && CoordinateDD.TryParse(coord, out cdd, true)) { results.Add(output.Name, cdd.ToString(output.Format, new CoordinateDDFormatter())); } break; case CoordinateType.DMS: CoordinateDMS cdms; if (coordinateGetter.CanGetDMS(output.SRFactoryCode, out coord) && CoordinateDMS.TryParse(coord, out cdms, true)) { results.Add(output.Name, cdms.ToString(output.Format, new CoordinateDMSFormatter())); } break; case CoordinateType.DDM: CoordinateDDM ddm; if (coordinateGetter.CanGetDDM(output.SRFactoryCode, out coord) && CoordinateDDM.TryParse(coord, out ddm, true)) { results.Add(output.Name, ddm.ToString(output.Format, new CoordinateDDMFormatter())); } break; case CoordinateType.GARS: CoordinateGARS gars; if (coordinateGetter.CanGetGARS(output.SRFactoryCode, out coord) && CoordinateGARS.TryParse(coord, out gars)) { results.Add(output.Name, gars.ToString(output.Format, new CoordinateGARSFormatter())); } break; case CoordinateType.MGRS: CoordinateMGRS mgrs; if (coordinateGetter.CanGetMGRS(output.SRFactoryCode, out coord) && CoordinateMGRS.TryParse(coord, out mgrs)) { results.Add(output.Name, mgrs.ToString(output.Format, new CoordinateMGRSFormatter())); } break; case CoordinateType.USNG: CoordinateUSNG usng; if (coordinateGetter.CanGetUSNG(output.SRFactoryCode, out coord) && CoordinateUSNG.TryParse(coord, out usng)) { results.Add(output.Name, usng.ToString(output.Format, new CoordinateMGRSFormatter())); } break; case CoordinateType.UTM: CoordinateUTM utm; if (coordinateGetter.CanGetUTM(output.SRFactoryCode, out coord) && CoordinateUTM.TryParse(coord, out utm)) { results.Add(output.Name, utm.ToString(output.Format, new CoordinateUTMFormatter())); } break; default: break; } } CoordinateBase.IsOutputInProcess = false; } return(results); }