|
|
@@ -0,0 +1,48 @@
|
|
|
+using System;
|
|
|
+using System.Collections.Generic;
|
|
|
+using System.Linq;
|
|
|
+using System.Text;
|
|
|
+using System.Threading.Tasks;
|
|
|
+using parkMonitor.DB;
|
|
|
+using System.Configuration;
|
|
|
+
|
|
|
+namespace parkMonitor.server.CoreThread
|
|
|
+{
|
|
|
+ class AllotParkingSpace
|
|
|
+ {
|
|
|
+ //根据车位位置及状态分配目标车位,返回Parking Space的ID
|
|
|
+ public Parking_Space MallocParkingSpace(CEntrance pt_Ent)
|
|
|
+ {
|
|
|
+ DBOperation o = new DBOperation();
|
|
|
+ List<Parking_Space> lps = o.GetParkingSpace();
|
|
|
+ double xWeight = Convert.ToDouble(ConfigurationManager.AppSettings["xWeight"]);
|
|
|
+ double yWeight = Convert.ToDouble(ConfigurationManager.AppSettings["yWeight"]);
|
|
|
+ double zWeight = Convert.ToDouble(ConfigurationManager.AppSettings["zWeight"]);
|
|
|
+
|
|
|
+ Parking_Space rps = new Parking_Space();
|
|
|
+
|
|
|
+ float min_dis = 10000;
|
|
|
+ for (int i = 0; i < lps.Count(); i++)
|
|
|
+ {
|
|
|
+ float deltaX = (lps[i].parkingSpaceX - pt_Ent.parkingEntX) * (float)xWeight;
|
|
|
+ float deltaY = (lps[i].parkingSpaceY - pt_Ent.parkingEntY) * (float)yWeight;
|
|
|
+ float deltaZ = (lps[i].parkingSpaceZ - pt_Ent.parkingEntZ) * (float)zWeight;
|
|
|
+ float d = (float)System.Math.Sqrt(deltaX * deltaX + deltaY * deltaY + deltaZ * deltaZ);
|
|
|
+ if (d < min_dis)
|
|
|
+ {
|
|
|
+ min_dis = d;
|
|
|
+ rps = lps[i];
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ return rps;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public class CEntrance
|
|
|
+ {
|
|
|
+ public int parkingEntX { get; set; }
|
|
|
+ public int parkingEntY { get; set; }
|
|
|
+ public int parkingEntZ { get; set; }
|
|
|
+ }
|
|
|
+}
|