VB.Net - GetGeometry only returns a ShapeBuffer

2553
2
05-17-2012 04:04 PM
DavidTriggs
New Contributor III
I have been playing with the API in VB.net and can not get a geometry from the GetGeometry() function.

According to the C# examples:
PointShapeBuffer pointGeometry = row.GetGeometry();
          point = pointGeometry.point;

In Vb.net the GetGeometry function explicity states it returns a ShapeBuffer. It will not accept a CType converstion to PointShapeBuffer, and will not accept a PointShapeBuffer as an output. The Help states the Geometry function returns a ShapeBuffer so I do not understand how to get a point from (Get)Geometry function.

Any advice would be appreciated.

David
0 Kudos
2 Replies
SiqiLi
by Esri Contributor
Esri Contributor
I have been playing with the API in VB.net and can not get a geometry from the GetGeometry() function.

According to the C# examples:
PointShapeBuffer pointGeometry = row.GetGeometry();
          point = pointGeometry.point;

In Vb.net the GetGeometry function explicity states it returns a ShapeBuffer. It will not accept a CType converstion to PointShapeBuffer, and will not accept a PointShapeBuffer as an output. The Help states the Geometry function returns a ShapeBuffer so I do not understand how to get a point from (Get)Geometry function.

Any advice would be appreciated.

David


Hi David,
I am running into a very similar issue on casting ShapeBuffer to MultipartBuffer. I find the cast works with .NET Wrapper-C#, but not with VB.net. I don't know why exactly the cast fails with VB.net, and I am trying to find out too. I guess it has something to do with generated C++\CLI .NET code. But, anyway, give C# a try, hope it also fix the issue at your end too. Thanks.
0 Kudos
WillFreeman
New Contributor

Anyone still having problems with this in VB.Net?  I ran on to the same problem with version 1.4 as well as 1.5. I wrote a C# DLL with some "Get Geometry" functions to deal with all the buffer types.  One point to note is that when the new geometry is returned, it still shows as a ShapeBuffer in debugging, but you can still access the PointShapeBuffer, MultiPointShapeBuffer, MultiPartShapeBuffer, MultiPatchShapeBuffer properties regardless.  I hope this helps someone:

Usage:

Imports ESRIFileGDB.ConvertShapeBuffer

.

.

.

Dim geometry As New PointShapeBuffer = GetPointGeometry(row)

----------------------------------------------------------------------------------------------------------

ESRIFileGDB.cs

===============================

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Esri.FileGDB;

namespace ESRIFileGDB
{
    public class ConvertShapeBuffer
    {

    public ConvertShapeBuffer()
    {
    }

    public static PointShapeBuffer GetPointGeometry(ref Esri.FileGDB.Row shapeRow)
    {
      try
      {
        PointShapeBuffer pointGeometry = shapeRow.GetGeometry();
        return pointGeometry;
      }
      catch
      {
        return null;
      }
    }

    public static MultiPointShapeBuffer GetMultiPointGeometry(ref Esri.FileGDB.Row shapeRow)
    {
      try
      {
        MultiPointShapeBuffer multipointGeometry = shapeRow.GetGeometry();
        return multipointGeometry;
      }
      catch
      {
        return null;
      }
    }

    public static MultiPatchShapeBuffer GetMultiPatchGeometry(ref Esri.FileGDB.Row shapeRow)
    {
      try
      {
        MultiPatchShapeBuffer patchGeometry = shapeRow.GetGeometry();
        return patchGeometry;
      }
      catch
      {
        return null;
      }
    }

    public static MultiPartShapeBuffer GetMultiPartGeometry(ref Esri.FileGDB.Row shapeRow)
    {
      try
      {
        MultiPartShapeBuffer multipartGeometry = shapeRow.GetGeometry();
        return multipartGeometry;
      }
      catch
      {
        return null;
      }
    }
    }
}

===========================================================

0 Kudos