How to install PostgreSQL with PostGIS spatial on OSX
October 26th, 2007
Recently spatial calculations have fascinated me. Hardly what most people would consider fascinating, but hey!
Most of the modern enterprise (I use that term loosely as someone is bound to comment complaining that some of this list are not ‘enterprise’ enough) RDBMS have spatial GIS extensions. This allows them to conduct exteamly complex calculations about size, posistion and location in a three dimensional way – pretty freaking cool! Common databases that have GIS extensions are:
PostGRE – PostGIS
Oracle – Oracle spatial
DB2 – IBM Spatial
MySQL – MySQL spatial entensions
there are lots more… just google for your specific backend.
Anyway… for this article we’ll focus on PostGRE PostGIS, and running it on OSX.
Step 1
You will need to (download a whole bunch of frameworks from here)[http://www.kyngchaos.com/software/unixport/frameworks] and run the installer. That will give you some of the base libs and frameworks that PostGIS requires; such as GEOS, GDAL etc etc
Step 2
Add a new user on your system and make sure its short name is postgres – this is the user you will run the database server as. See below from my box:

Step 3
Download the latest PostGRE installer from here. This will load up PostGRE in /usr/local/pgsql; while your there i’d install the startup item so you dont have to load the server manually evertime you restart your mac.
Once installed you need to do some editing of the conf files. For me, I just needed a local development server, so I loaded up /usr/local/pgsql/data/postgresql.conf and changed the line
#listen_addresses = ‘‘
to
listen_addresses = ‘‘
This will ensure that our server binds to all the interfaces the box has. If you want to be more specific, just enter the IP of your machine.
Next, you need to edit the pg_hba.conf file to add a generic host like so:
host all all 0.0.0.0/0 md5
This lets anyone from any IP/subnet connect as any user. I must stress that this was for development purposes so you might want to be a bit more explicit for a production enviroment.
Step 4
Now you have PostGRE installed and configured, run the PostGIS installer – this will PostGIS to your install. We now need to create a new database and add the spatial extensions to it so that our querys will work… but before we can do that we’ll need to enable PL/SQL like so:
CREATE LANGUAGE 'plpgsql' HANDLER plpgsql_call_handler LANCOMPILER 'PL/pgSQL'
Then, from PgAdmin3, open the query tool, and browse to /usr/local/pgsql/share/lwpostgis.sql – run that query, and dont worry about the output (unless its an error!) and refresh the view in PgAdmin3, you should then see the functions list gone from 0 for 600+ – thats all your spatial extensions loaded up ready for use.
That should be it – check out Boston GIS for more on GIS querys and so on – its exteamly complex and out of scope for this article. Happy geocoding people….
Making XMPie work with PostGRE SQL 8.3 backend
October 19th, 2007
For all the good things about XMPie, one of my niggles has been the lack of support for PostGRE SQL. I guess thats pretty understanderble; most of there client base use SQL server and other such MS products to some degree. There are times when id really like to use PostGre SQL as the backend and it can be a bit annoying. Anyway…thats another story…. for now were just going to look at implementing the OLEDB conectivity onto the servers to make it talk to our datasource.
Before we begin please note that it is critical to make sure that your PostgreSQL server can accept connections from your host IP. Otherwise you will get an error detailing that windows could not initialize the OLEDB provider. So, for those not familiar with PGSQL, check your postgresql.conf and pg_hba.conf….
Step 1
Ok, firstly you will need to install the OLEDB driver onto the server (and all extension serves where applicible)…
Download the OLEDB driver files from here - its currently in beta so do bear that in mind. Once downloaded, unzip it and copy libpq.dll and PgOleDb.dll to your windows\system32 folder.
Next, to register those new files as sources, go Start > Run and type
regsvr32 PGOLEDB.DLL
All being well you should see a sucsess box - if not, then i guess check your spelling against the DLL :)
Step 2
Now, provided you got your working OLEDB driver up and running in the previous step (be sure to test this with a UDL script) you should be able to add the database into the xmpie dashboard using a dsn something like this:
Provider=PostgreSQL OLE DB Provider;Password=<pass>;
User ID=root;Data Source=127.0.0.1;Location=demo;Extended Properties=””
I am going to be doing some testing to see if this is any quicker than SQL Server (fingers crossed it will be) - stay tunned readers!
Give me a shout if you dont seem to be able to make this work (for whatever reason)
Im sure Microsoft must be a synonym for crap?
October 15th, 2007
I recently have had to do come C++ coding - not my usual play ground i must admit, but never the less, something I needed to do.
My first port of call was to download the Visual C++ installer, which I did. Fine and dandy I thought, it seemed to work ok. The GUI was typical 2007 style, so yes, I couldn’t find a thing.
I then set about doing some coding, only to find that even simple stuff like
#include <windows.h>
I was getting all manner of errors in the bottom console. I only then found out that without the super duper “Microsoft Platform SDK” you couldn’t actually do sweet f**k all. So, to another 500mb download, on top of the painful download and installation of the IDE, this was somewhat insulting.
<rant>
Microsoft, we the developers and end users of your software urge you to please plug your brain in before making these kinds of choices! I know you say VC++ is meant to only ‘give a taste’ for windows C++ development, but if you want that taste to be something other than bitter resentment, make sure your products work properly out of the box!!
</rant>
Do you like spear wielding spartans?
October 6th, 2007
This has to be one of the best films of the year....
Ruby SMS gateway client for sign-up.to
October 5th, 2007
Well, I finally got round to getting my own RubyForge project! Its been a while coming now, but I decided to release some of the work ive done using the (SignUpTo)[http://sign-up.to] SMS gateway as a gem :)
Its still very early stages, as i only needed something rough for the project I was working on, however i put it out anyway – its rough but it does work I assure you! lol
You can check the project page at (signupto.rubyforge.org)[http://signupto.rubyforge.org] and download the source files (here)[http://rubyforge.org/frs/?group_id=4542].
Otherwise, if you wanna install via gems, just do the usual:
sudo gem install signupto
So how do I use it?
For this example, we’ll use rails, at thats probally where people might use it most often… In your boot.rb do
gem 'signupto'
Then require the files in your enviroment.rb
require 'net/sms/signupto'
That will then let you use the classes anywhere in your app :) such as
account = Net::SMS::SignupTo::Account.new(‘YOUR ACCOUNT HASH’, ‘CUSTOMER’)
message = Net::SMS::SignupTo::Message.new(RECIPIENT_NUMBER,
’NAME OF SENDER (max 12 chars)’,
‘BODY OF MESSAGE, NON-URI encoded’)
send = Net::SMS::SignupTo::Send.new(account, message)
The SMS’s should then just fly out the door! Apologies as I know this is a very rushed first post about this, but I have places to go and people to see ;) I’ll be bolstering the unit tests and examples soon. Stay tuned people!!