定制 kravenor/gpx2png 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

kravenor/gpx2png

Composer 安装命令:

composer require kravenor/gpx2png

包简介

Gpx and track to image on OSM and other tiles

README 文档

README

Php class that helps draw track and points on OSM maps.

This repository is a fork of Gpx2Png by Alexey Knyazev. That seems to be abandoned.

Install

Via Composer

$ composer require kravenor/gpx2png

Basic usage

require "vendor/autoload.php";
use Gpx2Png\Gpx2Png;

$gpx = new Gpx2Png();
$gpx2png->loadFile($gpxTrackFile);

$res = $gpx2png->generateImage();
$res->saveToFile($target_file);

Extend usage

require "vendor/autoload.php";
use Gpx2Png\Gpx2Png;
use Gpx2Png\Models\Overlays\DrawParamsPoint;
use Gpx2Png\Models\Point;

// prepare points set from own source 

$points = array();
foreach ($mypoints as $mypoint) {
    $points[] = new Point($mypoint['lat'], $mypoint['lon'], $point['timestamp']);
}

// load points

$gpx2png->loadPoints($points);

// set custom draw params

$gpx2png->drawParams->track->color = "black";
$gpx2png->drawParams->track->opacity = "0.3";
$gpx2png->drawParams->track->startPoint->color = "yellow";
$gpx2png->drawParams->track->distanceLabel->text_size = 20;
$gpx2png->drawParams->track->distanceLabel->text_color = 'red';

// set osm source type

$gpx2png->setMapSourceName("osm_topo");

// set custom tiles cache directory
// default: sys_get_temp_dir().'/tiles'

$gpx2png->mapSource->setTilesDirectory(__DIR__.'/tiles');

// receive result

$res = $gpx2png->generateImage();

// add extra overlays

$extraPoint = $points[mt_rand(0, count($points)-1)];
$drawParamsPoint = new DrawParamsPoint();
$drawParamsPoint->setTemplate(DrawParamsPoint::TPL_LIVE_POINT);

$res->image->drawPoint($extraPoint, $drawParamsPoint);

// save or output file

$res->saveToFile("result.png");
$res->output();

Credits

License

The MIT License (MIT). Please see License File for more information.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-06-25