|
Posted by noone on 09/28/81 11:41
Michael Trausch wrote:
> Hello everyone,
>
> I'm having a little bit of trouble trying to implement some arithmetic
> logic into an application that I'm working on, and I'm hoping that
> somebody can possibly point me in the right direction. I am working
> with a database with ZIP codes, latitudes, and longitudes, and am
> working to implement the Haversine formula alongside with another
> formula for creating a "box" that I can use to get locations from within
> a square (or as close as you can get with the Earth, anyway).
>
> While I was reading up on the math and working through the problem, I
> wrote a function (well, two) in the bc calculator language to process
> this information manually while initially working with the concepts.
> Now that I have a semi-functional understanding of the problem, I
> rewrote the logic in PHP, and am having a problem actually computing
> longitude portions of coordinates for the "box" that I want to use to
> pull data about a given region.
>
> The problem as best as I can tell resides in the latlong_box($lat,
> $long, $miles) function that I've written in PHP, but I'm not seeing
> anything different, computationally, from what I've implemented in bc;
> of course, I could just be suffering from staring at it too long, too.
> :-) I'm not sure if I am expecting something that PHP won't provide, or
> if I'm handling something not quite right in PHP's arithmetic eyes, or
> what, really. The latitudes being computed are correct, it's just the
> longitudes that are way off.
>
> I will go ahead and give a link to the code and include a sample run of
> the script. I appreciate any help/pointers!
>
> Thanks in advance,
> Mike
>
> The source:
> http://www.staffasap.com/zip_test.phps
>
> The sample run:
>
>
>>./zip_test.php
>
> Array
> (
> [zipcode] => 30034
> [latitude] => +33.6907570
> [longitude] => -084.2511710
> [city] => DECATUR
> [state] => GEORGIA
> [abbr] => GA
> )
>
> Query SELECT * FROM dataZipCode WHERE latitude <= 33.980220566111 AND
> latitude >= 33.401293433889 AND longitude <= -122.70422048692 AND
> longitude >= -122.70422048692
> Returned 0 rows
if Decatur GA is at [longitude] => -084.2511710 where is the range in
your query .. should it not be somwhere between -70 and -122
[longitude <= -122.70422048692 AND longitude >= -122.70422048692] =
-122.70422048692
Navigation:
[Reply to this message]
|