Geographic Information Systems Asked on February 6, 2021
I have added a layer in the ArcMap. I want to see the different values of the items of this layer using the "Time Slider". For this, I have prepared a table that contains a field named DateTime and its type is Date. After completing data preparation I have joined the table with the layer using ArcObjects C# .NET AddJoin tool. After this, when I calculate the layer time extent. It set start time and end time the same as the start time.
If I remove join from the layer or skip the join operation using ArcObjects and join the table with the layer manually in ArcMap then it works fine.
public AddJoin(string inputLayerName, string inputTableField, string tableToBeJoinedPath, string toBeJoinedField)
{
_inputLayerName = inputLayerName;
_inputTableField = inputTableField;
_tableToBeJoinedPath = tableToBeJoinedPath;
_toBeJoinedField = toBeJoinedField;
}
public IGpResult Execute()
{
try
{
var addJoinTool = InitTool();
var result = _gp.Execute(addJoinTool, null) as IGeoProcessorResult;
return null;
}
catch (Exception exception)
{
return null;
}
}
private ESRI.ArcGIS.DataManagementTools.AddJoin InitTool()
{
_gp = new Geoprocessor { OverwriteOutput = true, AddOutputsToMap = false };
var addJoin = new ESRI.ArcGIS.DataManagementTools.AddJoin()
{
in_layer_or_view = _inputLayerName,
in_field = _inputTableField,
join_table = _tableToBeJoinedPath.Replace(@"", @""),
join_field = _toBeJoinedField,
join_type = "KEEP_ALL",
};
_gp.OverwriteOutput = true;
return addJoin;
}
}
How can I join it using ArcObjects and make it workable?
Instead of AddJoin geoprocessor tool, I do it with IDisplayRelationshipClass and now it's working fine.
Code developed for this:
public void Join(IFeatureLayer featureLayer, string foreignKeyField, ITable table, string primaryKeyField)
{
try
{
using (var comReleaser = new ComReleaser())
{
var memRelClassFactoryType = Type.GetTypeFromProgID("esriGeodatabase.MemoryRelationshipClassFactory");
var memRelClassFactory = (IMemoryRelationshipClassFactory)Activator.CreateInstance(memRelClassFactoryType);
var tableObjectClass = (ESRI.ArcGIS.Geodatabase.IObjectClass)table;
var geoFeatureLayer = featureLayer as ESRI.ArcGIS.Carto.IGeoFeatureLayer;
var pRelClass = memRelClassFactory.Open(table.Name + "To" + featureLayer.Name, tableObjectClass, primaryKeyField, geoFeatureLayer.DisplayFeatureClass, foreignKeyField, "ForwardPath", "BackwardPath",
esriRelCardinality.esriRelCardinalityOneToMany);
comReleaser.ManageLifetime(pRelClass);
var displayRelationshipClass = (ESRI.ArcGIS.Carto.IDisplayRelationshipClass)geoFeatureLayer;
comReleaser.ManageLifetime(displayRelationshipClass);
displayRelationshipClass.DisplayRelationshipClass(pRelClass, esriJoinType.esriLeftOuterJoin);
}
}
catch (COMException e)
{
Console.WriteLine(e);
}
}
Answered by osman on February 6, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP