twohundredcouches/gpx-merger

将多个gpx文件合并成一个

1.1.0 2021-09-02 14:10 UTC

This package is auto-updated.

Last update: 2024-09-29 05:56:54 UTC


README

此库将gpx文件中的航点、路线和轨迹合并到单个gpx文件中。

安装

$ composer require twohundredcouches/gpx-merger

用法

use TwohundredCouches\GpxMerger\GpxMerger;
use TwohundredCouches\GpxMerger\Model\GpxMetaData;

$files = ['path/to/file1.gpx', 'path/to/file2.gpx', 'path/to/file3.gpx'];

$destination = 'path/to/frankfurt-merged.gpx'; 

$optionalMetaData = GpxMetaData::create(
    // name
    'Frankfurt Tour',
    // description 
    'My hike tour in Frankfurt',
    // author 
    'Jane Doe'
);

$compression = 0.0;

GpxMerger::merge($filesToMerge, $destination, $optionalMetaData, $compression);

GpxMerger

此包的主要类。提供一个静态的合并函数。

merge(array $files, ?string $destination = null, GpxMetaData $metaData = null, float $compression = 0.0): string

返回: string

抛出: GpxMergerException

将提供的.gpx文件数组合并成一个文件,该文件可以通过$destination定义。如果提供了一个GpxMetaData对象,将给定的元数据添加到该文件中。对于压缩,您可以传递一个介于0(无压缩)和1(最大压缩)之间的浮点值。压缩意味着从gpx文件中删除航点、路线和轨迹节点。1.0的压缩值意味着除了始终保留的第一个和最后一个节点外,将删除所有节点。0.5的压缩值意味着将删除50%的节点,而0.0则表示不删除任何节点(这是默认值)。返回输出文件的路径。

GpxMetaData

命名空间: TwohundredCouches\GpxMerger\Model

一个对象,用于将名称、描述和作者作为元数据添加到合并的文件中。提供了一个静态的create方法作为构造函数的替代。

__construct(?string $name, ?string $description = null, ?string $author = null): GpxMetaData

返回: GpxMetaData

返回一个具有提供字段的GpxMetaData对象(所有都是可选的)。

create(?string $name, ?string $description = null, ?string $author = null): GpxMetaData

返回: GpxMetaData

返回一个具有提供字段的GpxMetaData对象(所有都是可选的)。