usmanaleem

parsing in_memory geometry give wrong result

Discussion created by usmanaleem on Sep 18, 2011
Latest reply on Sep 19, 2011 by usmanaleem
Hi All,

I am facing some problem to read a in_memory buffer geometry i am sure about buffer for point feature. Is this is a known problem or am i doing something wrong.

So what i do i create a buffer layer (in_memory) then try to read all its respective points when i do that it only show me Two points that it. then when i try to save this layer in a shapefile and then retrive its shape points it gives me correct result list of points which is correctly. Why it is not parse correctly for (in_memory) features.  And i am working with arcobject 10 for java

here is my code.

public void doSaveBuffer1(String output)
{

  java.io.File outputFile = new java.io.File(output);

  if (outputFile.isDirectory())
  {
   JOptionPane.showMessageDialog(this,
     "The specified file is actually a directory. Please enter a shapefile name.");
   return;
  }
  String strFClassName = outputFile.getName();

  if (this.result != null)
  {
   try
   {
    ShapefileWorkspaceFactory factory = new ShapefileWorkspaceFactory();
    Workspace workspace = (Workspace) factory.openFromFile(outputFile.getParent(), 0);

    // Make sure the featureclass doesn't already exist...
    try
    {
     IFeatureClass test = workspace.openFeatureClass(strFClassName + ".shp");
     if (test != null)
     {
      JOptionPane.showMessageDialog(this, strFClassName
        + " already exists. Please specify a unique shapefile name");
      return;
     }
    }
    catch (Exception e)
    {/* It's okay if the file doesn't exist */
    }
    System.out.println("Before........................................");
    PolygonToString((Polygon)result);
    System.out.println("End Before........................................");

    // Set up the Fields...
    // Make the shape field it will need a geometry definition, with a spatial reference
    Fields fields = new Fields();
    Field field = new Field();
    field.setName("Shape");
    field.setType(esriFieldType.esriFieldTypeGeometry);

    GeometryDef geometryDef = new GeometryDef();
    geometryDef.setGeometryType(esriGeometryType.esriGeometryPolygon);
    geometryDef.setSpatialReferenceByRef(new UnknownCoordinateSystem());

    field.setGeometryDefByRef(geometryDef);
    fields.addField(field);

    // Add another miscellaneous text field
    field = new Field();
    field.setLength(30);
    field.setName("Scale");
    field.setType(esriFieldType.esriFieldTypeDouble);
    fields.addField(field);

    // Create the shapefile (some parameters apply to geodatabase options and can be defaulted as Nothing)
    IFeatureClass featureClass = workspace.createFeatureClass(strFClassName, fields, null, null,
      esriFeatureType.esriFTSimple, "Shape", "");

    // Now, add the buffer polygon as a feature
    IFeatureCursor featureCursor = featureClass.IFeatureClass_insert(true);
    IFeatureBuffer featureBuffer = featureClass.createFeatureBuffer();

    featureBuffer.setShapeByRef(result);
    int index = featureBuffer.getFields().findField("Scale");
    featureBuffer.setValue(index, new Double(Double.parseDouble(_distance)));
    featureCursor.insertFeature(featureBuffer);
    featureCursor.flush();
   
    System.out.println("After........................................");
    IFeature feature = featureClass.getFeature(0);
    PolygonToString((Polygon)feature.getShape());
    System.out.println("End After........................................");
   }
   catch (Exception e)
   {
    System.out.println("Error saving shapefile: " + e);
   }
  }
}

____________________________________________________________________________________
____________________________________________________________________________________
Here is my console result.
____________________________________________________________________________________

Before........................................
polygon.ExteriorRingCount = 1
polygon.ExteriorRing[0]
Point[0] = X : 1247230.9121495092 Y : 867691.4203271978
Point[1] = X : 1247230.9121495092 Y : 867691.4203271978
polygon.InteriorRingCount[exteriorRing0] = 0
End Before........................................


After........................................
polygon.ExteriorRingCount = 1
polygon.ExteriorRing[0]
Point[0] = X : 1247230.9121495092 Y : 867691.4203271978
Point[1] = X : 1247231.9540385758 Y : 867691.3291737156
Point[2] = X : 1247232.9642703703 Y : 867691.0584829218
Point[3] = X : 1247233.9121495108 Y : 867690.6164796194
Point[4] = X : 1247234.7688751693 Y : 867690.0165938549
Point[5] = X : 1247235.5084161703 Y : 867689.2770528536
Point[6] = X : 1247236.1083019346 Y : 867688.4203271948
Point[7] = X : 1247236.5503052366 Y : 867687.4724480541
Point[8] = X : 1247236.82099603 Y : 867686.4622162596
Point[9] = X : 1247236.9121495117 Y : 867685.4203271929
Point[10] = X : 1247236.8209960295 Y : 867684.3784381263
Point[11] = X : 1247236.550305236 Y : 867683.3682063317
Point[12] = X : 1247236.1083019334 Y : 867682.4203271911
Point[13] = X : 1247235.5084161689 Y : 867681.5636015326
Point[14] = X : 1247234.7688751677 Y : 867680.8240605317
Point[15] = X : 1247233.912149509 Y : 867680.2241747675
Point[16] = X : 1247232.9642703682 Y : 867679.7821714655
Point[17] = X : 1247231.9540385734 Y : 867679.511480672
Point[18] = X : 1247230.9121495069 Y : 867679.4203271903
Point[19] = X : 1247229.8702604403 Y : 867679.5114806725
Point[20] = X : 1247228.8600286457 Y : 867679.7821714663
Point[21] = X : 1247227.9121495052 Y : 867680.2241747687
Point[22] = X : 1247227.0554238467 Y : 867680.8240605332
Point[23] = X : 1247226.3158828458 Y : 867681.5636015345
Point[24] = X : 1247225.7159970815 Y : 867682.4203271932
Point[25] = X : 1247225.2739937794 Y : 867683.368206334
Point[26] = X : 1247225.003302986 Y : 867684.3784381285
Point[27] = X : 1247224.9121495043 Y : 867685.4203271952
Point[28] = X : 1247225.0033029865 Y : 867686.4622162618
Point[29] = X : 1247225.2739937801 Y : 867687.4724480563
Point[30] = X : 1247225.7159970826 Y : 867688.420327197
Point[31] = X : 1247226.3158828472 Y : 867689.2770528555
Point[32] = X : 1247227.0554238483 Y : 867690.0165938564
Point[33] = X : 1247227.912149507 Y : 867690.6164796206
Point[34] = X : 1247228.8600286478 Y : 867691.0584829226
Point[35] = X : 1247229.8702604426 Y : 867691.329173716
Point[36] = X : 1247230.9121495092 Y : 867691.4203271978
polygon.InteriorRingCount[exteriorRing0] = 0
End After........................................

Outcomes