Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

unable to map all parts of SDO_GEOMETRY

 
saipraneeth nallapareddy
Ranch Hand
Posts: 159
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello every one,
i have come across a new type in oracle SDO_GEOMETRY in the recent past, i am using hibernate in my app.
after searching online for a lot of time i came to know hibernate-spatial.jar and jts.jar are proper jars to deal this type.
the classes i have used are

with the above mappings i am able to fetch the data without errors but not the entire data that has been inserted into the DB.

for example

INSERT INTO LINES (id,geom) VALUES (1, MDSYS.SDO_GEOMETRY(2002,null,null, MDSYS.SDO_ELEM_INFO_ARRAY(1,2,1), MDSYS.SDO_ORDINATE_ARRAY(10,10,20,25,30,10,40,10)));

in the above example 2 columns are being inserted in a row where 1 is the data in the first column and the remaining data into 2nd column, which contains 5 sub columns as well.

SDO_GTYPE
SDO_SRID
SDO_POINT
SDO_ELEMINFO
SDO_ORDINATES

the above data has been collected from Pro Oracle Spatial for Oracle Database 11g

With the help of the classes i mentioned i retrieved the data of SDO_ORDINATES where java will eliminate the words MDSYS.SDO_ORDINATE_ARRAY and give them to us as
LINESTRING(10,10,20,25,30,10,40,10)

it is actually right there are many such types like POINT, LINESTRING, POLYGON, MULTIPOINT, MULTILINE, MULTIPOLYGON and etc (they are the only few i explored).

i guess by now everyone can understand my problem what is the proper mapping(Class) for the remaining data to handle by hibernate(hibernate-spatial).

can any one help me in this regard.
 
saipraneeth nallapareddy
Ranch Hand
Posts: 159
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can anyone help me in this regard
 
Christian Dillinger
Ranch Hand
Posts: 200
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How do you create that INSERT-statement?
I'd create a Geometry-Object and set the data you need and leave the rest to HibernateSpatial and JTS.



Edit:
A valid mapping:

 
saipraneeth nallapareddy
Ranch Hand
Posts: 159
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thank you for the reply
Christian Dillinger wrote: new WKTReader().read(wkt);

it did the work, this is exactly what i have been looking for.
Even my doubt was true that 3 out of 5 argument (eliminating SRID) data are used to append the string before the last argument, and the above class is the one i require to convert the string to fill the remaining arguments to insert the data through hibernate.

thank you Christian Dillinger.
 
Christian Dillinger
Ranch Hand
Posts: 200
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Don't forget to call setSRID(xyz) before saving the geometry because it's not included in WKT. If you don't you won't see that geometry at the right place in a GIS-Tool. IIRC.
 
saipraneeth nallapareddy
Ranch Hand
Posts: 159
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
what is the use of SRID?
 
Christian Dillinger
Ranch Hand
Posts: 200
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
saipraneeth nallapareddy wrote:what is the use of SRID?


The SRID describes how the coordinates should be interpreted; a code for your coordinate system. If you say there is a point called (20,0) where is it? Where is (0,0)? Is there a difference between (0,0) and (0,0)? These can be different points when you use different coordinates.

http://en.wikipedia.org/wiki/SRID
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic