migda/gugik-php-sdk

PHP SDK for http://capap.gugik.gov.pl/api/fts/ API

Fund package maintenance!
migda

dev-main 2021-09-19 18:34 UTC

This package is auto-updated.

Last update: 2024-10-20 01:10:37 UTC


README

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

PLEASE READ TERMS OF USE OF CAPAP GUGiK API BEFORE USE THIS PACKAGE: http://capap.gugik.gov.pl/api/fts/#_informacja_o_licencji

PHP SDK for http://capap.gugik.gov.pl/api/fts/ API - geocoding and reverse geocoding of administration units, addresses, plots, etc in Poland.

This is an unofficial PHP SDK for the CAPAP GUGiK API.

Installation

You can install the package via composer:

composer require migda/gugik-php-sdk

Usage

// Geocode commune

$gugik = new Gugik();

$reqs = new GcSingleJpaCollection([
    new GcSingleJpa([
        "gm_nazwa" => "dębno",
        "pow_nazwa" => "brzeski",
        "woj_nazwa" => "małopolskie",
    ]),
]);

$req = new GcReqJpa([
    'reqs' => $reqs,
]);

$results = $gugik->gcGmi($req);
$currentResult = $results->current();
// Reverse geocode address point

$gugik = new Gugik();

$req = new RgcReqAdr([
    'd' => 500.00,
    'x' => 16.925,
    'y' => 51.089,
]);

$result = $gugik->rgcAdr($req);
// Reverse geocode plot

$gugik = new Gugik();

$req = new RgcReqDze([
    'd' => 500.00,
    'x' => 16.925,
    'y' => 51.089,
]);

$result = $gugik->rgcDze($req);

Available methods:

Geocoding

/**
 * Geokodowanie działek - lpis
 * Geocode plots (lpis) using post
 *
 * http://capap.gugik.gov.pl/api/fts/#_geocodedzelpisusingpost
 */
public function gcDzeLpis(GcReqDze $req): GcResultCollection

/**
 * Geokodowanie gmin
 * Geocode communes using post
 *
 * http://capap.gugik.gov.pl/api/fts/#_geocodegmiusingpost
 */
public function gcGmi(GcReqJpa $req): GcResultCollection

Reverse geocoding

/**
 * Odwrotne geokodowanie - punkty adresowe
 * Reverse geocode address points using get
 *
 * http://capap.gugik.gov.pl/api/fts/#_d8df035f1b22f89d3c826789834b2d65
 */
public function rgcAdr(RgcReqAdr $req): GcResult


/**
 * Odwrotne geokodowanie - działki
 * Reverse geocode plots using get
 *
 * http://capap.gugik.gov.pl/api/fts/#_dzeusingget
 */
public function rgcDze(RgcReqDze $req): GcResult

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

TODO

  1. Handle more endpoints from: http://capap.gugik.gov.pl/api/fts/
  2. More complex DTO for responses (right now there is only very basic GcResult class)
  3. More tests
  4. Improve exceptions

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

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