nubs/coordinator 问题修复 & 功能扩展

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

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

nubs/coordinator

Composer 安装命令:

composer require nubs/coordinator

包简介

A general purpose geo library.

README 文档

README

A general purpose geo library for PHP.

Build Status Scrutinizer Code Quality Code Coverage

Latest Stable Version Total Downloads Latest Unstable Version License

Dependency Status

Installation

This package uses composer so you can just add nubs/coordinator as a dependency to your composer.json file or execute the following command:

composer require nubs/coordinator

Usage

Coordinates

A coordinate is a latitude/longitude pair. They are created using radians, although the CoordinateFactory and various CoordinateSystem's discussed below can help create them as well.

Creating a coordinate

Using the constructor, you can create a coordinate using radians.

<?php
use Nubs\Coordinator\Coordinate;

$coordinate = new Coordinate($latitudeInRadians, $longitudeInRadians);
Using the Coordinate Factory

Using the CoordinateFactory, you can create coordinates in a similar way.

<?php
use Nubs\Coordinator\CoordinateFactory;

$coordinateFactory = new CoordinateFactory();
$coordinate = $coordinateFactory->createFromRadians(
    $latitudeInRadians,
    $longitudeInRadians
);

The CoordinateFactory, however, can also create coordinates from latitude and longitude specified in degrees.

<?php
use Nubs\Coordinator\CoordinateFactory;

$coordinateFactory = new CoordinateFactory();
$coordinate = $coordinateFactory->createFromDegrees(
    $latitudeInDegrees,
    $longitudeInDegrees
);

Accessing Coordinate Data

The latitude and longitude in radians can be pulled back out of the Coordinate.

echo "Latitude: {$coordinate->latitudeInRadians()}\n";
echo "Longitude: {$coordinate->longitudeInRadians()}\n";

The latitude and longitude can also be pulled back out in degrees.

echo "Latitude: {$coordinate->latitudeInDegrees()}\n";
echo "Longitude: {$coordinate->longitudeInDegrees()}\n";

A __toString() helper also exists that returns the coordinate in degrees.

echo (string)$coordinate;

Coordinate Systems

Coordinate systems help convert coordinates from other systems/projections into standard latitude/longitude. Currently the Mercator projection is defined.

Coordinate systems operate on a given Spheroid, and there is an Earth spheroid defined.

Converting Coordinates

A coordinate in a coordinate system can be converted to degrees/radians.

<?php
use Nubs\Coordinator\CoordinateFactory;
use Nubs\Coordinator\CoordinateSystem\Mercator;
use Nubs\Coordinator\Spheroid\Earth;

$mercator = new Mercator(new Earth(), new CoordinateFactory());
$coordinate = $mercator->loadCoordinate($xCoordinate, $yCoordinate);
echo (string)$coordinate;

License

Coordinator is licensed under the MIT license. See LICENSE for the full license text.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2014-02-23

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固