POST
|
Found after a search on the web in annotation - ArcObjects Anno Classes - Geographic Information Systems Stack Exchange IAnnotationClassExtension annoClassExtension = featureLayer.FeatureClass.Extension as IAnnotationClassExtension; IAnnotateLayerPropertiesCollection annoLayerPropsCollection = annoClassExtension.AnnoProperties; ... etcetera Thanks anyway, Pieter
... View more
07-13-2016
06:45 AM
|
0
|
0
|
338
|
POST
|
Hello, How do I get the AnnotationProperties of a IAnnotationLayer? A non-annotation IFeaturelayer is also a IGeoFeatureLayer, which has an IAnnotateLayerPropertiesCollection, but an IAnnotationLayer has not. I'm aware of the IAnnoClass and IAnnoClassExtension, but how to get there? IAnnoClass annoClass = featureLayer.FeatureClass as IAnnoClass doesn't work, it returns null. Kind regards, Pieter
... View more
07-06-2016
07:21 AM
|
0
|
1
|
1460
|
POST
|
Hello, It was definitely a problem of memory consumption. This loop for searching surrounding points foreach(7771 points) { IFeatureCursor = featureClass.Search(spatialFilter, False) .... do something with the found features .... Marshal.ReleaseComObject(featureCursor) } was too much; every other operation using some memory caused a 'Out of memory'-error. I finally could solve it by using the NetTopologySuite and creating a STRTree. Kind regards, Pieter
... View more
12-11-2015
02:33 AM
|
0
|
0
|
335
|
POST
|
Yes, the points are in the same coordinate system. When I noticed the empty IGeometryCollection my featureclass contained 7771 point features, of which 4353 were selected and stored as 'PtClass' into the 'PtCollection'. The spatial search for surrounding points included all points in the featureclass, but the ones whose references were not found in the 'PtCollection' were skipped. The result of BufferCollection(...) was an empty collection, but a second program run ('PtCollection' loaded from XML) returned 335 buffers (where exploded = true & unionoverlap = true). I've noiticed with Memory Profiler, when spatial searching, a grow of used instances and bytes, and at about 2/3 of the time a spectacular grow of Generation #0 GCs, at the end of the search 162k instances, 10M9 bytes, 47 Gen #0 (upper line), 8 Gen #1 (middle line) and 1 Gen #2 (lower line). A second test with a featureclass with 4050 points from which 2278 were selected, gave me in one run a collection of 142 buffers. Kind greetings, Pieter
... View more
12-04-2015
01:27 AM
|
0
|
0
|
335
|
POST
|
Hello, In my program I've created a custom class 'PtClass' which contains an IPoint named 'Pt' and a collection of 'PtClass' named 'Surround'. This class can be written to and restored from XML. I read several point features from a featureclass 'FC' with a feature cursor. For every point feature I create an instance of 'PtClass', use the point feature coordinates to create 'Pt' - to be sure there is no link between the feature and the instance - and store the instance to a collection 'PtCollection'. When finished, I loop every item in 'PtCollection' to search surrounding point features in 'FC' with a spatial cursor, find the corresponding items in 'PtCollection' and put them in 'Surround'. Finally this collection is stored to XML. Then I need some overlapping buffers around certain groups of 'PtClass' points (pointList is a List of 'Pt' from 'PtCollection'): private IGeometryCollection BufferCollection(List<IPoint> pointList, ISpatialReference spatialReference, double bufferDistance, bool explodeBuffers, bool unionOverlapBuffers) { IGeometryBag bufferBag = new GeometryBag() as IGeometryBag; bufferBag.SpatialReference = spatialReference; IGeometryCollection bufferCollection = bufferBag as IGeometryCollection; object missing = Type.Missing; try { // make a MultiPoint geometry from the collection IPoint's IMultipoint mp = new Multipoint() as IMultipoint; mp.SpatialReference = spatialReference; IGeometryCollection multiPoint = mp as IGeometryCollection; foreach (IPoint point in pointList) { multiPoint.AddGeometry(point, ref missing, ref missing); } // add the MultiPoint to a geometrybag IGeometryBag bag = new GeometryBag() as IGeometryBag; bag.SpatialReference = spatialReference; IGeometryCollection obstacleBag = bag as IGeometryCollection; obstacleBag.AddGeometry((IGeometry)multiPoint, ref missing, ref missing); // create an enumerator IEnumGeometry enumGeometry = obstacleBag as IEnumGeometry; // build buffers around the points IBufferConstruction bufferConstruction = new BufferConstruction(); IBufferConstructionProperties bufferConstructionProperties = (IBufferConstructionProperties)bufferConstruction; bufferConstructionProperties.ExplodeBuffers = explodeBuffers; bufferConstructionProperties.UnionOverlappingBuffers = unionOverlapBuffers; bufferConstruction.ConstructBuffers(enumGeometry, bufferDistance, bufferCollection); } catch (Exception ex) { // do something with the error } return bufferCollection; } But sometimes it returns an empty collection, unless when I start the program anew, skip the 'FC' search and create 'PtCollection' from XML. All the featurecursors are non-recycling and are released with Marshal.ReleaseComObject immediately afterwards. I'm using Visual Studio 2010 and ArcGIS 10.2.2. Does it have anything to do with memory usage?
... View more
12-03-2015
06:25 AM
|
0
|
3
|
2850
|
POST
|
After reviewing the code, I've found an overseen piece that did reset the selectionsymbol. Thus, the above code works for both featurerenderer and selectionsymbol. Many thank for your help!
... View more
07-02-2014
05:46 AM
|
0
|
0
|
819
|
POST
|
Thanks Robby and Neil. I have now this code: private IFeatureLayer FeatureLayerFromFeatureClass(IFeatureClass featureClass, string layername)
{
IFeatureLayer featureLayer = new FeatureLayerClass();
featureLayer.Name = layerName;
featureLayer.FeatureClass = featureClass;
IFeatureSelection featureSelection = featureLayer as IFeatureSelection;
if (File.Exists(_layerFilePath))
{
// open the layer from the .lyr-file
ILayerFile layerFile = new LayerFileClass();
layerFile.Open(_layerFilePath);
IGeoFeatureLayer sourceGeoFeatureLayer = layerFile.Layer as IGeoFeatureLayer;
// destination
IGeoFeatureLayer destinationGeoFeatureLayer = featureLayer as IGeoFeatureLayer;
// copier
IObjectCopy objectCopy = new ObjectCopyClass();
// get the symbology
IFeatureRenderer featureRenderer = objectCopy.Copy(sourceGeoFeatureLayer.Renderer) as IFeatureRenderer;
destinationGeoFeatureLayer.Renderer = featureRenderer;
// get the feature selectionsymbol
IFeatureSelection sourceFeatureSelection = sourceGeoFeatureLayer as IFeatureSelection;
featureSelection.SelectionSymbol = objectCopy.Copy(sourceFeatureSelection.SelectionSymbol) as ISymbol;
featureSelection.SetSelectionSymbol = true;
// close nicely
layerFile.Close();
}
return featureLayer;
} and it retrieves the symbology but not the selectionsymbol. {edited} I adapted the .lyr-files in ArcCatalog and selected a custom symbol, but when I open the FeatureLayerSelectionPropertyPage in the program it is the default symbol, what I don't want. {/edited}
... View more
07-02-2014
01:57 AM
|
0
|
0
|
819
|
POST
|
Thanks Robert for your reply. My program reads a XML-file with the names the FeatureClasses to load (several sub-projects with the same kind of data but for multiple users on different locations). Then it creates FeatureLayers based on the FeatureClasses, with the symbology stored in binary files as described above, and, as I would like to do, also the ISymbol which is used to show the selected features (IFeaturelayer -> IFeatureSelection -> SelectionSymbol), but I don't need to store/retrieve a selectionset. I could try to store the layer properties in a .lyr-file, but that gives a lot of overhead, and it takes time to open a .lyr-file, as it contains also a reference to the source (if the source can't be found, the symbology is invalid). Have a nice day, Pieter
... View more
07-01-2014
01:13 AM
|
0
|
0
|
819
|
POST
|
Hello, Like symbology, I would like to save to and restore from file the featurelayer's IFeatureSelection properties. This properties are set on the FeatureLayerSelectionPropertyPage. I can do it (save to file) with the featurelayer's symbology with IGeoFeatureLayer geoFeatureLayer = (IGeoFeatureLayer)featureLayer; IMemoryBlobStream memoryBlobStream = new MemoryBlobStreamClass(); IObjectStream objectStream = new ObjectStreamClass(); objectStream.Stream = (IMemoryBlobStream)memoryBlobStream; IPropertySet propertySet = new PropertySet(); IPersistStream persistStream = (IPersistStream)propertySet; propertySet.SetProperty("Symbology", geoFeatureLayer.Renderer); persistStream.Save(objectStream, 0); memoryBlobStream.SaveToFile(filePath); but for the featureselection I can't find anything. Does anybody know how to do it? Many thanks, Pieter
... View more
06-27-2014
05:54 AM
|
0
|
6
|
1187
|
POST
|
Dear Neil, No, I didn't, but when I do, it works! How could I forget it..... Many thanks! Have a nice day,
... View more
08-16-2010
05:19 AM
|
0
|
0
|
462
|
POST
|
Dear all, When I want to set the shape property of a newly created feature, I get this error:[INDENT]System.Runtime.InteropServices.COMException (0x80040907): Item not found in this collection. at ESRI.ArcGIS.Geodatabase.IFeature.set_Shape(IGeometry Shape) at <myFunction> [/INDENT]This is what I do: I have two featurelayers - the one with the originating polygons which has Z, and a destination layer with polygons which has _no_ Z.[INDENT] IFeature polygonFeature = <selected polygon feature>;
IGeometry splitGeometry = <polyline drawn by IRubberBand.TrackNew>;
IGeometry polygonGeometry = polygonFeature.ShapeCopy;
IGeometry leftSplitPart;
IGeometry rightSplitPart;
ITopologicalOperator topoOperator = polygonGeometry as ITopologicalOperator;
topoOperator.Cut(splitGeometry as IPolyline, out leftSplitPart, out rightSplitPart); [/INDENT]The resulting geometries leftSplitPart and rightSplitPart are not empty and have the same shapetype of the featureclass I want to put them in; Remove the Z from the leftSplitPart (with ZAware.DropZs()), but it makes no difference, because the error occurs even when I skip this step; Start the IWorkspaceEdit::StartEditing(false) and IWorkspaceEdit::StartEditOperation (on the destination layer);[INDENT] IFeature newFeature = destinationLayer.FeatureClass.CreateFeature();
newFeature.Shape = leftSplitPart; [/INDENT]and there the error pops up..... What am I doing wrong? Any ideas? I'm (still) using 9.2 SP 6. Many thanks,
... View more
08-13-2010
05:29 AM
|
0
|
3
|
3718
|
POST
|
Thanks Neil for your answer. I did as you wrote: created a new StandAloneTable, set its Table property to geodatabaseTable and tried to add it to the collection, but there it fails. Never mind, I made a class which contains the ITable and a Name property, and put that in an ICollection - an ITableCollection doesn't have a Name property.
... View more
06-30-2010
06:27 AM
|
0
|
0
|
691
|
POST
|
Hi, When I try to add a table from a MDB to a MapControl's StandAloneTableCollection, I get an error. What am I doing wrong? The table exists and is not empty. {System.InvalidCastException: Unable to cast COM object of type 'System.__ComObject' to interface type 'ESRI.ArcGIS.Carto.IStandaloneTable'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{FFC6B179-E3EC-11D3-A096-00C04F6BC626}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)). at <snip>.AddTableToMapControl() in <snip><snip>} public void AddTableToMapControl() { IMapControl3 pMapControl = (IMapControl3)this.AxMapControl1.Object; IWorkspaceFactory accessWorkspaceFactory = new AccessWorkspaceFactoryClass(); IFeatureWorkspace featureWorkspace; ITable geodatabaseTable; IStandaloneTable geodatabaseStTable; IStandaloneTableCollection pStTableCollection = pMapControl as IStandaloneTableCollection; try { featureWorkspace = accessWorkspaceFactory.OpenFromFile("c:/somewhere/somedb.mdb", 0) as IFeatureWorkspace; geodatabaseTable = featureWorkspace.OpenTable("SomeTable"); geodatabaseStTable = (IStandaloneTable)geodatabaseTable; <----- here it fails with the error pStTableCollection.AddStandaloneTable(geodatabaseStTable); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } } Many thanks,
... View more
06-30-2010
01:58 AM
|
0
|
2
|
3176
|
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:23 AM
|