Package com.lbslocal.cc.common

Examples of com.lbslocal.cc.common.TCPClientDecarta


    poiRouteIDs = getPoiRouteCurrentIDs(ro.getRouteDetails().getPoiRoute());

    Connection con = dataBase.getConnection("DADOS_WEBSERVICES");

    TCPClientDecarta tcpDecarta = new TCPClientDecarta(_server, _port);

    try {
      Statement st = con.createStatement();
      ResultSet rr = st.executeQuery(" SELECT * FROM TB_DADOS_ROUTEPROXIMITY WHERE ID_LICENCA = " + idLicenca);

      while (rr.next()) {
        clientDataSource = rr.getString("DS_DECARTA");
        proximity = true;

        if (ro.getRadius() == 0)
          ro.setRadius(10);

        if (ro.getRouteDetails().getRouteType() == 12 || ro.getRouteDetails().getRouteType() == 13)
          proximity = false;
      }

      st.close();
      rr.close();
    } catch (Exception ex) {
      // throw ex;
    } finally {
      con.close();
    }
    List<String> poiRoutes = new ArrayList<String>();

    try {
      if (ro.getRouteDetails().getPoiRoute() != null) {
        for (int c = 0; c < ro.getRouteDetails().getPoiRoute().length; c++) {
          String poiRoute = ro.getRouteDetails().getPoiRoute()[c];

          con = dataBase.getConnection("DADOS_WEBSERVICES");

          Statement st = con.createStatement();
          ResultSet rr = st.executeQuery("SELECT * FROM TB_POIROUTE WHERE poiRoute = '" + poiRoute + "'");

          while (rr.next()) {
            if (!Functions.IsNullOrEmpty(ro.getDataSource())) {
              if (ro.getDataSource().toUpperCase().equals("BR"))
                poiRoutes.add(rr.getString("decartaRodSource"));
              else
                poiRoutes.add(rr.getString("decartaSource"));
            } else
              poiRoutes.add(rr.getString("decartaSource"));
          }

          st.close();
          rr.close();
        }
      }
    } catch (Exception ex) {

    } finally {
      con.close();
    }

    RouteStop[] rStopSelect = removeRouteStop(rs, 0);

    try {
      String[] partMaster = _response.split(Pattern.quote("|"));

      double cumulativeDistance = 0;
      int paradas = 1;

      List<TollFeeAux> pedagioList = new ArrayList<TollFeeAux>();

      for (int x = 0; x < partMaster.length; x++) {
        if (partMaster[x].indexOf("S2=") >= 0) {
          poiList.clear();
          String[] part = partMaster[x].split(Pattern.quote("%"));

          SegAux segAux = new SegAux();
          segAux.seg = new SegmentDescription();

          for (int z = 0; z < part.length; z++) {
            if (part[z].indexOf("DIST=K") >= 0) {
              cumulativeDistance += Functions.formatDouble(part[z].replace("DIST=K", ""), "0.00");
              segAux.seg.setCumulativeDistance(Functions.formatDouble(cumulativeDistance, "0.00"));
              segAux.seg.setDistance(Functions.formatDouble(part[z].replace("DIST=K", ""), "0.00"));
              segAux.seg.setDistance(segAux.seg.getDistance());
            }
            if (part[z].indexOf("TIME=") >= 0) {
              segAux.seg.setTime(part[z].replace("TIME=", ""));
            }
            if (part[z].indexOf("AC=") >= 0) {
              if (part[z].contains("21")) {
                if (Functions.IsNullOrEmpty(segAux.seg.getCity().getName())) {
                  segAux.seg.setCity(new City());
                  segAux.seg.getCity().setName(Functions.CamelCase(part[z + 1].replace("S2=", "").split(Pattern.quote("\\"))[1]));
                  segAux.seg.getCity().setState(part[z + 1].replace("S2=", "").split(Pattern.quote("\\"))[4]);
                }
              }

              if (part[z].contains("71")) {
                if (Functions.IsNullOrEmpty(segAux.seg.getDescription())) {
                  if (part[z + 1].indexOf("#") >= 0)
                    segAux.seg.setDescription(Functions.CamelCase(part[z + 1].substring(0, part[z + 1].indexOf("#")).replace(
                        "S2=", "")));
                  else
                    segAux.seg.setDescription(Functions.CamelCase(part[z + 1].replace("S2=", "")));

                  try {
                    segAux.seg.setRoadType(part[z + 1].split(Pattern.quote("_"))[1].replace("T:", ""));
                  } catch (Exception ex) {
                    segAux.seg.setRoadType(part[z + 1].substring(part[z + 1].indexOf("T:") + 2, 2).replace("_", ""));
                  }
                }
              }
            }

            if (part[z].indexOf("TURN=") >= 0)
              segAux.seg.setCommand(Translate(part[z].replace("TURN=", ""), ro.getLanguage()));

            if (part[z].indexOf("LL=") >= 0) {
              if (segAux.seg.getPoint().getX() == 0) {
                segAux.seg.setPoint(new Point());
                segAux.seg.getPoint()
                    .setX(Double.parseDouble(part[z].replace("LL=", "").split(Pattern.quote(","))[1].replace("|", "").replace(
                        "%", "")));
                segAux.seg.getPoint()
                    .setY(Double.parseDouble(part[z].replace("LL=", "").split(Pattern.quote(","))[0].replace("|", "").replace(
                        "%", "")));
              }
            }

            if (part[z].indexOf("VR7=") >= 0) {
              segAux.vr = part[z].replace("VR7=", "").substring(part[z].replace("VR7=", "").indexOf(",") + 1);
              // if (ro.getVehicle().getTollFeeCat() > 0)
              // {
              // Object[] obj = addPedagio(part[z], ro, segAux,
              // pedagioList, rs.length);
              // segAux = (SegAux) obj[0];
              // pedagioList = (List<TollFeeAux>) obj[1];
              // }
              //
              // if (ro.getRouteDetails().getPoiRoute() != null)
              // {
              // Object[] obj = addPOI(poiRoutes.toArray(new
              // String[0]), part[z], ro, segAux, poiList);
              // segAux = (SegAux) obj[0];
              // poiList = (List<POIDetails>) obj[1];
              // }

              if (ro.getVehicle().getTollFeeCat() > 0 || ro.getRouteDetails().getPoiRoute() != null) {
                Object[] obj = addPOIsRota(part[z], ro, segAux, pedagioList, poiList, rs.length, poiRouteIDs);
                segAux = (SegAux) obj[0];
                pedagioList = (List<TollFeeAux>) obj[1];
                poiList = (List<POIDetails>) obj[2];
              }

              if (proximity) {
                if (ro.getRouteDetails().getRouteType() == 12) {
                  String response = tcpDecarta.Send("PNB0|%" + part[z] + "%RAD=M2|%M=1000%LL%S2%S1%DS=telefonica_rotas||");
                  String[] partMasterPOI = response.split(Pattern.quote("|"));

                  for (int w = 0; w < partMasterPOI.length; w++) {
                    POIDetails poi = new POIDetails();

                    if (partMasterPOI[w].indexOf("S1") >= 0) {
                      try {
                        String[] p = partMasterPOI[w].replace("%", "").replace("S2", "").replace("S1", "").replace("LL", "")
                            .split(Pattern.quote("="));
                        int ind = p[1].lastIndexOf("\\");
                        poi.setClientID(p[2].substring(0, p[2].indexOf("\\")) + "|" + p[1].substring(ind).replace("\\", ""));
                        poi.getPoint().setX(Double.parseDouble(p[3].split(Pattern.quote(","))[1]));
                        poi.getPoint().setY(Double.parseDouble(p[3].split(Pattern.quote(","))[0]));

                        poiList.add(poi);
                        segAux.seg.setPoiRoute("S");
                        segAux.seg.setPoiRouteDetails((POIDetails[]) poiList.toArray());
                      } catch (Exception ex) {
                      }
                    }
                  }
                } else {
                  if (ro.getRouteDetails().getRouteType() == 13) {
                    String response = tcpDecarta.Send("PNB0|%" + part[z] + "%RAD=M2|%M=1000%LL%S2%S1%DS=telefonica_pf||");
                    String[] partMasterPOI = response.split(Pattern.quote("|"));

                    for (int w = 0; w < partMasterPOI.length; w++) {
                      POIDetails poi = new POIDetails();

                      if (partMasterPOI[w].indexOf("S1") >= 0) {
                        try {
                          String[] p = partMasterPOI[w].replace("%", "").replace("S2", "").replace("S1", "")
                              .replace("LL", "").split(Pattern.quote("="));
                          int ind = p[1].lastIndexOf("\\");
                          poi.setClientID(p[2].substring(0, p[2].indexOf("\\")) + "|"
                              + p[1].substring(ind).replace("\\", ""));
                          poi.getPoint().setX(Double.parseDouble(p[3].split(Pattern.quote(","))[1]));
                          poi.getPoint().setY(Double.parseDouble(p[3].split(Pattern.quote(","))[0]));

                          poiList.add(poi);
                          segAux.seg.setPoiRoute("S");
                          segAux.seg.setPoiRouteDetails((POIDetails[]) poiList.toArray());
                        } catch (Exception ex) {
                        }
                      }
                    }
                  } else {
                    String response = tcpDecarta.Send("PNB0|%" + part[z] + "%RAD=m" + ro.getRadius() + "|%M=1000%LL%S2%S1%DS="
                        + clientDataSource + "||");
                    String[] partMasterPOI = response.split(Pattern.quote("|"));

                    for (int w = 0; w < partMasterPOI.length; w++) {
                      POIDetails poi = new POIDetails();
View Full Code Here


  String[] requestProximity(String message, RouteStop[] rs, RouteProximityOptions ro, MapSize ms, String dataSource) throws Exception {
    String[] ret = new String[2];
    String response = message;

    StringBuilder request = new StringBuilder();
    TCPClientDecarta tcpDecarta = new TCPClientDecarta(_server, _port);

    try {
      String[] part = message.split(Pattern.quote("%"));

      if (message.toLowerCase().indexOf("%vr7=") > 0) {
        ret[0] = message;
        ret[0] = "";
        return ret;
      }

      int reqNumber = 0;
      Point ptCheck = new Point();

      if (response.toLowerCase().indexOf("find route") > 0) {
        ret[0] = response;
        ret[1] = request.toString();
        return ret;
      }

      while (reqNumber < 25 && (response.toLowerCase().indexOf("cannot") > 0)) {
        if (response.toLowerCase().indexOf("origin") > 0) {
          ptCheck.setX(rs[0].getPoint().getX());
          ptCheck.setY(rs[0].getPoint().getY());
        }

        if (response.toLowerCase().indexOf("destination") > 0) {
          ptCheck.setX(rs[rs.length - 1].getPoint().getX());
          ptCheck.setY(rs[rs.length - 1].getPoint().getY());
        }

        if (response.toLowerCase().indexOf("waypoint") > 0) {
          part = response.split(Pattern.quote("%"));
          ptCheck.setX(rs[Integer.parseInt(part[1].replace("WP=", "")) + 1].getPoint().getX());
          ptCheck.setY(rs[Integer.parseInt(part[1].replace("WP=", "")) + 1].getPoint().getY());
        }

        // PNB1|%LL=-23.63874,-46.62146|%S1FIELD0=?
        // *%RAD=m1000%TIMEOUT=500%DS=lbslocal_rotas%LL||

        request = new StringBuilder();
        request.append("PNB1");
        request.append("|");
        request.append("%LL=" + String.valueOf(ptCheck.getY()).replace(",", ".") + "," + String.valueOf(ptCheck.getX()).replace(",", "."));
        request.append("|");
        request.append("%S1FIELD0=? *%RAD=m2500");
        request.append("%TIMEOUT=500");
        request.append("%DS=" + dataSource + "%LL");
        request.append("||");

        String teste = tcpDecarta.Send(request.toString());

        if (teste.toLowerCase().indexOf("records") >= 0) {
          request = new StringBuilder();
          request.append("PNB1");
          request.append("|");
          request.append("%LL=" + String.valueOf(ptCheck.getY()).replace(",", ".") + "," + String.valueOf(ptCheck.getX()).replace(",", "."));
          request.append("|");
          request.append("%S1FIELD0=? *%RAD=k10");
          request.append("%TIMEOUT=500");
          request.append("%DS=" + dataSource + "%LL");
          request.append("||");

          teste = tcpDecarta.Send(request.toString());

          if (teste.toLowerCase().indexOf("records") >= 0) {
            request = new StringBuilder();
            request.append("PNB1");
            request.append("|");
            request.append("%LL=" + String.valueOf(ptCheck.getY()).replace(",", ".") + ","
                + String.valueOf(ptCheck.getX()).replace(",", "."));
            request.append("|");
            request.append("%S1FIELD0=? *%RAD=k100");
            request.append("%TIMEOUT=500");
            request.append("%DS=" + dataSource + "%LL");
            request.append("||");

            teste = tcpDecarta.Send(request.toString());
          }

          if (teste.toLowerCase().indexOf("records") >= 0) {
            if (response.indexOf("Cannot find path destination") > 0) {
              throw (new Exception("Não foi possível encontrar ligação com o ponto " + (rs.length) + " ("
                  + rs[rs.length - 1].getDescription() + ") "));
            }

            if (response.indexOf("Cannot find path origin") > 0) {
              throw (new Exception("Não foi possível encontrar ligação com o ponto " + (1) + " (" + rs[0].getDescription() + ") "));
            }

            if (response.toLowerCase().indexOf("wp") > 0) {
              throw (new Exception("Não foi possível encontrar ligação com o ponto "
                  + (Integer.parseInt(response.substring(response.indexOf("WP=") + 3,
                      response.substring(response.indexOf("WP=") + 3).indexOf("%"))) + 1)
                  + " ("
                  + rs[Integer.parseInt(response.substring(response.indexOf("WP=") + 3,
                      response.substring(response.indexOf("WP=") + 3).indexOf("%"))) + 1].getDescription() + ") "));
            }
          }
        }

        if (teste.indexOf("Plugin error") >= 0) {
          request = new StringBuilder();
          request.append("PNB1");
          request.append("|");
          request.append("%LL=" + String.valueOf(ptCheck.getY()).replace(",", ".") + "," + String.valueOf(ptCheck.getX()).replace(",", "."));
          request.append("|");
          request.append("%S1FIELD0=? *%RAD=m500");
          request.append("%TIMEOUT=500");
          request.append("%DS=" + dataSource + "%LL");
          request.append("||");

          teste = tcpDecarta.Send(request.toString());
        }

        if (teste.toLowerCase().indexOf("feature") >= 0) {
          request = new StringBuilder();
          request.append("PNB1");
          request.append("|");
          request.append("%LL=" + String.valueOf(ptCheck.getY()).replace(",", ".") + "," + String.valueOf(ptCheck.getX()).replace(",", "."));
          request.append("|");
          request.append("%S1FIELD0=? *%RAD=m5000");
          request.append("%TIMEOUT=500");
          request.append("%DS=" + dataSource + "%LL");
          request.append("||");

          teste = tcpDecarta.Send(request.toString());
        }

        Point newPoint = new Point();
        newPoint.setX(Double.parseDouble(teste.substring(teste.indexOf("LL=") + 3, teste.indexOf("LL=") + 3 + 21).split(Pattern.quote(","))[1]
            .replace("|", "").replace("%", "")));
        newPoint.setY(Double.parseDouble(teste.substring(teste.indexOf("LL=") + 3, teste.indexOf("LL=") + 3 + 21).split(Pattern.quote(","))[0]
            .replace("|", "").replace("%", "")));

        if ((ptCheck.getX() == newPoint.getX()) && (ptCheck.getY() == newPoint.getY())) {
          if (response.toLowerCase().indexOf("wp") > 0) {
            throw (new Exception("Não foi possível encontrar ligação com o ponto "
                + (Integer.parseInt(response.substring(response.indexOf("WP=") + 3, response.substring(response.indexOf("WP=") + 3)
                    .indexOf("%"))) + 1)
                + " ("
                + rs[Integer.parseInt(response.substring(response.indexOf("WP=") + 3, response.substring(response.indexOf("WP=") + 3)
                    .indexOf("%"))) + 1].getDescription() + ") "));
          }
        }

        if (response.toLowerCase().indexOf("origin") > 0) {
          rs[0].getPoint().setX(newPoint.getX());
          rs[0].getPoint().setY(newPoint.getY());
        }

        if (response.toLowerCase().indexOf("destination") > 0) {
          rs[rs.length - 1].getPoint().setX(newPoint.getX());
          rs[rs.length - 1].getPoint().setY(newPoint.getY());
        }

        if (response.toLowerCase().indexOf("waypoint") > 0) {
          rs[Integer.parseInt(part[1].replace("WP=", "")) + 1].getPoint().setX(newPoint.getX());
          rs[Integer.parseInt(part[1].replace("WP=", "")) + 1].getPoint().setY(newPoint.getY());
        }

        request = new StringBuilder();

        request.append("RMAN");
        request.append("|");

        request.append("%OLL=" + String.valueOf(rs[0].getPoint().getY()).replace(",", ".") + ","
            + String.valueOf(rs[0].getPoint().getX()).replace(",", "."));

        for (int x = 1; x < rs.length - 1; x++) {
          request.append("%WP");
          request.append("%WDLL=" + String.valueOf(rs[x].getPoint().getY()).replace(",", ".") + ","
              + String.valueOf(rs[x].getPoint().getX()).replace(",", "."));
          request.append("%WOLL=" + String.valueOf(rs[x].getPoint().getY()).replace(",", ".") + ","
              + String.valueOf(rs[x].getPoint().getX()).replace(",", "."));
        }

        request.append("%DLL=" + String.valueOf(rs[rs.length - 1].getPoint().getY()).replace(",", ".") + ","
            + String.valueOf(rs[rs.length - 1].getPoint().getX()).replace(",", "."));

        request.append("|%TIME");

        if (rs.length < 10 && ro.getRouteDetails().isOptimizeRoute())
          request.append("%OPT=1");
        else
          request.append("%OPT=0");

        switch (ro.getRouteDetails().getRouteType()) {
        case 0:
          request.append("%RS=F");
          break;
        case 1:
          request.append("%RS=S");
          break;
        case 2:
          request.append("%RS=P");
          break;
        /*
         * case 3: { request.append("%RS=F"); setTraffic(dataSource); }
         * break; case 4: { request.append("%RS=S");
         * setTraffic(dataSource); } break;
         */
        case 5:
          request.append("%RS=F");
          break;
        case 6: // 6 Rotas evitando balsas
          request.append("%ADJUSTCOST=FERRYBOAT,INF");
          break;
        case 7: // 7 Rotas evitando estradas de terra
          request.append("%ADJUSTCOST=TUNNEL,INF");
          break;
        case 8: // 8 Rotas evitando balsas e estradas de terra
          request.append("%ADJUSTCOST=FERRYBOAT,INF%ADJUSTCOST=TUNNEL,INF");
          break;
        case 9: // 9 Rotas evitando estradas com condi��es
          // prec�rias
          request.append("%ADJUSTCOST=SKYWAY,INF");
          break;
        case 10: // 10 Rotas evitando ped�gios
          request.append("%ADJUSTCOST=TOLLROAD,INF");
          break;
        case 12:
          request.append("%RS=F");
          break;
        case 13:
          request.append("%RS=F");
          break;
        }

        request.append("%S2");
        request.append("%AC");
        request.append("%TDIST=K");
        request.append("%DIST=K");
        request.append("%LLMAX");
        request.append("%LLMIN");

        if (ms.getHeight() != 0 || ro.getRouteDetails().getPoiRoute() != null || ro.getVehicle().getTollFeeCat() > 0)
          request.append("%RG");

        request.append("%VR7");
        request.append("%TURN");
        request.append("%LL");

        switch (ro.getRouteDetails().getRouteType()) {
        case 5:
          request.append("%DS=ccr_rotas");
          break;
        case 12:
          request.append("%DS=telefonica_rotas");
          break;
        case 13:
          request.append("%DS=telefonica_pf");
          break;
        /*
         * case 3: if (setTraffic(dataSource)) request.append("%EDS=" +
         * dataSource + "_edit"); else request.append("%DS=" +
         * dataSource); break; case 4: if (setTraffic(dataSource))
         * request.append("%EDS=" + dataSource + "_edit"); else
         * request.append("%DS=" + dataSource); break;
         */
        case 6: // 6 Rotas evitando balsas
          request.append("%DS=lbslocal_rodoviaria_rotas_evitando_balsas");
          break;
        case 7: // 7 Rotas evitando estradas de terra
          request.append("%DS=lbslocal_rodoviaria_rotas_evitando_terra");
          break;
        case 8: // 8 Rotas evitando balsas e estradas de terra
          request.append("%DS=lbslocal_rodoviaria_rotas_evitando_balsa_terra");
          break;
        case 9: // 9 Rotas evitando estradas com condi��es
          // prec�rias
          request.append("%DS=lbslocal_rodoviaria_rotas_evitando_condicoes_precarias");
          break;
        case 10: // 10 Rotas evitando ped�gios
          request.append("%DS=lbslocal_rodoviaria_rotas_evitando_pedagios");
          break;
        default:
          request.append("%DS=" + dataSource);
          break;
        }

        request.append("%TIMEOUT=50000");
        request.append("||");

        response = tcpDecarta.Send(request.toString());

        reqNumber++;
      }
    } catch (Exception ex) {
      throw ex;
View Full Code Here

            break;
          }
          r.append("%TIMEOUT=50000||");
        }

        response = new TCPClientDecarta(_server, _port).Send(r.toString());

        if (!(response.toLowerCase().indexOf("s=ok") > 0)) {
          String[] resp = requestProximity(response, rs, ro, ms, dataSource);
          response = resp[0];

          if ((!"".equals(response)) && (response != null)) {
            if (!"".equals(routeID) && createFile) {
              generateFileRouteID(routeID, resp[1], response);
              createFile = false;
            }
          }
        }
      } else {
        request.append("RMAN");
        request.append("|");

        request.append("%CUST=" + idLicenca + ":" + methodID + "%OLL=" + String.valueOf(rs[0].getPoint().getY()).replace(",", ".") + ","
            + String.valueOf(rs[0].getPoint().getX()).replace(",", "."));

        for (int x = 1; x < rs.length - 1; x++) {
          request.append("%WP");
          request.append("%WDLL=" + String.valueOf(rs[x].getPoint().getY()).replace(",", ".") + ","
              + String.valueOf(rs[x].getPoint().getX()).replace(",", "."));
          request.append("%WOLL=" + String.valueOf(rs[x].getPoint().getY()).replace(",", ".") + ","
              + String.valueOf(rs[x].getPoint().getX()).replace(",", "."));
        }

        request.append("%DLL=" + String.valueOf(rs[rs.length - 1].getPoint().getY()).replace(",", ".") + ","
            + String.valueOf(rs[rs.length - 1].getPoint().getX()).replace(",", "."));

        request.append("|%TIME");

        /*
         * if (ro.routeDetails.optimizeRoute) { clsOptimize.Cities
         * cityListOpt = new Cities();
         *
         * if (rs.length < 10) { request.append("%OPT=1"); } else {
         * request = new StringBuilder();
         *
         * clsOptimize.Cities cityList = new clsOptimize.Cities(); for
         * (int i = 0; i < rs.length; i++) { cityList.Add(new
         * clsOptimize.City(rs[i].point.x, rs[i].point.y, i)); }
         * Optimize opt = new Optimize(); cityListOpt =
         * opt.Begin(cityList);
         *
         * RouteStop[] rsAux = new RouteStop[rs.length]; for (int i = 0;
         * i < rs.length; i++) { rsAux[i] = new RouteStop();
         * rsAux[i].description = rs[i].description; }
         *
         * for (int i = 0; i < cityListOpt.Count; i++) {
         * rs[i].description = rsAux[cityListOpt[i].ID].description;
         * rs[i].point.x = cityListOpt[i].Location.X; rs[i].point.y =
         * cityListOpt[i].Location.Y; }
         *
         * request.append("RMAN"); request.append("|");
         *
         * request.Append("%CUST=" + idLicenca +":" + methodID + "%OLL="
         * + cityListOpt[0].Location.Y.ToString().replace(",", ".") +
         * "," + cityListOpt[0].Location.X.ToString().replace(",",
         * "."));
         *
         * for (int x = 1; x < cityListOpt.Count - 1; x++) {
         * request.append("%WP"); request.Append("%WDLL=" +
         * cityListOpt[x].Location.Y.ToString().replace(",", ".") + ","
         * + cityListOpt[x].Location.X.ToString().replace(",", "."));
         * request.Append("%WOLL=" +
         * cityListOpt[x].Location.Y.ToString().replace(",", ".") + ","
         * + cityListOpt[x].Location.X.ToString().replace(",", ".")); }
         *
         * request.Append("%DLL=" + cityListOpt[cityListOpt.Count -
         * 1].Location.Y.ToString().replace(",", ".") + "," +
         * cityListOpt[cityListOpt.Count -
         * 1].Location.X.ToString().replace(",", "."));
         *
         * request.append("|");
         *
         * request.append("%OPT=0"); } } else
         */
        request.append("%OPT=0");

        switch (ro.getRouteDetails().getRouteType()) {
        case 0:
          request.append("%RS=F");
          break;
        case 1:
          request.append("%RS=S");
          break;
        case 2:
          request.append("%RS=P");
          break;
        case 3: {
          request.append("%RS=F");
          // setTraffic(dataSource);
        }
          break;
        case 4: {
          request.append("%RS=S");
          // setTraffic(dataSource);
        }
          break;
        case 5:
          request.append("%RS=F");
          break;
        case 6: // 6 Rotas evitando balsas
          request.append("%ADJUSTCOST=FERRYBOAT,INF");
          break;
        case 7: // 7 Rotas evitando estradas de terra
          request.append("%ADJUSTCOST=TUNNEL,INF");
          break;
        case 8: // 8 Rotas evitando balsas e estradas de terra
          request.append("%ADJUSTCOST=FERRYBOAT,INF%ADJUSTCOST=TUNNEL,INF");
          break;
        case 9: // 9 Rotas evitando estradas com condi��es
          // prec�rias
          request.append("%ADJUSTCOST=SKYWAY,INF");
          break;
        case 10: // 10 Rotas evitando ped�gios
          request.append("%ADJUSTCOST=TOLLROAD,INF");
          break;
        case 12:
          request.append("%RS=F");
          break;
        case 13:
          request.append("%RS=F");
          break;
        }

        request.append("%S2");
        request.append("%AC");
        request.append("%TDIST=K");
        request.append("%DIST=K");
        request.append("%LLMAX");
        request.append("%LLMIN");

        if (ms.getHeight() != 0 || ro.getRouteDetails().getPoiRoute() != null || ro.getVehicle().getTollFeeCat() > 0 || rs.length > 14)
          request.append("%RG");

        request.append("%VR7");
        request.append("%TURN");
        request.append("%LL");

        switch (ro.getRouteDetails().getRouteType()) {
        case 5:
          request.append("%DS=ccr_rotas");
          break;
        case 12:
          request.append("%DS=telefonica_rotas");
          break;
        case 13:
          request.append("%DS=telefonica_pf");
          break;
        /*
         * case 3: if(setTraffic(dataSource)) request.append("%EDS=" +
         * dataSource + "_edit"); else request.append("%DS=" +
         * dataSource); break;
         */
        /*
         * case 4: if (setTraffic(dataSource)) request.append("%EDS=" +
         * dataSource + "_edit"); else request.append("%DS=" +
         * dataSource); break;
         */
        case 6: // 6 Rotas evitando balsas
          request.append("%DS=lbslocal_rodoviaria_rotas_evitando_balsas");
          break;
        case 7: // 7 Rotas evitando estradas de terra
          request.append("%DS=lbslocal_rodoviaria_rotas_evitando_terra");
          break;
        case 8: // 8 Rotas evitando balsas e estradas de terra
          request.append("%DS=lbslocal_rodoviaria_rotas_evitando_balsa_terra");
          break;
        case 9: // 9 Rotas evitando estradas com condi��es
          // prec�rias
          request.append("%DS=lbslocal_rodoviaria_rotas_evitando_condicoes_precarias");
          break;
        case 10: // 10 Rotas evitando ped�gios
          request.append("%DS=lbslocal_rodoviaria_rotas_evitando_pedagios");
          break;
        default:
          request.append("%DS=" + dataSource);
          break;
        }

        request.append("%TIMEOUT=50000");
        request.append("||");

        response = new TCPClientDecarta(_server, _port).Send(request.toString());

        if (!(response.toLowerCase().indexOf("s=ok") > 0)) {
          String[] resp = requestProximity(response, rs, ro, ms, dataSource);
          response = resp[0];

View Full Code Here

  double totalPedagios = 0;

  public Object[] addPedagio(String vr, RouteProximityOptions ro, SegAux segAux, List<TollFeeAux> pedagioList, int nroParadas) throws IOException {
    Object[] obj = new Object[2];

    TCPClientDecarta tcpDecarta = new TCPClientDecarta(_server, _port);

    String dataSourcePOI = "lbslocal_pedagio";

    if (!Functions.IsNullOrEmpty(ro.getDataSource())) {
      if (ro.getDataSource().toUpperCase().equals("BR"))
        dataSourcePOI = "lbslocal_postos_rod_pedagio";
    }

    String response = tcpDecarta.Send("PNB0|%" + vr + "%RAD=m7|%M=500%PLL%S2%DS=" + dataSourcePOI + "||");

    if (!response.contains("No records found")) {
      String[] partMasterPOI = response.split(Pattern.quote("|"));

      for (int w = 0; w < partMasterPOI.length; w++) {
View Full Code Here

  }

  public Object[] addPOI(String[] poiRoutes, String vr, RouteProximityOptions ro, SegAux segAux, List<POIDetails> poiList) throws IOException {
    Object[] obj = new Object[2];

    TCPClientDecarta tcpDecarta = new TCPClientDecarta(_server, _port);

    for (int x = 0; x < poiRoutes.length; x++) {
      if (!Functions.IsNullOrEmpty(poiRoutes[x])) {
        String response = tcpDecarta.Send("PNB0|%" + vr + "%RAD=m7|%M=500%PLL%S2%DS=" + poiRoutes[x] + "||");
        String[] partMasterPOI = response.split(Pattern.quote("|"));

        if (!response.contains("No records found")) {
          for (int w = 0; w < partMasterPOI.length; w++) {
            if (partMasterPOI[w].indexOf("POI_") >= 0) {
View Full Code Here

  public Object[] addPOIsRota(String vr, RouteProximityOptions ro, SegAux segAux, List<TollFeeAux> pedagioList, List<POIDetails> poiList,
      int nroParadas, int[] poiRouteIDs) throws IOException {
    Object[] obj = new Object[3];

    TCPClientDecarta tcpDecarta = new TCPClientDecarta(_server, _port);

    String dataSourcePOI = "lbslocal_postos";

    if (!Functions.IsNullOrEmpty(ro.getDataSource())) {
      if (ro.getDataSource().toUpperCase().equals("BR"))
        dataSourcePOI = "lbslocal_postos_rod";
    }

    String response = tcpDecarta.Send("PNB0|%" + vr + "%RAD=m7|%EXTIME%M=500%PLL%S2%DS=" + dataSourcePOI + "||");

    String[] partMasterPOI = response.split(Pattern.quote("|"));

    if (!response.contains("No records found")) {
      for (int w = 0; w < partMasterPOI.length; w++) {
View Full Code Here

    _dataSource = dataSource;
    File fileDir = new File(_output);
    if (!fileDir.exists())
      fileDir.mkdirs();

    tcpDecarta = new TCPClientDecarta(server, port);
  }
View Full Code Here

        BufferedReader sr = new BufferedReader(new FileReader(_dirLayer + File.separator + pRota));
        String request = sr.readLine();
        sr.close();

        TCPClientDecarta tcpDecarta = new TCPClientDecarta(_server, _port);
        response = tcpDecarta.Send(request.toString());
      } else
        response = routeResponse;

      String[] parts = response.split("%");
View Full Code Here

      tolerance = 10;

    AddressLocation al = new AddressLocation();
    String response = "";

    TCPClientDecarta tcpDecarta = new TCPClientDecarta(_server, _port);
    String sendToDeCarta = "S2LN|%CUST=" + idLicenca + ":" + methodID + "%LL=" + point.getY() + "," + point.getX() + "|%RAD=m"
        + (int) (tolerance) + "%INTERPADDR%ALLATTRS%LL%DS=" + _dataSourceRevGeo + "||";
    try {
      response = tcpDecarta.Send(sendToDeCarta);
    } catch (Exception e) {
      throw e;
    }
    try {
      String[] part = response.split("%");
View Full Code Here

            //sb.append("%M=3");
            //sb.append("%EXTIME");
            sb.append("%DS=" + _dataSourceRevGeo);
            sb.append("||");

            TCPClientDecarta tcpDecarta = new TCPClientDecarta(_server, _port);
            String response = tcpDecarta.Send(sb.toString());

            String[] splitLines = response.split(Pattern.quote("|"));
            String[] splitField;
           
            String xll;
View Full Code Here

TOP

Related Classes of com.lbslocal.cc.common.TCPClientDecarta

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.