createGeometryFromWkbVariant giving Null Pointer exception

2250
1
Jump to solution
01-20-2016 10:54 PM
ImranRajjad
New Contributor III

I have been trying to use the  IGeometryFactoryProxy.createGeometryFromWkbVariant to convert OGC WKB into an IGeometry object. I have had no luck with this at all. Was unable to find any Java example on this. The Wkb bytes are valid since I am able to convert them into geometry using another third party API esri-geometry-core. The doucumentation suggests that I should pass in the byte[], a single element array of IGeometry (I have no idea if this array should be empty or populated with empty geometry but I assigned an empty geometry anyways), lastly a single element int[1] which holds the size of WKB at [0]. as suggested by the documentation. I get Null Pointer exception with the following stack

java.lang.NullPointerException

        at com.esri.arcgis.interop.Dispatch.vtblInvoke(Unknown Source)

        at com.esri.arcgis.geometry.IGeometryFactoryProxy.createGeometryFromWkbV

ariant(Unknown Source)

my java code

IGeometry[] geomArr = new IGeometry[1];

geomArr[0]=new com.esri.arcgis.geometry.Polygon(); //populate with an empty polygon

byte[] wkb = ... //populate bytes array

int[] intArr = new int[1];

intArr[0]=wkb.length; //size of bytes

IGeometryFactory3Proxy geometryFactory = new IGeometryFactory3Proxy();

  geometryFactory.createGeometryFromWkb(intArr, wkb, geomArr); //tried this

  geometryFactory.createGeometryFromWkbVariant(wkb, geomArr, intArr); //also tried this

  geomArr[0].toString();

any idea what am I doing wrong.

0 Kudos
1 Solution

Accepted Solutions
ImranRajjad
New Contributor III

Ok I have solved it, thanks and no thanks to terrible arcobjects java code samples folks

instead of using IGeometryFactory3Proxy use GeometryEnvironment and use createGeometryFromWkbVariant(wkb, geomArr, intArr)

hope this helps somebody

View solution in original post

0 Kudos
1 Reply
ImranRajjad
New Contributor III

Ok I have solved it, thanks and no thanks to terrible arcobjects java code samples folks

instead of using IGeometryFactory3Proxy use GeometryEnvironment and use createGeometryFromWkbVariant(wkb, geomArr, intArr)

hope this helps somebody

0 Kudos