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

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


    CityLocation[] location;

    try {
      int iCount = 0;

      Pagination pg;

      // Se for diferente de 0,1,2 ou 3, seta o valor padr�o de 2 -
      // anywhere
      if ((ao.getSearchType() != AddressOptions.Exact) && (ao.getSearchType() != AddressOptions.BeginsWith)
          && (ao.getSearchType() != AddressOptions.Anywhere) && (ao.getSearchType() != AddressOptions.EndsWith))
        ao.setSearchType(AddressOptions.Anywhere);

      String country;

      if (!Functions.IsNullOrEmpty(city.getCountry()))
        country = city.getCountry();
      else
        country = "BRASIL";

      // transformar valores null em "" para n�o dar null pointer
      // exception
      if (city.getName() == null)
        city.setName("");
      if (city.getState() == null)
        city.setState("");

      Connection con = dataBase.getConnection(Functions.getDataBase(idLicenca, country).getSource());
      CallableStatement cst = null;

      cst = con.prepareCall("{call CP_WS_TB_CIDADES_SELECT_FONETICO(?,?,?,?,?)}");
      cst.setString(1, city.getName());
      cst.setString(2, city.getState());
      cst.setInt(3, (ao.isUsePhonetic()) ? 1 : 0);
      cst.setInt(4, ao.getSearchType());
      cst.setInt(5, 0);

      cst.execute();

      ResultSet rs1 = cst.getResultSet();

      CachedRowSetImpl crs = new CachedRowSetImpl();
      crs.populate(rs1);

      int TotalRecords = crs.size();

      if (TotalRecords > 0) {
        pg = Functions.definePage(TotalRecords, ao.getResultRange().getRecordsPerPage(), ao.getResultRange().getPageIndex());

        if (pg.getRecordsInitial() <= TotalRecords) {
          location = new CityLocation[(pg.getRecordsFinal() - pg.getRecordsInitial()) + 1];

          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")));
              location[iCount].getPoint().setY(Double.parseDouble(rs1.getString("Y")));
              // definir carAccess
              location[iCount].setCarAccess(true);
              // atribuir CEP
              location[iCount].setZipRangeStart(rs1.getString("CEP_INI"));
              location[iCount].setZipRangeEnd(rs1.getString("CEP_FIM"));
              location[iCount].setCapital(rs1.getBoolean("CAPITAL"));

              location[iCount].setAddressesAvailable(true);

              iCount++;
            }
          }
        } else {
          location = new CityLocation[0];
        }

        cityLocationInfo.setRecordCount((int) pg.getRecordCount());
        cityLocationInfo.setPageCount(pg.getPageCount());
        cityLocationInfo.setCityLocation(location);
      } else {
        location = new CityLocation[0];
        cityLocationInfo.setCityLocation(location);
      }
