Package com.lbslocal.cc.objects.v0.common

Examples of com.lbslocal.cc.objects.v0.common.Extent


      comandoContinue = "Sigue";
    }
    SegAux segTemp = new SegAux();
    segTemp.seg = new SegmentDescription();
    segTemp.seg.setDistance(0);
    segTemp.seg.setCity(new City());
    segTemp.seg.getCity().setName("");
    segTemp.seg.getCity().setState("");
    segTemp.seg.setCumulativeDistance(0);
    segTemp.segPosition = 0;
    segTemp.seg.setCommand(comandoInicio);
    segTemp.seg.setDescription(rs[0].getDescription());
    segTemp.seg.setPoint(new Point());
    segTemp.seg.getPoint().setX(Functions.formatDouble(rs[0].getPoint().getX(), "0.00000"));
    segTemp.seg.getPoint().setY(Functions.formatDouble(rs[0].getPoint().getY(), "0.00000"));
    segmentList.add(segTemp);

    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();

                      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("\\");

                          try {
                            poi.setClientID(p[2].substring(0, p[2].indexOf("\\")) + "|"
                                + p[1].substring(ind).replace("\\", ""));
                          } catch (Exception ex) {
                            poi.setClientID(p[2]);
                            try {
                              poi.setSource(p[1].substring(ind + 1));
                            } catch (Exception ex1) {
                            }
                            ;
                          }

                          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) {
                        }
                      }
                    }
                  }
                }
              }
            }
          }

          if (Functions.IsNullOrEmpty(segAux.seg.getCommand())) {
            if (rs.length > 2) {
              if (paradas < rs.length - 1) {
                if (ro.getRouteDetails().isOptimizeRoute()) {
                  if (rs.length >= 10) {
                    segAux.seg.setCommand(comandoContinue);

                    SegAux seg = new SegAux();
                    seg.seg = segAux.seg;
                    seg.seg.setDescription(rs[paradas].getDescription());
                    seg.seg.setCommand("Parada " + paradas);
                    seg.seg.setDistance(0);
                    seg.seg.getPoint().setX(rs[paradas].getPoint().getX());
                    seg.seg.getPoint().setY(rs[paradas].getPoint().getY());
                    seg.vr = "";
                    seg.vrPosition = 0;

                    paradas++;
                    segmentList.add(segAux);
                    segmentList.add(seg);
                  } else {
                    segAux.seg.setCommand(comandoContinue);

                    SegAux seg = new SegAux();
                    seg.seg.setCommand(comandoContinue);

                    for (int z = 0; z < rStopSelect.length; z++) {
                      if (String.format("0.00000", rStopSelect[z].getPoint().getX()).equals(
                          String.format("0.00000", segAux.seg.getPoint().getX()))
                          && String.format("0.00000", segAux.seg.getPoint().getY()).equals(
                              String.format("0.00000", rStopSelect[z].getPoint().getY()))) {
                        seg.seg = segAux.seg;
                        seg.seg.setDescription(rStopSelect[z].getDescription());
                        seg.seg.setCommand("Parada " + paradas);
                        seg.seg.setDistance(0);
                        seg.seg.getPoint().setX(rStopSelect[z].getPoint().getX());
                        seg.seg.getPoint().setY(rStopSelect[z].getPoint().getY());
                        seg.vr = "";
                        seg.vrPosition = 0;
                        rStopSelect = removeRouteStop(rStopSelect, z);
                        break;
                      }
                    }

                    if (seg.seg.getCommand().toLowerCase().indexOf("parada") < 0) {
                      List<RouteSummary> rsList = new ArrayList<RouteSummary>();

                      for (int z = 0; z < rStopSelect.length; z++) {
                        RouteSummary r = new RouteSummary();
                        r.setDistance(Math.sqrt(Math
                            .pow((rStopSelect[z].getPoint().getX() - segAux.seg.getPoint().getX()), 2)
                            + Math.pow((rStopSelect[z].getPoint().getY() - segAux.seg.getPoint().getY()), 2)));
                        r.setDescription(String.valueOf(z));

                        rsList.add(r);
                      }

                      Collections.sort(rsList, COMPARATOR);

                      /*
                       * rsList.Sort(delegate(RouteSummary
                       * p1, RouteSummary p2) { return
                       * (Double
                       * .parseDouble(p1.distance).
                       * CompareTo (
                       * Double.parseDouble(p2.distance)))
                       * ; });
                       */

                      seg.seg = segAux.seg;
                      seg.seg.setDescription(rStopSelect[Integer.parseInt(rsList.get(0).getDescription())].getDescription());
                      seg.seg.setCommand("Parada " + paradas);
                      seg.seg.setDistance(0);
                      seg.seg.getPoint().setX(rStopSelect[Integer.parseInt(rsList.get(0).getDescription())].getPoint().getX());
                      seg.seg.getPoint().setY(rStopSelect[Integer.parseInt(rsList.get(0).getDescription())].getPoint().getY());
                      seg.vr = "";
                      seg.vrPosition = 0;
                      rStopSelect = removeRouteStop(rStopSelect, Integer.parseInt(rsList.get(0).getDescription()));
                    }

                    paradas++;
                    segmentList.add(segAux);
                    segmentList.add(seg);
                  }
                } else {
                  segAux.seg.setCommand(comandoContinue);

                  SegAux seg = new SegAux();
                  seg.seg = segAux.seg;
                  seg.seg.setDescription(rs[paradas].getDescription());
                  seg.seg.setCommand("Parada " + paradas);
                  seg.seg.setDistance(0);
                  seg.seg.getPoint().setX(rs[paradas].getPoint().getX());
                  seg.seg.getPoint().setY(rs[paradas].getPoint().getY());
                  seg.vr = "";
                  seg.vrPosition = 0;

                  paradas++;

                  segmentList.add(segAux);
                  segmentList.add(seg);
                }
              } else {
                segAux.seg.setCommand(comandoContinue);

                if (Functions.IsNullOrEmpty(segAux.seg.getCity().getName()) && segmentList.size() > 0)
                  segAux.seg.setCity(segmentList.get(segmentList.size() - 1).seg.getCity());

                segmentList.add(segAux);
              }
            } else {
              segAux.seg.setCommand(comandoContinue);

              if (Functions.IsNullOrEmpty(segAux.seg.getCity().getName()) && segmentList.size() > 0)
                segAux.seg.setCity(segmentList.get(segmentList.size() - 1).seg.getCity());

              segmentList.add(segAux);
            }
          } else {
            if (Functions.IsNullOrEmpty(segAux.seg.getCity().getName()) && segmentList.size() > 0)
              segAux.seg.setCity(segmentList.get(segmentList.size() - 1).seg.getCity());

            segmentList.add(segAux);
          }
        }
      }

      SegAux segFim = new SegAux();
      segFim.seg = new SegmentDescription();
      segFim.seg.setDistance(0);
      segFim.seg.setCity(new City());
      segFim.seg.getCity().setName("");
      segFim.seg.getCity().setState("");
      segFim.seg.setCumulativeDistance(segmentList.get(segmentList.size() - 1).seg.getCumulativeDistance());
      segFim.segPosition = segmentList.size() + 1;
      segFim.seg.setCommand(comandoFimDaRota);
      segFim.seg.setDescription(rs[rs.length - 1].getDescription());
      segFim.seg.setPoint(new Point());
      segFim.seg.getPoint().setX(Functions.formatDouble(rs[rs.length - 1].getPoint().getX(), "0.00000"));
      segFim.seg.getPoint().setY(Functions.formatDouble(rs[rs.length - 1].getPoint().getY(), "0.00000"));
      segmentList.add(segFim);

      ret = new SegmentDescription[segmentList.size()];

      for (int cont = 0; cont < segmentList.size(); cont++)
        ret[cont] = segmentList.get(cont).seg;

      cumulativeDistance = 0;
      for (int x = 0; x < ret.length; x++) {
        cumulativeDistance += ret[x].getDistance();
        ret[x].setCumulativeDistance(cumulativeDistance);
      }

      ret = setToolFeeDB(ret, pedagioList, tollFeeCat);

      if (ro.getRouteDetails().getPoiRoute() != null)
        ret = setPoiRouteDB(ret, ro.getRouteDetails().getPoiRoute());

      List<SegmentDescription> segList = new ArrayList<SegmentDescription>();
      segList.add(ret[0]);
      // Verificar aqui
      if (ro.getRouteDetails().getDescriptionType() == 1) {
        double totalTime = 0;
       
//        totalTime = 0;
//        for (int x = 0; x < ret.length; x++) {
//            if (!ret[x].getTime().equals(""))
//              totalTime += Double.parseDouble(ret[x].getTime().substring(0,ret[x].getTime().indexOf(' ')));
//        }
       
        for (int x = 0; x < ret.length; x++) {
          if (    ret[x].getDescription().toUpperCase().indexOf("ROD.") >= 0 ||
              ret[x].getDescription().toUpperCase().indexOf("ESTR.") >= 0
              || !Functions.IsNullOrEmpty(ret[x].getTollFee()) || ret[x].getCommand().toLowerCase().contains("parada")
              || ret[x].getCommand().toLowerCase().contains("fim da")) {
            SegmentDescription seg = new SegmentDescription();
            if (!ret[x].getTime().equals(""))
              totalTime += Double.parseDouble(ret[x].getTime().substring(0,ret[x].getTime().indexOf(' ')));
            seg = ret[x];
            seg.setTime(totalTime + " sec");
            segList.add(seg);
            totalTime = 0;
          }else
            if (!ret[x].getTime().equals(""))
              totalTime += Double.parseDouble(ret[x].getTime().substring(0,ret[x].getTime().indexOf(' ')));

        }

        segList.add(ret[ret.length - 1]);

        ret = new SegmentDescription[segList.size()];
        ret = segList.toArray(new SegmentDescription[0]);

        for (int x = 1; x < ret.length - 2; x++) {
          if (!(ret[x].getCommand().toLowerCase().indexOf("parada") >= 0))
            ret[x].setCommand("Continue");

          if ((ret[x].getCommand().toLowerCase().indexOf("parada") >= 0))
            ret[x].setRoadType(ret[x - 1].getRoadType());
        }

        int qtdSeg = ret.length;
        SegmentDescription[] retAux = new SegmentDescription[qtdSeg];
        retAux = ret;

//        totalTime = 0;
//        for (int x = 0; x < ret.length; x++) {
//            if (!ret[x].getTime().equals(""))
//              totalTime += Double.parseDouble(ret[x].getTime().substring(0,ret[x].getTime().indexOf(' ')));
//        }
       
        Object[] obj = removeDuplicates(12, qtdSeg, retAux, ret, ro);

        ret = new SegmentDescription[0];
        ret = (SegmentDescription[]) obj[1];
//        totalTime = 0;
//        for (int x = 0; x < ret.length; x++) {
//            if (!ret[x].getTime().equals(""))
//              totalTime += Double.parseDouble(ret[x].getTime().substring(0,ret[x].getTime().indexOf(' ')));
//        }
       
        qtdSeg = (Integer) obj[0] + 1;
        ret = new SegmentDescription[0];
        ret = (SegmentDescription[]) obj[1];

        retAux = new SegmentDescription[qtdSeg];

        // String lastCity = "";

        for (int x = 0; x < qtdSeg; x++) {
          retAux[x] = new SegmentDescription();
          retAux[x].setCity(new City());

          if (x == 0) {
            // if (!Functions.IsNullOrEmpty(ret[x +
            // 1].getCity().getName()))
            // lastCity = ret[x + 1].getCity().getName();

            retAux[x].getCity().setName(ret[x + 1].getCity().getName());
            retAux[x].getCity().setState(ret[x + 1].getCity().getState());
          }

          retAux[x].getCity().setName(ret[x].getCity().getName());
          retAux[x].getCity().setState(ret[x].getCity().getState());

          retAux[x].setCommand(ret[x].getCommand());
          retAux[x].setCumulativeDistance(ret[x].getCumulativeDistance());

          retAux[x].setTime(ret[x].getTime());
         
          if (ret[x].getDescription().indexOf("passando") > 0)
            retAux[x].setDescription(ret[x].getDescription().substring(0, ret[x].getDescription().indexOf("passando") - 1));
          else
            retAux[x].setDescription(ret[x].getDescription());

          retAux[x].setDistance(ret[x].getDistance());

          retAux[x].setPoint(new Point());
          retAux[x].getPoint().setX(ret[x].getPoint().getX());
          retAux[x].getPoint().setY(ret[x].getPoint().getY());
          retAux[x].setRoadType(ret[x].getRoadType());

          retAux[x].setTollFee(ret[x].getTollFee());
          retAux[x].setTollFeeDetails(new TollFeeDetails());
          retAux[x].getTollFeeDetails().setAddress(ret[x].getTollFeeDetails().getAddress());
          retAux[x].getTollFeeDetails().setConcession(ret[x].getTollFeeDetails().getConcession());
          retAux[x].getTollFeeDetails().setDirection(ret[x].getTollFeeDetails().getDirection());
          retAux[x].getTollFeeDetails().setName(ret[x].getTollFeeDetails().getName());
          retAux[x].getTollFeeDetails().setPhone(ret[x].getTollFeeDetails().getPhone());
          retAux[x].getTollFeeDetails().setPrice(ret[x].getTollFeeDetails().getPrice());
          retAux[x].getTollFeeDetails().setPricePerAxle(ret[x].getTollFeeDetails().getPricePerAxle());
          retAux[x].getTollFeeDetails().setState(ret[x].getTollFeeDetails().getState());

          retAux[x].setPoiRoute(ret[x].getPoiRoute());

          if (ret[x].getPoiRouteDetails() != null) {
            retAux[x].setPoiRouteDetails(new POIDetails[ret[x].getPoiRouteDetails().length]);

            for (int z = 0; z < ret[x].getPoiRouteDetails().length; z++) {
              retAux[x].getPoiRouteDetails()[z] = new POIDetails();
              retAux[x].getPoiRouteDetails()[z].setAddressInfo(ret[x].getPoiRouteDetails()[z].getAddressInfo());

              retAux[x].getPoiRouteDetails()[z].setClientID(ret[x].getPoiRouteDetails()[z].getClientID());
              retAux[x].getPoiRouteDetails()[z].setName(ret[x].getPoiRouteDetails()[z].getName());
              retAux[x].getPoiRouteDetails()[z].setPoint(new Point());
              retAux[x].getPoiRouteDetails()[z].getPoint().setX(ret[x].getPoiRouteDetails()[z].getPoint().getX());
              retAux[x].getPoiRouteDetails()[z].getPoint().setY(ret[x].getPoiRouteDetails()[z].getPoint().getY());
              retAux[x].getPoiRouteDetails()[z].setSource(ret[x].getPoiRouteDetails()[z].getSource());
            }
          }
        }

        ret = new SegmentDescription[qtdSeg];
        ret = retAux;

        ret[0].setRoadType("O");
        ret[ret.length - 1].setRoadType("D");
      }

      if (ro.getRouteDetails().getDescriptionType() == 2) {

      }

      if (ro.getRouteDetails().getDescriptionType() == 10) {
        for (int x = 0; x < ret.length; x++) {
          ret[x].setDescription(ret[x].getDescription().replace(" Pista Lateral", "").replace(" - Pista Lateral", "")
              .replace("Ac. P/ ", "").replace("Rod ", "Rod. ").replace(" -", ""));
        }

        SegmentDescription[] _segmentDescriptionAux = ret;
        SegmentDescription[] _segmentDescription = ret;
        int qtdSeg = ret.length;

        Object[] obj = removeDuplicates(1, qtdSeg, _segmentDescriptionAux, _segmentDescription, ro);

        qtdSeg = (Integer) obj[0] + 1;
        _segmentDescription = new SegmentDescription[0];
        _segmentDescription = (SegmentDescription[]) obj[1];

        _segmentDescriptionAux = new SegmentDescription[qtdSeg];

        for (int x = 0; x < qtdSeg; x++) {
          _segmentDescriptionAux[x] = new SegmentDescription();
          _segmentDescriptionAux[x].setCity(new City());
          _segmentDescriptionAux[x].getCity().setName(_segmentDescription[x].getCity().getName());
          _segmentDescriptionAux[x].getCity().setState(_segmentDescription[x].getCity().getState());

          _segmentDescriptionAux[x].setCommand(_segmentDescription[x].getCommand());
          _segmentDescriptionAux[x].setCumulativeDistance(_segmentDescription[x].getCumulativeDistance());
          _segmentDescriptionAux[x].setDescription(_segmentDescription[x].getDescription());
          _segmentDescriptionAux[x].setDistance(_segmentDescription[x].getDistance());

          _segmentDescriptionAux[x].setPoint(new Point());
          _segmentDescriptionAux[x].getPoint().setX(_segmentDescription[x].getPoint().getX());
          _segmentDescriptionAux[x].getPoint().setY(_segmentDescription[x].getPoint().getY());
          _segmentDescriptionAux[x].setRoadType(_segmentDescription[x].getRoadType());

          _segmentDescriptionAux[x].setTollFee(_segmentDescription[x].getTollFee());
          _segmentDescriptionAux[x].setTollFeeDetails(new TollFeeDetails());
          _segmentDescriptionAux[x].getTollFeeDetails().setAddress(_segmentDescription[x].getTollFeeDetails().getAddress());
          _segmentDescriptionAux[x].getTollFeeDetails().setConcession(_segmentDescription[x].getTollFeeDetails().getConcession());
          _segmentDescriptionAux[x].getTollFeeDetails().setDirection(_segmentDescription[x].getTollFeeDetails().getDirection());
          _segmentDescriptionAux[x].getTollFeeDetails().setName(_segmentDescription[x].getTollFeeDetails().getName());
          _segmentDescriptionAux[x].getTollFeeDetails().setPhone(_segmentDescription[x].getTollFeeDetails().getPhone());
          _segmentDescriptionAux[x].getTollFeeDetails().setPrice(_segmentDescription[x].getTollFeeDetails().getPrice());
          _segmentDescriptionAux[x].getTollFeeDetails().setPricePerAxle(_segmentDescription[x].getTollFeeDetails().getPricePerAxle());
          _segmentDescriptionAux[x].getTollFeeDetails().setState(_segmentDescription[x].getTollFeeDetails().getState());

          _segmentDescriptionAux[x].setPoiRoute(_segmentDescription[x].getPoiRoute());

          if (_segmentDescription[x].getPoiRouteDetails() != null) {
            _segmentDescriptionAux[x].setPoiRouteDetails(new POIDetails[_segmentDescription[x].getPoiRouteDetails().length]);

            for (int z = 0; z < _segmentDescription[x].getPoiRouteDetails().length; z++) {
              _segmentDescriptionAux[x].getPoiRouteDetails()[z] = new POIDetails();
              _segmentDescriptionAux[x].getPoiRouteDetails()[z].setAddressInfo(_segmentDescription[x].getPoiRouteDetails()[z]
                  .getAddressInfo());

              _segmentDescriptionAux[x].getPoiRouteDetails()[z].setClientID(_segmentDescription[x].getPoiRouteDetails()[z]
                  .getClientID());
              _segmentDescriptionAux[x].getPoiRouteDetails()[z].setName(_segmentDescription[x].getPoiRouteDetails()[z].getName());
              _segmentDescriptionAux[x].getPoiRouteDetails()[z].setPoint(new Point());
              _segmentDescriptionAux[x].getPoiRouteDetails()[z].getPoint().setX(
                  _segmentDescription[x].getPoiRouteDetails()[z].getPoint().getX());
              _segmentDescriptionAux[x].getPoiRouteDetails()[z].getPoint().setY(
                  _segmentDescription[x].getPoiRouteDetails()[z].getPoint().getY());
              _segmentDescriptionAux[x].getPoiRouteDetails()[z].setSource(_segmentDescription[x].getPoiRouteDetails()[z].getSource());
            }
          }
        }

        _segmentDescription = new SegmentDescription[qtdSeg];
        _segmentDescription = _segmentDescriptionAux;

        Object[] obj1 = removeDuplicates(4, qtdSeg, _segmentDescriptionAux, _segmentDescription, ro);

        qtdSeg = (Integer) obj1[0] + 1;
        _segmentDescription = new SegmentDescription[0];
        _segmentDescription = (SegmentDescription[]) obj1[1];

        _segmentDescriptionAux = new SegmentDescription[qtdSeg];

        for (int x = 0; x < qtdSeg; x++) {
          _segmentDescriptionAux[x] = new SegmentDescription();
          _segmentDescriptionAux[x].setCity(new City());

          if (_segmentDescription[x].getCity().getName().contains("_"))
            _segmentDescriptionAux[x].getCity().setName(
                _segmentDescription[x].getCity().getName().substring(0, _segmentDescription[x].getCity().getName().length() - 1));
          else
            _segmentDescriptionAux[x].getCity().setName(_segmentDescription[x].getCity().getName());

          _segmentDescriptionAux[x].getCity().setState(_segmentDescription[x].getCity().getState());

          _segmentDescriptionAux[x].setCommand(_segmentDescription[x].getCommand());
          _segmentDescriptionAux[x].setCumulativeDistance(_segmentDescription[x].getCumulativeDistance());
          _segmentDescriptionAux[x].setDescription(_segmentDescription[x].getDescription());
          _segmentDescriptionAux[x].setDistance(_segmentDescription[x].getDistance());

          _segmentDescriptionAux[x].setPoint(new Point());
          _segmentDescriptionAux[x].getPoint().setX(_segmentDescription[x].getPoint().getX());
          _segmentDescriptionAux[x].getPoint().setY(_segmentDescription[x].getPoint().getY());
          _segmentDescriptionAux[x].setRoadType(_segmentDescription[x].getRoadType());

          _segmentDescriptionAux[x].setTollFee(_segmentDescription[x].getTollFee());
          _segmentDescriptionAux[x].setTollFeeDetails(new TollFeeDetails());
          _segmentDescriptionAux[x].getTollFeeDetails().setAddress(_segmentDescription[x].getTollFeeDetails().getAddress());
          _segmentDescriptionAux[x].getTollFeeDetails().setConcession(_segmentDescription[x].getTollFeeDetails().getConcession());
          _segmentDescriptionAux[x].getTollFeeDetails().setDirection(_segmentDescription[x].getTollFeeDetails().getDirection());
          _segmentDescriptionAux[x].getTollFeeDetails().setName(_segmentDescription[x].getTollFeeDetails().getName());
          _segmentDescriptionAux[x].getTollFeeDetails().setPhone(_segmentDescription[x].getTollFeeDetails().getPhone());
          _segmentDescriptionAux[x].getTollFeeDetails().setPrice(_segmentDescription[x].getTollFeeDetails().getPrice());
          _segmentDescriptionAux[x].getTollFeeDetails().setPricePerAxle(_segmentDescription[x].getTollFeeDetails().getPricePerAxle());
          _segmentDescriptionAux[x].getTollFeeDetails().setState(_segmentDescription[x].getTollFeeDetails().getState());

          _segmentDescriptionAux[x].setPoiRoute(_segmentDescription[x].getPoiRoute());

          if (_segmentDescription[x].getPoiRouteDetails() != null) {
            _segmentDescriptionAux[x].setPoiRouteDetails(new POIDetails[_segmentDescription[x].getPoiRouteDetails().length]);

            for (int z = 0; z < _segmentDescription[x].getPoiRouteDetails().length; z++) {
              _segmentDescriptionAux[x].getPoiRouteDetails()[z] = new POIDetails();
              _segmentDescriptionAux[x].getPoiRouteDetails()[z].setAddressInfo(_segmentDescription[x].getPoiRouteDetails()[z]
                  .getAddressInfo());

              _segmentDescriptionAux[x].getPoiRouteDetails()[z].setClientID(_segmentDescription[x].getPoiRouteDetails()[z]
                  .getClientID());
              _segmentDescriptionAux[x].getPoiRouteDetails()[z].setName(_segmentDescription[x].getPoiRouteDetails()[z].getName());
              _segmentDescriptionAux[x].getPoiRouteDetails()[z].setPoint(new Point());
              _segmentDescriptionAux[x].getPoiRouteDetails()[z].getPoint().setX(
                  _segmentDescription[x].getPoiRouteDetails()[z].getPoint().getX());
              _segmentDescriptionAux[x].getPoiRouteDetails()[z].getPoint().setY(
                  _segmentDescription[x].getPoiRouteDetails()[z].getPoint().getY());
              _segmentDescriptionAux[x].getPoiRouteDetails()[z].setSource(_segmentDescription[x].getPoiRouteDetails()[z].getSource());
            }
          }
        }

        ret = null;
        ret = _segmentDescriptionAux;

        segList = new ArrayList<SegmentDescription>();
        SegmentDescription seg = new SegmentDescription();
        String rodoviaAnterior = "";
        double distanciaRodovia = 0;
        int posicaoRodovia = 0;

        for (int x = 0; x < ret.length; x++) {
          if ((!ret[x].getDescription().toLowerCase().contains("rod.") && !ret[x].getDescription().toLowerCase().contains("rod ") && !ret[x]
              .getDescription().toLowerCase().contains("estr."))) {
            if (ret[x].getCommand().toLowerCase().contains("início") || ret[x].getCommand().toLowerCase().contains("fim")
                || ret[x].getDescription().toLowerCase().contains("retorno") || ret[x].getCommand().toLowerCase().contains("parada")) {
              seg = ret[x];
              segList.add(seg);
              seg = new SegmentDescription();
            } else {
              if (!Functions.IsNullOrEmpty(ret[x].getTollFee())) {
                seg = ret[x];
                segList.add(seg);
                seg = new SegmentDescription();
              } else {
                // seg = ret[x];
                seg.setDescription("Perímetro Urbano");
                seg.setCumulativeDistance(ret[x].getCumulativeDistance());
                seg.setDistance(seg.getDistance() + ret[x].getDistance());
                seg.setCity(ret[x].getCity());
                seg.setCommand("Continue");
                seg.setPoint(ret[x].getPoint());
                seg.setRoadType("P");

                if (!Functions.IsNullOrEmpty(seg.getPoiRoute()))
                  seg.setPoiRoute(ret[x].getPoiRoute());

                if (ret[x].getPoiRouteDetails() != null) {
                  if (seg.getPoiRouteDetails() == null) {
                    seg.setPoiRouteDetails(new POIDetails[ret[x].getPoiRouteDetails().length]);

                    for (int z = 0; z < ret[x].getPoiRouteDetails().length; z++) {
                      seg.getPoiRouteDetails()[z] = new POIDetails();
                      seg.getPoiRouteDetails()[z].setAddressInfo(ret[x].getPoiRouteDetails()[z].getAddressInfo());

                      seg.getPoiRouteDetails()[z].setClientID(ret[x].getPoiRouteDetails()[z].getClientID());
                      seg.getPoiRouteDetails()[z].setName(ret[x].getPoiRouteDetails()[z].getName());
                      seg.getPoiRouteDetails()[z].setPoint(new Point());
                      seg.getPoiRouteDetails()[z].getPoint().setX(ret[x].getPoiRouteDetails()[z].getPoint().getX());
                      seg.getPoiRouteDetails()[z].getPoint().setY(ret[x].getPoiRouteDetails()[z].getPoint().getY());
                      seg.getPoiRouteDetails()[z].setSource(ret[x].getPoiRouteDetails()[z].getSource());
                    }
                  } else {

                  }
                }

                if (x + 1 < ret.length) {
                  if (ret[x + 1].getDescription().toLowerCase().contains("rod.")
                      || ret[x + 1].getDescription().toLowerCase().contains("estr.")
                      || !Functions.IsNullOrEmpty(ret[x + 1].getTollFee())
                      || ret[x + 1].getCommand().toLowerCase().contains("parada")
                      || ret[x + 1].getCommand().toLowerCase().contains("início")
                      || ret[x + 1].getDescription().toLowerCase().contains("retorno")
                      || ret[x + 1].getCommand().toLowerCase().contains("fim")) {
                    segList.add(seg);
                    seg = new SegmentDescription();
                  }
                }
              }
            }
          } else {
            if (!Functions.IsNullOrEmpty(ret[x].getTollFee())) {
              seg = ret[x];
              segList.add(seg);
              seg = new SegmentDescription();

              distanciaRodovia += ret[x].getDistance();
            } else {
              if (Functions.IsNullOrEmpty(rodoviaAnterior)) {
                rodoviaAnterior = ret[x].getDescription().replace(" Pista Lateral", "").replace(" - Pista Lateral", "")
                    .replace("Ac. P/ ", "");

                // seg = ret[x];
                seg.setCity(new City());
                seg.setDescription("#Siga pela " + rodoviaAnterior);
                seg.setCumulativeDistance(0);
                seg.setCommand("");
                seg.setPoint(ret[x].getPoint());
                seg.setDistance(ret[x].getDistance());

                distanciaRodovia = ret[x].getDistance();

                segList.add(seg);
                seg = new SegmentDescription();
                posicaoRodovia = segList.size() - 1;

                segList.add(ret[x]);
              } else {
                if ((rodoviaAnterior.equals(ret[x].getDescription()) || rodoviaAnterior.contains(ret[x].getDescription()) || ret[x]
                    .getDescription().contains(rodoviaAnterior))) {
                  distanciaRodovia += ret[x].getDistance();
                  segList.add(ret[x]);

                  if (x + 1 < ret.length) {
                    if ((!ret[x + 1].getDescription().toLowerCase().contains("rod ")
                        && !ret[x + 1].getDescription().toLowerCase().contains("rod.") && !ret[x + 1].getDescription()
                        .toLowerCase().contains("estr."))) {
                      // segList.Add(seg);
                      SegmentDescription[] segAux = new SegmentDescription[segList.size()];

                      for (int c = 0; c < segList.size(); c++)
                        segAux[c] = (SegmentDescription) segList.get(c);

                      segAux[posicaoRodovia].setDistance(distanciaRodovia);
                      segList.clear();

                      for (int w = 0; w < segAux.length; w++)
                        segList.add(segAux[w]);

                      rodoviaAnterior = "";
                      distanciaRodovia = 0;
                    }
                  }
                } else {
                  SegmentDescription[] segAux = new SegmentDescription[segList.size()];

                  for (int c = 0; c < segList.size(); c++)
                    segAux[c] = (SegmentDescription) segList.get(c);

                  segAux[posicaoRodovia].setDistance(distanciaRodovia);
                  segList.clear();

                  for (int w = 0; w < segAux.length; w++)
                    segList.add(segAux[w]);

                  rodoviaAnterior = ret[x].getDescription().replace(" Pista Lateral", "").replace(" - Pista Lateral", "")
                      .replace("Ac. P/ ", "");

                  // seg = ret[x];
                  seg.setCity(new City());
                  seg.setDescription("#Siga pela " + rodoviaAnterior);
                  seg.setCumulativeDistance(0);
                  seg.setCommand("");
                  seg.setPoint(ret[x].getPoint());
                  seg.setDistance(ret[x].getDistance());

                  distanciaRodovia = ret[x].getDistance();

                  segList.add(seg);
                  seg = new SegmentDescription();
                  posicaoRodovia = segList.size() - 1;

                  segList.add(ret[x]);
                }
              }
            }
          }
        }

        ret = null;
        ret = new SegmentDescription[segList.size()];

        for (int c = 0; c < segList.size(); c++)
          ret[c] = (SegmentDescription) segList.get(c);
      }

      if (ro.getRouteDetails().getDescriptionType() == 3) {
        SegmentDescription[] _segmentDescriptionAux = ret;
        SegmentDescription[] _segmentDescription = ret;
        int qtdSeg = ret.length;

        Object[] obj1 = removeDuplicates(1, qtdSeg, _segmentDescriptionAux, _segmentDescription, ro);

        qtdSeg = (Integer) obj1[0] + 1;
        _segmentDescription = new SegmentDescription[0];
        _segmentDescription = (SegmentDescription[]) obj1[1];

        _segmentDescriptionAux = new SegmentDescription[qtdSeg];

        for (int x = 0; x < qtdSeg; x++) {
          _segmentDescriptionAux[x] = new SegmentDescription();
          _segmentDescriptionAux[x].setCity(new City());
          _segmentDescriptionAux[x].getCity().setName(_segmentDescription[x].getCity().getName());
          _segmentDescriptionAux[x].getCity().setState(_segmentDescription[x].getCity().getState());

          _segmentDescriptionAux[x].setCommand(_segmentDescription[x].getCommand());
          _segmentDescriptionAux[x].setCumulativeDistance(_segmentDescription[x].getCumulativeDistance());
          _segmentDescriptionAux[x].setDescription(_segmentDescription[x].getDescription());
          _segmentDescriptionAux[x].setDistance(_segmentDescription[x].getDistance());

          _segmentDescriptionAux[x].setPoint(new Point());
          _segmentDescriptionAux[x].getPoint().setX(_segmentDescription[x].getPoint().getX());
          _segmentDescriptionAux[x].getPoint().setY(_segmentDescription[x].getPoint().getY());
          _segmentDescriptionAux[x].setRoadType(_segmentDescription[x].getRoadType());

          _segmentDescriptionAux[x].setTollFee(_segmentDescription[x].getTollFee());
          _segmentDescriptionAux[x].setTollFeeDetails(new TollFeeDetails());
          _segmentDescriptionAux[x].getTollFeeDetails().setAddress(_segmentDescription[x].getTollFeeDetails().getAddress());
          _segmentDescriptionAux[x].getTollFeeDetails().setConcession(_segmentDescription[x].getTollFeeDetails().getConcession());
          _segmentDescriptionAux[x].getTollFeeDetails().setDirection(_segmentDescription[x].getTollFeeDetails().getDirection());
          _segmentDescriptionAux[x].getTollFeeDetails().setName(_segmentDescription[x].getTollFeeDetails().getName());
          _segmentDescriptionAux[x].getTollFeeDetails().setPhone(_segmentDescription[x].getTollFeeDetails().getPhone());
          _segmentDescriptionAux[x].getTollFeeDetails().setPrice(_segmentDescription[x].getTollFeeDetails().getPrice());
          _segmentDescriptionAux[x].getTollFeeDetails().setPricePerAxle(_segmentDescription[x].getTollFeeDetails().getPricePerAxle());
          _segmentDescriptionAux[x].getTollFeeDetails().setState(_segmentDescription[x].getTollFeeDetails().getState());

          _segmentDescriptionAux[x].setPoiRoute(_segmentDescription[x].getPoiRoute());

          if (_segmentDescription[x].getPoiRouteDetails() != null) {
            _segmentDescriptionAux[x].setPoiRouteDetails(new POIDetails[_segmentDescription[x].getPoiRouteDetails().length]);

            for (int z = 0; z < _segmentDescription[x].getPoiRouteDetails().length; z++) {
              _segmentDescriptionAux[x].getPoiRouteDetails()[z] = new POIDetails();
              _segmentDescriptionAux[x].getPoiRouteDetails()[z].setAddressInfo(_segmentDescription[x].getPoiRouteDetails()[z]
                  .getAddressInfo());

              _segmentDescriptionAux[x].getPoiRouteDetails()[z].setClientID(_segmentDescription[x].getPoiRouteDetails()[z]
                  .getClientID());
              _segmentDescriptionAux[x].getPoiRouteDetails()[z].setName(_segmentDescription[x].getPoiRouteDetails()[z].getName());
              _segmentDescriptionAux[x].getPoiRouteDetails()[z].setPoint(new Point());
              _segmentDescriptionAux[x].getPoiRouteDetails()[z].getPoint().setX(
                  _segmentDescription[x].getPoiRouteDetails()[z].getPoint().getX());
              _segmentDescriptionAux[x].getPoiRouteDetails()[z].getPoint().setY(
                  _segmentDescription[x].getPoiRouteDetails()[z].getPoint().getY());
              _segmentDescriptionAux[x].getPoiRouteDetails()[z].setSource(_segmentDescription[x].getPoiRouteDetails()[z].getSource());
            }
          }
        }

        _segmentDescription = new SegmentDescription[qtdSeg];
        _segmentDescription = _segmentDescriptionAux;

        Object[] obj11 = removeDuplicates(4, qtdSeg, _segmentDescriptionAux, _segmentDescription, ro);

        qtdSeg = (Integer) obj11[0] + 1;
        _segmentDescription = new SegmentDescription[0];
        _segmentDescription = (SegmentDescription[]) obj11[1];

        _segmentDescriptionAux = new SegmentDescription[qtdSeg];

        for (int x = 0; x < qtdSeg; x++) {
          _segmentDescriptionAux[x] = new SegmentDescription();
          _segmentDescriptionAux[x].setCity(new City());

          if (_segmentDescription[x].getCity().getName().contains("_"))
            _segmentDescriptionAux[x].getCity().setName(
                _segmentDescription[x].getCity().getName().substring(0, _segmentDescription[x].getCity().getName().length() - 1));
          else
            _segmentDescriptionAux[x].getCity().setName(_segmentDescription[x].getCity().getName());

          _segmentDescriptionAux[x].getCity().setState(_segmentDescription[x].getCity().getState());

          _segmentDescriptionAux[x].setCommand(_segmentDescription[x].getCommand());
          _segmentDescriptionAux[x].setCumulativeDistance(_segmentDescription[x].getCumulativeDistance());
          _segmentDescriptionAux[x].setDescription(_segmentDescription[x].getDescription());
          _segmentDescriptionAux[x].setDistance(_segmentDescription[x].getDistance());

          _segmentDescriptionAux[x].setPoint(new Point());
          _segmentDescriptionAux[x].getPoint().setX(_segmentDescription[x].getPoint().getX());
          _segmentDescriptionAux[x].getPoint().setY(_segmentDescription[x].getPoint().getY());
          _segmentDescriptionAux[x].setRoadType(_segmentDescription[x].getRoadType());

          _segmentDescriptionAux[x].setTollFee(_segmentDescription[x].getTollFee());
          _segmentDescriptionAux[x].setTollFeeDetails(new TollFeeDetails());
          _segmentDescriptionAux[x].getTollFeeDetails().setAddress(_segmentDescription[x].getTollFeeDetails().getAddress());
          _segmentDescriptionAux[x].getTollFeeDetails().setConcession(_segmentDescription[x].getTollFeeDetails().getConcession());
          _segmentDescriptionAux[x].getTollFeeDetails().setDirection(_segmentDescription[x].getTollFeeDetails().getDirection());
          _segmentDescriptionAux[x].getTollFeeDetails().setName(_segmentDescription[x].getTollFeeDetails().getName());
          _segmentDescriptionAux[x].getTollFeeDetails().setPhone(_segmentDescription[x].getTollFeeDetails().getPhone());
          _segmentDescriptionAux[x].getTollFeeDetails().setPrice(_segmentDescription[x].getTollFeeDetails().getPrice());
          _segmentDescriptionAux[x].getTollFeeDetails().setPricePerAxle(_segmentDescription[x].getTollFeeDetails().getPricePerAxle());
          _segmentDescriptionAux[x].getTollFeeDetails().setState(_segmentDescription[x].getTollFeeDetails().getState());

          _segmentDescriptionAux[x].setPoiRoute(_segmentDescription[x].getPoiRoute());

          if (_segmentDescription[x].getPoiRouteDetails() != null) {
            _segmentDescriptionAux[x].setPoiRouteDetails(new POIDetails[_segmentDescription[x].getPoiRouteDetails().length]);

            for (int z = 0; z < _segmentDescription[x].getPoiRouteDetails().length; z++) {
              _segmentDescriptionAux[x].getPoiRouteDetails()[z] = new POIDetails();
              _segmentDescriptionAux[x].getPoiRouteDetails()[z].setAddressInfo(_segmentDescription[x].getPoiRouteDetails()[z]
                  .getAddressInfo());

              _segmentDescriptionAux[x].getPoiRouteDetails()[z].setClientID(_segmentDescription[x].getPoiRouteDetails()[z]
                  .getClientID());
              _segmentDescriptionAux[x].getPoiRouteDetails()[z].setName(_segmentDescription[x].getPoiRouteDetails()[z].getName());
              _segmentDescriptionAux[x].getPoiRouteDetails()[z].setPoint(new Point());
              _segmentDescriptionAux[x].getPoiRouteDetails()[z].getPoint().setX(
                  _segmentDescription[x].getPoiRouteDetails()[z].getPoint().getX());
              _segmentDescriptionAux[x].getPoiRouteDetails()[z].getPoint().setY(
                  _segmentDescription[x].getPoiRouteDetails()[z].getPoint().getY());
              _segmentDescriptionAux[x].getPoiRouteDetails()[z].setSource(_segmentDescription[x].getPoiRouteDetails()[z].getSource());
            }
          }
        }

        ret = null;
        ret = _segmentDescriptionAux;
      }
    } catch (Exception ex) {
      ex.printStackTrace();
    }

    if (!Functions.IsNullOrEmpty(ro.getDataSource())) {
      if (ro.getDataSource().toUpperCase().equals("BR")) {
        for (int x = 1; x < ret.length - 1; x++) {
          if (!(ret[x].getCommand().toLowerCase().indexOf("parada") >= 0))
            ret[x].setCommand("Continue");

          if ((ret[x].getCommand().toLowerCase().indexOf("parada") >= 0))
            ret[x].setRoadType(ret[x - 1].getRoadType());
        }

        int qtdSeg = ret.length;
        SegmentDescription[] retAux = new SegmentDescription[qtdSeg];
        retAux = ret;

        Object[] obj11 = removeDuplicates(10, qtdSeg, retAux, ret, ro);

        qtdSeg = (Integer) obj11[0] + 1;
        ret = new SegmentDescription[0];
        ret = (SegmentDescription[]) obj11[1];

        retAux = new SegmentDescription[qtdSeg];

        String lastCity = "";

        for (int x = 0; x < qtdSeg; x++) {
          retAux[x] = new SegmentDescription();
          retAux[x].setCity(new City());

          if (x == 0) {
            if (!Functions.IsNullOrEmpty(ret[x + 1].getCity().getName()))
              lastCity = ret[x + 1].getCity().getName();

View Full Code Here


    this.point = point;
  }

  public AddressLocation() {
        address = new Address();
        address.setCity(new City());
        point = new Point();
        carAccess = true;
        zipL = "";
        zipR = "";
  }
View Full Code Here

        AddressInfo ai = new AddressInfo();

        ObjectsHelper[] addressDependencyObjects = new ObjectsHelper[1];

        addressDependencyObjects[0] = cr.new ObjectsHelper();
        addressDependencyObjects[0].object = new City();
        addressDependencyObjects[0].alias = "city";

        ObjectsHelper[] addressOptionsDependencyObjects = new ObjectsHelper[1];

        addressOptionsDependencyObjects[0] = cr.new ObjectsHelper();
        addressOptionsDependencyObjects[0].object = new ResultRange();
        addressOptionsDependencyObjects[0].alias = "resultRange";

        Address address = (Address) cr.getObjectFromXML(ph.XMLFile, "address", Address.class, addressDependencyObjects);
        AddressOptions ao = (AddressOptions) cr.getObjectFromXML(ph.XMLFile, "ao", AddressOptions.class, addressOptionsDependencyObjects);

        try {
          ai = cAf.findAddress(address, ao, id_licenca);
        } catch (Exception e) {
          e.printStackTrace();
        }

        response.setContentType("text/xml");
        response.setCharacterEncoding("UTF-8");

        ObjectsHelper[] dependencyObjects = new ObjectsHelper[2];

        dependencyObjects[0] = cr.new ObjectsHelper();
        dependencyObjects[0].object = new AddressInfo();
        dependencyObjects[0].alias = "AddressInfo";

        dependencyObjects[1] = cr.new ObjectsHelper();
        dependencyObjects[1].object = new AddressLocation();
        dependencyObjects[1].alias = "AddressLocation";

        response.getWriter().write("<?xml version='1.0' encoding='UTF-8'?>\n" + cr.getXMLFromObject(ai, dependencyObjects) + "");
      }

      if (ph.fields[0].equals("findCity")) {
        CityLocationInfo ci = new CityLocationInfo();

        ObjectsHelper[] addressOptionsDependencyObjects = new ObjectsHelper[1];

        addressOptionsDependencyObjects[0] = cr.new ObjectsHelper();
        addressOptionsDependencyObjects[0].object = new ResultRange();
        addressOptionsDependencyObjects[0].alias = "resultRange";

        City city = (City) cr.getObjectFromXML(ph.XMLFile, "cidade", City.class, null);
        AddressOptions ao = (AddressOptions) cr.getObjectFromXML(ph.XMLFile, "ao", AddressOptions.class, addressOptionsDependencyObjects);

        try {
          ci = cAf.findCity(city, ao, id_licenca);
        } catch (Exception e) {
          e.printStackTrace();
        }
       
        response.setContentType("text/xml");
        response.setCharacterEncoding("UTF-8");

        ObjectsHelper[] dependencyObjects = new ObjectsHelper[2];

        dependencyObjects[0] = cr.new ObjectsHelper();
        dependencyObjects[0].object = new CityLocationInfo();
        dependencyObjects[0].alias = "CityLocationInfo";

        dependencyObjects[1] = cr.new ObjectsHelper();
        dependencyObjects[1].object = new CityLocation();
        dependencyObjects[1].alias = "CityLocation";

        response.getWriter().write("<?xml version='1.0' encoding='UTF-8'?>\n" + cr.getXMLFromObject(ci, dependencyObjects) + "");
      }

      if (ph.fields[0].equals("findPOI")) {
        POIInfo pi = new POIInfo();

        String name = cr.getFieldFromXML(ph.XMLFile, "name");
        City city = (City) cr.getObjectFromXML(ph.XMLFile, "city", City.class, null);
        ResultRange resultRange = (ResultRange) cr.getObjectFromXML(ph.XMLFile, "resultRange", ResultRange.class, null);

        try {
          pi = cAf.findPOI(name, city, resultRange, id_licenca);
        } catch (Exception e) {
          e.printStackTrace();
        }

        ObjectsHelper[] dependencyObjects = new ObjectsHelper[2];

        dependencyObjects[0] = cr.new ObjectsHelper();
        dependencyObjects[0].object = new POILocation();
        dependencyObjects[0].alias = "POILocation";

        dependencyObjects[1] = cr.new ObjectsHelper();
        dependencyObjects[1].object = new POIInfo();
        dependencyObjects[1].alias = "POIInfo";

        response.getWriter().write("<?xml version='1.0' encoding='UTF-8'?>\n" + cr.getXMLFromObject(pi, dependencyObjects) + "");
      }
      if (ph.fields[0].equals("getAddress")) {
        AddressLocation al = new AddressLocation();

       
       
        Double tolerance = Double.valueOf(cr.getFieldFromXML(ph.XMLFile, "tolerance"));
        Point point = (Point) cr.getObjectFromXML(ph.XMLFile, "point", Point.class, null);

        try {
          al = cAf.getAddress(point, tolerance, id_licenca);
        } catch (Exception e) {
          e.printStackTrace();
        }

        ObjectsHelper[] dependencyObjects = new ObjectsHelper[3];

        dependencyObjects[0] = cr.new ObjectsHelper();
        dependencyObjects[0].object = new Address();
        dependencyObjects[0].alias = "address";

        dependencyObjects[1] = cr.new ObjectsHelper();
        dependencyObjects[1].object = new Point();
        dependencyObjects[1].alias = "point";

        dependencyObjects[2] = cr.new ObjectsHelper();
        dependencyObjects[2].object = new AddressLocation();
        dependencyObjects[2].alias = "AddressLocation";

        String valor = "<?xml version='1.0' encoding='UTF-8'?>\n" + cr.getXMLFromObject(al, dependencyObjects);

        response.getWriter().write(new String(valor.getBytes("UTF-8"), "ISO-8859-1"));
      }
      if (ph.fields[0].equals("getIntersection")) {

        City city = (City) cr.getObjectFromXML(ph.XMLFile, "city", City.class, null);

        String street1 =cr.getFieldFromXML(ph.XMLFile, "street1");
        String street2 =cr.getFieldFromXML(ph.XMLFile, "street2");
        IntersectionInfo ii = null;
       
View Full Code Here

  public Address() {
    this.street = "";
    this.houseNumber = "";
    this.zip = "";
    this.district = "";
    this.city = new City();
  }
View Full Code Here

    this.command = "";
    this.description = "";
    this.poiRoute = "";
    this.poiRouteDetails = new POIDetails[0];
    this.city = new City();
    this.tollFee = "";
    this.tollFeeDetails = new TollFeeDetails();
    this.roadType = "";
    this.distance = 0;
    this.cumulativeDistance = 0;
View Full Code Here

                dl[iCount] = new DistrictLocation();

                dl[iCount].setDistrict(new District());
                dl[iCount].getDistrict().setName(rs1.getString("NOME"));

                dl[iCount].getDistrict().setCity(new City());
                dl[iCount].getDistrict().getCity().setName(rs1.getString("CIDADE"));
                dl[iCount].getDistrict().getCity().setState(rs1.getString("UF"));

                dl[iCount].setPoint(new Point());
                dl[iCount].getPoint().setX(Double.parseDouble(rs1.getString("X")));
View Full Code Here

          for (int intI = pg.getRecordsInitial(); intI <= pg.getRecordsFinal(); intI++) {
            if (rs1.absolute(intI)) {
              // definir city
              location[iCount] = new CityLocation();
              location[iCount].setCity(new City());
              location[iCount].getCity().setName(rs1.getString("MUNICY"));
              location[iCount].getCity().setState(rs1.getString("UF"));
              // definir point
              location[iCount].setPoint(new Point());
              location[iCount].getPoint().setX(Double.parseDouble(rs1.getString("X")));
View Full Code Here

                rl[iCount] = new RoadLocation();
                rl[iCount].setRoad(new Road());
                rl[iCount].getRoad().setName(rs1.getString("ENDERECO"));
                rl[iCount].getRoad().setRoadNumber(rs1.getString("NUMERO"));

                rl[iCount].getRoad().setCity(new City());
                rl[iCount].getRoad().getCity().setName(rs1.getString("MUNICIPIO"));
                rl[iCount].getRoad().getCity().setState(rs1.getString("UF"));
                rl[iCount].getRoad().setZip(rs1.getString("CEP"));

                rl[iCount].setRoadDetail(new RoadDetail());
View Full Code Here

              poil[iCount].setPoint(new Point());
              poil[iCount].getPoint().setX(Double.parseDouble(rs1.getString("X")));
              poil[iCount].getPoint().setY(Double.parseDouble(rs1.getString("Y")));

              poil[iCount].setCity(new City());
              poil[iCount].setCity(city);
              poil[iCount].setDataSource(city.getState().toUpperCase());

              iCount++;
            }
View Full Code Here

            al[0].setAddress(new Address());
            al[0].getAddress().setStreet(crs.getString("Endereco"));
            al[0].getAddress().setZip(crs.getString("CEP"));
            al[0].getAddress().setDistrict(crs.getString("BAIRRO"));
            al[0].getAddress().setHouseNumber("");
            al[0].getAddress().setCity(new City());
            al[0].getAddress().getCity().setName(crs.getString("Cidade"));
            al[0].getAddress().getCity().setState(crs.getString("EStado"));
            al[0].setZipL(crs.getString("CEP"));
            al[0].setZipR(crs.getString("CEP"));
View Full Code Here

TOP

Related Classes of com.lbslocal.cc.objects.v0.common.Extent

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.