pgr_createTopology: fix cast of record to integer, improve error

Closes #210, superceeds #193