[postgis-users] RC6 + ArcObjects

strk at refractions.net strk at refractions.net
Wed Apr 13 01:09:01 PDT 2005


On Tue, Apr 12, 2005 at 03:59:30PM -0700, Craig Miller wrote:
> I believe lightweight geometry (LWGEOM) stored in the database whereas the
> asBinary() function returns OGIS WKB.  
> --Craig

Canonical binary output returns EWKB.
AsBinary() returns WKB.
Postgis manual contains more info.
--strk;

> 
> 
> -----Original Message-----
> From: postgis-users-bounces at postgis.refractions.net
> [mailto:postgis-users-bounces at postgis.refractions.net] On Behalf Of Abe
> Gillespie
> Sent: Tuesday, April 12, 2005 3:50 PM
> To: PostGIS Users Discussion
> Subject: Re: [postgis-users] RC6 + ArcObjects
> 
> Ok, I've now reproduced the problem with ODBC.  The data that comes
> from the server as a byte array - in code - is different from what's
> actually in the database.  I compare values by looking at the hex
> representation in the debugger and the values in pgAdmin Query (and
> also the sql script generated by shp2pgsql to double-check).
> 
> I believe this sufficiently removes the possibility of the problem
> being in Npgsql or ArcObjects.  So I gather it's either in
> PostgreSQL's ability to xmit the correct data or a problem with the
> asbinary() func.
> 
> I'm running RC6 with the latest Windows install of Postgres.  I tested
> against my Linux install and was having problems there too.  But
> Postgres and PostGIS are rather old on my Linux box anyhow.
> 
> I'm not sure where to go from here.  Please let me know if I can help.
> 
> -Abe
> 
> On Apr 12, 2005 5:39 PM, Abe Gillespie <abe.gillespie at gmail.com> wrote:
> > Ok, I've confirmed that the data I get into a byte array is different
> > than what should be in the actual database.  I'll try to see if it's a
> > problem with the Npgsql data provider by testing against the
> > PostgreSQL ODBC driver.  I'll check back when I've tested.
> > 
> > -Abe
> > 
> > On Apr 12, 2005 4:18 PM, strk at refractions.net <strk at refractions.net>
> wrote:
> > > 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
> > > _______________________________________________
> > > 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