Add Zip Code/Distance function to Find page

A place for users and developers of the Xataface to discuss and receive support.

Add Zip Code/Distance function to Find page

Postby manifold » Sat Aug 13, 2011 9:21 am

Hello all,

I am looking to create a calculation function and a search function for my database, and ideally add it to the Find page (or, alternatively, to a separate page accessible via menu tabs).

First, I need to calculate the number of fire departments within a certain distance of a zipcode that have certain types of equipment. For instance, how many fire departments within 10 miles of zip code 07075 have a NIMS Type I Fire Engine? So, I would need to enter a central zip code, specify a search radius, match the zip code to coordinates, run the coordinates through an algorithm/function, and get the list of results.

I have what looks to be a great php function from Micah Carrick (http://www.micahcarrick.com/php-zip-cod ... ation.html); I also have a listing of US fire departments with zip codes and a listing of US zip codes with coordinates (both of which are already installed in my database). Perhaps someone has some experience in working with this?

Second, I need to figure out where within Xataface to incorporate this function.

Any thoughts on how to get started would be appreciated!

TYIA,
-manifold
Last edited by manifold on Sat Aug 13, 2011 12:05 pm, edited 1 time in total.
"Heisenberg may have slept here."

"I'm positive I've lost an electron...."
manifold
 
Posts: 31
Joined: Wed Jun 29, 2011 8:49 am

Re: Add function to Find page

Postby shannah » Sat Aug 13, 2011 9:53 am

The way I would look at this problem is in terms of longitude and latitude. Your database should store the longitude and latitude coordinates of each fire department. Then you'll be able to search on ranges of those to zero in on any rectangular region.

The second part is you need to be able to convert from a ZIP code to a longitude/latitude range. You also need to be able to perform some arithmetic with longitude and latitude. E.g. Given a latitude of X. What is the latitude 5 miles north of X. etc...

Once you have all of those pieces in place (and none of that should be too tricky... I've run across a fair number of databases in the public domain to convert zip codes to longitude/latitude -and the arithmetic is not that hard), you can create an action that takes a zip code and a radius as input, and produces longitude and latitude ranges either forwards to the list view for that result set - or returns the results directly. You can also look at implementing a slot or block on the find form to insert your "widget" for this.

-Steve
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm


Return to Xataface Users

Who is online

Users browsing this forum: No registered users and 29 guests

Powered by Dataface
© 2005-2007 Steve Hannah All rights reserved