Ruby Weekly is a weekly newsletter covering the latest Ruby and Rails news.

Using RubyInline and C To Speed Up Polygonal Point Searches

By Peter Cooper / March 19, 2007

Evan Weaver had a basic problem to solve:

We need to compute whether a point lies within a polygon. And we need to do it a lot.

Due to MySQL's lacking geometry features, Evan had to perform location searches using Ruby code to find points within certain polygons. Keen for a speed-up, Evan digs out some C code from 1987 and sets about using RubyInline to speed up the whole process. The end result? A 22x increase of speed.

Of particular interest to RubyInline newbies will be the way Evan had to adjust the C code for it to work directly on Ruby objects.

Other Posts to Enjoy

Twitter Mentions