Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hibernate spatial index annotation

I am using jts geometry object to store my geometry objects as an Oracle SDO_Geometry. However when I want to use SDO_GEOM.RELATE methods they are not working properly,I realized that I need to create a spatial index but dont know how to do with hibernate. Do you know any annotation for this problem.

@Type(type="org.hibernate.spatial.GeometryType")
 private Geometry area;
like image 438
Merve Kaya Avatar asked Aug 03 '15 13:08

Merve Kaya


1 Answers

Well, just create the index on the table where you store those geometries. Use SQL for that.

You need also (before you create the index) to add the proper metadata so that the index creation has the proper information it needs (coordinate system, bounds, tolerance). For example, assuming your geometries are in WGS84 coordinates:

insert into user_sdo_geom_metadata (table_name, column_name, diminfo, srid)
values (
  'US_CITIES', 
  'GEOMETRY',
  sdo_dim_array (
    sdo_dim_element('long', -180.0, 180.0, 0.5),
    sdo_dim_element('lat', -90.0, 90.0, 0.5)
  ),
  4326
);
commit;

Then create the index:

create index us_cities_sx on us_cities (geometry)
  indextype is mdsys.spatial_index;
like image 187
Albert Godfrind Avatar answered Sep 28 '22 02:09

Albert Godfrind