|
@@ -75,10 +75,25 @@ $points_asText = unserialize(file_get_contents('points_asText.txt'));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
+function joins2lineString($joins_keys) {
|
|
|
|
|
+ global $joins_asText;
|
|
|
|
|
+ if ($joins_keys) {
|
|
|
|
|
+ foreach ($joins_keys as $join_key) {
|
|
|
|
|
+ $points[] = Vendor_Geophp::load($joins_asText[$join_key], 'wkt');
|
|
|
|
|
+ }
|
|
|
|
|
+ return new LineString($points);
|
|
|
|
|
+ } else return null;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
function findWay($joinA, $joinB, $path = array()) {
|
|
function findWay($joinA, $joinB, $path = array()) {
|
|
|
global $ways2joins, $joins2ways, $points2joins, $ways_asText, $points_asText;
|
|
global $ways2joins, $joins2ways, $points2joins, $ways_asText, $points_asText;
|
|
|
- if ($joinA == $joinB) return $path;
|
|
|
|
|
- else {
|
|
|
|
|
|
|
+ if ($joinA == $joinB) {
|
|
|
|
|
+ $joinsPath = array($joinB);
|
|
|
|
|
+ foreach (array_reverse($path) as $way_key) {
|
|
|
|
|
+ array_unshift($joinsPath, $ways2joins[$way_key][1 - array_search($joinsPath[0], $ways2joins[$way_key])]);
|
|
|
|
|
+ }
|
|
|
|
|
+ return $joinsPath;
|
|
|
|
|
+ } else {
|
|
|
$subPaths = array();
|
|
$subPaths = array();
|
|
|
foreach ($joins2ways[$joinA] as $way_key) {
|
|
foreach ($joins2ways[$joinA] as $way_key) {
|
|
|
if (!in_array($way_key, $path)) {
|
|
if (!in_array($way_key, $path)) {
|
|
@@ -107,10 +122,20 @@ function findWay($joinA, $joinB, $path = array()) {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-$res = findWay(100,110);
|
|
|
|
|
-$distance = 0;
|
|
|
|
|
-foreach ($res as $way_key) {
|
|
|
|
|
- $distance += Vendor_Geophp::load($ways_asText[$way_key], 'wkt')->greatCircleLength();
|
|
|
|
|
-}
|
|
|
|
|
-print_r($res);
|
|
|
|
|
-echo "Distance: ".$distance."m\n";
|
|
|
|
|
|
|
+#echo joins2lineString($res = findWay(100,110))->asText();
|
|
|
|
|
+#echo joins2lineString($res = findWay(25690,20134))->asText();
|
|
|
|
|
+$timeStart = microtime();
|
|
|
|
|
+echo joins2lineString($res = findWay(25690,23039))->asText();
|
|
|
|
|
+$timeEnd = microtime();
|
|
|
|
|
+
|
|
|
|
|
+list($usecStart, $secStart) = explode(" ", $timeStart);
|
|
|
|
|
+list($usecEnd, $secEnd) = explode(" ", $timeEnd);
|
|
|
|
|
+$diff = $secEnd - $secStart + $usecEnd - $usecStart;
|
|
|
|
|
+echo "\n\nCzas liczenia: ".$diff." s\n";
|
|
|
|
|
+
|
|
|
|
|
+//$distance = 0;
|
|
|
|
|
+//foreach ($res as $way_key) {
|
|
|
|
|
+// $distance += Vendor_Geophp::load($ways_asText[$way_key], 'wkt')->greatCircleLength();
|
|
|
|
|
+//}
|
|
|
|
|
+//print_r($res);
|
|
|
|
|
+//echo "Distance: ".$distance."m\n";
|