POST
|
Also in API v4.x there's still no way to do that. We really appreciate of that's coming.
... View more
11-28-2022
01:25 AM
|
0
|
0
|
198
|
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
|
370
|
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
|
406
|
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
|
472
|
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
|
2356
|
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
|
2356
|
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
|
2356
|
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
|
2356
|
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
|
2599
|
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
|
799
|
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
|
921
|
POST
|
I have a VS-project that contains some code for some ArcMap-Extensions (no AddIn). Thus when compiling I also register them using ESRIRegAsm as follows: <Target Name="BeforeClean">
<Exec WorkingDirectory="$(CommonProgramFiles)\ArcGIS\bin" Command="esriRegasm.exe "$(TargetPath)" /p:Desktop /u /s" Condition="Exists('$(TargetPath)')" />
</Target>
<Target Name="AfterBuild">
<Exec WorkingDirectory="$(CommonProgramFiles)\ArcGIS\bin" Command="esriRegasm.exe "$(TargetPath)" /p:Desktop /s" />
</Target> However I always get the following error on ReBuild, which invokes BeforeClean: error MSB3073: The command "esriRegasm.exe "MyAssembly.dll" /p:Desktop /u /s" terminated with the code -1. I looked for the appropriate ECFG-file within "C:\Program Files (x86)\Common Files\ArcGIS\Desktop10.6\Configuration\CATID" and there is none for the mentioned project. Therefor I assumed that esriregasm with the /u-switch enabled just returns -1 when there is no such ECGF-file. However when I run the command within a shell with the /u-switch it works just fine, nothing is returned at all, even when there is no ECFG-file: C:\Program Files (x86)\Common Files\ArcGIS\bin>esriRegasm.exe "C:\MyPath\MyAssembly.dll" /p:Desktop /u /s Is there any log that indicates why registerung/unregistering fails? I´m using VS2017 and ArcGIS Desktop 10.6.1.
... View more
06-13-2019
03:47 AM
|
0
|
0
|
628
|
POST
|
I will remember . Greatly appreciate your feedback. I searched a lot for this and it took me a week or so.
... View more
12-14-2018
08:16 AM
|
0
|
0
|
957
|
POST
|
As you see in my code I already use IClone.IsEqual. However as of the docs this does not consider any information about precision and tolerance, which is why I use IsPrecisionEqual.
... View more
10-29-2018
04:46 AM
|
0
|
0
|
566
|
POST
|
In order to compare the spatial reference of my map and this of my database I use the following code: var mapSR = myMap.ActiveView.SpatialReference;
var gdbSR = ((IGeoDataset)myFeatureClass).SpatialReference;
bool areSame = ((IClone)mapSR).IsEqual((IClone)gdbSR);
if(areSame) // also compare map-resolution as suggested here: https://desktop.arcgis.com/en/arcobjects/latest/net/webframe.htm#ISpatialReference_IsPrecisionEqual.htm
mapSR.IsPrecisionEqual(gdbSR, out areSame); After calling IsPrecisionEqual areSame will be false (I ensured the method was called by setting a breakpoint), which I don´t understand. When I dive into the spatial references, e.g. using a watch, I can´t see any (meaningful) differences: (ISpatialReferenceResolution)mapSR
COM Object
[System.__ComObject]: COM Object
Abbreviation: ""
Alias: ""
FactoryCode: 0
MResolution: 0.0001
MResolution: 0.0001
MTolerance: 0.001
MToleranceValid: esriSRToleranceOK
Name: "ETRS89_UTM32"
PrecisionExImpl: 1529763776
PrecisionImpl: 1533456216
Remarks: ""
SpatialReferenceImpl: 689094056
VerticalCoordinateSystem: null
XYTolerance: 0.0001
XYToleranceValid: esriSRToleranceOK
ZCoordinateUnit: null
ZTolerance: 0.001
ZToleranceValid: esriSRToleranceOK
(ISpatialReferenceResolution)gdbSR
COM Object
[System.__ComObject]: COM Object
Abbreviation: null
Alias: null
FactoryCode: 0
MResolution: 0.0001
MResolution: 0.0001
MTolerance: 0.001
MToleranceValid: esriSRToleranceOK
Name: "ETRS89_UTM32"
PrecisionExImpl: 1103993808
PrecisionImpl: 1100159248
Remarks: null
SpatialReferenceImpl: 689094056
VerticalCoordinateSystem: null
XYTolerance: 0.0001
XYToleranceValid: esriSRToleranceOK
ZCoordinateUnit: null
ZTolerance: 0.001
ZToleranceValid: esriSRToleranceOK
Also get_XYResolution(false) returns 0.00001 (which is 10times the XYTolerance, as seen above) for both the maps and the databases spatial reference. I also tried to use ISpatialReference3.IsXYResolutionEqual, because I´m only interested in plane resolution and tolerance. However this also returns false when comparing the two spatial references. So what do IsXYResolutionEqual and IsResolutionEqual compare asside from the above properties? Are those Impl- and ExImp-properties considered as well (which is not documented)?
... View more
10-26-2018
02:55 AM
|
0
|
2
|
719
|
Title | Kudos | Posted |
---|---|---|
1 | 08-29-2019 02:09 AM | |
4 | 10-02-2018 02:03 AM | |
1 | 10-01-2018 06:19 AM | |
1 | 02-26-2018 06:57 AM | |
1 | 11-18-2016 01:43 AM |
Online Status |
Offline
|
Date Last Visited |
02-21-2024
06:38 AM
|