Artifact [bf1fa46099]

Artifact bf1fa4609971b5afea06ea3d30d15f3ac8d16ba4:

Wiki page [Coords] by densch 2016-10-18 01:03:08.
D 2016-10-18T01:03:08.977
L Coords
P b6d60664767e9b7916100b1b2c2b02e22739134b
U densch
W 1658
<h2>ZIP2Coords</h2>

This is a webservice that allows us to map US ZIP codes to a pair of
coordinates.

Usage is very simple, just query the service with a ZIP code as a parameter:
<tt>http://localhost/zip2coords/?zip=90210</tt>

And receive the coordinates in JSON format:

<pre>
    {"latitude":"34.0901000","longitude":"-118.4065000"}
</pre>

Data comes from <a href="http://download.geonames.org/export/zip/">GeoNames Postal Codes</a>. It is distributed as a plain text file. To build the MySQL database run the <tt>database/geonames.sh</tt> shell script. It'll download the required data, setup the database structure and import the data into it using MySQL's native load functionality.

Requires PHP with PDO and JSON support.


<h2>Nearest Location</h2>


A webservice to find the nearest location (for example the nearest office,
store, etc of a business) to the given location (typically the user's), either by coordinates or ZIP code, in the latter case using the ZIP2Coords webservice.

Locations are stored in the file <tt>locations.json</tt> in JSON format.

To use just query the service with either a ZIP code or a pair of coordinates: <tt>http://localhost/nearest/?zip=90210</tt> or <tt>http://localhost/nearest/?lat=40&lng=-73</tt>.

To get a response such as:

<pre>
{
    "location": "Orlando",
    "URL": "http:\/\/localhost\/Orlando_FL.html",
    "distance": 198.46303408646,
    "latitude": 28.661653,
    "longitude": -81.354558
}
</pre>

Requires PHP with cURL support and <a href="http://www.memcached.org/">memcached</a>.  To run the tests you need <a href="https://phpunit.de/">PHPUnit</a>.
Z 7abd3b64dad3f7e6654b5b255d9e0d60