예제 #1
0
  /**
   * 翻转线路,生成逆向行驶数组,并保存
   *
   * @timestamp Feb 23, 2016 11:41:56 PM
   * @param h
   */
  private void reverse(String h, StandardArea area) {
    String[] rs = h.split(",");
    List<String> list = new ArrayList<>();
    Collections.addAll(list, rs);

    String one =
        list.toString() //
            .replaceAll("\\[", "")
            .replaceAll("\\]", "")
            .replaceAll(" ", "");
    Collections.reverse(list);
    String two =
        list.toString() //
            .replaceAll("\\[", "")
            .replaceAll("\\]", "")
            .replaceAll(" ", "");
    for (int i = 30; i <= 100; i = i + 10) { // 30KM/H到100KM/H不等
      StandardRoute route = new StandardRoute();
      route.setSpeed(Double.parseDouble(String.format("%.2f", (i / 3.6 * 100)))); // 速度单位-->cm/s
      route.setRouteTable(one);
      route.setAreaId(area.getId());
      routeService.insertRoute(route);
      route = new StandardRoute();
      route.setSpeed(Double.parseDouble(String.format("%.2f", (i / 3.6 * 100)))); // 速度单位-->cm/s
      route.setRouteTable(two);
      route.setAreaId(area.getId());
      routeService.insertRoute(route);
    }
  }
예제 #2
0
 /**
  * 初始化车
  *
  * @timestamp Feb 24, 2016 1:43:57 PM
  * @param area
  */
 private void initCar(StandardArea area) {
   for (char a = 'a'; a <= 'e'; a++) {
     StandardCar car = new StandardCar();
     String image = "127.0.0.1:8080/center/image/" + String.valueOf(a) + ".png";
     car.setImage(image);
     car.setAreaId(area.getId());
     carService.insertCar(car);
   }
 }
예제 #3
0
  /**
   * 初始化区域
   *
   * @timestamp Feb 19, 2016 8:44:48 PM
   */
  private void initArea(StandardArea area) {
    this.areaService =
        (StandardAreaService)
            ServiceProxy //
                .getServiceProxy(new StandardAreaServiceImpl());
    this.crossService =
        (StandardCrossService)
            ServiceProxy //
                .getServiceProxy(new StandardCrossServiceImpl());
    this.roadService =
        (StandardRoadService)
            ServiceProxy //
                .getServiceProxy(new StandardRoadServiceImpl());
    this.laneService =
        (StandardLaneService)
            ServiceProxy //
                .getServiceProxy(new StandardLaneServiceImpl());
    this.lightService =
        (StandardLightService)
            ServiceProxy //
                .getServiceProxy(new StandardLightServiceImpl());
    this.routeService =
        (StandardRouteService)
            ServiceProxy //
                .getServiceProxy(new StandardRouteServiceImpl());
    this.carService =
        (StandardCarService)
            ServiceProxy //
                .getServiceProxy(new StandardCarServiceImpl());
    area.setIp(Constant.AREAIP);
    area.setCrossNum(Constant.HORIZONTALNUM * Constant.VERTICALNUM);

    double AREALENGTH = Constant.ROADREALITYLENGTH * (Constant.HORIZONTALNUM + 1); // 浏览器中显示的长度
    double AREAWIDTH = Constant.ROADREALITYLENGTH * (Constant.VERTICALNUM + 1); // 浏览器中显示的宽度

    area.setLength(AREALENGTH);
    area.setWidth(AREAWIDTH);
    area.setLightNum(area.getCrossNum() * 4);
    area.setName(Constant.AREANAME);
    area.setPort(Constant.AREAPORT);
    area.setRoadNum(
        (Constant.HORIZONTALNUM + 1) * (Constant.VERTICALNUM + 1) * Constant.HORIZONTALNUM);
    areaService.insertArea(area);
  }