PostGIS Basics - Part 2 - Hello World
A quick hello world
There are a couple of things you must know about PostGIS and GIS in general before you can work with them.
First, PostGIS keeps a table of spatially enabled columns with metadata that you must update via built in functions (called geometry_columns). Consult the command reference for details, but I used the following to set up a POINT enabled column:
Read More »
Posted by Jeremy Tunnell on August 27th 9:06 PM| Comments (0)
PostGIS Basics - Part 1 - Installation
Why PostGIS?
PostGIS (good writeup) is actually the main reason I chose to go with PostgreSQL over MySQL for this new project I'm working on (there are many other benefits, though, and I really can't see myself ever going back). I'll leave the discussion of capabilities for another post, but for now I thought I'd share my experience installing and configuring this (very) squirrely extension to PostgreSQL.
Installation
Using the official documentation (which, unfortunately and like every other linux application, assumes that you are compiling from source) and a very helpful PostGIS basics guide I was able to get 90% there.
Read More »
Posted by Jeremy Tunnell on August 26th 9:01 PM| Comments (1)
Transforming an address into Latitude and Longitude using PHP and curl
Step 1 - Get a key
Yahoo offers a service that will translate any address (US only) into a latitude/longitude pair for free, for up to 5000 queries/day. The first thing you need to do is visit Yahoo and sign up for an api key: Yahoo API.
Read More »
Posted by Jeremy Tunnell on August 26th 8:03 PM| Comments (1)
Really hairy problem with (seemingly) random CRLF and spaces inserted in emails
The problem
On my custom bulk emailing application, it was recently brought to my attention that on outgoing emails there would occasionally be a word broken in two in the html body of the email. For example, the word "computer" in one email showed up as "com puter". If present, this problem occurred on every email no matter how many times the email was sent.
Opening up the offending email in a hex editor revealed that in the body of my outgoing email messages, something was inserting hex values "0A 0D 20", corresponding to CR, LF, Space, into my email body.
Read More »
Posted by Jeremy Tunnell on January 10th 7:13 PM| Comments (12)
How to configure your web application to correctly deal with character set/encoding issues
My interest in character set/encoding issues started way back in college when I maintained the school newspaper website. I noticed that sometimes when I cut-and-pasted text into the wysiwig that I was using that it would show up as garbage or question marks.
Let me tell you...if you've never had the pleasure of troubleshooting such issues, consider yourself lucky. There's nothing like trying to fix, much less define, a problem that you can't even see. That's why it's taken me years of scouring the internet to finally get to the point where I feel like I have my mind wrapped around the whole issue.
So below i'll attempt to lay out everything i've learned as concisely as possible. I'll talk specifically about PHP/MySQL, but much of the information applies to any platform.
Read More »
Posted by Jeremy Tunnell on November 26th 8:04 PM| Comments (0)
More ModRewrite - Using a dbm file instead of a txt file
So i'm using ModRewrite to do a 1-to-1 forwarding list of urls on a website where my cms can write to the map file automatically (so we don't have to edit httpd.conf every time we want to add or remove an entry).
The problem is that if the text file gets long enough (probably way longer than mine is, but i'm an efficiency freak, and having a hundred lookups before the user ever gets to your page is excessive).
So I decided to use a .dbm file (which is a hashed file of 1-to-1 matched phrases, Dbm on wikipedia). The problem is that the documentation for ModRewrite really sucks sometimes, and it doesn't explain fully how to get all the way through the process, which leaves you guessing sometimes.
Read More »
Posted by Jeremy Tunnell on September 15th 7:36 PM| Comments (3)
Mod_rewrite: Attempting to bend RewriteMap, RewriteCond, and RewriteRule to my will...
Mod_rewrite is a poorly documented, yet incredibly flexible package for Apache.
I've recently been occupied with how to set up a system of "short" urls for a website, that can be easily edited by regular users. Obviously, we can't use simple redirects or even rewriterules in httpd.conf because we don't want to give everyone write access to that file.
So it looks like the most straightforward way to do it is to use a rewritemap...basically a two-column text file (source/destination) that mod_rewrite uses to "look up" an incoming url and rewrite it to our target url.
Read More »
Posted by Jeremy Tunnell on August 21st 9:29 PM| Comments (10)