Reshaping polygon throws error

1109
8
07-25-2013 07:36 AM
CarstenSchumann
Occasional Contributor
Hey there,

after being glad to have solved my last problem I just come up with a new one which I can´t figure out. When reshaping a polygon I use Ring#Reshape(IPath), which gives me a boolean if all worked fine. Unfortunelty it won´t give me any return-value but an exception which is -2147220936. I just looked the codes and found NETWORK_E_EDIT_SESSION_IN_PROGRESS but as the last problem wasn´t related with any Network-features (since I do not use them at all) I´ll bet this error has also nothing to do with this confusing message. So I googled for the error-code and found out that the actual error-message to this code is "The coordinates or measures are out of bounds." (which I cannot conform again as I do not receive any error-message). But as the concerned feature is located in the centre of my featureClass I cannot imagine this is really the clue. So which error is right and what exactly does it have to do with my problem of reshaping an IRing?
0 Kudos
8 Replies
WeifengHe
Occasional Contributor II
Without seeing the actual data and code, I can only take a guess on the cause of the problem.

The error message should be "The coordinates or measures are out of bounds."  rather than the other one you mentioned, NETWORK_E_EDIT_SESSION_IN_PROGRESS.  The error code associated with this error message can be returned from various places in ArcGIS library.  In addition to check the feature geometry's location in the coordinate system, the attributes measurement such as Z and M is also considered as the possible cause here.  Also, if the geometry involves curve segment, like bezier, clothid, etc., can sometimes also causes this problem during the process.
0 Kudos
CarstenSchumann
Occasional Contributor
Thanks for the reply,

as I do not enabled m- or z-values I can ensure thats not the problem. I post some code that may help to identify the problem:

IGeometryCollection rings = (IGeometryCollection) editGeometry; // the rings of the edit-geometry
IGeometryCollection paths = (IGeometryCollection) reshaper; // the paths of the reshaper

if (paths.GeometryCount > 1) throw new ArgumentException("The reshape-geometry must be single-part");

for (int i = 0; i < rings.GeometryCount; i++) {

// get the affected rings of the current polygon

IRelationalOperator relOp1 = (IRelationalOperator) reshaper.FromPoint;
IRelationalOperator relOp2 = (IRelationalOperator) reshaper.ToPoint;
// check if Ring touches from- and toPoint of the reshaper
if (relOp1.Touches(singlePolygon) && relOp2.Touches(singlePolygon)) {
  IPath path = (IPath) paths.get_Geometry(0);
  bool res = ring.Reshape(path);   
  // only in case of success the ring is reshaped
  if (res && !ring.IsEmpty) return editGeometry;
}
}


I just figured out that the spatial-reference of the from- and toPoint of the ring is NULL although the rings reference-system is set. As this was also the problem on my last topic I assume it also has to do with the current one, but I don´t know why the reference gets lost or how I can reset it if the according ring already has one...

EDIT: Sry, I had a writing-mistake, the error-code is -2147220935 rather then 936, so it fits to the received error-message: "an internal error has occured in the geometry system".
0 Kudos
WeifengHe
Occasional Contributor II
Are the shaper geometry and edit geometry simple?
0 Kudos
CarstenSchumann
Occasional Contributor
Are the shaper geometry and edit geometry simple?

Yeap, checked it out bye making QI-call to ITopologicalOperator.
0 Kudos
WeifengHe
Occasional Contributor II
Can you please send the data containing the 2 geometries only.  I will write a piece of code to try to repro the problem.
0 Kudos
CarstenSchumann
Occasional Contributor
I try to...

The masterClass serves only for information, this is where the Reshaper came from. The slave (in the code above this is the editGeometry) should be reshaped by the Reshaper that has been derived from the MasterClass.

I hope it works...
0 Kudos
WeifengHe
Occasional Contributor II
Using the data you provided, I wrote a piece of VBA code, and the reshape call generates correct result.

Sub Test_Reshape()
    Dim mxDoc As IMxDocument
    Set mxDoc = ThisDocument
    Dim featLyr As IFeatureLayer
    Dim featCls As IFeatureClass
    Set featLyr = mxDoc.FocusMap.Layer(0) 'PolylineFC
    Set featCls = featLyr.FeatureClass
    Dim feat0 As IFeature
    Set feat0 = featCls.GetFeature(0)
    Dim geomColl0 As IGeometryCollection
    Set geomColl0 = feat0.ShapeCopy
    Dim geom0 As IGeometry
    Set geom0 = geomColl0.Geometry(0)
    Debug.Print geom0.GeometryType
   
    Set featLyr = mxDoc.FocusMap.Layer(1) 'SlaveClass
    Set featCls = featLyr.FeatureClass
    Dim feat1 As IFeature
    Set feat1 = featCls.GetFeature(0)
    Dim geomColl1 As IGeometryCollection
    Set geomColl1 = feat1.ShapeCopy
    Dim geom1 As IGeometry
    Set geom1 = geomColl1.Geometry(0)
    Debug.Print geom1.GeometryType
   
  
    Dim ring As IRing
    Set ring = geom1
    Dim path As IPath
    Set path = geom0
   
    Debug.Print ring.Reshape(path)
    Debug.Print ring.IsEmpty

End Sub
0 Kudos
CarstenSchumann
Occasional Contributor
As I already assumed reproducing this error could become hard...
0 Kudos