Skip to content

Commit 67834e4

Browse files
Nathaniel McHughderickr
authored andcommitted
Add README
1 parent b02ac6e commit 67834e4

File tree

1 file changed

+70
-0
lines changed

1 file changed

+70
-0
lines changed

README

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# geospatial - PHP Geospatial Extension
2+
3+
PHP Extension to handle common geospatial functions. The extension currently has implementations of the haversine and vincenty's formulas as well as a helmert transfomation function.
4+
5+
## Instalation
6+
----------------------------
7+
8+
git clone git@github.com:php-geospatial/geospatial.git
9+
cd geospatial
10+
phpize
11+
./configure --enable-geospatial
12+
make
13+
sudo make install
14+
15+
Then add the extension to an ini file e.g. /etc/php.ini
16+
17+
extension = geospatial.so
18+
19+
## Usage
20+
21+
The extension makes use of the geojson standard format for specying points as co-ordinates. One important thing to note about this format is that points are specied longitude **first** i.e. longitude, latitude.
22+
23+
e.g.
24+
25+
$greenwichObservatory = array(
26+
'type' => 'Point',
27+
'coordinates' => array( -0.001483 , 51.477917);
28+
);
29+
30+
31+
### Haversine
32+
33+
$from = array(
34+
'type' => 'Point',
35+
'coordinates' => array( -104.88544, 39.06546 )
36+
);
37+
$to = array(
38+
'type' => 'Point',
39+
'coordinates' => array( -104.80, 39.06546 )
40+
);
41+
var_dump(haversine($to, $from));
42+
43+
44+
### Vincenty's Formula
45+
46+
Vincenty's formula attempts to provide a more acurate distance between two points than the Haversine formula. Whereas the Haversine formula assumes a spherical earth the Vincenty method models the earth as an ellipsoid.
47+
48+
$flinders = array(
49+
'type' => 'Point',
50+
'coordinates' => array(144.42486788889, -37.951033416667 )
51+
);
52+
$buninyong = array(
53+
'type' => 'Point',
54+
'coordinates' => array(143.92649552778, -37.652821138889 )
55+
);
56+
var_dump(vincenty($flinders, $buninyong));
57+
58+
59+
### Helmert Transformation
60+
61+
The Helmert transformation allows for the transfomation of points between different datums. It can for instance be used to convert between the WGS84 ellipsoid used by GPS systems and OSGB36 used by ordnance survey in the UK.
62+
63+
$greenwichObservatory = array(
64+
'type' => 'Point',
65+
'coordinates' => array(-0.0014833333333333 , 51.477916666667)
66+
);
67+
68+
$greenwichObservatoryWGS84 = transform_datum($greenwichObservatory, GEO_WGS84, GEO_AIRY_1830);
69+
70+
var_dump($greenwichObservatoryWGS84);

0 commit comments

Comments
 (0)