[Georuby-devel] MySQL Point in unit test

Wayne Kao wayne at waynekao.com
Thu May 11 11:10:35 EDT 2006

Thanks for the suggestion, but that didn’t work, unfortunately, since it prints out a bunch of non-visible characters (code 255 for instance) that MySQL doesn’t like.  E.g.


INSERT INTO blah ('    ☺☺', ‘1’, '2002-12-30', '2002-12-30');

ActiveRecord::StatementInvalid: Mysql::Error: #22003Cannot get geometry object from data you send to the GEOMETRY field


Is that what it’s supposed to look like?


The GeomFromText method seems to be the only way I can reliably get data in, but YML’s quoting makes using that impossible.





From: Guilhem Vellut [mailto:guilhem.vellut at gmail.com] 
Sent: Thursday, May 11, 2006 3:14 AM
To: 'Wayne Kao'; georuby-devel at rubyforge.org
Subject: RE: [Georuby-devel] MySQL Point in unit test


This would indeed be devastating.

You can try to use the MySQL canonical form for geometries. It works when you try to insert a string in this form in a geometric column. 

The canonical form is as follows: 4 characters of code 255 followed by the strict WKB form of the geometry.

In the context of your test, you could do:


Id: 1

 Some_point: <%=  (255.chr * 4) + Geometry.from_ewkt( “POINT(0 0)”).as_wkb %>


Note that I haven’t tried myself yet. If it works, I will update the adapter tonight with a method which can do it for you. In the meantime, you will have to do it manually.





From: georuby-devel-bounces at rubyforge.org [mailto:georuby-devel-bounces at rubyforge.org] On Behalf Of Wayne Kao
Sent: 11 May 2006 13:15
To: georuby-devel at rubyforge.org
Subject: [Georuby-devel] MySQL Point in unit test


Is there a way to express a MySQL Point in Rails YML for a model unit test?


I’ve been trying something like this but it doesn’t work since it becomes quoted and turns into 'GeomFromText(\'POINT(0 0)\')'



  id: 1

  some_point: GeomFromText('POINT(0 0)')

  created_on: 2002-12-30

  updated_on: 2002-12-30


I can’t make it NULL either since MySQL enforces that geospatial columns be non-NULL.  So unless someone has an idea, my only option would be to not have a unit test for this model, which would be devastating.





-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://rubyforge.org/pipermail/georuby-devel/attachments/20060511/c855e415/attachment.htm 

More information about the Georuby-devel mailing list