-
Notifications
You must be signed in to change notification settings - Fork 35
/
index.html
335 lines (313 loc) · 14.1 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8'>
<title>Spherical Geometry Library in PHP @ GitHub</title>
<style type="text/css">
body {
margin-top: 12px;
background-color: #fdfdfd;
font-family: Helvetica, Arial, FreeSans, san-serif;
font-size:14px;
color: #222;
}
#container {
margin: 0 auto;
width: 800px;
}
h1 { font-size: 36px; color: #222; margin-bottom: 3px; }
h1 .small { font-size: 16px; }
h1 a { text-decoration: none }
h2 { font-size: 20px; color: #222; }
h3 {font-size:17px;
border-top: 1px solid #36C;
background-color: #E5ECF9;
padding: 3px 10px;
}
a { color: blue; }
table {
margin: 1em 0 0 1px;
border: 1px solid;
border-spacing: 0;
border-collapse: collapse;
border-color: #BBB;
font-size:13px;
}
th, td {vertical-align: top;}
th {
font-weight: bold;
text-align: left;
padding: 6px 12px;
border: 1px solid #BBB;
background-color: #E5ECF9;
}
td {
padding: 6px 12px;
border: 1px solid #BBB;
background-color: white;
text-align: left;
vertical-align: top;
}
table code, table pre {
font-family: monospace;
color: #007000;
}
.description { font-size: 1.2em; margin-bottom: 30px; margin-top: 30px; font-style: italic;}
.download { float: right; }
pre { background: #000; color: #fff; padding: 15px;}
hr { border: 0; width: 80%; border-bottom: 1px solid #aaa}
.footer { text-align:center; padding-top:30px; font-style: italic; }
</style>
</head>
<body>
<a href="https://github.com/tubalmartin/spherical-geometry-php"><img style="position: absolute; top: 0; right: 0; border: 0;" src="http://s3.amazonaws.com/github/ribbons/forkme_right_darkblue_121621.png" alt="Fork me on GitHub" /></a>
<div id="container">
<div class="download">
<a href="https://github.com/tubalmartin/spherical-geometry-php/zipball/master">
<img border="0" width="90" src="https://github.com/images/modules/download/zip.png"></a>
<a href="https://github.com/tubalmartin/spherical-geometry-php/tarball/master">
<img border="0" width="90" src="https://github.com/images/modules/download/tar.png"></a>
</div>
<h1><a href="https://github.com/tubalmartin/spherical-geometry-php">Spherical Geometry Library in PHP</a>
<span class="small">by <a href="https://github.com/tubalmartin">Túbal Martín</a></span></h1>
<div class="description">
<p>This library provides classes and functions for the computation of geometric data on the surface of the Earth.</p>
<p>This library ports a small but useful subset of classes from the <a href="http://code.google.com/intl/en/apis/maps/documentation/javascript/">Google Maps Javascript API version 3</a>.</p>
<p>Tested against Google Maps API versions 3.5 to 3.18.</p>
</div>
<h2>How to use</h2>
<p>Include the <code>spherical-geometry.class.php</code> file in your code and use the API!</p>
<p>Notes: </p>
<ul>
<li>The API is nearly identical to the Google Maps Javascript API.</li>
<li>All computed lengths are returned in <strong>meters</strong>.</li>
</ul>
<h2>API</h2>
<p>Classes and libraries ported from the Google Maps Javascript API:</p>
<ul>
<li><a href="http://code.google.com/intl/en/apis/maps/documentation/javascript/geometry.html">Geometry Library - google.maps.geometry.spherical static methods</a></li>
<li><a href="http://code.google.com/intl/en/apis/maps/documentation/javascript/reference.html#LatLng">Base - google.maps.LatLng class</a></li>
<li><a href="http://code.google.com/intl/en/apis/maps/documentation/javascript/reference.html#LatLngBounds">Base - google.maps.LatLngBounds class</a></li>
</ul>
<h3>
<a name="spherical"></a>
SphericalGeometry class (static)
</h3>
<p>Utility functions for computing geodesic angles, distances and areas. The default radius is Earth's radius of 6378137 meters.</p>
<p>If you don't know how to use some of these methods read this excellent article by Gabriel Svennerberg: <a href="http://www.svennerberg.com/2011/04/calculating-distances-and-areas-in-google-maps-api-3/">Calculating Distances and Areas in Google Maps API 3</a></p>
<h4>Static Methods</h4>
<table summary="namespace spherical - Static Methods" width="100%">
<thead>
<th>Methods</th>
<th>Return Value</th>
<th>Description</th>
</thead>
<tbody>
<tr>
<td><code>getEarthRadius()</code></td>
<td><code>number</code></td>
<td>Gets the Earth's radius.</td>
</tr>
<tr>
<td><code>computeArea(loop:Array.<<a href="#LatLng">LatLng</a>>)</code></td>
<td><code>number</code></td>
<td>Computes the area of the given loop. Loops must be closed.</td>
</tr>
<tr>
<td><code>computeBounds(center:<a href="#LatLng">LatLng</a>, radius:number)</code></td>
<td><code><a href="#LatLngBounds">LatLngBounds</a></code></td>
<td>Computes a bounding rectangle from a LatLng point and a given radius (radius must be given in meters). See <a href="http://www.movable-type.co.uk/scripts/latlong-db.html">this page</a> for more info.</td>
</tr>
<tr>
<td><code>computeDistanceBetween(from:<a href="#LatLng">LatLng</a>, to:<a href="#LatLng">LatLng</a>)</code></td>
<td><code>number</code></td>
<td>Computes the distance between two LatLngs.</td>
</tr>
<tr>
<td><code>computeHeading(from:<a href="#LatLng">LatLng</a>, to:<a href="#LatLng">LatLng</a>)</code></td>
<td><code>number</code></td>
<td>Computes the heading from one LatLng to another LatLng.</td>
</tr>
<tr>
<td><code>computeLength(path:Array.<<a href="#LatLng">LatLng</a>>)</code></td>
<td><code>number</code></td>
<td>Computes the length of the given path.</td>
</tr>
<tr>
<td><code>computeOffset(from:<a href="#LatLng">LatLng</a>, distance:number, heading:number)</code></td>
<td><code><a href="#LatLng">LatLng</a></code></td>
<td>Computes the LatLng produced by starting from a given LatLng and heading a given distance.</td>
</tr>
<tr>
<td><code>computeSignedArea(loop:Array.<<a href="#LatLng">LatLng</a>>)</code></td>
<td><code>number</code></td>
<td>Computes the signed area of the given loop. Loops must be closed. The signed area may be used to determine the orientation of a loop.</td>
</tr>
<tr>
<td><code>interpolate(from:<a href="#LatLng">LatLng</a>, to:<a href="#LatLng">LatLng</a>, fraction:number)</code></td>
<td><code><a href="#LatLng">LatLng</a></code></td>
<td>Travels a fraction of the way from one LatLng to another LatLng.</td>
</tr>
</tbody>
</table>
<h3>LatLng class <a name="LatLng"></a></h3>
<p><code><a href="#LatLng">LatLng</a></code> is a point in geographical coordinates, latitude and longitude.</p> <p>Notice that although usual map projections associate longitude with the x-coordinate of the map, and latitude with the y-coordinate, the latitude coordinate is always written <em>first</em>, followed by the longitude.</p> <p>Notice also that you cannot modify the coordinates of a <code><a href="#LatLng">LatLng</a></code>. If you want to compute another point, you have to create a new one.</p>
<h4>Constructor</h4>
<table summary="class LatLng - Constructor" width="100%">
<thead>
<th>Constructor</th>
<th>Description</th>
</thead>
<tbody>
<tr>
<td><code>LatLng(lat:number, lng:number, noWrap?:boolean)</code></td>
<td>Notice the ordering of latitude and longitude. If the noWrap flag is true, then the numbers will be used as passed, otherwise latitude will be clamped to lie between -90 degrees and +90 degrees, and longitude will be wrapped to lie between -180 degrees and +180 degrees.</td>
</tr>
</tbody>
</table>
<h4>Methods</h4>
<table summary="class LatLng - Methods" width="100%">
<thead>
<th>Methods</th>
<th>Return Value</th>
<th>Description</th>
</thead>
<tbody>
<tr>
<td><code>equals(other:<a href="#LatLng">LatLng</a>)</code></td>
<td><code>boolean</code></td>
<td>Comparison function.</td>
</tr>
<tr>
<td><code>getLat()</code></td>
<td><code>number</code></td>
<td>Returns the latitude in degrees.</td>
</tr>
<tr>
<td><code>getLng()</code></td>
<td><code>number</code></td>
<td>Returns the longitude in degrees.</td>
</tr>
<tr>
<td><code>toString()</code></td>
<td><code>string</code></td>
<td>Converts to string representation.</td>
</tr>
<tr>
<td><code>toUrlValue(precision?:number)</code></td>
<td><code>string</code></td>
<td>Returns a string of the form "lat,lng" for this LatLng. We round the lat/lng values to 6 decimal places by default.</td>
</tr>
</tbody>
</table>
<h3>
<a name="LatLngBounds"></a>
LatLngBounds class
</h3>
<p>A <code><a href="#LatLngBounds">LatLngBounds</a></code> instance represents a rectangle in geographical coordinates, including one that crosses the 180 degrees longitudinal meridian.</p>
<h4>Constructor</h4>
<table summary="class LatLngBounds - Constructor" width="100%">
<thead>
<th>Constructor</th>
<th>Description</th>
</thead>
<tbody>
<tr>
<td><code>LatLngBounds(sw?:<a href="#LatLng">LatLng</a>, ne?:<a href="#LatLng">LatLng</a>)</code></td>
<td>Constructs a rectangle from the points at its south-west and north-east corners.</td>
</tr>
</tbody>
</table>
<h4>Methods</h4>
<table summary="class LatLngBounds - Methods" width="100%">
<thead>
<th>Methods</th>
<th>Return Value</th>
<th>Description</th>
</thead>
<tbody>
<tr>
<td><code>contains(latLng:<a href="#LatLng">LatLng</a>)</code></td>
<td><code>boolean</code></td>
<td>Returns true if the given lat/lng is in this bounds.</td>
</tr>
<tr>
<td><code>equals(other:<a href="#LatLngBounds">LatLngBounds</a>)</code></td>
<td><code>boolean</code></td>
<td>Returns true if this bounds approximately equals the given bounds.</td>
</tr>
<tr>
<td><code>extend(point:<a href="#LatLng">LatLng</a>)</code></td>
<td><code><a href="#LatLngBounds">LatLngBounds</a></code></td>
<td>Extends this bounds to contain the given point.</td>
</tr>
<tr>
<td><code>getCenter()</code></td>
<td><code><a href="#LatLng">LatLng</a></code></td>
<td>Computes the center of this LatLngBounds</td>
</tr>
<tr>
<td><code>getNorthEast()</code></td>
<td><code><a href="#LatLng">LatLng</a></code></td>
<td>Returns the north-east corner of this bounds.</td>
</tr>
<tr>
<td><code>getSouthWest()</code></td>
<td><code><a href="#LatLng">LatLng</a></code></td>
<td>Returns the south-west corner of this bounds.</td>
</tr>
<tr>
<td><code>intersects(other:<a href="#LatLngBounds">LatLngBounds</a>)</code></td>
<td><code>boolean</code></td>
<td>Returns true if this bounds shares any points with this bounds.</td>
</tr>
<tr>
<td><code>isEmpty()</code></td>
<td><code>boolean</code></td>
<td>Returns if the bounds are empty.</td>
</tr>
<tr>
<td><code>toSpan()</code></td>
<td><code><a href="#LatLng">LatLng</a></code></td>
<td>Converts the given map bounds to a lat/lng span.</td>
</tr>
<tr>
<td><code>toString()</code></td>
<td><code>string</code></td>
<td>Converts to string.</td>
</tr>
<tr>
<td><code>toUrlValue(precision?:number)</code></td>
<td><code>string</code></td>
<td>Returns a string of the form "lat_lo,lng_lo,lat_hi,lng_hi" for this bounds, where "lo" corresponds to the southwest corner of the bounding box, while "hi" corresponds to the northeast corner of that box.</td>
</tr>
<tr>
<td><code>union(other:<a href="#LatLngBounds">LatLngBounds</a>)</code></td>
<td><code><a href="#LatLngBounds">LatLngBounds</a></code></td>
<td>Extends this bounds to contain the union of this and the given bounds.</td>
</tr>
</tbody>
</table>
<h2>Tests</h2>
<p>You can view the tests located in the <a href="https://github.com/tubalmartin/spherical-geometry-php/tree/master/tests">tests folder</a>.</p>
<p>To run the tests, download the project and upload it to a server with PHP installed. Open your browser and enter the absolute URL to the <code>tests</code> folder in your server.</p>
<h2>License</h2>
<p>Dual licensed under the MIT or GPL Version 2 licenses.</p>
<h2>Authors</h2>
<p>Túbal Martín (tubalmartin at gmail dot com)</p>
<h2>Download</h2>
<p>
You can download this project in either
<a href="https://github.com/tubalmartin/spherical-geometry-php/zipball/master">zip</a> or
<a href="https://github.com/tubalmartin/spherical-geometry-php/tarball/master">tar formats.
</p>
<p>You can also clone the project with <a href="http://git-scm.com">Git</a>
by running:
<pre>$ git clone git://github.com/tubalmartin/spherical-geometry-php</pre>
</p>
<div class="footer">
Get the source code on GitHub : <a href="https://github.com/tubalmartin/spherical-geometry-php">tubalmartin/spherical-geometry-php</a>
</div>
</div>
</body>
</html>