masterskill/afa-api-laravel 问题修复 & 功能扩展

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

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

masterskill/afa-api-laravel

最新稳定版本:3.0.3

Composer 安装命令:

composer require masterskill/afa-api-laravel

包简介

A package for the AFA Code API Integration, that needs to interacts with it's database and existing database

README 文档

README

API v0.2.1 from the AFACodes

Endpoints and functionalities of the Logistic Grid, syntax “CM-$etc”. For Scientific Grid (syntax “CM+$etc”) and covers, see next documentation. We use, instead a Swagger, the “page endpoint” that is self-explanatory.

Installation

With composer

composer require masterskill/afa-code-laravel

City Querying

For querying a city, you should initialize the cityQuery class.

Make sure you have the App\Models\City on the project.

use Masterskill\AfaApiLaravel\Domains\Http\City\CityQuery;

$cityQuery = new CityQuery();

$query ="CM-SOA";

$result = $cityQuery->query($query);

print_r($cityQuery);

Level

For the level correspondance, it depends on the side you want it.
From application, we use all these level, that is all the point of view from the user :

  • 180 : 1m
  • 155 : 6m
  • 130 : 30m
  • 105 : 200m
  • 80 : 1km

Side

From AFACode, there is no level defined. Instead, they use side for the point of view.
With that, we need to make sure we transform all level into side
Below the SIDE and LEVEL relation.

  • 0.5 : 180
  • 2.5 : 155
  • 16 : 130
  • 90.5 : 105
  • 512 : 80

To push it a little further, below the calculation.

    switch (($side)) {
        case $side < 2.5:
            return 180;
        case    2.5 <= $side && $side < 15:
            return 155;
        case 15 <= $side && $side < 100:
            return 130;
        case 100 <= $side && $side < 600:
            return 105;
        case 600 <= $side:
            return 80;
    }

Centroid

Each city or point in the API will be assigned a centroid. This centroid can be used everywhere, but you can be sure there is always this centroid. You can calculate the centroid of point dirrectly too, but make sure to have the coordinatees in form of an array of lon / lat object.

To calculate it manually, you have the helper \Masterskill\AfaApiLaravel\Helpers\Centroide, and call calculateCentroid method statically.

Cell

A cell is a portion of territory in the AFACode API. You can get the cell either with the longitude and lattitude or directly with the BANOC code directly, both will generate a cell. The difference is that we often use the BANOC Code if we search a city or something we know the format, and we use the GeoQuery if we want to use a lon / lat format.

Make sure you instanciate the CellByGeoQuery class before using it. When you pass the lon and lat and eventually the level, for exemple lon : 11.20524 and lat : 1.6580, it will be processed to make sure that the request will be valid in the AFACode API.

Thanks

Thanks for AFACode for their beautifull API. You can check their tools at https://afa.codes.

For example, in Yaoundé region, we can have https://afa.codes/CM-YE4-6DS

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-09-27