PHP Classes

File: readme_Geocode.txt

Recommend this page to a friend!
  Classes of Ray Paseur   PHP Geocode Address Formatter   readme_Geocode.txt   Download  
File: readme_Geocode.txt
Role: Documentation
Content type: text/plain
Description: readme text file
Class: PHP Geocode Address Formatter
Parse a location string and returns its details
Author: By
Last change:
Date: 5 years ago
Size: 2,468 bytes
 

Contents

Class file image Download
Class Geocode This is a lightweight class that normalizes geocodes (Lat,Lng pairs). It has a single method, the constructor, which receives a geocode string in any of several common and very relaxed formats. See the "demo" file for examples. The constructor attempts to interpret the input string. It returns an instance of the Geocode object with public properties as shown below. If it's impossible to make sense of the input, the "error" property will have some explanation of what went wrong. If "error" is not empty, you should not rely on the other values in the object. This shows the Geocode object for the Post Office at ZIP code 15213 in Pittsburgh: Geocode Object ( [name] => Post Office 15213 in Pittsburgh [lat] => 40.4401766 [lng] => -79.9526167 [geo] => 40.4401766,-79.9526167 [lat_dms] => 40°26'24.636"N [lng_dms] => 79°57'9.42"W [geo_dms] => 40°26'24.636"N,79°57'9.42"W [lat_dmd] => 40°26.4106'N [lng_dmd] => 79°57.157'W [geo_dmd] => 40°26.4106'N,79°57.157'W [lat_dd] => 40.4401766°N [lng_dd] => 79.9526167°W [geo_dd] => 40.4401766°N,79.9526167°W [olc] => 87G2C2RW+3X [input] => 40.4401766,-79.9526167 [error] => ) You must provide a geocode string or an open location code string to use the object. You may provide an optional name that can identify the place the geocode points to. To get this object, create an instance of Geocode like these: require_once('class_Geocode.php'); $geo = new Geocode('40.4401766,-79.9526167', 'Post Office 15213 in Pittsburgh'); To use this object, first check $geo->error for empty() status, then you can get any of the properties that make sense for your application, eg: echo $geo->geo_dms; // prints 40°26'24.636"N,79°57'9.42"W echo $geo->olc; // prints 87G2C2RW+3X Reconstruction of Lat,Lng pairs is accurate when using explicit geocodes because the geocode points to a place on earth. Accuracy is a bit less when using an open location code. A 10-digit plus code has only about "rooftop" accuracy; the generated geocode will point to the southwest corner of the area defined by the OLC. References: https://journeynorth.org/tm/LongitudeIntro.html https://en.wikipedia.org/wiki/Horizontal_position_representation https://en.wikipedia.org/wiki/Geographic_coordinate_system https://en.wikipedia.org/wiki/Decimal_degrees https://en.wikipedia.org/wiki/Open_Location_Code