View Full Code Here


  public RoadInfo findRoad(Road road, int idLicenca) throws Exception {
    int iCount = 0, roadNumber = 0;

    RoadInfo ri = new RoadInfo();
    Pagination pg;

    boolean hasState = (road.getCity().getState() != null && road.getCity().getState().compareTo("") != 0);

    if (!hasState) {
      throw (new Exception("O estado deve ser informado."));
    }

    if (Functions.IsNullOrEmpty(road.getCity().getCountry()))
      road.getCity().setCountry("Brasil");

    try {
      // transformar valores null em "" para n�o dar null pointer
      // exception
      if (road.getName() == null)
        road.setName("");
      if (road.getRoadNumber() == null)
        road.setRoadNumber("");
      if (road.getCity().getName() == null)
        road.getCity().setName("");
      if (road.getCity().getState() == null)
        road.getCity().setState("");
      if (road.getZip() == null)
        road.setZip("");

      // validando n�mero
      if (!road.getRoadNumber().equals("")) {
        if (Functions.isNumeric(road.getRoadNumber().replace(".", "").replace(",", "").replace("-", "").replace("e", "")))
          roadNumber = Integer.parseInt(road.getRoadNumber());
      }
      if (roadNumber == 0)
        road.setRoadNumber("");
      else
        road.setRoadNumber(String.valueOf(roadNumber));

      // se o valor de endere�o, cidade e estado for em branco erro
      // se cepe o cep forem em brancos da a mensagem de erro
      if (road.getZip() == "")
        if ((road.getName() == "") && ((road.getCity().getName() == "") || (road.getCity().getState() == "")))
          throw (new Exception(
              "Os atributos address.street, city.name e city.state devem ser informados quando o atributo address.zip nao e informado."));

      if (road.getZip().length() == 8)
        road.setZip(road.getZip().substring(0, 5) + "-" + road.getZip().substring(5, 8));

      Connection con = dataBase.getConnection(Functions.getDataBase(idLicenca, "Brasil").getSource());

      CallableStatement cst = con.prepareCall("{call cp_WS_KM(?,?,?,?,?)}");
      cst.setString(1, road.getRoadNumber());
      cst.setString(2, road.getName());
      cst.setString(3, road.getCity().getName());
      cst.setString(4, road.getCity().getState());
      cst.setString(5, road.getZip());

      cst.execute();

      ResultSet rs1 = cst.getResultSet();

      CachedRowSetImpl crs = new CachedRowSetImpl();
      crs.populate(rs1);

      int TotalRecords = crs.size();

      if (TotalRecords > 0) {
        try {
          pg = Functions.definePage(TotalRecords, 1, 0);
          RoadLocation[] rl;

          if (pg.getRecordsInitial() <= TotalRecords) {
            rl = new RoadLocation[(pg.getRecordsFinal() - pg.getRecordsInitial()) + 1];

            for (int intI = pg.getRecordsInitial(); intI <= pg.getRecordsFinal(); intI++) {
              if (rs1.absolute(intI)) {
                // classe road
                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());
                rl[iCount].getRoadDetail().setAlterName(rs1.getString("ENDERECOALT"));
                rl[iCount].getRoadDetail().setComplement(rs1.getString("COMPLEMENTO"));
                rl[iCount].getRoadDetail().setDirection(rs1.getString("SENTIDO"));
                rl[iCount].getRoadDetail().setDistrict(rs1.getString("BAIRRO"));

                iCount++;
              }
            }
            ri.setRecordCount((int) pg.getRecordCount());
            ri.setPageCount(pg.getPageCount());
          } else {
            rl = new RoadLocation[0];
          }

          ri.setRoadLocation(rl);
View Full Code Here

        po.getResultRange().setRecordsPerPage(50);
     
      if (po.getResultRange().getRecordsPerPage() < 1)
        po.getResultRange().setRecordsPerPage(5);
     
      Pagination pg = Functions.definePage(nrReg, po.getResultRange().getRecordsPerPage(), po.getResultRange().getPageIndex());
     
      strSelect = "select tabela, x, y, 102960 *  SQRT(POWER(x - " + point.getX() + ",2) + POWER(y - " + point.getY() + ",2)) as distancia, " + fields + " from dados_clientes." + tb[i]
          + " where x<>0 and ((x>=" + ext.getXMin() + " and x<=" + ext.getXMax() + ") and (y>=" + ext.getYMin() + " and y<=" + ext.getYMax() + "))" + whereClause[0] + " order by distancia "
          + orderBy + " LIMIT " + (pg.getRecordsInitial() - 1) + "," + (pg.getRecordsFinal());
     
      con = dataBase.getConnection("DADOS_WEBSERVICES");
     
      st = con.createStatement();
      rr = st.executeQuery(strSelect.toUpperCase());
     
      int columnCount = rr.getMetaData().getColumnCount();
      String[][] resultSet = new String[Math.abs((pg.getRecordsInitial() - 1) - pg.getRecordsFinal())][columnCount];
     
      while (rr.next())
      {
        int w = rr.getRow();
       
View Full Code Here

        po.getResultRange().setRecordsPerPage(50);
     
      if (po.getResultRange().getRecordsPerPage() < 1)
        po.getResultRange().setRecordsPerPage(5);
     
      Pagination pg = Functions.definePage(nrReg, po.getResultRange().getRecordsPerPage(), po.getResultRange().getPageIndex());
     
      strSelect = "select tabela, x, y, 102960 *  SQRT(POWER(x - " + point.getX() + ",2) + POWER(y - " + point.getY() + ",2)) as distancia, " + fields + " from dados_clientes." + tb[i]
          + " where x<>0 " + whereClause[0] + " order by distancia " + orderBy + " LIMIT " + (pg.getRecordsInitial() - 1) + "," + (pg.getRecordsFinal());
     
      con = dataBase.getConnection("DADOS_WEBSERVICES");
     
      st = con.createStatement();
      rr = st.executeQuery(strSelect.toUpperCase());
     
      int columnCount = rr.getMetaData().getColumnCount();
      String[][] resultSet = new String[Math.abs((pg.getRecordsInitial() - 1) - pg.getRecordsFinal())][columnCount];
     
      while (rr.next())
      {
        int w = rr.getRow();
       
View Full Code Here

        po.getResultRange().setRecordsPerPage(50);
     
      if (po.getResultRange().getRecordsPerPage() < 1)
        po.getResultRange().setRecordsPerPage(5);
     
      Pagination pg = Functions.definePage(nrReg, po.getResultRange().getRecordsPerPage(), po.getResultRange().getPageIndex());
     
      strSelect = "select tabela, x, y, 102960 *  SQRT(POWER(x - " + point.getX() + ",2) + POWER(y - " + point.getY() + ",2)) as distancia, " + fields + " from dados_clientes." + tb[i]
          + " where x<>0 and ((x>=" + ext.getXMin() + " and x<=" + ext.getXMax() + ") and (y>=" + ext.getYMin() + " and y<=" + ext.getYMax() + "))" + whereClause[0] + " order by distancia "
          + orderBy + " LIMIT " + (pg.getRecordsInitial() - 1) + "," + (pg.getRecordsFinal());
     
      con = dataBase.getConnection("DADOS_WEBSERVICES");
     
      st = con.createStatement();
      rr = st.executeQuery(strSelect.toUpperCase());
     
      int columnCount = rr.getMetaData().getColumnCount();
      String[][] resultSet = new String[Math.abs((pg.getRecordsInitial() - 1) - pg.getRecordsFinal())][columnCount];
     
      while (rr.next())
      {
        int w = rr.getRow();
       
View Full Code Here

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

            // retAux[x].city.name = ret[x + 1].city.name;
            // retAux[x].city.state = ret[x + 1].city.state;
          }

          if (x > 0) {
            if ((ret[x].getCity().getName().toLowerCase().equals(lastCity.toLowerCase()))) {
              retAux[x].getCity().setName("");
              retAux[x].getCity().setState(ret[x].getCity().getState());
            } else {
              if (!Functions.IsNullOrEmpty(ret[x].getCity().getName()))
                lastCity = ret[x].getCity().getName();

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

          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());
            }
          }
View Full Code Here

        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");
View Full Code Here

          List<RouteStop> rsList = new ArrayList<RouteStop>();

          for (int x = 0; x < routeStopFile.length; x++) {
            if (routeStopFile[x].toUpperCase().indexOf("POINT") >= 0) {
              RouteStop rsAux = new RouteStop();
              rsAux.setPoint(new Point());
              rsAux.getPoint().setX(
                  Double.parseDouble(routeStopFile[x]
                      .substring(routeStopFile[x].indexOf("'"),
                          routeStopFile[x].indexOf("y") - (routeStopFile[x].indexOf("'") + 2)).replace("'", "")
                      .replace("/", "").replace(">", "")));
View Full Code Here

            break;

          Point[] pts = new Point[parts.length - 1];

          for (int z = 0; z < parts.length - 1; z++)
            pts[z] = new Point(Double.parseDouble(parts[z].split(" ")[0]), Double.parseDouble(parts[z].split(" ")[1]));

          ptLists.add(pts);
        }

        sr.close();

      } else {
        sr.close();
        sb = new StringBuilder("");

        for (int x = 0; x < parts.length; x++) {
          if (parts[x].indexOf("VR7=") >= 0) {
            int y = 0;
            String[] co = parts[x].toString().replace("|", "").replace("\0", "").split(",");
            Point[] pts = new Point[Integer.parseInt(co[0].substring(co[0].indexOf("=") + 1))];

            Point pt;
            for (int z = 1; z < co.length; z++) {
              if (z == 1) {
                pt = new Point();
                pt.setY(Double.parseDouble(co[z]) * Math.pow(10, -7));
                pt.setX(Double.parseDouble(co[z + 1]) * Math.pow(10, -7));
              } else {
                pt = new Point();
                pt.setY((pts[y].getY()) + Integer.parseInt(co[z]) * Math.pow(10, -7));
                pt.setX((pts[y].getX()) + Integer.parseInt(co[z + 1]) * Math.pow(10, -7));
                y++;
              }
              pts[y] = pt;

              sb.append(Functions.formatDoubleToString(pt.getX(), 7) + " " + Functions.formatDoubleToString(pt.getY(), 7) + "|");
              z++;
            }
            sb.append("\n");
            ptLists.add(pts);
          }

        }
        Functions.writeFile(_dirLayer, routeID + "-response", sb.toString());

      }

      sb = new StringBuilder("");

      Point last = new Point();
      for (int w = 0; w < ptLists.size(); w++) {
        Point[] points = ptLists.get(w);

        for (int i = 0; i < points.length; i++) {
          if (points[i].getX() != 0 && points[i].getY() != 0) {
            if ((ex.getXMax() > points[i].getX() && ex.getXMin() < points[i].getX() && ex.getYMax() > points[i].getY() && ex.getYMin() < points[i]
                .getY())) {
              if ((i == 0) || (this.getDistanceDegree(last, points[i]) > precision)) {
                if ((int) (102960 * Math.sqrt(Math.pow((points[i].getX() - last.getX()), 2)
                    + Math.pow((points[i].getY() - last.getY()), 2))) > 15000) {
                  // String b = "asd";
                }
                last = points[i];
                sb.append(Functions.formatDoubleToString(points[i].getX(), 7) + " "
                    + Functions.formatDoubleToString(points[i].getY(), 7) + ";");
View Full Code Here

       
        if (!mapType.toLowerCase().equals("gif") && !mapType.toLowerCase().equals("png") && !mapType.toLowerCase().equals("jpg") ){
          mapType = "png";
        }
       
        Point point = (Point) cr.getObjectFromXML(ph.XMLFile, "point", Point.class, null);
       
        ObjectsHelper[] mapOptionsDependencyObjects = new ObjectsHelper[4];
       
        mapOptionsDependencyObjects[0] = cr.new ObjectsHelper();
        mapOptionsDependencyObjects[0].object = new MapSize();
        mapOptionsDependencyObjects[0].alias = "mapSize";
       
        mapOptionsDependencyObjects[1] = cr.new ObjectsHelper();
        mapOptionsDependencyObjects[1].object = new Icon[0];
        mapOptionsDependencyObjects[1].alias = "icon";
       
        mapOptionsDependencyObjects[2] = cr.new ObjectsHelper();
        mapOptionsDependencyObjects[2].object = new Icon();
        mapOptionsDependencyObjects[2].alias = "Icon";
       
        mapOptionsDependencyObjects[3] = cr.new ObjectsHelper();
        mapOptionsDependencyObjects[3].object = new Point();
        mapOptionsDependencyObjects[3].alias = "point";
 
        MapOptions mo = (MapOptions) cr.getObjectFromXML(ph.XMLFile, "mo", MapOptions.class, mapOptionsDependencyObjects);
       
        String routeId = cr.getFieldFromXML(ph.XMLFile, "routeId");
        int radius = Integer.valueOf(cr.getFieldFromXML(ph.XMLFile, "radius"));
       
        try
        {
          mi = cMr.getZoomRadius(routeId, point, radius, mo, id_licenca, mapType);
        }
        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 Extent();
        dependencyObjects[0].alias = "extent";
       
        dependencyObjects[1] = cr.new ObjectsHelper();
        dependencyObjects[1].object = new MapInfo();
        dependencyObjects[1].alias = "MapInfo";

        response.getWriter().write("<?xml version='1.0' encoding='UTF-8'?>\n" + cr.getXMLFromObject(mi, dependencyObjects) + "");
      }
      if (ph.fields[0].equals("getMap"))
      {
        MapInfo mi = new MapInfo();
       
        String mapType = cr.getFieldFromXML(ph.XMLFile, "maptype");
       
        if (!mapType.toLowerCase().equals("gif") && !mapType.toLowerCase().equals("png") && !mapType.toLowerCase().equals("jpg") ){
          mapType = "png";
        }
       
        Extent extent = (Extent) cr.getObjectFromXML(ph.XMLFile, "extent", Extent.class, null);
       
        ObjectsHelper[] mapOptionsDependencyObjects = new ObjectsHelper[4];
       
        mapOptionsDependencyObjects[0] = cr.new ObjectsHelper();
        mapOptionsDependencyObjects[0].object = new MapSize();
        mapOptionsDependencyObjects[0].alias = "mapSize";
       
        mapOptionsDependencyObjects[1] = cr.new ObjectsHelper();
        mapOptionsDependencyObjects[1].object = new Icon[0];
        mapOptionsDependencyObjects[1].alias = "icon";
       
        mapOptionsDependencyObjects[2] = cr.new ObjectsHelper();
        mapOptionsDependencyObjects[2].object = new Icon();
        mapOptionsDependencyObjects[2].alias = "Icon";
       
        mapOptionsDependencyObjects[3] = cr.new ObjectsHelper();
        mapOptionsDependencyObjects[3].object = new Point();
        mapOptionsDependencyObjects[3].alias = "point";
 
        MapOptions mo = (MapOptions) cr.getObjectFromXML(ph.XMLFile, "mo", MapOptions.class, mapOptionsDependencyObjects);
       
        String routeId = cr.getFieldFromXML(ph.XMLFile, "routeId");
View Full Code Here

TOP

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

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.