Przeglądaj źródła

Drobne poprawki

Mariusz Muszyński 8 lat temu
rodzic
commit
4e244262a9
1 zmienionych plików z 7 dodań i 7 usunięć
  1. 7 7
      SE/se-lib/Route/ViewTableAjax.php

+ 7 - 7
SE/se-lib/Route/ViewTableAjax.php

@@ -768,12 +768,12 @@ class Route_ViewTableAjax extends RouteBase {
 		}
 
 		// Scalenie pobliskich kolizji występujących na różnych liniach
-		$starts = array_filter($_points, function($point) { return in_array('iistart', $point['type']); }, ARRAY_FILTER_USE_BOTH);
-		$stops = array_filter($_points, function($point) { return in_array('iistop', $point['type']); }, ARRAY_FILTER_USE_BOTH);
-		$points = array_filter($_points, function($point) { return in_array('p', $point['type']); }, ARRAY_FILTER_USE_BOTH);
-		foreach ($stops as $i => $stopPoint) {
-			if (isset($points[$i + 1]) && isset($starts[$i + 2])) {
-				if (Geometry::distance($stopPoint['point'], $points[$i + 1]['point']) + Geometry::distance($points[$i + 1]['point'], $starts[$i + 2]['point']) < 1) {
+		$starts = array_keys(array_filter($_points, function($point) { return in_array('iistart', $point['type']); }));
+		$stops = array_keys(array_filter($_points, function($point) { return in_array('iistop', $point['type']); }));
+		$points = array_keys(array_filter($_points, function($point) { return in_array('p', $point['type']); }));
+		foreach ($stops as $i) {
+			if (in_array($i+1, $points) && in_array($i+2, $starts)) {
+				if (Geometry::distance($_points[$i]['point'], $_points[$i+1]['point']) + Geometry::distance($_points[$i+1]['point'], $_points[$i+2]['point']) < 1) {
 					unset($_points[$i]);
 					unset($_points[$i + 2]);
 					$_points[$i + 1]['type'][] = 'ii';
@@ -814,7 +814,7 @@ class Route_ViewTableAjax extends RouteBase {
 					'iistart' => 'Kolizja (II) start',
 					'iistop' => 'Kolizja (II) stop'
 				];
-				if (!in_array($_type, $types)) return $types[$_type];
+				if (isset($types[$_type])) return $types[$_type];
 				throw new Exception("Nieznany typ punktu - {$_type} (" . __CLASS__ . '::' . __FUNCTION__ . ')');
 			}, $type));
 		};