[postgis-users] RC6 + ArcObjects

strk at refractions.net strk at refractions.net
Tue Apr 12 10:43:17 PDT 2005


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




More information about the postgis-users mailing list