瀏覽代碼

Drobna poprawka do CSV

Mariusz Muszyński 8 年之前
父節點
當前提交
63572b1ff0
共有 1 個文件被更改,包括 14 次插入0 次删除
  1. 14 0
      SE/se-lib/Route/ViewTableAjax.php

+ 14 - 0
SE/se-lib/Route/ViewTableAjax.php

@@ -767,6 +767,20 @@ class Route_ViewTableAjax extends RouteBase {
 			$_points[] = ['point' => $line->b, 'type' => ['p']];
 		}
 
+		// 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) {
+					unset($_points[$i]);
+					unset($_points[$i + 2]);
+					$_points[$i + 1]['type'][] = 'ii';
+				}
+			}
+		}
+
 		// Połączenie kilku takich samych punktów w jeden punkt (np. punkt początku linii oraz punkt początku kolizji - gdy wypadają w tym samym miejscu)
 		$points = [];
 		$lastPoint = null;