[postgis-users] RC6 + ArcObjects

strk at refractions.net strk at refractions.net
Tue Apr 12 13:18:36 PDT 2005


On Tue, Apr 12, 2005 at 03:43:20PM -0400, Abe Gillespie wrote:
> Well, I did do a few small by-hand tests going from WKB to ArcObjects
> and vice versa (in fact, some where examples from MySQL ... heh). 
> Those all worked ok.  Maybe I just havn't come up with the right
> example yet.  The weird thing though, is a given record will work
> sometimes but other times not.  That's where I'm confused.

If you can get postgis return different results with the
same query on the same record that would be a good bug report!

--strk;

> 
> Anyone know where I can get my hands on the WKB spec?
> 
> Thanks for the help.
> -Abe
> 
> On Apr 12, 2005 3:26 PM, Darren Houston <dhouston at beyondcompliance.ca> wrote:
> > Hello Abe,
> > 
> > I didn't spend much time on the following situation so I don't know how
> > correct this statement is.
> > 
> > I have a friend who is playing around with MySQL WKB and ArcObjects. He is
> > having similar problems as you. Looking deeper, he found that the WKB
> > ArcObjects produced is not the same as WKB from MySQL and therefore probably
> > PostGIS. I looked at the WKB that he sent me for the same point from
> > ArcObjects and MySQL - MySQL looked correct but ArcObjects WKB looked wrong
> > (it started off with what looked like default bits for padding or something
> > else specific to ArcObjects). I would honestly look at the WKB objects from
> > ArcObjects as the problem, comparing input and output. Like I said, I looked
> > at both WKB outputs and told my friend "MySQL is right, ArcObjects is wrong".
> > That is as far as I took it. But nonetheless, I hope this helps you some.
> > 
> > Darren H.
> > 
> > On April 12, 2005 11:51 am, Abe Gillespie wrote:
> > > 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
> > >
> > > _______________________________________________
> > > 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