-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHgtReader.php
More file actions
44 lines (36 loc) · 1.45 KB
/
Copy pathHgtReader.php
File metadata and controls
44 lines (36 loc) · 1.45 KB
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
<?php
use Tito10047\HgtReader\Coordinate;
use Tito10047\HgtReader\HgtReader as NewHgtReader;
use Tito10047\HgtReader\Resolution;
use Tito10047\HgtReader\TileProvider\LocalFileSystemTileProvider;
/**
* @deprecated Use \Mostka\HgtReader\HgtReader instead. This class is a legacy wrapper.
*/
class HgtReader {
private static ?NewHgtReader $instance = null;
private static string $destination;
private static int $res;
public static function init($htgFilesDestination, $resolution = null) {
self::$destination = $htgFilesDestination;
self::$res = $resolution ?? 3; // default to 3 for legacy compatibility or storage
$provider = new LocalFileSystemTileProvider($htgFilesDestination);
$resEnum = null;
if ($resolution !== null) {
$resEnum = $resolution === 1 ? Resolution::Arc1 : Resolution::Arc3;
}
self::$instance = new NewHgtReader($provider, $resEnum);
}
public static function closeAllFiles() {
self::$instance = null; // Destructor in the new HgtReader will close all sources (DataSource::close)
}
public static function getElevation($lat, $lon, &$fName = null) {
if (self::$instance === null) {
throw new \Exception("Use HgtReader::init(..., ...);");
}
if ($fName !== null || func_num_args() > 2) {
$coord = new Coordinate($lat, $lon);
$fName = $coord->getTileName();
}
return self::$instance->getElevation($lat, $lon);
}
}