POST
|
I have a number of polylinesthat are split at crossing-points so they do not overlap. Now I want to create distinct polygons from those polylines, where none of those polygons overlaps another one. We can´t use the Polyline2Polygon.features here, because we simply don´t have any features but just geometries. So let´s define this structure as network having edges and nodes. My first idea was to remove all the polylines that are outside a common polygon. Or in other words delete the polylines that simply lead to nowhere. This way I get a polygon that contains most of the edges (that´s the red outlined polygon in the image beyond). Now I can use ITopologicalOperator4.Cut2 on this polygon in order to get all the areas within that polygon. Just an asside: Cut2 can´t handle those dead-edges mentioned before and will throw an exception. That´s why I want to delete them before. However I have no idea how to define this common polygon.
... View more
12-13-2019
07:28 AM
|
0
|
1
|
84
|
POST
|
Seems we can´t assign a new spatial-reference, but modify the existing to fit the parameters of the provided one: ( ( IClone ) myMap . SpatialReference ) . Assign ( ( IClone ) anotherWorkspace . SpatialReference ) ;
... View more
12-04-2019
02:01 AM
|
0
|
0
|
32
|
POST
|
I have a map containign some layers in a user-defined spatial-reference (some version of the German DE_DHDN_3GK2). As of the docs my map gets the spatial-reference of ther very first layer, which is identical to the mentioned one. However when I assign another reference-sytem to my map, nothing happens: var myMap = ( ( IMxDocument ) myApp . Document ) . FocusMap ; myMap . SpatialReference = anotherWorkspace . SpatialReference ; In particular when I query the properties of the maps spatial-reference I get its old values: ( ( ISpatialReferenceResolution ) myMap . SpatialReference ) . get_XYResolution ( false ) ; The same applies when I use this: ( ( ISpatialReference ) myMap . SpatialReference ) . GetFalseOriginAndUnits ( out var falseX , out var falseY , out var xyUnits ) ; So I wonder if assigning a spatial-reference to a map has any purpose at all. When I compare the spatial references using var transformEqual = ( ( IClone ) myMap . SpatialReference ) . IsEqual ( ( IClone ) anotherWorkspace . SpatialReference ) ; myMap . SpatialReference . IsPrecisionEqual ( anothrWorkspace . SpatialReference , out var precisionEqual ) ; I get true for transformEqual and false for precisionEqual , which makes me assume that the setter for IMap.SpatialReference checks for IClone.IsEqual first and does nothing in case of true . The above code runs in an AddIn on ArcMap 10.6.1.
... View more
12-03-2019
07:19 AM
|
0
|
1
|
98
|
POST
|
Thanks for your reply. That sample indeed is helpful in some way - as you mentioned it shows how to display data within a grid. My workflow however is a bit different. I have a list of objects (type Reservation , implements INotifyPropertyChanged ). Now I´m updating some data within a standalone-table, whereby also some of those items within the list get updated (e.g. lets suppose each Reservation has a Name ). You´re right, this happens on another thread, so I have to use BindingOperations.EnableCollectionSynchronization of course. I don´t need a notification when the list itself changes - which can easily be achieved via the (ReadOnly-)ObservableCollection , but when the items within that list are modified. All this WPF-stuff is quite new to me, we implemented ArcObjects and WinForms for years, so I may miss the obvious. I would appreciate if we could continue this on DevSummit in Berlin, as I have a working solution for now. Hope to see you there. I think I will show my final code within my answer.
... View more
08-30-2019
12:40 AM
|
0
|
0
|
254
|
POST
|
If the Reservation-type also implements INotifyPropertyChanged, our ReadOnlyObservableCollection will automatically recieve the events and update the UI.
... View more
08-29-2019
04:49 AM
|
0
|
3
|
254
|
POST
|
" Thus when my list is updated within Module1 , this should be reflected in the ViewModel and thus in the pane. Or am I missing some binding from DockpaneViewmodel.MyList to Module.Mylist ?" Assuming we have a binding for our viewmodels list: BindingOperations . EnableCollectionSynchronization ( this . MyList , this . m_LockObject ) ; updating the list within the Module will be reflected within the dockpane. However this seems to apply only for deletes/inserts into that list. Modifications on a single element within that list are not notified.
... View more
08-29-2019
02:38 AM
|
0
|
4
|
254
|
POST
|
I solved my problem with the table by registering for the MapViewInitializedEvent: protected override bool Initialize ( ) { MapViewInitializedEvent . Subscribe ( x = > QueuedTask . Run ( ( ) = > { var table = x . MapView . Map . GetStandaloneTable ( . . . ) ; this . _myList . AddRange ( /* get data from table */ ) ; } return true ; } However I still stumble on presenting the tables information within my dockpane, which is attached to the modules MyList -property: internal class Dockpane1ViewModel : DockPane { public ReadOnlyObservableCollection<Reservation> MyList => Module1.MyList; } From my understanding the Modules Initialize -method is called as soon as my dopckpane is first shown. As the MyList -property within MyModule is initialized within its constructor: class Module1 : Module { public ReadOnlyObservableCollection < Reservation > MyList { get ; } = new ReadOnlyObservableCollection < Reservation > ( _myList ) ; protected override bool Initialize ( ) { . . . } } both Dockpane1ViewModel.MyList and Module1.MyList should reference the exact same collection. Thus when my list is updated within Module1 , this should be reflected in the ViewModel and thus in the pane. Or am I missing some binding from DockpaneViewmodel.MyList to Module.Mylist ? After all my solution now looks like this: //Module1.cs private readonly ObservableCollection < Reservation > _myList = new ObservableCollection < Reservation > ( ) ; public ReadOnlyObservableCollection < Reservation > MyList { get ; } = new ReadOnlyObservableCollection < Reservation > ( this . _myList ) ; protected override bool Initialize ( ) { MapViewInitializedEvent . Subscribe ( x = > QueuedTask . Run ( ( ) = > { var table = x . MapView . Map . GetStandaloneTable ( . . . ) ; this . _myList . AddRange ( /* get data from table */ ) ; } return true ; } // Dockpane1ViewModel.cs public ReadOnlyObservableCollection < Reservation > MyList { get ; } = Module1 . Current . MyList ; private readonly object m_LockObject = new object ( ) ; public Dockpane1ViewModel ( ) { BindingOperations . EnableCollectionSynchronization ( this . MyList , this . m_LockObject ) ; } // Reservation.cs public class Reservation : INotifyPropertyChanged { public string Name { get = > _name ; set { _name = value ; this . OnPropertyChanged ( nameof ( Name ) ) ; } } public event PropertyChangedEventHandler PropertyChanged ; /// <inheritDoc /> protected virtual void OnPropertyChanged ( [ CallerMemberName ] string propertyName = null ) { PropertyChanged ? . Invoke ( this , new PropertyChangedEventArgs ( propertyName ) ) ; } } And finally within some command I update a Reservation: // MyCommand.cs protected override void OnClick ( ) { QueuedTask . Run ( ( ) = > Module . Current . MyList . First ( ) . Name = "MyNewName" ) ; } The key here was just three points: our collection itself implements INotifyCollectionChanged and thus fires event when items are added/removed our items implement INotifyPropertyChanged so we get an event when a member within our data-object is updated we need to bind the list to our view using BindingOperations.EnableCollectionSynchronization (this.MyList, this.m_LockObject because the items are modified on another thread, and thus the events would never get to the UI.
... View more
08-29-2019
02:09 AM
|
1
|
5
|
254
|
POST
|
I have a dockpane which presents some information from a standalone-table. All examples I found Map.GetStandaloneTable. However during startup - in particular when the dockpane and its related module are initialized - there is no such map: protected override bool Initialize ( ) { QueuedTask . Run ( ( ) = > { var map = // MapView.Active is null at this point var table = map . GetStandaloneTable ( "MyTable" ) ; // do something with the table } ) ) ; return true ; } Is there a way to load a table without the map being fully loaded? Alternativly I would initialize the module when the map is fully loadedwhich assumes there is an event which I can register.
... View more
08-28-2019
03:42 AM
|
0
|
7
|
497
|
POST
|
I got it working by not using the Modify-operation, but just registering an OnChange-eventhandler when a row is modified: RowChangedEvent . Subscribe ( this . RowChanged , fc ) ; while ( rowCursor . MoveNext ( ) ) { var feature = ( Feature ) rowCursor . Current ; var geomTest = feature . GetShape ( ) ; if ( geomTest != null ) { var geomProjected = GeometryEngine . Instance . Project ( geometry , geomTest . SpatialReference ) ; // we are looking for polygons that are completely intersected by the cut line if ( GeometryEngine . Instance . Relate ( geomProjected , geomTest , "TT*F*****" ) ) { oids . Add ( rowCursor . Current . GetObjectID ( ) ) ; } } } cutOperation . Split ( layer , oids , geometry ) ; var operationResult = cutOperation . Execute ( ) ; The RowChanged-method is this and is executed upon EditOperation.Execute private void RowChanged ( RowChangedEventArgs obj ) { if ( m_CurrentRowChangedOid == obj . Row . GetObjectID ( ) ) return ; this . m_CurrentRowChangedOid = obj . Row . GetObjectID ( ) ; obj . Row [ obj . Row . GetTable ( ) . GetDefinition ( ) . FindField ( "FSK" ) ] = "MyNewFsk" ; } However we have to unsubscribe from the event. Otherwise the handler is registered on every call to our tool.
... View more
08-21-2019
06:43 AM
|
0
|
1
|
37
|
POST
|
I´ve edited the CutTool-example from GitHub to also modify the created/changed features. his is my modified code: var rowCursor = layer . Search ( myGeometry , SpatialRelationship . Crosses ) ; var fc = layer . GetFeatureClass ( ) ; var fkzFieldIndex = fc . GetDefinition ( ) . FindField ( "FSK" ) ; if ( fkzFieldIndex == - 1 ) return Task . FromResult ( false ) ; int index = 0 ; // add the feature IDs into our prepared list while ( rowCursor . MoveNext ( ) ) { var feature = ( Feature ) rowCursor . Current ; var geomTest = feature . GetShape ( ) ; if ( geomTest != null ) { // make sure we have the same projection for geomProjected and geomTest var geomProjected = GeometryEngine . Instance . Project ( geometry , geomTest . SpatialReference ) ; // we are looking for polygons are completely intersected by the cut line if ( GeometryEngine . Instance . Relate ( geomProjected , geomTest , "TT*F*****" ) ) { // add the current feature to the overall list of features to cut oids . Add ( rowCursor . Current . GetObjectID ( ) ) ; cutOperation . Modify ( rowCursor . Current , fkzFieldIndex , "MyNewFKZ" ) ; } } } // add the elements to cut into the edit operation cutOperation . Split ( layer , oids , geometry ) ; //execute the operation var operationResult = cutOperation . Execute ( ) ; return Task . FromResult ( operationResult ) ; So I have a list of oids of features that I want to assign new attributes and that I want to split afterwards. My feature is split, but it does not get the value "MyNewFKZ" assigned to the FKZ-field. Did I miss anything here? I can´t see how may code differs from the example. Just an asside: I also subscribed to the RowCreatedEvent in order to set the FKZ for the newly created feature as well. The handler is appropriately called and the new feature gets the FKZ-field assigned. Uncommenting that handler however has no effect on the modified feature.
... View more
08-20-2019
12:44 AM
|
0
|
3
|
159
|
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:24 AM
|