|
POST
|
Luke, Thanks for the email. No, I was never able to solve the problem. I could never figure out how to create the menus on the fly. I could create forms and commands that way, but not menus. I'm intrigued by your code so I will give it a try when I have some time. Thanks, Carlos
... View more
04-25-2011
08:37 AM
|
0
|
0
|
440
|
|
POST
|
Thanks a lot Neil, that's exactly what I needed! Never used those properties before. Carlos
... View more
02-24-2011
10:37 AM
|
0
|
0
|
633
|
|
POST
|
Hi everyone, I am displaying fields of a layer in a combo box and do not want to include the ESRI generated fields, OID, Shape_Area, etc. I can easily pick out the OID and geometry fields by using the esriFieldType enumerator, but I cannot do the same for Shape_Area, Shape.Area, etc. because they are field type double and there might be other fields of the same type that I want to show. I know I can exclude them if I get the name of each field but the shape area and length fields are called different things depending on the data type, Shape.Area, Shape_Area, Shape, etc. I am hoping there is a more elegant way of doing it. I am programming in C# but code in any language will work as I can convert it to what I need. Thanks, Carlos if (pLayerFields.get_Field(i).Type == esriFieldType.esriFieldTypeOID)
... View more
02-24-2011
08:56 AM
|
0
|
2
|
905
|
|
POST
|
Hi everyone, Thanks a lot for all of your suggestions! Between all of them, I have been able to improve the performance of the update cursor to 1/3 of the original time! The winning combination was to treat the feature class as a table and use Iworkspace::ExecuteSQL to update all the fields at once per record instead of updating each field separately. Thanks again!!! Carlos
... View more
11-22-2010
09:29 AM
|
0
|
0
|
781
|
|
POST
|
Thanks James, I'll give your suggestions a try. Carlos Carlos, 1. Instead of just updating the FeatureCursor, have you tried accomplishing this with an Update on an IFeatureBuffer? This should speed up the ArcObjects side of things. Dim pFeatCur As IFeatureCursor
Dim pFeatBuf As IFeatureBuffer
pFeatBuf = pFeatureClass.CreateFeatureBuffer
pFeatCur = pFeatureClass.Insert(True)
pFeatBuf.Value(pFeatBuf.Fields.FindField("TheFieldName")) = CStr("blah")
pFeatCur.UpdateFeature(pFeatBuf) ...err something to that effect. That above is WAY untested there! 2. I agree that you if this is just updating attributes, then let a PL/SQL package handle it -- for just about all of my attribute updating, its almost always be faster if done on the server rather than the application tier. Get with your DBA to put together the SQL (sorry I can't help much as I deal mostly with SQLServer Stored Procedure development). 3. I am not sure about using an ADO.NET DataTable instead of the DataReader being faster. I think it'd actually be slower because there is more overhead in creating and filling a DataSet and DataTable compared to the DataReader. But don't mean to discourage you on that: you will need to setup an OracleDataAdapter, Fill a DataSet with the DataTable, then you can have access to it from there. You are real close to doing this, just replace the DataReader with the DataAdapter. http://msdn.microsoft.com/en-us/library/system.data.oracleclient.oracledataadapter.aspx 4. Last idea.... If this is not versioned data, and you cannot setup the PL/SQL package, then *perhaps* doing a straight-up .Update on a DataAdapter might be another option to increase speed. Letting the ADO.NET CommandBuilder generate the INSERT/UPDATE/DELETE commands might take away some performance, but you could mitigate this by coding these yourself. http://msdn.microsoft.com/en-us/library/z1z2bkx2.aspx Again, I don't have experience with Oracle db to say if this is even possible, but I don't see why it wouldn't work.
... View more
11-16-2010
09:19 AM
|
0
|
0
|
781
|
|
POST
|
Unfortunately, I do not know C++ at all or have access to a C++ developer. I do have C++ as part of my Visual Studio 2008 install however but am cluless on how to ever start coding in C++. I've spent the last 15 months teaching myself C# and it's been a mighty steep learning curve switching from VBA. If you know enough C++ or you have access to a C++ developer, you can always write a little proof of concept. If you find it is 10X faster it might be a lot easier to convince the decision makers with hard proof. If you only get small gains then you don't need to bother convincing people.
... View more
11-09-2010
11:01 AM
|
0
|
0
|
781
|
|
POST
|
Matt, Thanks for the reply. Unfortunately, we are only allowed to develop code in C#. Can C++ be easily converted to C#? Carlos We had this same problem and the real bottleneck is if you use a .NET language there is a delay on the interop between COM and .NET. Each time you update a feature there is an interop delay between COM and the .NET wrapper. If you use straight C++ COM you will see a HUGE performance increase. We were trying to update >100,000 records took almost an hour to run through the loop with .NET and a couple minutes with pure C++/COM. Unfortunately you will not find much information out there about this in the ESRI documentation. There is one page: http://help.arcgis.com/en/sdk/10.0/arcobjects_net/conceptualhelp/index.html#//0001000000wm000000 It suggests you use managed c++, but I think you will find it is easier and faster to completely skip out on .NET and just use straight COM. Which is not well documented either. If you need some sample code to get started in C++ I can help you with that.
... View more
11-09-2010
09:17 AM
|
0
|
0
|
1850
|
|
POST
|
Steve, Thanks for the reply, unfortunately, I am not familiar with PL/SQL at all. 😞 Carlos You have too much overhead doing your updates with ArcObjects and ADO .Net. If all you're doing is updating attributes than perhaps you should consider doing this operation in Oracle with PL/SQL. If you are concerned about versioning than look into the Oracle packages supplied by ESRI to deal with using SQL on versioned data. Just as a reference, I once updated a versioned SDE featureclass with 1.7+ million records in 5 to 6 hours using PL/SQL where it would of taken me days using ArcObjects.
... View more
11-09-2010
08:53 AM
|
0
|
0
|
1850
|
|
POST
|
Alexander, Thanks for your suggestions. To speed up testing, I reduced the number of records to 1,000 in my test layer and it appears that the bottle neck is the update cursor. Without the Oracle query and using dummy values, it took 2:35 minutes and with the Oracle query it took 2:45 minutes. Setting recycling to true had no effect and I could not remove the edit operation/session because I am using and update cursor which requires an edit session. The query with the sub fields had no affect either. The only thing I did not try that you suggested is the ado.net table in local memory because I do not know how to do that. Do you have an example in VBA/VB/.NET that I can see how to do this? Carlos There a few things you can try but it is hard to tell what is the major bottle neck, the update cursor or the oracle queries. If you try the update cursor without the oracle query as a test (setting some dummy value) you may get a better idea where to focus. As far as the update cursor is concerned, you can try removing the edit operation and edit session, that is like using the field calculator outside of an edit session (no undo) and you can try setting the recycling to true. You can also create a query filter with a null where clause but where you restrict the sub fields and pass it into the update method. Querying only the fields you need might help a little. As far as oracle is concerned, perhaps querying all the rows into a ado.net table in local memory and then selecting the rows from there might be more efficient.
... View more
11-09-2010
08:52 AM
|
0
|
0
|
1850
|
|
POST
|
Hi everyone, I know this question has been asked many times in the past but I have tried every suggestion I found on the forums (been going through them for a week now) and have had little success in improving the speed of my code. I have 16 SDE layers with a combined 75,000+ features. I have to go through every feature in every layer, run an Oracle query against one table and populate 49 fields in the SDE layer with this info. The code below works fine but takes three hours to run and my boss wants the info updated every hour. I've tried joining the table to each layer instead of doing the Oracle query and used ICalculator with IDisplayTable to update the fields but this took even longer, 9 hours. I've also tried search cursors, IFeature::Store and several others that I can't think of right now but they all have worse performance. For the sake of brevity, I'm only showing three fields in the query/code and hard coded the layer. The full code is MUCH longer than it is here. Does anyone have an idea how I can speed this code up? Thanks, Carlos public static void ProcessLayer()
{
try
{
Type appRefType = Type.GetTypeFromProgID("esriFramework.AppRef");
object appRefObj = Activator.CreateInstance(appRefType);
IApplication pApplication = appRefObj as IApplication;
IMxDocument pMxDocument = (IMxDocument)pApplication.Document;
IMap pMap = pMxDocument.FocusMap;
IFeatureLayer pFeatureLayer = new FeatureLayerClass();
pFeatureLayer = pMap.get_Layer(0) as IFeatureLayer;
IFeatureClass pFeatureClass = pFeatureLayer.FeatureClass as IFeatureClass;
//get the Workspace from the IDataset interface on the feature class
IDataset pDataset = pFeatureClass as IDataset;
IWorkspace pWorkspace = pDataset.Workspace;
//Get a handle to the editor extension.
UID pUID = new UIDClass();
pUID.Value = "esriEditor.Editor";
IEditor pEditor = (IEditor)pApplication.FindExtensionByCLSID(pUID);
pEditor.StartEditing(pWorkspace);
pEditor.StartOperation();
IFeatureCursor pFeatureCursor = pFeatureClass.Update(null, false);
int permitNoIdx = pFeatureCursor.FindField("PERMIT_NO");
int appNoIdx = pFeatureCursor.FindField("APP_NO");
int projectNameIdx = pFeatureCursor.FindField("PROJECT_NAME");
string appNo = string.Empty;
string permitNo = string.Empty;
string projectName = string.Empty;
OracleConnection dataConnection = new OracleConnection();
dataConnection.ConnectionString = "Data Source=genp;" +
"Persist Security Info=True;" +
"User ID=pub;" +
"Password=pub;" +
"Unicode=True";
dataConnection.Open();
OracleCommand dataCommand = new OracleCommand();
dataCommand.Connection = dataConnection;
IFeature pFeature = pFeatureCursor.NextFeature();
while (pFeature != null)
{
appNo = pFeature.get_Value(appNoIdx).ToString();
dataCommand.CommandText = "SELECT PERMIT_NO, PROJECT_NAME " +
"FROM reg_gis " +
"WHERE app_no = '" + appNo + "'";
OracleDataReader dataReader = dataCommand.ExecuteReader();
while (dataReader.Read())
{
if (!dataReader.IsDBNull(0))
{
permitNo = dataReader.GetString(0);
pFeature.set_Value(permitNoIdx, permitNo);
}
if (!dataReader.IsDBNull(1))
{
projectName = dataReader.GetString(1);
pFeature.set_Value(projectNameIdx, projectName);
}
}
dataReader.Close();
pFeatureCursor.UpdateFeature(pFeature);
pFeature = pFeatureCursor.NextFeature();
//Clear values.
appNo = string.Empty;
permitNo = string.Empty;
projectName = string.Empty;
}
//Stop editing
//pWorkspaceEdit.StopEditOperation();
//pWorkspaceEdit.StopEditing(true);
pEditor.StopOperation("Done");
pEditor.StopEditing(true);
//Release the Cursor
System.Runtime.InteropServices.Marshal.ReleaseComObject(pFeatureCursor);
}
catch (Exception ex)
{
MessageBox.Show(ex.StackTrace + "\r\n" + ex.Message, "Warning", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
... View more
11-08-2010
10:04 AM
|
0
|
16
|
6283
|
|
POST
|
Thanks everyone for your help! I think I am on the right track. I have been able to create a stand alone C# executeable that grabs a bunch of SDE layers, joins them to an Oracle table and creates new layers with the joined attributes. All without having to call up ArcMap! Now I have to expand it to do all the other things the VBA code did but with all of your help I've gotten this far and I REALLY appreciate everyones help! Thanks, Carlos
... View more
11-01-2010
12:08 PM
|
0
|
0
|
1400
|
|
POST
|
Steve, Thank you VERY much for the sample code, this should help a lot! I have VB.Net on this machine too so I'll get it working there first and then port it to C#. Carlos
... View more
10-28-2010
11:13 AM
|
0
|
0
|
1400
|
|
POST
|
By exhibit I mean creating a layout with predetermined elements, (scale bar, tittle, etc.) and exporting it as a jpg. You have me VERY intrigued. Do you have sample code in either C#, VB or VBA where you use IMapDocument to do some of things I mentioned without opening ArcMap? I'm not sure what you mean by exhibit but it's highly unlikely you need ArcMap. The IMapDocument interface allows you to open a document and access the map, the layout, the map layers, etc. You can make changes and save those changes.
... View more
10-28-2010
10:19 AM
|
0
|
0
|
1400
|
|
POST
|
Neil, Thanks for the reply. The processes the program does is merge several layers into one, create a new layer that buffers all the polygons in the merged layer and then does a spatial query between an area of concern layer with the merged layer as well as the buffered layer. Lastly, it gets lot information from Oracle tables, puts everything into an Access database and makes automatic exhibits for each polygon falling in an area of concern. I probably don't need ArcMap for some of the steps, but I'm pretty sure I need it for the spatial queries and exhibits. Carlos If all you're doing is processing data then you don't need ArcMap at all. Just write a standalone program that accesses the data directly and does what it needs to do. If you need information from the map document, use IMapDocument to open it.
... View more
10-28-2010
09:28 AM
|
0
|
0
|
1400
|
|
POST
|
Alexander, Thanks for the reply! I've only done one extension before and it was quite a struggle to learn it. I was hoping to avoid having to create an extension for it. I don't mind changing the design if I can find a better way of doing it so if you have other ideas, I'm all ears. Thanks, Carlos! Well there is at least 3-4 more elegant ways of doing this sort of thing depending on the nature of the operations the code is doing. However if you just want to migrate changing the least things to your design, there is a MxDocument_OpenDocument event in C#. You need to create an ArcMap extension and create a listener in the oncreate event of the extension to the IDocumentEvents OpenDocument event and put your code in there. Putting the code in the oncreate of the event is a possibility too but typically ArcMap is not finished loading at that time.
... View more
10-28-2010
09:22 AM
|
0
|
0
|
1400
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 02-11-2016 06:06 AM | |
| 1 | 08-07-2015 10:13 AM | |
| 2 | 06-29-2015 12:45 PM |
| Online Status |
Offline
|
| Date Last Visited |
11-11-2020
02:23 AM
|