Some working code for the latitude-longitude conversion project

Thursday, February 21, 2008, 10:39 PM
Source Code by John

An email came in tonight that had some trouble applying the information from the post about building a system that converts latitudes and longitudes into X-Y co-ordinates for use with images generated by GD with PHP.

In the interest of promoting a little more applicability, I'm going to post the code that generates an actual PNG file from the map database.

This loads all the co-ordinates into three arrays. One for the rivers in the county. Another for the roads. A third for the county political boundaries.

Advertisements


Then it goes through the arrays, and draws the lines onto the image. The line colors and thicknesses are based on the type of river or stream listed from the original shapefiles.

This probably doesn't make things any clearer, but it at least gives you a look at proven production code.

And, for the critics... please refer to the post where I admit that I am very lazy about constructing anything into a usable object class. Yeah, I know the functions is significantly more recursive and could be done better with some OOP. I just don't care, because the code works.

Anyhow... I hope this gives some folks who were looking at the lat-long post something with a little more meat to chew on.


Mail article to a friend
Download getmap.zip

© 2008 Pro Content and Design. All rights reserved.


Tools

Check Google PageRank


Recent articles

  1. Fixing an open relay on Postfix
  2. Google updates PageRanks
  3. The joy of errors: 426 Failure writing network stream
  4. Back to Basics: Scrubbing POSTs in PHP
  5. Back to basics: Scrubbing for alphanumeric input in PHP
  6. Back to basics: Using PHP's GD library to make a border
  7. Blacklisting by country works
  8. GoDaddy: something nice to say
  9. TV's fetish for making the internet sound evil
  10. Small user-generated websites

Welcome!

Wonder where to start with your web design business?

This blog follows along with my efforts to build and grow a website design business, Pro Content and Design.

The goal of this blog is to fill in blanks that may be empty as you get your business rolling.

This blog, particularly the source code section, is not intended for beginners. If you are not comfortable with databases, Ajax, DOM objects and other advanced methods, I strongly suggest you go take a look over at W3 Schools before even reading -- let alone tinkering with -- any of the code here.

I hope this blog has some value to web designers as they attempt to get their businesses going.

Good luck, and happy reading.

Thank you,
John Crawford
Pro Content and Design

Books


I highly recommend Art of the Start if you have no idea where to start with marketing.

Links

Coding
W3 Schools
IBM's Mastering Ajax Series

Graphic Design
Worth 1000
Stock.XCHNG
Urban Fonts

Website Software
Apache Web Server
SquirrelMail
PHP/Zend

Website Design Issues
Non-Standard Character Guide
Google Trends
Search Engine Optimization Analyzer

Business
Guy Kawasaki's Blog
Seth Godin's Blog
Freakonomics

Computers
NewEgg

My Main Website
Pro Content and Design

Websites I have built
PunxsyPage: local free classifieds website

Farm N Land: low-cost real estate listing website

InvestYoung: semi-defunct finance blog

Groundhog Festival: for the local summer festival

Weather Discovery Center

My Webapps
TV Stations Transmitter Database

Google PageRank Checker

Website where I did the code, database and admin
Tour de Toona: annual bicycle race in Altoona, PA