Canada Addresses and Zip Codes

103 views
Skip to first unread message

damon.so...@gmail.com

unread,
Apr 18, 2013, 11:37:31 AM4/18/13
to dstk-...@googlegroups.com
Hello,

First off, I would like to give props to DSTK. Very nice. I installed an instance on EC2 from the command line, and it works great.

However, I am trying to geocode Canadian zip codes and it is returning 0 results.

Example: H3W2L9, QC CA

Any ideas?

Thanks,
-damon

Pete Warden

unread,
Apr 18, 2013, 3:42:37 PM4/18/13
to dstk-...@googlegroups.com
Hi Damon,
               thanks for your kind words! Believe it or not Canadian postal codes are actually somewhat controversial, thanks to an attempt by the government to claim copyright on them:
I thought the short form (the first three letters) was supported, thanks to a recent data import I did from geonames.org, but when I just tested it, it wasn't showing any results. Happily that turned out to be an easy fix once I dug into it. You can try it for "QC H3W, Canada" with this URL:

Is that helpful? I'd love to get better resolution on postal codes.

cheers,
           Pete


--
You received this message because you are subscribed to the Google Groups "dstk-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dstk-users+...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 



--
Jetpac

damon.so...@gmail.com

unread,
Apr 18, 2013, 3:56:26 PM4/18/13
to dstk-...@googlegroups.com, pe...@jetpac.com
It does indeed. I have an instance running here:


Mine returns different results however.

{ "status": "OK", "results": [ { "geometry": { "location_type": "APPROXIMATE", "viewport": { "northeast": { "lng": -90.0, "lat": 65.0 }, "southwest": { "lng": -100.0, "lat": 55.0 } }, "location": { "lng": -95.0, "lat": 60.0 } }, "types": [ "country", "political" ], "address_components": [ { "types": [ "country", "political" ], "short_name": "CA", "long_name": "Canada" } ] } ] }

Thoughts?

Pete Warden

unread,
Apr 18, 2013, 4:13:12 PM4/18/13
to dstk-...@googlegroups.com
If you pull down the latest code, it should have the fix. Here's what you'll need to do once you've ssh-ed into your instance:
cd ~/sources/dstk
git pull origin master

Let me know if that doesn't work.

cheers,
           Pete

Pete Warden

unread,
Apr 18, 2013, 4:13:54 PM4/18/13
to dstk-...@googlegroups.com
Oh, and one thing I forgot, to restart the Sinatra server process run

touch tmp/restart.txt

cheers,
           Pete

damon.so...@gmail.com

unread,
Apr 18, 2013, 4:20:45 PM4/18/13
to dstk-...@googlegroups.com, pe...@jetpac.com
Ok, I forgot to associate a key-pair. Must recreate the instance.

I will try that and let you know.

Thanks.

damon.so...@gmail.com

unread,
Apr 18, 2013, 5:21:47 PM4/18/13
to dstk-...@googlegroups.com, pe...@jetpac.com
Ok. Getting Internal Server Error now.

Not sure I did the restart thing correctly.

Do I do touch tmp/restart.txt from within ~/sources/dstk?

I see this in /var/logs/apache2/error.log

ERROR:  relation "postal_codes" does not exist
LINE 1: DECLARE myportal CURSOR FOR SELECT * FROM postal_codes WHERE...
                                                  ^
SystemExit - exit:

Pete Warden

unread,
Apr 18, 2013, 5:34:52 PM4/18/13
to dstk-...@googlegroups.com
My mistake - I added the post code data after the last VM snapshot. You'll have to run these commands to grab the latest data and rebuild the database:

cd ~/source/dstkdata
git pull origin master
cd ~/source/dstk
./populate_database.rb

It will take about an hour to run, unfortunately!

damon.so...@gmail.com

unread,
Apr 18, 2013, 5:41:05 PM4/18/13
to dstk-...@googlegroups.com, pe...@jetpac.com
No worries. I appreciate all of the help.

Does the tmp/restart.txt go inside of ~/sources/dstk or is it /tmp/restart.txt?

Pete Warden

unread,
Apr 18, 2013, 5:43:59 PM4/18/13
to dstk-...@googlegroups.com
That's inside sources/dstk, ie the full path is /home/ubuntu/sources/dstk/tmp/restart.txt

Damon Sorrentino

unread,
Mar 30, 2017, 10:25:02 AM3/30/17
to dstk-users, damon.so...@gmail.com
Hi Pete,

Been using the DSTK for awhile now. Works great. I have the latest version installed and am getting a 500 on a particular Canadian postal code. It works on the dstk web site, but not mine. I am guessing the postal code is not in the database, however when I run populate_database.rb I am getting the folllowing error:

NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index "cities_pkey" for table "cities"

./populate_database.rb:31:in `foreach': No such file or directory - ../dstkdata/worldcitiespop.csv (Errno::ENOENT)

from ./populate_database.rb:31:in `load_cities'

from ./populate_database.rb:420


Here is the URL I am calling for information:

Works:

Damon Sorrentino

unread,
Apr 3, 2017, 5:12:50 PM4/3/17
to dstk-users, damon.so...@gmail.com
Never mind, I restarted the server and all works.

Sam Winters

unread,
May 3, 2017, 1:52:27 PM5/3/17
to dstk-users, damon.so...@gmail.com

Hi Pete/Damon,

I am having the same issue generally--getting 500 errors on my own instance but not getting them on the main DSTK website. I am trying to steps as specified above but am also getting the "No such file or directory" error when trying to run ./populate_database.rb . How did you resolve this?

Thanks!
Sam

Damon Sorrentino

unread,
May 3, 2017, 1:53:39 PM5/3/17
to Sam Winters, dstk-users
Hi Sam,

I restarted the server and everything worked great.

See earlier in the thread on how to restart the server. 

-damon
Reply all
Reply to author
Forward
0 new messages