|
POST
|
Well the exercise would be fraught with danger of returning the wrong type of workspace but to pass in the type as a parameter negates the purpose. Which is why I have never done it. However it is done in esri code because the GxDialog returns IGxObjects that have an IName. The IName allows you to open the item which means creating a workspace somewhere. I just haven't quite figured out how to do it with the IGxObject and IGxObjectFactory (which is strongly typed.) Somewhere in the GxDialog, it recognizes the file types on disc and it can later open by creating the appropriate workspace. I think we have run off the original topic here.
... View more
02-12-2013
12:41 PM
|
0
|
0
|
1323
|
|
POST
|
Well same as if you try openFromFile with string "taco" on a valid workspace factory. In this case, failure just comes earlier. The whole point is validating the string before you even create the workspace factory. In the process of trying to figure out the type of workspace there is a step that checks if it is a valid directory or file, if not throw an argument exception. If after trying a bunch of combination, the code still can't figure out a valid workspace type, throw an argument exception.
... View more
02-12-2013
11:10 AM
|
0
|
0
|
1323
|
|
POST
|
You would not want to pass a string, because that is not type safe. What if someone passed in a misspelled string? Not a string containing the type, a string containing the path to the workspace. Based on the type of string, *.gdb, *mdb, *.sde etc. or the contents of the directory (info sub dir) or shapefiles, etc. the code decides which workspace factory is appropriate to instantiate.
... View more
02-12-2013
10:18 AM
|
0
|
0
|
1323
|
|
POST
|
There is a really cool thing called the ArcObjects API. Granted, I can't hold it against anyone who tries to make sense of the ArcObjects .NET API, because you can't find anything without expanding, expanding, expanding.. This is a Java example, so sorry for that. I opened eclipse and used the new project wizard to create a console application. Then I used the sample ArcGIS snippets for listing feature classes of a FGDB workspace. Notice in listFeatureclass, they use the concrete class FileGeodatabaseWorkspaceFactory to create new FileGeodatabaseWorkspaceFactory. Notice in listFeatureclass2, we're using the WorkspaceFactory class .. what? What kind of black magic is that? Give them a try, pass in a file name of "c:\\myfgdb.gdb" and see what happens.
public static void listFeatureclass(String file) throws java.net.UnknownHostException, java.io.IOException {
com.esri.arcgis.datasourcesGDB.FileGDBWorkspaceFactory factory = new com.esri.arcgis.datasourcesGDB.FileGDBWorkspaceFactory();
com.esri.arcgis.geodatabase.IWorkspace workspace = factory.openFromFile(file, 0);
com.esri.arcgis.geodatabase.IEnumDataset enumDataset = workspace.getDatasets(com.esri.arcgis.geodatabase.esriDatasetType.esriDTFeatureClass);
com.esri.arcgis.geodatabase.IDataset ds = null;
ds = enumDataset.next();
while(ds != null){
com.esri.arcgis.geodatabase.IFeatureClass fClass = new com.esri.arcgis.geodatabase.IFeatureClassProxy(ds);
int fCount = fClass.featureCount(null);
System.out.println("FeatureClass "+ fClass.getAliasName() +" has "+fCount+ " features.");
ds = enumDataset.next();
}
}
public static void listFeatureclass2(String file) throws java.net.UnknownHostException, java.io.IOException {
com.esri.arcgis.geodatabase.WorkspaceFactory factory = new com.esri.arcgis.geodatabase.WorkspaceFactory(new com.esri.arcgis.datasourcesGDB.FileGDBWorkspaceFactory());
com.esri.arcgis.geodatabase.IWorkspace workspace = factory.openFromFile(file, 0);
com.esri.arcgis.geodatabase.IEnumDataset enumDataset = workspace.getDatasets(com.esri.arcgis.geodatabase.esriDatasetType.esriDTFeatureClass);
com.esri.arcgis.geodatabase.IDataset ds = null;
ds = enumDataset.next();
while(ds != null){
com.esri.arcgis.geodatabase.IFeatureClass fClass = new com.esri.arcgis.geodatabase.IFeatureClassProxy(ds);
int fCount = fClass.featureCount(null);
System.out.println("FeatureClass "+ fClass.getAliasName() +" has "+fCount+ " features.");
ds = enumDataset.next();
}
}
That is really interesting, Java is very different when it comes to that sort of thing. You can't do that in .NET, the constructor for workspacefactory is not accessible outside the its own assembly. Typically in .NET you don't declare an object as a class, always an interface even if you know the exact type of class to which you have a reference, the .NET runtime still does not have the required metadata to cast the variable to a strongly typed RCW http://help.arcgis.com/en/sdk/10.0/arcobjects_net/conceptualhelp/index.html#//000100000151000000
... View more
02-12-2013
09:02 AM
|
0
|
0
|
3109
|
|
POST
|
Are you talking about the Factory Method pattern? If yes, then you create an interface for creating objects, and let subclasses define what type of object is being created. Yes I was talking about Factory method pattern. I was thinking something along those lines. A class where you just pass a string in the constructor, no workspace factory, and it spit out the appropriate workspace. It seems like a recipe for trouble for not much gain. I really don't feel like maintaining the code for every possible type of workspace including some that don't exist yet. Now if that sort of class was provided as part of the API, like an actual factory class, it would abstract a lot of the things you need to do and would reduce programmer error. WorkspaceFactory Class ctor workspaceStr Determine type of workspace needed Create workspace factory for type workspace property Open workspace return workspace
... View more
02-12-2013
08:43 AM
|
0
|
0
|
3109
|
|
POST
|
You are correct sir. I was being intentionally less obvious to the OP because I thought maybe they would see the difference between Interfaces and Classes and realize the answer to their question. I didn't mean your answer was incorrect or anything. I just got thinking about the class factory design pattern, in which the factory class decides what type of object to create. This is different from the workspace factory since you have to know what type of workspace you want (shapefile, file gdb, sde, etc.) before creating a specific type of workspace factory to get that same type of workspace. It strikes me as somewhat going against what the factory design pattern is supposed to be. Factories are supposed to decide the specific class type for you...
... View more
02-11-2013
10:20 AM
|
0
|
0
|
3109
|
|
POST
|
The interface is generic (IWorkspaceFactory) but the classes that implement it are all specific to the data type. There isn't a workspaceFactory Factory class that creates the one you need based on the data type you input or that figures out the data type provided in the file path (.shp, .gdb or .sde.) To make it would be easy but of limited value.
... View more
02-11-2013
08:45 AM
|
0
|
0
|
3109
|
|
POST
|
Hi there, I have always used getMessage (no 's') with the index of the message to retrieve. Base on some examples, the value passed in is an integer that reflects the message severity you want. Based on the second example, I assume that passing in a null objects will return all messages. http://help.arcgis.com/en/sdk/10.0/arcobjects_net/conceptualhelp/index.html#//000100000424000000 http://help.arcgis.com/en/sdk/10.0/arcobjects_net/conceptualhelp/index.html#//000100000102000000
... View more
02-11-2013
07:07 AM
|
0
|
0
|
884
|
|
POST
|
That might happen if you try to add values outside of the z domain. In ArcCatalog, if you open the properties of the featureclass and go to the domain tab, A. Do you see a 'Z Domain' box below the XY domain, and B. If it is there are the values you are entering within that domain? Another thing, if you are doing this within an edit session in ArcMap, you need to bracket this with a startoperation and stopoperation on the ieditor extension interface.
... View more
02-07-2013
12:02 PM
|
0
|
0
|
2319
|
|
POST
|
Firstly you need arcinfo license, ArcView won't do. Find Identical info is here: http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//001700000054000000 delete identical http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#/Delete_Identical/001700000053000000/ the vb.net help might be of use to show how to call the tool, it will be a little different in VBA. http://help.arcgis.com/en/sdk/10.0/arcobjects_net/conceptualhelp/index.html#//000100000m0s000000 VBA support is being phased out by esri so there is not a lot of info on it and expect to see it disappear (I would not used VBA for new development.)
... View more
02-07-2013
10:17 AM
|
0
|
0
|
2970
|
|
POST
|
sounds like you have a z-aware featureclass... The ZAware property should return true before you set it. If it doesn't there is a problem with the featureclass, setting it won't help. In my experience, I have found that creating a new polyline and setting the coordinate system reference same as the old one and then adding new points as you read the points from the original polyline and then calling simplify and setting the feature shape property to the new shape has yielded better results.
... View more
02-07-2013
09:13 AM
|
0
|
0
|
2319
|
|
POST
|
The basic geoprocessor is pretty much obsolete. I believe it came out in the 8.x series as a replacement for the geoprocessing tools that ArcView GIS 3.2 had at the time. Back then, the toolbox was a separate application from ArcMap and ArcCatalog and ArcView 3.x had these tools in the main application so they needed that too. You can't really compare them to the Geoprocessing tools, they are completely different. You can call GP tools from ArcObjects though but that is very different from using IBasicGeoprocessor. IBasicGeoprocessor provides access to the methods and properties of the BasicGeoprocessor object. The functionality of the BasicGeoprocessor object had been superseded by the new Geoprocessing framework of ArcGIS starting at version 9.0. Developers should utilize the new tools whenever possible.
... View more
02-07-2013
08:46 AM
|
0
|
0
|
2970
|
|
POST
|
IRelationalOperator::equals is a good idea but in my experience you need to compare all geometries to all other geometries it can be very slow for large feature classes. You can try to be smarter and check if the index intersects first but it is still quite slow. I build a tool to do this back in 9.1 for a client. I used featureindex to narrow down the search and then IRelationalOperator.equals. I have found the featureindex to be somewhat finicky. If I had to do it again I would try to use the find intersect tool.
... View more
02-07-2013
07:43 AM
|
0
|
0
|
2970
|
|
POST
|
Hi there, would the geoprocessing tool "find identical" using only the shape field not do this for you? Shape field would compare geometries...
... View more
02-07-2013
06:57 AM
|
0
|
0
|
2970
|
|
POST
|
yeah that code is not going to work... The messagebox call does an implicit cast of the value in the field to a string (calls default toString method.) However if the value in the field is a null (dbnull.value) or a value that does not have a tostring method (i.e. geometry, blob, raster...), you will get an error for sure. Dim pMap As IMap = My.ArcMap.Document.FocusMap Dim pPIDLayer As IFeatureLayer = pMap.Layer(0) Dim pPIDFClass As IFeatureClass = pPIDLayer.FeatureClass Dim pPIDFCursor As IFeatureCursor = pPIDFClass.Search(Nothing, False) Dim pPIDFeature As IFeature = pPIDFCursor.NextFeature For i As Integer = 0 To 5 if pPIDFeature.fields.field(i).type <> esriFieldTypeGeometry andalso _ pPIDFeature.fields.field(i).type <>esriFieldTypeBlob andalso _ pPIDFeature.fields.field(i).type <>esriFieldTypeRaster andalso _ pPIDFeature.Value(i) isnot system.dbnull.value then MsgBox(pPIDFeature.Value(i)) end if Next The code above assumes the table has more than 6 fields, otherwise it will also fail. If you check the field types on the featureclass before doing the search, you can pass in a query filter with only the field names in the subfields that can be converted to a string and only query those fields. You still have to check for nulls though... One last thing, when posting to the forum that you have 'an error' it is useful to the forum to post the exact error message, that cuts out a lot of guessing.
... View more
02-06-2013
11:56 AM
|
0
|
0
|
1357
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 12-02-2024 10:26 AM | |
| 1 | 07-05-2024 08:45 AM | |
| 1 | 10-05-2022 02:19 PM | |
| 6 | 03-27-2017 01:16 PM | |
| 1 | 05-05-2016 05:46 AM |
| Online Status |
Offline
|
| Date Last Visited |
03-28-2025
07:37 AM
|