1

We are a GIS RoR-based software company which works with spatial data. At the present time, we directly execute our pure SQL in Oracle, but it's a challenging process, now we consider the idea of switching to GeoRuby.
We want to adopt GeoRuby with our corporation's Oracle database and our Rails environment.
As far as you probably know, there is no well-structured adapter for this purpose.
Presently, I am working on my own spatial oracle adapter. For now, I can create tables and Geometry columns with migrations. Also, I can manage to create models for a table.
For example, with assumption of having a GeoShape model which have two properties (name:string and geom:geometry), I can do:

g = GeoShape.new(:name => "Point1", geom: Point.from_x_y(-1.6, 2.8, 123))

After executing above statement, I have:

=> #<GeoShape id: nil, name: "Point1", geom: <GeoRuby::SimpleFeatures::Point:0x6a3cb030 @srid=123, @with_z=false, @with_m=false, @y=2.8, @x=-1.6, @z=0.0, @m=0.0>, created_at: nil, updated_at: nil>

Now I want to save my model to DB with g.save.

I am getting the following errors which is completely logical becasue the type mismatch between GeoRuby and Oracle types.

INSERT INTO "GEO_SHAPES" ("CREATED_AT", "GEOM", "ID", "NAME", "UPDATED_AT") VALUES (:a1, :a2, :a3, :a4, :a5)  [["created_at", Sun, 01 Jul 2012 04:34:34 UTC +00:00], ["geom", #<GeoRuby::SimpleFeatures::Point:0x6a3d3410 @srid=123, @with_z=false, @with_m=false, @y=2.8, @x=-1.6, @z=0.0, @m=0.0>], ["id", 10053], ["name", "Point1"], ["updated_at", Sun, 01 Jul 2012 04:34:34 UTC +00:00]]
ActiveRecord::StatementInvalid: OCIError: ORA-00932: inconsistent datatypes: expected MDSYS.SDO_GEOMETRY got CHAR: INSERT INTO "GEO_SHAPES" ("CREATED_AT", "GEOM", "ID", "NAME", "UPDATED_AT") VALUES (:a1, :a2, :a3, :a4, :a5)   


Anyone have any idea regarding the process of doing this?
I guess, I must map my GeoRuby structure to corresponding Oracle SDO_Geometry, but I don't have any idea about the process.

Thanks very much for your helps.

Dave Qorashi
  • 326
  • 2
  • 11

2 Answers2

1

There is a nice gem rgeo

its core is an implementation of the industry standard OGC Simple Features Specification, which provides data representations of geometric objects such as points, lines, and polygons, along with a set of geometric analysis operations. This makes it ideal for modeling geolocation data. It also supports a suite of optional add-on modules that provide various geolocation-related services.

Yuri Barbashov
  • 5,407
  • 1
  • 24
  • 20
0

I could manage to do this. Now I can directly save from GeoRuby models to Oracle DB. The process is illustrated in this thread.

Community
  • 1
  • 1
Dave Qorashi
  • 326
  • 2
  • 11