项目作者: mscpatrykkosiba

项目描述 :
PHP patchfind algorithm in (X,Y) coords weight graph
高级语言: PHP
项目地址: git://github.com/mscpatrykkosiba/dijkstra-patchfind-algorithm.git


dijkstra-patchfind-algorithm

Scrutinizer Code Quality
Build Status
Code Intelligence Status

PHP patchfind algorithm in (X,Y) coords weight graph.

How to use

The maximum position in the graph and image size is 1000x1000 [px]. Can be changed in the code.

First, enter the coordinates of the start and end points in the graph. The coordinates cannot be larger than the size of the declared or loaded from the graph file.

In order to add obstacles on the route of the calculated route, it is necessary to load the graphics from the .jpg file. White background corresponds to free space, dark obstacle.

The algorithm returns the route to be taken in the form of points (x, y) and allows you to generate a route in the preview image.

  1. <?php
  2. require __DIR__ .'/vendor/autoload.php';
  3. $output = new PatchFind\Calculate();
  4. //set start and finish position
  5. $output->setStartXY(0,0);
  6. $output->setEndXY(100,100);
  7. //calculate patch in blank graph
  8. $graph = $output->makeGraph(100,100);
  9. $patch = $output->getPatch($graph);
  10. var_dump($patch);
  11. /*
  12. var_dump($patch) returns:
  13. ex. (0,0),(0,1)(1,1),(1,2)
  14. ..array
  15. */
  16. //calculate patch in obstacle graph
  17. $graph = $output->loadGraph(__DIR__."/test.jpg");
  18. $patch = $output->getPatch($graph);
  19. var_dump($patch);
  20. /*
  21. var_dump($patch) returns:
  22. ex. (0,0),(0,1)(1,1),(1,2)
  23. ..array
  24. */

Render preview image

  1. <?php
  2. //render patch image
  3. $image_url = $output->renderPatch(__DIR__.'/test.jpg', $patch);

blank graph preview load graph preview

Requirements

  • PHP version 5.5 or later
  • PHP GB Library
  • PHPUnit for tests (optional)

Installation

This library depends on composer for installation . For installation of composer, please visit getcomposer.org.
You can download .zip for compile composer.json file to create vendor directory.

Authors

MSc Patryk Kosiba
See profile on linkedin (https://www.linkedin.com/in/patryk-kosiba/)

License

This project is licensed under the MIT License.