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

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


    String routeID = _maquina + "_" + Calendar.getInstance().getTimeInMillis();

    try {

      response = requestRoute(routeID, true, rs, ro, new Extent(), new MapSize(), null, idLicenca, _dataSource, methodID);

      ri.setRouteId(routeID);

      // ri.setProximityList(getRouteProximity(response, ro.radius,
      // idLicenca, ro.routeDetails.getRouteType()));
View Full Code Here


    SegmentDescription[] segRet = new SegmentDescription[0];

    String routeID = _maquina + "_" + Calendar.getInstance().getTimeInMillis();

    try {
      response = requestRoute(routeID, true, rs, ro, ext, new MapSize(), null, idLicenca, _dataSource, methodID);
      segRet = getSegmentDescriptionAlternative(response, ro.getVehicle().getTollFeeCat(), ro, rs, _dataSource, idLicenca);
    } catch (Exception ex) {
      Utils.LogError("CC", "getRouteWithMap - IdWebservice : Interno ", ex.getMessage() + "|" + ex.getStackTrace());

      throw (ex);
View Full Code Here

  }

  public RouteTotals getRouteTotals(int idLicenca, RouteStop[] rs, RouteProximityOptions ro, int methodID) throws Exception {
    String barriersRoute = "";

    String response = requestRoute("", false, rs, ro, new Extent(), new MapSize(), barriersRoute, idLicenca, _dataSource, methodID);

    SegmentDescription[] segDescription = getSegmentDescriptionAlternative(response, ro.getVehicle().getTollFeeCat(), ro, rs, _dataSource,
        idLicenca);
    RouteTotals rt = getTotals(segDescription, ro, rs, totalPedagios);
View Full Code Here

  }

  public RouteSummary[] getRouteSummary(int idLicenca, RouteStop[] rs, RouteProximityOptions ro, int methodID) throws Exception {
    String barriersRoute = "";

    String response = requestRoute("", false, rs, ro, new Extent(), new MapSize(), barriersRoute, idLicenca, _dataSource, methodID);

    SegmentDescription[] segDescription = getSegmentDescriptionAlternative(response, ro.getVehicle().getTollFeeCat(), ro, rs, _dataSource,
        idLicenca);
    RouteSummary[] routeSummary = getSummary(segDescription, rs, ro);
View Full Code Here

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

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

    Point pt = new Point();
    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)) {
                pt.setX(Double.parseDouble(rs1.getString("X")));
                pt.setY(Double.parseDouble(rs1.getString("Y")));

                iCount++;
View Full Code Here

    }
  }

  public POIInfo findPOI(String name, City city, ResultRange resultRange, int idLicenca) throws Exception {
    POIInfo poii = new POIInfo();
    Pagination pg;

    int iCount = 0;

    String country;

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

    if (!country.toUpperCase().equals("BRASIL"))
      return poii;

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

    boolean hasCity = (city.getName() != null && city.getName().compareTo("") != 0);

    if (!hasCity || !hasState) {
      throw (new Exception("Cidade e estado devem ser informados."));
    }

    try {
      Connection con = dataBase.getConnection(Functions.getDataBase(idLicenca, country).getSource());

      CallableStatement cst = con.prepareCall("{call CP_WS_TB_POI_BRASIL(?,?,?)}");
      cst.setString(1, name);
      cst.setString(2, city.getName());
      cst.setString(3, city.getState());

      cst.execute();

      ResultSet rs1 = cst.getResultSet();

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

      int TotalRecords = crs.size();

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

        POILocation[] poil;

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

          for (int intI = pg.getRecordsInitial(); intI <= pg.getRecordsFinal(); intI++) {
            if (rs1.absolute(intI)) {
              poil[iCount] = new POILocation();
              poil[iCount].setName(rs1.getString("NOME"));
              poil[iCount].setDistrict(rs1.getString("BAIRRO"));
              poil[iCount].setCarAccess(rs1.getBoolean("ROTAPE"));

              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++;
            }
          }
        } else {
          poil = new POILocation[0];
        }

        poii.setRecordCount((int) pg.getRecordCount());
        poii.setPageCount(pg.getPageCount());
        poii.setPoiLocations(poil);
      } else {
        poii.setPoiLocations(new POILocation[0]);
      }
