[postgis-users] RC6 + ArcObjects

Abe Gillespie abe.gillespie at gmail.com
Tue Apr 12 10:51:15 PDT 2005


The SQL query always succeeds.  It's when the WKB data is converted to
an ArcObject via geoEnv.CreateGeometryFromWkbVariant(bin, out geo, out
byteCnt) do I encounter intermittent problems.  I realize this could
be a problem with the CreateGeometryFromWkbVariant call, but could it
be data from PostGIS causing the problem?  I'm not sure how to verify
this.

-Abe

On Apr 12, 2005 1:43 PM, strk at refractions.net <strk at refractions.net> wrote:
> Abe, if you want to find out you should try to provide
> a simple SQL-only script showing the problem.
> --strk;
> 
> On Tue, Apr 12, 2005 at 12:06:05PM -0400, Abe Gillespie wrote:
> > I'm dabbling in connecting / using PostGIS in ESRI ArcObjects.  I'm
> > experiencing intermittent problems though.  I've included the code I'm
> > using below.  I realize there are three different technologies
> > entering the mix here: Npgsql, PostGIS, and ArcObjects.  However, I'm
> > led to believe the problem is with PostGIS and not the others; this
> > use to fail *every* time in earlier PostGIS releases.
> >
> > The thing to notice is different runs produce different outputs.  The
> > output being the IDs of the records throwing exceptions.
> >
> > I've attached the sql script of the problematic data.  I'd appreciate
> > it if anyone could look into this but also realize this problems spans
> > multiple areas of expertise.
> >
> > Thansk.
> > -Abe
> >
> > // begin code -->
> > using System;
> > using ESRI.ArcObjects.Core;
> > using Npgsql;
> >
> > namespace WKB
> > {
> >     class Program
> >     {
> >         static void Main(string[] args)
> >         {
> >             // Connect to PostGIS and query.
> >             NpgsqlConnection con = new NpgsqlConnection(connectionString);
> >             con.Open();
> >             NpgsqlCommand cmd = con.CreateCommand();
> >             cmd.CommandText = "select asbinary(the_geom) as shape,gid
> > from roads;";
> >             NpgsqlDataReader dr = cmd.ExecuteReader();
> >
> >             // Setup objects and ArcObjects.
> >             object bin;
> >             IGeometry geo;
> >             int byteCnt;
> >             GeometryEnvironmentClass geoEnv = new GeometryEnvironmentClass();
> >
> >             while (dr.Read())
> >             {
> >                 bin = null;
> >                 geo = null;
> >                 byteCnt = 0;
> >
> >                 bin = dr["shape"];
> >                 try
> >                 {
> >                     // Try to convert raw data into an ArcObject.
> >                     geoEnv.CreateGeometryFromWkbVariant(bin, out geo,
> > out byteCnt);
> >                 }
> >                 catch
> >                 {
> >                     // There was a failure.
> >                     // The exception always has a generic description.
> >                     Console.WriteLine(dr["gid"].ToString());
> >                     continue;
> >                 }
> >             }
> >         }
> >
> >         static private string connectionString { get { return
> > "your_con_str_here"; } }
> >     }
> > }
> > // <-- end code.
> 
> > _______________________________________________
> > postgis-users mailing list
> > postgis-users at postgis.refractions.net
> > http://postgis.refractions.net/mailman/listinfo/postgis-users
> 
> _______________________________________________
> postgis-users mailing list
> postgis-users at postgis.refractions.net
> http://postgis.refractions.net/mailman/listinfo/postgis-users
>



More information about the postgis-users mailing list