[Georuby-devel] Patch to geometry.rb speeds up as_hex_ewkb method

Justin Leitgeb justin at phq.org
Wed Mar 18 21:44:04 EDT 2009

Hi folks,

In some of my work at Outside.in, I noticed that importing SHP files with
the GeoRuby library was a bit slow.  Profiling on the import process showed
that the method as_hex_ewkb in geometry.rb was the biggest culprit.

I modified the method slightly to use "unpack" instead of the sprintf
conversion to hex, and the performance improvement was considerable...
importing 29 shapes from a TIGER shape file[1] went from about 45 seconds
before the patch to 10 seconds afterwards.

All unit tests in GeoRuby pass with the minor patch, and I verified that
several tested the method changed.  Any reason that this can't be applied

Thanks for creating a very useful library!


[1] - I used the "Metropolitan Division" file available on
http://www2.census.gov/cgi-bin/shapefiles/national-files for testing
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://rubyforge.org/pipermail/georuby-devel/attachments/20090318/b3cd549a/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: unpack_to_hex_ewkb.diff
Type: application/octet-stream
Size: 830 bytes
Desc: not available
URL: <http://rubyforge.org/pipermail/georuby-devel/attachments/20090318/b3cd549a/attachment.obj>

More information about the Georuby-devel mailing list