View Full Code Here

  public AddressInfo findAddress(Address address, AddressOptions ao, int idLicenca) throws Exception {
    String tbRuas = "";
    int iCount = 0, houseNumber = 0;

    AddressInfo ai = new AddressInfo();
    Pagination pg;

    if ((address.getStreet() != "" && address.getStreet() != null) || (address.getZip() != "" && address.getZip() != null)
        || (address.getDistrict() != "" && address.getDistrict() != null)) {
      String country = "";
      String state = "";

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

      String dataB = "";

      if (ao.getSearchType() == 10) {
        if (address.getCity().getCountry().indexOf("|") > 0) {
          ao.setSearchType(0);
          dataB = address.getCity().getCountry().split(Pattern.quote("|"))[0];
          tbRuas = address.getCity().getCountry().split(Pattern.quote("|"))[1];

          address.getCity().setCountry(Functions.getCountryByDataBase(dataB).getName());
        } else {
          ao.setSearchType(0);
          dataB = address.getCity().getCountry();

          address.getCity().setCountry(Functions.getCountryByDataBase(dataB).getName());
        }
      } else
        dataB = Functions.getDataBase(idLicenca, country).getSource();

      // transformar valores null em "" para não dar null pointer
      // exception
      if (address.getStreet() == null)
        address.setStreet("");
      if (address.getHouseNumber() == null)
        address.setHouseNumber("");
      if (address.getZip() == null)
        address.setZip("");
      if (address.getDistrict() == null)
        address.setDistrict("");
      if (address.getCity().getName() == null)
        address.getCity().setName("");
      if (address.getCity().getState() == null)
        address.getCity().setState("");

      // validando número
      if (!address.getHouseNumber().equals("")) {
        if (Functions.isNumeric(address.getHouseNumber().replace(".", "").replace(",", "").replace("-", "").replace("e", "")))
          houseNumber = Integer.parseInt(address.getHouseNumber());
      }

      if (houseNumber == 0)
        address.setHouseNumber("");
      else
        address.setHouseNumber(String.valueOf(houseNumber));

      // 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.AnywhereDistrict)
          && (ao.getSearchType() != AddressOptions.EndsWith) && (ao.getSearchType() != AddressOptions.Auto)) {
        if (((ao.getSearchType() == AddressOptions.ExactUTM) || (ao.getSearchType() == AddressOptions.BeginsWithUTM)
            || (ao.getSearchType() == AddressOptions.AnywhereUTM) || (ao.getSearchType() == AddressOptions.EndsWithUTM))
            && ao.getSearchType() >= 100) {
          ao.setSearchType(ao.getSearchType() - 100);
        } else
          ao.setSearchType(AddressOptions.Anywhere);
      }

      if (address.getCity().getName() != "" && Functions.IsNullOrEmpty(tbRuas))
        tbRuas = Functions.getTabelaRuas(address.getCity(), idLicenca, dataB);

      country = Functions.getCountryByDataBase(dataB).getName();

      if (!Functions.IsNullOrEmpty(address.getHouseNumber()))
        address.setHouseNumber(address.getHouseNumber().replace(" ", ""));

      Connection con = dataBase.getConnection(dataB);

      CallableStatement cst = con.prepareCall("{call CP_WS_ST_RUAS_FONETICO(?,?,?,?,?,?,?)}");
      cst.setString(1, tbRuas);
      cst.setString(2, address.getStreet());
      cst.setString(3, address.getHouseNumber());
      cst.setString(4, address.getZip().replace("-", ""));
      cst.setString(5, address.getDistrict());
      cst.setInt(6, (ao.isUsePhonetic()) ? 1 : 0);
      cst.setInt(7, ao.getSearchType());

      cst.execute();

      ResultSet rs1 = cst.getResultSet();

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

      int TotalRecords = crs.size();

      AddressLocation[] al;

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

        if (country.toLowerCase().equals("brasil")) {
          Statement stEstado = con.createStatement();

          crs.next();
          String sql = " select FNCCAMELCASE(estado) estado from TB_CIDADES where geocode = '" + crs.getString("TABELA") + "' ";
          ResultSet rrEstado = stEstado.executeQuery(sql.toUpperCase());

          CachedRowSetImpl crsEstado = new CachedRowSetImpl();
          crsEstado.populate(rrEstado);

          if (crsEstado.size() != 0) {
            crsEstado.next();
            state = crsEstado.getString("ESTADO");
          }

          if (pg.getRecordsInitial() <= TotalRecords) {
            al = new AddressLocation[(pg.getRecordsFinal() - pg.getRecordsInitial()) + 1];
            for (int intI = pg.getRecordsInitial(); intI <= pg.getRecordsFinal(); intI++) {
              if (rs1.absolute(intI)) {
                al[iCount] = new AddressLocation();
                al[iCount].setZipL(rs1.getString("CEPL"));
                al[iCount].setZipR(rs1.getString("CEPR"));
                al[iCount].setCarAccess(rs1.getBoolean("ROTAPE"));

                // classe address
                al[iCount].getAddress().setStreet(rs1.getString("LOGRAC"));
                al[iCount].getAddress().setDistrict(rs1.getString("BAIRRO"));
                al[iCount].getAddress().getCity().setName(rs1.getString("MUNICIPIO"));
                al[iCount].getAddress().getCity().setCountry(country);
                // al[iCount].getAddress().setZone(rs1.getString("REGIAO"));

                if (!country.toLowerCase().equals("brasil"))
                  al[iCount].getAddress().getCity().setState(state);
                else
                  al[iCount].getAddress().getCity().setState(rs1.getString("TABELA").substring(0, 2).toUpperCase());

                if (!al[iCount].getZipL().equals(""))
                  al[iCount].getAddress().setZip(al[iCount].getZipL());
                if (!al[iCount].getZipR().equals(""))
                  al[iCount].getAddress().setZip(al[iCount].getZipR());

                al[iCount].getAddress().setHouseNumber(rs1.getString("MEDIA"));

                try {
                  al[iCount].setPoint(Functions.getGeocodeSQL(rs1.getInt("L_F_ADD"), rs1.getInt("L_T_ADD"), rs1.getInt("R_F_ADD"),
                      rs1.getInt("R_T_ADD"), al[iCount].getAddress().getHouseNumber(), rs1.getString("COORDS")));
                } catch (Exception ex) {
                  al[iCount].getPoint().setX(0.0);
                  al[iCount].getPoint().setY(0.0);
                }

                iCount++;
              }

            }

            ai.setRecordCount((int) pg.getRecordCount());
            ai.setPageCount(pg.getPageCount());
          } else {
            al = new AddressLocation[0];
            // throw (new
            // Exception("Endere�o n�o encontrado em nossa base de dados!"));
          }
View Full Code Here

    return str == null || str.trim().length() == 0;
  }

  public static Pagination definePage(Integer recordCount, Integer recordsPerPage, Integer pageIndex) throws Exception {
    try {
      Pagination pg = new Pagination();

      pg.setRecordCount(recordCount);
      pg.setPageIndex(pageIndex);

      if (pg.getPageIndex() <= 0)
        pg.setPageIndex(1);
      else
        pg.setPageIndex(pageIndex);

      if (pg.getRecordCount() <= 0)
        return new Pagination();

      if (recordsPerPage == 0)
        pg.setRecordsPerPage(recordCount);
      else
        pg.setRecordsPerPage(recordsPerPage);

      pg.setRecordsInitial(((pg.getPageIndex() - 1) * pg.getRecordsPerPage()) + 1);
      pg.setRecordsFinal((Integer) (pg.getPageIndex() * pg.getRecordsPerPage()));

      pg.setPageCount((Integer) pg.getRecordCount() / pg.getRecordsPerPage());

      if ((pg.getRecordCount() % pg.getRecordsPerPage()) != 0)
        pg.setPageCount(pg.getPageCount() + 1);

      if (pg.getPageIndex() % pg.getRecordsPerPage() == 0)
        pg.setPageMin(pg.getPageIndex() - (pg.getRecordsPerPage() - 1));
      else {
        pg.setPageMin(((pg.getPageIndex() / pg.getRecordsPerPage()) * pg.getRecordsPerPage()) + 1);
      }

      pg.setPageMax(pg.getPageMin() + pg.getRecordsPerPage() - 1);

      if (pg.getPageMax() > pg.getPageCount())
        pg.setPageMax(pg.getPageCount());

      if (pg.getPageIndex() == pg.getPageCount())
        pg.setRecordsFinal((Integer) (pg.getRecordsFinal() - (Integer) (pg.getRecordsFinal() - pg.getRecordCount())));

      return pg;
    } catch (Exception ex) {
      throw (new Exception("Erro ao paginar busca!"));
    }
View Full Code Here

    DistrictInfo ri = new DistrictInfo();

    try {
      int iCount = 0;

      Pagination pg;

      Boolean hasState = (district.getCity().getState() != null && !district.getCity().getState().equals(""));
      Boolean hasCity = (district.getCity().getName() != null && !district.getCity().getName().equals(""));

      if (!hasCity || !hasState) {
        throw (new Exception("Cidade e estado devem ser informados."));
      }

      if (district.getName() == null)
        district.setName("");

      if (district.getCity().getName() == null)
        district.getCity().setName("");

      if (district.getCity().getState() == null)
        district.getCity().setState("");

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

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

      CallableStatement cst = con.prepareCall("{call CP_WS_DISTRICT(?,?,?)}");
      cst.setString(1, district.getName());
      cst.setString(2, district.getCity().getName());
      cst.setString(3, district.getCity().getState());

      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, rr.getRecordsPerPage(), rr.getPageIndex());
          DistrictLocation[] dl;

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

            for (int intI = pg.getRecordsInitial(); intI <= pg.getRecordsFinal(); intI++) {
              // classe district
              if (rs1.absolute(intI)) {
                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")));
                dl[iCount].getPoint().setY(Double.parseDouble(rs1.getString("Y")));

                dl[iCount].getDistrict().setZone(rs1.getString("REGIAO"));

                iCount++;
              }
            }

            ri.setRecordCount((int) pg.getRecordCount());
            ri.setPageCount(pg.getPageCount());
          } else {
            dl = new DistrictLocation[0];
          }

          ri.setDistrictLocation(dl);
View Full Code Here

TOP

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

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.