本文整理汇总了C#中ESRI.AddWarning方法的典型用法代码示例。如果您正苦于以下问题:C# ESRI.AddWarning方法的具体用法?C# ESRI.AddWarning怎么用?C# ESRI.AddWarning使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ESRI
的用法示例。
在下文中一共展示了ESRI.AddWarning方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Execute
//.........这里部分代码省略.........
{
return;
}
#endregion
#region clean any existing data from loading targets
ESRI.ArcGIS.Geoprocessing.IGeoProcessor2 gp = new ESRI.ArcGIS.Geoprocessing.GeoProcessorClass();
IGeoProcessorResult gpResult = new GeoProcessorResultClass();
try
{
IVariantArray truncateParameters = new VarArrayClass();
truncateParameters.Add(((IWorkspace)featureWorkspace).PathName + "\\" + targetDataElement.Name + "\\" + targetDataElement.Name + "_osm_pt");
gpResult = gp.Execute("TruncateTable_management", truncateParameters, TrackCancel);
truncateParameters = new VarArrayClass();
truncateParameters.Add(((IWorkspace)featureWorkspace).PathName + "\\" + targetDataElement.Name + "\\" + targetDataElement.Name + "_osm_ln");
gpResult = gp.Execute("TruncateTable_management", truncateParameters, TrackCancel);
truncateParameters = new VarArrayClass();
truncateParameters.Add(((IWorkspace)featureWorkspace).PathName + "\\" + targetDataElement.Name + "\\" + targetDataElement.Name + "_osm_ply");
gpResult = gp.Execute("TruncateTable_management", truncateParameters, TrackCancel);
truncateParameters = new VarArrayClass();
truncateParameters.Add(((IWorkspace)featureWorkspace).PathName + "\\" + targetDataElement.Name + "_osm_relation");
gpResult = gp.Execute("TruncateTable_management", truncateParameters, TrackCancel);
truncateParameters = new VarArrayClass();
truncateParameters.Add(((IWorkspace)featureWorkspace).PathName + "\\" + targetDataElement.Name + "_osm_revision");
gpResult = gp.Execute("TruncateTable_management", truncateParameters, TrackCancel);
}
catch (Exception ex)
{
message.AddWarning(ex.Message);
}
#endregion
Dictionary<string, OSMToolHelper.simplePointRef> osmNodeDictionary = null;
foreach (string osmDownloadDocument in downloadedOSMDocuments.Reverse<string>())
{
long nodeCapacity = 0;
long wayCapacity = 0;
long relationCapacity = 0;
message.AddMessage(resourceManager.GetString("GPTools_OSMGPFileReader_countingNodes"));
osmToolHelper.countOSMStuff(osmDownloadDocument, ref nodeCapacity, ref wayCapacity, ref relationCapacity, ref TrackCancel);
message.AddMessage(String.Format(resourceManager.GetString("GPTools_OSMGPFileReader_countedElements"), nodeCapacity, wayCapacity, relationCapacity));
if (osmNodeDictionary == null)
osmNodeDictionary = new Dictionary<string, OSMToolHelper.simplePointRef>(Convert.ToInt32(nodeCapacity));
#region load points
osmToolHelper.loadOSMNodes(osmDownloadDocument, ref TrackCancel, ref message, targetDatasetGPValue, osmPointFeatureClass, false, false, Convert.ToInt32(nodeCapacity), ref osmNodeDictionary, featureWorkspace, downloadSpatialReference, availableDomains, false);
#endregion
if (TrackCancel.Continue() == false)
{
return;
}
#region load ways
if (wayCapacity > 0)
{
List<string> missingWays = null;
示例2: retrieveAdditionalRelations
private string retrieveAdditionalRelations(string osmID, ref ITrackCancel TrackCancel, ESRI.ArcGIS.Geodatabase.IGPMessages message, IGPString baseURLString, HttpWebRequest httpClient, ref HttpWebResponse httpResponse)
{
string osmDocumentLocation = String.Empty;
try
{
if (TrackCancel.Continue() == false)
{
return osmDocumentLocation;
}
httpClient = HttpWebRequest.Create(baseURLString.Value + "/api/0.6/relation/" + osmID + "/full") as HttpWebRequest;
httpClient = AssignProxyandCredentials(httpClient);
httpResponse = httpClient.GetResponse() as HttpWebResponse;
osmDocumentLocation = System.IO.Path.GetTempFileName();
using (System.IO.FileStream fileStream = new System.IO.FileStream(osmDocumentLocation, FileMode.Append, FileAccess.Write))
{
using (StreamReader streamReader = new StreamReader(httpResponse.GetResponseStream()))
{
UTF8Encoding encoding = new UTF8Encoding();
byte[] byteBuffer = encoding.GetBytes(streamReader.ReadToEnd());
fileStream.Write(byteBuffer, 0, byteBuffer.Length);
}
}
}
catch (Exception ex)
{
System.Diagnostics.Debug.WriteLine(ex.Message);
message.AddWarning(ex.Message);
if (ex is WebException)
{
WebException webException = ex as WebException;
string serverErrorMessage = webException.Response.Headers["Error"];
if (!String.IsNullOrEmpty(serverErrorMessage))
{
message.AddWarning(serverErrorMessage);
}
}
}
return osmDocumentLocation;
}
示例3: Execute
//.........这里部分代码省略.........
createdByTag.v = "ArcGIS Editor for OpenStreetMap";
changeSetTags.Add(createdByTag);
tag commentTag = new tag();
commentTag.k = "comment";
commentTag.v = uploadCommentGPString.Value;
changeSetTags.Add(commentTag);
createChangeSet.tag = changeSetTags.ToArray();
createChangeSetOSM.Items = new object[] { createChangeSet };
api apiCapabilities = null;
// retrieve some server settings
try
{
httpResponse = httpClient.GetResponse() as HttpWebResponse;
osm osmCapabilities = null;
Stream stream = httpResponse.GetResponseStream();
XmlTextReader xmlReader = new XmlTextReader(stream);
osmCapabilities = serializer.Deserialize(xmlReader) as osm;
xmlReader.Close();
apiCapabilities = osmCapabilities.Items[0] as api;
httpResponse.Close();
}
catch (Exception ex)
{
System.Diagnostics.Debug.WriteLine(ex.Message);
message.AddWarning(ex.Message);
}
if (apiCapabilities != null)
{
// read the timeout parameter
secondsToTimeout = Convert.ToInt32(apiCapabilities.timeout.seconds);
httpClient.Timeout = secondsToTimeout * 1000;
// update the setting of allowed features per changeset from the actual capabilities response
maxElementsinChangeSet = Convert.ToInt32(apiCapabilities.changesets.maximum_elements);
}
// retrieve some information about the user
try
{
httpClient = null;
httpClient = HttpWebRequest.Create(baseURLGPString.Value + "/api/0.6/user/details") as HttpWebRequest;
httpClient = OSMGPDownload.AssignProxyandCredentials(httpClient);
SetBasicAuthHeader(httpClient, userCredentialGPValue.EncodedUserNamePassWord);
httpResponse = httpClient.GetResponse() as HttpWebResponse;
osm osmCapabilities = null;
Stream stream = httpResponse.GetResponseStream();
XmlTextReader xmlReader = new XmlTextReader(stream);
osmCapabilities = serializer.Deserialize(xmlReader) as osm;
xmlReader.Close();
user userInformation = osmCapabilities.Items[0] as user;
if (userInformation != null)
示例4: Execute
//.........这里部分代码省略.........
ComReleaser.ReleaseCOMObject(osmPolygonFeatureClass);
osmPolygonFeatureClass = null;
List<string> nodeOSMFileNames = new List<string>(numberOfThreads);
List<string> nodeGDBFileNames = new List<string>(numberOfThreads);
List<string> wayOSMFileNames = new List<string>(numberOfThreads);
List<string> wayGDBFileNames = new List<string>(numberOfThreads);
List<string> relationOSMFileNames = new List<string>(numberOfThreads);
List<string> relationGDBFileNames = new List<string>(numberOfThreads);
if (TrackCancel.Continue() == false)
{
return;
}
// split the original OSM xml file into smaller pieces for the python processes
osmToolHelper.splitOSMFile(osmFileLocationString.GetAsText(), scratchWorkspaceFolder, nodeCapacity, wayCapacity, relationCapacity, numberOfThreads,
out nodeOSMFileNames, out nodeGDBFileNames, out wayOSMFileNames, out wayGDBFileNames, out relationOSMFileNames, out relationGDBFileNames);
IGPParameter deleteSourceOSMFileParameter = paramvalues.get_Element(in_deleteOSMSourceFileNumber) as IGPParameter;
IGPBoolean deleteSourceOSMFileGPValue = gpUtilities3.UnpackGPValue(deleteSourceOSMFileParameter) as IGPBoolean;
if (deleteSourceOSMFileGPValue.Value)
{
try
{
System.IO.File.Delete(osmFileLocationString.GetAsText());
}
catch (Exception ex)
{
message.AddWarning(ex.Message);
}
}
if (TrackCancel.Continue() == false)
{
return;
}
if (nodeOSMFileNames.Count == 0)
{
nodeOSMFileNames.Add(osmFileLocationString.GetAsText());
nodeGDBFileNames.Add(osmPointsFeatureClassGPValue.GetAsText());
wayOSMFileNames.Add(osmFileLocationString.GetAsText());
wayGDBFileNames.Add(osmLineFeatureClassGPValue.GetAsText());
relationOSMFileNames.Add(osmFileLocationString.GetAsText());
relationGDBFileNames.Add(osmPolygonFeatureClassGPValue.GetAsText());
}
else
{
// for the nodes let's load one of the parts directly into the target file geodatabase
nodeGDBFileNames[0] = ((IWorkspace)pointFeatureWorkspace).PathName;
}
// define variables helping to invoke core tools for data management
IGeoProcessorResult2 gpResults2 = null;
IGeoProcessor2 geoProcessor = new GeoProcessorClass();
IGPParameter deleteSupportingNodesParameter = paramvalues.get_Element(in_deleteSupportNodesNumber) as IGPParameter;
IGPBoolean deleteSupportingNodesGPValue = gpUtilities3.UnpackGPValue(deleteSupportingNodesParameter) as IGPBoolean;
示例5: Execute
//.........这里部分代码省略.........
{
return;
}
#region clean any existing data from loading targets
ESRI.ArcGIS.Geoprocessing.IGeoProcessor2 gp = new ESRI.ArcGIS.Geoprocessing.GeoProcessorClass();
IGeoProcessorResult gpResult = new GeoProcessorResultClass();
try
{
IVariantArray truncateParameters = new VarArrayClass();
truncateParameters.Add(((IWorkspace)featureWorkspace).PathName + "\\" + targetDataElement.Name + "\\" + targetDataElement.Name + "_osm_pt");
gpResult = gp.Execute("TruncateTable_management", truncateParameters, TrackCancel);
truncateParameters = new VarArrayClass();
truncateParameters.Add(((IWorkspace)featureWorkspace).PathName + "\\" + targetDataElement.Name + "\\" + targetDataElement.Name + "_osm_ln");
gpResult = gp.Execute("TruncateTable_management", truncateParameters, TrackCancel);
truncateParameters = new VarArrayClass();
truncateParameters.Add(((IWorkspace)featureWorkspace).PathName + "\\" + targetDataElement.Name + "\\" + targetDataElement.Name + "_osm_ply");
gpResult = gp.Execute("TruncateTable_management", truncateParameters, TrackCancel);
truncateParameters = new VarArrayClass();
truncateParameters.Add(((IWorkspace)featureWorkspace).PathName + "\\" + targetDataElement.Name + "_osm_relation");
gpResult = gp.Execute("TruncateTable_management", truncateParameters, TrackCancel);
truncateParameters = new VarArrayClass();
truncateParameters.Add(((IWorkspace)featureWorkspace).PathName + "\\" + targetDataElement.Name + "_osm_revision");
gpResult = gp.Execute("TruncateTable_management", truncateParameters, TrackCancel);
}
catch (Exception ex)
{
message.AddWarning(ex.Message);
}
#endregion
bool fastLoad = false;
//// check for user interruption
//if (TrackCancel.Continue() == false)
//{
// message.AddAbort(resourceManager.GetString("GPTools_toolabort"));
// return;
//}
//IFeatureCursor deleteCursor = null;
//using (ComReleaser comReleaser = new ComReleaser())
//{
// // let's make sure that we clean out any old data that might have existed in the feature classes
// deleteCursor = osmPointFeatureClass.Update(null, false);
// comReleaser.ManageLifetime(deleteCursor);
// for (IFeature feature = deleteCursor.NextFeature(); feature != null; feature = deleteCursor.NextFeature())
// {
// feature.Delete();
// // check for user interruption
// if (TrackCancel.Continue() == false)
// {
// message.AddAbort(resourceManager.GetString("GPTools_toolabort"));
// return;
// }
// }
//}
示例6: Execute
//.........这里部分代码省略.........
{
// Check if the input field already exists.
string nameofTag = tagCollectionGPValue.get_Value(valueIndex).GetAsText();
tagKey = convert2AttributeFieldName(nameofTag, illegalCharacters);
int fieldIndex = osmInputTable.FindField(tagKey);
if (fieldIndex < 0)
{
// generate a new attribute field
IFieldEdit fieldEdit = new FieldClass();
fieldEdit.Name_2 = tagKey;
fieldEdit.AliasName_2 = nameofTag + resourceManager.GetString("GPTools_OSMGPAttributeSelector_aliasaddition");
fieldEdit.Type_2 = esriFieldType.esriFieldTypeString;
fieldEdit.Length_2 = 100;
osmInputTable.AddField(fieldEdit);
message.AddMessage(string.Format(resourceManager.GetString("GPTools_OSMGPAttributeSelector_addField"), tagKey, nameofTag));
// re-generate the attribute index
fieldIndex = osmInputTable.FindField(tagKey);
}
if (fieldIndex > 0)
{
tagsAttributesIndices.Add(nameofTag, fieldIndex);
attributeFieldLength.Add(fieldIndex, osmInputTable.Fields.get_Field(fieldIndex).Length);
}
}
catch (Exception ex)
{
// the key is already there, this might result because from multiple upper and lower-case combinations of the same key
message.AddWarning(ex.Message + " (" + convert2OSMKey(tagKey, illegalCharacters) + ")");
}
}
}
else
{
List<string> listofAllTags = extractAllTags(osmInputTable, osmQueryFilter, osmTagCollectionFieldIndex);
foreach (string nameOfTag in listofAllTags)
{
if (TrackCancel.Continue() == false)
return;
try
{
// Check if the input field already exists.
tagKey = convert2AttributeFieldName(nameOfTag, illegalCharacters);
int fieldIndex = osmInputTable.FindField(tagKey);
if (fieldIndex < 0)
{
// generate a new attribute field
IFieldEdit fieldEdit = new FieldClass();
fieldEdit.Name_2 = tagKey;
fieldEdit.AliasName_2 = nameOfTag + resourceManager.GetString("GPTools_OSMGPAttributeSelector_aliasaddition");
fieldEdit.Type_2 = esriFieldType.esriFieldTypeString;
fieldEdit.Length_2 = 100;
osmInputTable.AddField(fieldEdit);
message.AddMessage(string.Format(resourceManager.GetString("GPTools_OSMGPAttributeSelector_addField"), tagKey, nameOfTag));
示例7: Execute
//.........这里部分代码省略.........
IFeature matchFeature = null;
while ((matchFeature = matchFeatureCursor.NextFeature()) != null)
{
IPointCollection intersectionPointCollection = null;
try
{
ITopologicalOperator topoOperator = sourceLine as ITopologicalOperator;
if (topoOperator.IsSimple == false)
{
((ITopologicalOperator2)topoOperator).IsKnownSimple_2 = false;
topoOperator.Simplify();
}
IPolyline matchPolyline = matchFeature.Shape as IPolyline;
if (queryFilter != null)
{
matchPolyline.Project(sourceLine.SpatialReference);
}
if (((ITopologicalOperator)matchPolyline).IsSimple == false)
{
((ITopologicalOperator2)matchPolyline).IsKnownSimple_2 = false;
((ITopologicalOperator)matchPolyline).Simplify();
}
intersectionPointCollection = topoOperator.Intersect(matchPolyline, esriGeometryDimension.esriGeometry0Dimension) as IPointCollection;
}
catch (Exception ex)
{
message.AddWarning(ex.Message);
continue;
}
if (intersectionPointCollection != null && intersectionPointCollection.PointCount > 0)
{
numberOfIntersections = numberOfIntersections + intersectionPointCollection.PointCount;
if (String.IsNullOrEmpty(intersectedFeatures))
{
intersectedFeatures = matchFeature.OID.ToString();
}
else
{
intersectedFeatures = intersectedFeatures + "," + matchFeature.OID.ToString();
}
}
}
if (numberOfIntersectionsFieldIndex > -1)
{
sourceFeature.set_Value(numberOfIntersectionsFieldIndex, numberOfIntersections);
}
if (sourceRefIDFieldIndex > -1)
{
if (intersectedFeatures.Length > sourceFeatureClass.Fields.get_Field(sourceRefIDFieldIndex).Length)
{
sourceFeature.set_Value(sourceRefIDFieldIndex, intersectedFeatures.Substring(0, sourceFeatureClass.Fields.get_Field(sourceRefIDFieldIndex).Length));
}
else
{
sourceFeature.set_Value(sourceRefIDFieldIndex, intersectedFeatures);
示例8: Execute
public void Execute(ESRI.ArcGIS.esriSystem.IArray paramvalues, ESRI.ArcGIS.esriSystem.ITrackCancel TrackCancel, ESRI.ArcGIS.Geoprocessing.IGPEnvironmentManager envMgr, ESRI.ArcGIS.Geodatabase.IGPMessages message)
{
try
{
IGPUtilities3 gpUtilities3 = new GPUtilitiesClass();
if (TrackCancel == null)
{
TrackCancel = new CancelTrackerClass();
}
IGPParameter inputSourceLayerParameter = paramvalues.get_Element(in_sourcelayerNumber) as IGPParameter;
IGPValue inputSourceLayerGPValue = gpUtilities3.UnpackGPValue(inputSourceLayerParameter) as IGPValue;
IGPParameter inputTargetLayerParameter = paramvalues.get_Element(in_targetlayerNumber) as IGPParameter;
IGPValue inputTargetLayerGPValue = gpUtilities3.UnpackGPValue(inputTargetLayerParameter) as IGPValue;
ILayer sourceLayer = gpUtilities3.DecodeLayer(inputSourceLayerGPValue);
ILayer targetLayer = gpUtilities3.DecodeLayer(inputTargetLayerGPValue);
ILayerExtensions sourceLayerExtensions = sourceLayer as ILayerExtensions;
if (sourceLayerExtensions == null)
{
message.AddWarning(resourceManager.GetString("GPTools_GPCopyLayerExtension_source_noext_support"));
return;
}
ILayerExtensions targetLayerExtensions = targetLayer as ILayerExtensions;
if (targetLayerExtensions == null)
{
message.AddWarning(resourceManager.GetString("GPTools_GPCopyLayerExtension_target_noext_support"));
return;
}
// test if the feature classes already exists,
// if they do and the environments settings are such that an overwrite is not allowed we need to abort at this point
IGeoProcessorSettings gpSettings = (IGeoProcessorSettings)envMgr;
if (gpSettings.OverwriteOutput == true)
{
}
else
{
if (gpUtilities3.Exists(inputTargetLayerGPValue) == true)
{
message.AddError(120003, String.Format(resourceManager.GetString("GPTools_GPCopyLayerExtension_targetlayeralreadyexists"), inputTargetLayerGPValue.GetAsText()));
return;
}
}
for (int targetExtensionIndex = 0; targetExtensionIndex < targetLayerExtensions.ExtensionCount; targetExtensionIndex++)
{
targetLayerExtensions.RemoveExtension(targetExtensionIndex);
}
for (int sourceExtensionIndex = 0; sourceExtensionIndex < sourceLayerExtensions.ExtensionCount; sourceExtensionIndex++)
{
targetLayerExtensions.AddExtension(sourceLayerExtensions.get_Extension(sourceExtensionIndex));
}
}
catch (Exception ex)
{
message.AddError(120004, ex.Message);
}
}
示例9: UpdateSpatialGridIndex
private void UpdateSpatialGridIndex(ESRI.ArcGIS.esriSystem.ITrackCancel TrackCancel, ESRI.ArcGIS.Geodatabase.IGPMessages message, IGeoProcessor2 geoProcessor, string inputFeatureClass)
{
IVariantArray parameterArrary = null;
IGeoProcessorResult2 gpResults2 = null;
parameterArrary = CreateDefaultGridParamterArrary(inputFeatureClass);
gpResults2 = geoProcessor.Execute("CalculateDefaultGridIndex_management", parameterArrary, TrackCancel) as IGeoProcessorResult2;
List<double> gridIndexList = new List<double>(3);
for (int index = 0; index < gpResults2.OutputCount; index++)
{
string gridIndexString = gpResults2.GetOutput(index).GetAsText();
double gridIndexValue = 0;
Double.TryParse(gridIndexString, out gridIndexValue);
gridIndexList.Add(gridIndexValue);
}
// delete the current spatial index if it does exist
// this is expected to fail if no such index exists
try
{
gpResults2 = geoProcessor.Execute("RemoveSpatialIndex_management", parameterArrary, TrackCancel) as IGeoProcessorResult2;
}
catch (Exception ex)
{
message.AddWarning(ex.Message);
if (gpResults2 != null)
{
message.AddMessages(gpResults2.GetResultMessages());
}
}
parameterArrary = CreateAddGridIndexParameterArray(inputFeatureClass, gridIndexList[0], gridIndexList[1], gridIndexList[2]);
gpResults2 = geoProcessor.Execute("AddSpatialIndex_management", parameterArrary, TrackCancel) as IGeoProcessorResult2;
}