Table linked

26 views
Skip to first unread message

bocher

unread,
Mar 19, 2007, 2:22:45 PM3/19/07
to H2 Database
Hi Thomas,

I have uploaded in H2 a new datatype named geometry. Now you can
create a spatial table like this :
CREATE TABLE mytable(gid int, the_geom geometry);

The table is populated with this function :

INSERT INTO mytable VALUES(1, GEOMFROMTEXT('POINT(1 1)', -1));


You can also use spatial operators and predicates like in postgis.

Look at : http://geosysin.iict.ch/irstv-trac/wiki/H2spatial/Download


Nevertheless, I have a problem with the function create table link.

When I import a postgres table with a field geometry the value is
transformed in another datatype . Great.
But, the values from postgres to H2 are quite different. In H2 I have
186 bytes but in Postgres I have 21 bytes.


Do you have an idea ?

Thanks

R1.

Thomas Mueller

unread,
Mar 19, 2007, 5:58:18 PM3/19/07
to h2-da...@googlegroups.com
Hi,
Thanks for your help! I will try to integrate your code, but not sure
when I have time to do that.

> When I import a postgres table with a field geometry the value is
> transformed in another datatype . Great.
> But, the values from postgres to H2 are quite different. In H2 I have
> 186 bytes but in Postgres I have 21 bytes.

I'm not sure, maybe PostgreSQL stores it in a binary format, and H2
stores it as a serialized Java object (PostgreSQL doesn't understand
serialized Java objects). Maybe the object should be stored in H2 in
the same binary format as PostgreSQL to be compatible, but this is
just a guess. I'm not sure how to solve this, sorry.

Thomas

bocher

unread,
Mar 21, 2007, 1:05:04 PM3/21/07
to H2 Database
Hi,

The geometry is stored in a binary format . When I insert my value in
H2 with GEOMFROMTEXT() function the value is the same than in
Postgres. I don't understand why when the table is linked from
postgres to H2 the value change.

If I used the jdbc postgres driver without H2 I have not such a
problem.

R1.


On 19 mar, 22:58, "Thomas Mueller" <thomas.tom.muel...@gmail.com>
wrote:

Thomas Mueller

unread,
Mar 23, 2007, 11:10:04 PM3/23/07
to h2-da...@googlegroups.com
Hi,
Sorry, I don't fully understand what the problem is. Could you send me
a test case (with expected result) so that I understand how to
reproduce it please?
Thanks,
Thomas

bocher

unread,
Mar 24, 2007, 4:15:24 AM3/24/07
to H2 Database
Hi,

Here my method :

Create a geometry table in postgres with a point


CREATE TABLE onepoint (id int, the_geom geometry);
INSERT INTO onepoint VALUES(1, GEOMFROMTEXT('POINT(1 1)', -1));


Result in Postgres for the geometry value :
0101000000000000000000F03F000000000000F03F


When I create a link in H2, the geometry value is :
303130313030303030303030303030303030303030304630334630303030303030303030303046303346


Thanks

R1.


On 24 mar, 04:10, "Thomas Mueller" <thomas.tom.muel...@gmail.com>
wrote:
> Hi,


> Sorry, I don't fully understand what the problem is. Could you send me
> a test case (with expected result) so that I understand how to
> reproduce it please?
> Thanks,
> Thomas
>

bocher

unread,
Mar 28, 2007, 2:39:28 PM3/28/07
to H2 Database
Hi Thomas,

Do you have any idea to solve my problem?

Thanks

R1.

mic.m...@gmail.com

unread,
Mar 28, 2007, 3:03:52 PM3/28/07
to H2 Database
Hi R1,

Firsly, i'd like to say I'm very interested in your attempt to make a
Geographic database from H2 (but you already know that :-))

I've no answer about your problem, but just a remark about your data
representation

the first line is the hex representation on an object (the wkb
representation of your geometry I guess)

the second line represents integer values of each character in the
first line...

Hope that helps

Michaël

Reply all
Reply to author
Forward
0 new messages