[Georuby-devel] Can't load Polygon data into mysql using a fixture
Kyusik Chung
kyusik at gmail.com
Sat Mar 8 07:34:05 EST 2008
Hello,
I am having trouble trying to load data into a table that has a
polygon field.
I am using the Spatial Adapter and mysql (5.0.45), and I have followed
the documentation on how to use fixtures. The
Polygon.from_coordinates method seems to generate a polygon, but it
fails to load into the db when I run rake db:migrate. I have tried
both yml as well as csv and get 2 different errors.
Error with yml:
a YAML error occurred parsing ./db/migrate/data/cities.yml. Please
note that YAML must be consistently indented using spaces. Tabs are
not allowed. Please have a look at http://www.yaml.org/faq.html
The exact error was:
ArgumentError: syntax error on line 7, col 0:
`go5WtSwrQLqEQ29xG2JAVMN+T6wrK0B4YtaLIRtiQI8YPbfQJStA2IFzRhQb'
/usr/local/lib/ruby/gems/1.8/gems/activerecord-1.15.5/lib/
active_record/fixtures.rb:308:in `read_fixture_files'
...
NOTE: I have *not* used tabs to indent lines - I have used two spaces
at the front of each line.
Error with csv:
Mysql::Error: Cannot get geometry object from data you send to the
GEOMETRY field: INSERT INTO cities (`boundary`, `id`,
`total_businesses`, `city_name`, `state`) VALUES ('!binary | /////
wEDAAAAAQAAACAAAAD7zFmfchtiQE7QJodPMitABWoxeJgbYkC/YaJB', 3153, 0,
'Finegayan Station', 'GU')
/usr/local/lib/ruby/gems/1.8/gems/activerecord-1.15.5/lib/
active_record/connection_adapters/abstract_adapter.rb:128:in `log'
...
Here is what my yml looks like:
one:
id: 3153
city_name: Finegayan Station
state: GU
total_businesses: 0
boundary: <%=
Polygon.from_coordinates([[[144.857742,13.598263],
[144.862362,13.589922],[144.865169,13.587336],[144.862927,13.587665],
[144.861292,13.587321],[144.857597,13.585299],[144.847845,13.573858],
[144.846225,13.571014],[144.843605,13.566047],[144.842157,13.563831],
[144.841202,13.561991],[144.838305,13.556465],[144.834645,13.549919],
[144.834352,13.549395],[144.833825,13.548454],[144.831839,13.544451],
[144.830845,13.54081],[144.821543,13.545695],[144.8097993,13.55186285],
[144.814753,13.55755],[144.816744,13.56176944],[144.818862,13.566258],
[144.819402,13.568565],[144.822373,13.572223],
[144.8242032,13.57381149],[144.82634,13.575666],[144.83416,13.590365],
[144.83514,13.595657],[144.834284,13.59652],[144.834024,13.598031],
[144.83719,13.598061],[144.857742,13.598263]]]).to_fixture_format %>
Here is what my csv looks like:
id,city_name,state,total_businesses,boundary
3153,"Finegayan Station","GU",0,<%=
Polygon.from_coordinates([[[144.857742,13.598263],
[144.862362,13.589922],[144.865169,13.587336],[144.862927,13.587665],
[144.861292,13.587321],[144.857597,13.585299],[144.847845,13.573858],
[144.846225,13.571014],[144.843605,13.566047],[144.842157,13.563831],
[144.841202,13.561991],[144.838305,13.556465],[144.834645,13.549919],
[144.834352,13.549395],[144.833825,13.548454],[144.831839,13.544451],
[144.830845,13.54081],[144.821543,13.545695],[144.8097993,13.55186285],
[144.814753,13.55755],[144.816744,13.56176944],[144.818862,13.566258],
[144.819402,13.568565],[144.822373,13.572223],
[144.8242032,13.57381149],[144.82634,13.575666],[144.83416,13.590365],
[144.83514,13.595657],[144.834284,13.59652],[144.834024,13.598031],
[144.83719,13.598061],[144.857742,13.598263]]]).to_fixture_format %>
If anyone can shed some light, Id greatly appreciate it.
Thanks
Kyusik
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://rubyforge.org/pipermail/georuby-devel/attachments/20080308/4a87ebaa/attachment-0001.html
More information about the Georuby-devel
mailing list