出于某种原因,当我尝试运行我的php脚本时,
致命错误:Class' GeoTools \ LatLngCollection'没找到...
但是,我在同一目录中有类。即,我正在使用https://github.com/jkoreska/RouteboxerPHP
我将所有脚本放在同一目录中。
有人能告诉我我做错了吗?
当前脚本:
$points = [
[48.167, 17.104],
[48.399, 17.586],
[48.908, 18.049],
[49.22253, 18.734436],
[48.728115, 21.255798],
];
$collection = new GeoTools\LatLngCollection($points);
$boxer = new GeoTools\RouteBoxer();
//calculate boxes with 10km distance from the line between points
$boxes = $boxer->box(points, $distance = 10);
//boxes now contain an array of LatLngBounds
//literally have to return string that is printed to STDOUT
print $boxes
?>
答案 0 :(得分:1)
当您编写GeoTools\LatLngCollection
时,GeoTools
不是目录,而是类LatLngCollection
的命名空间。但是,链接的源代码根本没有定义名称空间,顺便说一下,没有名为LatLngCollection
的类。所以你最有可能需要做的是
require_once(__DIR__ . '/RouteBoxer.class.php');
$points = ...;
$collection = array();
array_push($collection, new LatLng(48.167, 17.104);
array_push($collection, new LatLng(48.399, 17.586);
/...
$boxer = new RouteBoxer();
//...
require包含一个文件。所以我假设你把这些类保存在文件" RouteBoxer.class.php "就像它在GitHub中一样。