承接 chillerlan/php-geojson-helpers 相关项目开发

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

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

chillerlan/php-geojson-helpers

最新稳定版本:2.0.0

Composer 安装命令:

composer require chillerlan/php-geojson-helpers

包简介

PHP 7.2+

README 文档

README

PHP Version Support version license Continuous Integration Coverage Scrunitizer Packagist downloads

Documentation

Requirements

Installation

requires composer

composer.json (note: replace dev-master with a version boundary)

{
	"require": {
		"php": "^7.4 || ^8.0",
		"chillerlan/php-geojson-helpers": "dev-master"
	}
}

Profit!

Usage

FeatureCollection

$featureCollection = (new FeatureCollection)->setBbox([0, 0, 1024, 1024]);

// add a single feature
$feature = new Feature([512, 512], 'Point', 1);
$featureCollection->addFeature($feature);

// add an iterable of features
$featureCollection->addFeatures([$feature, /* ... more features ... */]);

// create the GeoJSON, feed leaflet
$json = $featureCollection->toJSON();

// as of v2.x via JsonSerializable
$json = json_encode($featureCollection);
{
    "type":"FeatureCollection",
    "bbox":[0, 0, 1024, 1024],
    "features":[
        {
            "type":"Feature",
            "geometry":{
                "type":"Point",
                "coordinates":[512, 512]
            },
            "properties":{
                "id":1
            }
        }
    ]
}

PolylineSimplifyer

$polylineCoords = [[11, 12], [21, 22], [31, 32], /* ... */];

$ps             = new PolylineSimplifyer($polylineCoords);
$simplified     = $ps->simplify(5, true);

API

Feature methods

method return description
__construct(array $coords = null, string $type = null, $id = null) - coords: [x, y]
setGeometry(array $coords, string $type) Feature coords: [x, y], type is one of Feature::types
setProperties(array $properties) Feature
setID($id) Feature

FeatureCollection methods

method return description
__construct(iterable $features = null) -
addFeature(Feature $feature) FeatureCollection
addFeatures(iterable $features) FeatureCollection
clearFeatures() FeatureCollection

common methods to Feature and FeatureCollection

method return description
setBbox(array $bbox) Feature/FeatureCollection
toArray() array
toJSON(int $options = null) string
jsonSerialize() array from JsonSerializable

ContinentRect

method return description
__construct(array $continent_rect) - NW/SE corners [[nw_x, nw_y],[se_x, se_y]]
getBounds() array
getCenter() array
getPoly() array

PolylineSimplifyer

method return description
__construct(array $polylineCoords) - an array of polyline coordiantes: [[x1, y1], [x2, y2], ...]
simplify(float $tolerance = 1, bool $highestQuality = false) array

统计信息

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

GitHub 信息

  • Stars: 2
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-02-14