承接 tito10047/hgtreader 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

tito10047/hgtreader

最新稳定版本:1.0.0

Composer 安装命令:

composer require tito10047/hgtreader

包简介

World elevations reader

关键字:

README 文档

README

PHP Tests License

Professional PHP library for reading SRTM (HGT) files with high precision and minimal memory footprint. Designed for modern PHP 8.2+ with an emphasis on SOLID principles and flexibility.

🚀 Key Features

  • Extremely low memory footprint: Uses fseek for direct data access without loading entire files into RAM.
  • High precision: Implements bilinear interpolation for accurate elevation calculation between measurement points.
  • Flexible architecture: Abstraction of data sources (DataSource) and tile providers (TileProvider).
  • Resolution support: Full support for both SRTM-1 (1 arc-second) and SRTM-3 (3 arc-seconds).

📦 Installation

You can install the library via Composer:

composer require tito10047/hgtreader

🛠️ Quick Start (Modern API)

use Tito10047\HgtReader\HgtReader;
use Tito10047\HgtReader\Resolution;
use Tito10047\HgtReader\TileProvider\LocalFileSystemTileProvider;

// 1. Set the path to the folder containing .hgt files
$hgtPath = __DIR__ . '/data/hgt';

// 2. Create a tile provider (TileProvider)
$provider = new LocalFileSystemTileProvider($hgtPath);

// 3. Initialize the reader (Resolution is auto-detected from file size)
$reader = new HgtReader($provider);

// 4. Get precise elevation for coordinates
$lat = 49.38628;
$lon = 19.37702;
$elevation = $reader->getElevation($lat, $lon);

echo "Elevation: {$elevation} m";

🖼️ Purpose and Usage

The library is ideal for generating elevation profiles of tracks, terrain analysis, or visualizing geographical data.

Elevation profile 1 Example of track elevation profile rendering.

Elevation profile 2 Detailed visualization of terrain changes.

🧩 Advanced Features

Custom DataSources

If you need to read data from memory (e.g., during network transfers), you can use MemoryDataSource:

use Tito10047\HgtReader\DataSource\MemoryDataSource;
// ...
$content = file_get_contents('path/to/file.hgt');
$dataSource = new MemoryDataSource($content);

SRTM-1 Support

For more detailed data (3601x3601 points), simply change the resolution:

$reader = new HgtReader($provider, Resolution::Arc1);

👴 Legacy Support (Backward Compatibility)

The original static interface is available for existing projects:

// The old way of calling is still functional via a wrapper
HgtReader::init(__DIR__ . '/data/hgt', 3); // 3 for SRTM-3
$elevation = HgtReader::getElevation(49.38, 19.37);

📂 Where to download HGT data?

You can obtain data in .hgt format from various sources, for example:

🧪 Testing

The project is fully covered by tests using PHPUnit:

./vendor/bin/phpunit tests

📄 License

This project is licensed under the Apache-2.0 License - see the LICENSE file for details.

Author: Jozef Môstka

统计信息

  • 总下载量: 0
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 3
  • 点击次数: 4
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 3
  • Watchers: 3
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: Apache-2.0
  • 更新时间: 2026-03-07

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固