Note that there are some explanatory texts on larger screens.

plurals
  1. POWriting a GeoRuby Oracle Adapter for Ruby 1.9 and Rails 3.2.5
    text
    copied!<p>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. <br/> We want to adopt GeoRuby with our corporation's Oracle database and our Rails environment. <br/> As far as you probably know, there is no well-structured adapter for this purpose. <br/> 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. <br/> For example, with assumption of having a GeoShape model which have two properties (name:string and geom:geometry), I can do:</p> <pre><code>g = GeoShape.new(:name =&gt; "Point1", geom: Point.from_x_y(-1.6, 2.8, 123)) </code></pre> <p>After executing above statement, I have:</p> <pre><code>=&gt; #&lt;GeoShape id: nil, name: "Point1", geom: &lt;GeoRuby::SimpleFeatures::Point:0x6a3cb030 @srid=123, @with_z=false, @with_m=false, @y=2.8, @x=-1.6, @z=0.0, @m=0.0&gt;, created_at: nil, updated_at: nil&gt; </code></pre> <p>Now I want to save my model to DB with g.save. <br/></p> <p>I am getting the following errors which is completely logical becasue the type mismatch between GeoRuby and Oracle types.</p> <pre><code>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", #&lt;GeoRuby::SimpleFeatures::Point:0x6a3d3410 @srid=123, @with_z=false, @with_m=false, @y=2.8, @x=-1.6, @z=0.0, @m=0.0&gt;], ["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) </code></pre> <p><hr/> Anyone have any idea regarding the process of doing this? <br/> I guess, I must map my GeoRuby structure to corresponding Oracle SDO_Geometry, but I don't have any idea about the process. <br/></p> <p>Thanks very much for your helps.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload