trouble with tiger_import and metaphone module

44 views
Skip to first unread message

Peter

unread,
Apr 9, 2010, 10:04:12 AM4/9/10
to GeoCommons Geocoder
Hello!
I've built the geocoder on an Ubuntu 9.1 machine. I basically followed
these exact directions:

http://groups.google.com/group/geocommons-geocode/browse_thread/thread/c8443c08e383d84a

I'm only interested, for now, in Rhode Island addresses, so I
downloaded the 44_RHODE_ISLAND tiger directory. Here's the output of
tiger_import:

root@domU-12-31-39-09-14-45:~/geocoder# bin/tiger_import /opt/tiger/
geocoder.db /opt/tiger
--- /opt/tiger/44_RHODE_ISLAND/44001_Bristol_County
bin/../lib/geocoder/us/sqlite3.so: undefined symbol: ceil
memory
SQL error near line 16070: no such function: metaphone
SQL error near line 16098: no such function: digit_suffix
--- /opt/tiger/44_RHODE_ISLAND/44003_Kent_County
bin/../lib/geocoder/us/sqlite3.so: undefined symbol: ceil
memory
SQL error near line 66513: no such function: metaphone
SQL error near line 66541: no such function: digit_suffix
--- /opt/tiger/44_RHODE_ISLAND/44005_Newport_County
bin/../lib/geocoder/us/sqlite3.so: undefined symbol: ceil
memory
SQL error near line 35871: no such function: metaphone
SQL error near line 35899: no such function: digit_suffix
--- /opt/tiger/44_RHODE_ISLAND/44007_Providence_County
bin/../lib/geocoder/us/sqlite3.so: undefined symbol: ceil
memory
SQL error near line 188827: no such function: metaphone
SQL error near line 188855: no such function: digit_suffix
--- /opt/tiger/44_RHODE_ISLAND/44009_Washington_County
bin/../lib/geocoder/us/sqlite3.so: undefined symbol: ceil
memory
SQL error near line 77369: no such function: metaphone
SQL error near line 77397: no such function: digit_suffix


Now, the geocoder works, but only returns city level results:

root@domU-12-31-39-09-14-45:~# irb
irb(main):001:0> require 'rubygems'
=> true
irb(main):002:0> require 'geocoder/us'
=> true
irb(main):003:0> db = Geocoder::US::Database.new("/opt/tiger/
geocoder.db")
=> #<Geocoder::US::Database:0xb72876a4 @debug=false, @st={},
@threadsafe=false, @db=#<SQLite3::Database:0xb728762c @closed=false,
@translator=nil, @type_translation=false,
@driver=#<SQLite3::Driver::Native::Driver:0xb7287410 @busy_handler={},
@authorizer={},
@callback_data={"digit_suffix"=>#<SQLite3::Driver::Native::API::CallbackData:
0xb727123c>, "metaphone"=>#<SQLite3::Driver::Native::API::CallbackData:
0xb727132c>,
"nondigit_prefix"=>#<SQLite3::Driver::Native::API::CallbackData:
0xb72712b4>,
"levenshtein"=>#<SQLite3::Driver::Native::API::CallbackData:
0xb72713a4>}, @trace={}>, @statement_factory=SQLite3::Statement,
@results_as_hash=false, @handle=#<SWIG::TYPE_p_sqlite3:0xb727687c>,
@transaction_active=false>>
irb(main):011:0> p db.geocode("25 Dorrance St, Providence, RI")
zip results 2
[{:fips_county=>"44007", :lon=>"-71.412834", :city=>"Providence", :precision=>:city, :lat=>"41.823989", :score=>0.528, :zip=>"02913", :state=>"RI"}]


This makes me think the RI tiger files didn't import correctly, and
this had something to do with the metaphone and digit_suffix SQL
errors. Is the metaphone library not being loaded properly?

Thanks for any help!
Peter

John L. Poole

unread,
Apr 9, 2010, 12:15:34 PM4/9/10
to GeoCommons Geocoder
I believe those functions, metaphone & digit_suffix, are in the
special libraries you compile that need to be loaded into sqlite; your
error messages suggest the external library was not loaded. My
workstation from this project is unavailable to me until Sunday
(Spinrite disk recovery on a 1.5 TB drive takes 114 hours), so I
cannot point you directly to where.

On Apr 9, 7:04 am, Peter <peter.lan...@gmail.com> wrote:
> Hello!
> I've built the geocoder on an Ubuntu 9.1 machine. I basically followed
> these exact directions:
>

> http://groups.google.com/group/geocommons-geocode/browse_thread/threa...

Peter

unread,
Apr 9, 2010, 2:41:31 PM4/9/10
to GeoCommons Geocoder
Ok, I see. I think my problem is that libsqlite3_geocoder didn't build
cleanly. SQLite is unable to load the extension module, so metaphone
and digit_suffix aren't defined:

sqlite> .load /root/geocoder/lib/geocoder/us/sqlite3.so
/root/geocoder/lib/geocoder/us/sqlite3.so: undefined symbol: ceil
sqlite> select metaphone('test');
SQL error: no such function: metaphone

I see there's an open ticket for the ceil issue already (http://
github.com/geocommons/geocoder/issues#issue/16), but no resolution
yet. I'm assuming that's the root of my issue? I tried testing ceil()
in a program, and it compiles and runs properly for me, so I'm not
sure why extension.o is having trouble.

Peter

John L. Poole

unread,
Apr 9, 2010, 3:40:15 PM4/9/10
to GeoCommons Geocoder
See my previous posts, it looks like you are going to have to compile
and add the math library
to include the ceil() function, just as I did. I posted my modified
code showing the loading
of the math module, too.

On Apr 9, 11:41 am, Peter <peter.lan...@gmail.com> wrote:
<snip>


>
> sqlite> .load /root/geocoder/lib/geocoder/us/sqlite3.so
> /root/geocoder/lib/geocoder/us/sqlite3.so: undefined symbol: ceil

<snip>

Peter

unread,
Apr 12, 2010, 5:01:32 PM4/12/10
to GeoCommons Geocoder
Hello,
Thanks for the tip, but I think my issue was different. The ceil()
function that was missing wasn't missing from sqlite3; it was a C
function missing from the compiled libsqlite3_geocoder.so module. My c/
c++ is a little rusty, but I believe it was because the math library
wasn't being linked properly into libsqlite3_geocoder.so. I had to
update my Makefile to include the '-lm' flag when compiling the
module. I used Makefile.redhat on my Ubuntu system, following the post
I linked to in my original post. My src/libsqlite3_geocoder/Makefile
looks like this now:

all: libsqlite3_geocoder.so
CFLAGS=-fPIC
libsqlite3_geocoder.so: extension.o wkb_compress.o util.o metaphon.o
levenshtein.o
$(CC) $(CFLAGS) -lm -shared $^ -o $@

test: test_wkb_compress test_levenshtein

test_wkb_compress: wkb_compress.c
$(CC) -DTEST -o wkb_compress $^

test_levenshtein: levenshtein.c
$(CC) -DTEST -o levenshtein $^

clean:
rm -f *.o *.so wkb_compress levenshtein

After I made this change, the module compiled correctly, and the tiger
data for Rhode Island imported "correctly." I don't yet know enough to
say if this is specific to Ubuntu systems, but if it is would shipping
a Makefile.ubuntu be appropriate? Or should '-lm' be added to other
Makefiles?

Hope this helps,
Peter

PS - I say "correctly" because the geocode method returns a result
properly, but I'm getting lat/lng results in what looks like feet or
meters, so I may still have some kind of projection issue to track
down.

Reply all
Reply to author
Forward
0 new messages