vicchi/geojson-rewind 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

vicchi/geojson-rewind

最新稳定版本:1.0.1

Composer 安装命令:

composer require vicchi/geojson-rewind

包简介

PHP helper classes to enforce RFC7946 polygon winding order in GeoJSON

README 文档

README

Build Status

geojson-rewind

A set of PHP helper classes to assist in generating GeoJSON geometries that are compliant with the GeoJSON specification.

Polygon ring order was undefined in the original GeoJSON spec, but since RFC7946 the right hand rule is mandated.

A linear ring MUST follow the right-hand rule with respect to the area it bounds, i.e., exterior rings are counterclockwise, and holes are clockwise.

(If you know British English rather than American English, simply substitute anticlockwise for counterclockwise.)

Acknowledgements

geojson-rewind is a port to PHP of Mapbox's Node.JS geojson-rewind module by Tom McWright et al. Full credits, kudos and acknowledgements are due to Tom and the rest of the Mapbox team.

Install

The easiest way to install geojson-rewind is by using composer:

$> composer require vicchi/geojson-rewind

Usage

<?php

include "vendor/autoload.php";

$source = [
    'type' => 'Polygon',
    'coordinates' => [
    [ [100.0, 0.0], [101.0, 0.0], [101.0, 1.0], [100.0, 1.0], [100.0, 0.0] ],
    [ [100.2, 0.2], [100.8, 0.2], [100.8, 0.8], [100.2, 0.8], [100.2, 0.2] ]
    ]
];
$enforce_rfc7946=true;
$output = Vicchi\GeoJson\Rewind::rewind($source, $enforce_rfc7946);

// show output for demonstration purposes
var_dump($output);

?>

The output could look like this ($> is the command line prompt).

$> php test.php
array(2) {
  ["type"]=>
  string(7) "Polygon"
  ["coordinates"]=>
  array(2) {
    [0]=>
    array(5) {
      [0]=>
      array(2) {
        [0]=>
        float(100)
        [1]=>
        float(0)
      }
      [1]=>
      array(2) {
        [0]=>
        float(101)
        [1]=>
        float(0)
      }
      [2]=>
      array(2) {
        [0]=>
        float(101)
        [1]=>
        float(1)
      }
      [3]=>
      array(2) {
        [0]=>
        float(100)
        [1]=>
        float(1)
      }
      [4]=>
      array(2) {
        [0]=>
        float(100)
        [1]=>
        float(0)
      }
    }
    [1]=>
    array(5) {
      [0]=>
      array(2) {
        [0]=>
        float(100.2)
        [1]=>
        float(0.2)
      }
      [1]=>
      array(2) {
        [0]=>
        float(100.2)
        [1]=>
        float(0.8)
      }
      [2]=>
      array(2) {
        [0]=>
        float(100.8)
        [1]=>
        float(0.8)
      }
      [3]=>
      array(2) {
        [0]=>
        float(100.8)
        [1]=>
        float(0.2)
      }
      [4]=>
      array(2) {
        [0]=>
        float(100.2)
        [1]=>
        float(0.2)
      }
    }
  }
}

License

geojson-rewind is published under the BSD-3-Clause license. See License File for more information.

统计信息

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

GitHub 信息

  • Stars: 9
  • Watchers: 0
  • Forks: 10
  • 开发语言: PHP

其他信息

  • 授权协议: BSD-3-Clause
  • 更新时间: 2018-02-09