Package com.lbslocal.cc.objects.v4.addressFinder

Examples of com.lbslocal.cc.objects.v4.addressFinder.CityLocationInfo


          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!"));
          }

          ai.setAddressLocation(al);
        }
      } else {
        if (address.getStreet() == "" && (!Functions.IsNullOrEmpty(address.getZip()))) {
          String cmd = " select CEP, CORREIO_ENDERECO AS ENDERECO, CORREIO_MUNICIPIO AS CIDADE, CORREIO_UF AS ESTADO, "
              + "  COALESCE(X,0) as X, COALESCE(Y,0) as Y, COALESCE(CORREIO_BAIRRO_INI,'') AS BAIRRO " + "  FROM TB_CEP_BRASIL "
              + " WHERE CEP = REPLACE('" + address.getZip() + "','-','') " + " AND X IS NOT NULL".toUpperCase();

          con = dataBase.getConnection(dataB);

          Statement st = con.createStatement();

          ResultSet rr = st.executeQuery(cmd);

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

          if (crs.size() == 0) {
            crs.next();

            al = new AddressLocation[1];
            al[0] = new AddressLocation();

            al[0].setAddress(new Address());
            al[0].getAddress().setStreet(crs.getString("Endereco"));
            al[0].getAddress().setZip(crs.getString("CEP"));
            al[0].getAddress().setDistrict(crs.getString("BAIRRO"));
View Full Code Here


    CommonRest cr = new CommonRest();

    Point point = new Point(Double.parseDouble(request.getParameter("lng")), Double.parseDouble(request.getParameter("lat")));
    Double tolerance = 50D;
    AddressLocation al = new AddressLocation();

    try {
      al = cAf.getAddress(point, tolerance, Integer.parseInt(cm.getAppSettings("ID")));
    } catch (Exception e) {
      e.printStackTrace();
    }

    ObjectsHelper[] dependencyObjects = new ObjectsHelper[3];

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

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

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

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

    response.getWriter().write(new String(valor.getBytes("UTF-8"), "ISO-8859-1"));
View Full Code Here

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

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

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

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

        ObjectsHelper[] addressOptionsDependencyObjects = new ObjectsHelper[1];

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

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

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

        ObjectsHelper[] dependencyObjects = new ObjectsHelper[2];

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

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

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

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

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

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

        ObjectsHelper[] dependencyObjects = new ObjectsHelper[2];

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

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

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

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

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

        ObjectsHelper[] dependencyObjects = new ObjectsHelper[3];

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

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

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

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

        response.getWriter().write(new String(valor.getBytes("UTF-8"), "ISO-8859-1"));
View Full Code Here

  }

  public AddressLocation getAddress(Point point, double tolerance, int idLicenca) throws Exception {
    iniDate = System.currentTimeMillis();

    AddressLocation al = new AddressLocation();

    try {
      al = ca.getAddress(point, tolerance, idLicenca, CommonAddress._getAddress, 0);
      Functions.gravarLogUnique(idLicenca, CommonAddress._getAddress, 0, iniDate, 0);
    } catch (Exception e) {
View Full Code Here

      POIInfo pi = addressFinder.findPOI((String) o[0], (City) o[1], (ResultRange) o[2], tk.getId());
      respostaWs = Common.SerializeJSObject(pi);
      break;
    case getAddress:
      o = Common.getArrayByJSon(proxy.getParameters("tjss"), new Class[] { Point.class });
      AddressLocation al = addressFinder.getAddress((Point) o[0], 100, tk.getId());
      respostaWs = Common.SerializeJSObject(al);
      break;
    case findCitiesByState:
      o = Common.getArrayByJSon(proxy.getParameters("tjss"), new Class[] { String.class });
      City city = new City("", (String) o[0]);
View Full Code Here

      if ((address.getCity().getName() == "") || (address.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."));

    try {
      AddressOptions ao = new AddressOptions();
      ao.setUsePhonetic(true);
      ao.setSearchType(2);
      ao.setResultRange(new ResultRange());
      ao.getResultRange().setPageIndex(1);
      ao.getResultRange().setRecordsPerPage(1);

      AddressInfo ai = new AddressInfo();
      ai = findAddress(address, ao, idLicenca);
      if (ai.getRecordCount() > 0) {
        for (int x = 0; x < ai.getRecordCount(); x++) {
View Full Code Here

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

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

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

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

        ObjectsHelper[] dependencyObjects = new ObjectsHelper[2];

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

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

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

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

        ObjectsHelper[] addressOptionsDependencyObjects = new ObjectsHelper[1];

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

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

        try {
          ci = cAf.findCity(city, ao, id_licenca);
        } catch (Exception e) {
          e.printStackTrace();
View Full Code Here

      Point point = new Point();

      if (Functions.IsNullOrEmpty(ad.getStreet()) && Functions.IsNullOrEmpty(ad.getHouseNumber()) && Functions.IsNullOrEmpty(ad.getZip())
          && (!Functions.IsNullOrEmpty(ad.getCity().getName()) && !Functions.IsNullOrEmpty(ad.getCity().getState()))) {
        try {
          point = af.findCity(ad.getCity(), new AddressOptions(true, 10, new ResultRange(1, 1)), idLicenca).getCityLocation()[0].getPoint();
        } catch (Exception ex) {
          throw (new Exception("Nao foi possivel geocodificar o endereco."));
        }
      } else {
        point = af.getXY(ad, idLicenca);
View Full Code Here

      Point point = new Point();

      if (Functions.IsNullOrEmpty(ad.getStreet()) && Functions.IsNullOrEmpty(ad.getHouseNumber()) && Functions.IsNullOrEmpty(ad.getZip())
          && (!Functions.IsNullOrEmpty(ad.getCity().getName()) && !Functions.IsNullOrEmpty(ad.getCity().getState()))) {
        try {
          point = af.findCity(ad.getCity(), new AddressOptions(true, 0, new ResultRange(1, 1)), idLicenca).getCityLocation()[0].getPoint();
        } catch (Exception ex) {
          throw (new Exception("Nao foi possivel geocodificar o endereco."));
        }
      } else {
        point = af.getXY(ad, idLicenca);
View Full Code Here

      respostaWs = Common.SerializeJSObject(al);
      break;
    case findCitiesByState:
      o = Common.getArrayByJSon(proxy.getParameters("tjss"), new Class[] { String.class });
      City city = new City("", (String) o[0]);
      AddressOptions ao = new AddressOptions(false, 1, new ResultRange(0, 1500));

      CityLocationInfo clii = addressFinder.findCity(city, ao, tk.getId());

      StringBuilder sb = new StringBuilder("[");
      for (int i = 0; i < clii.getCityLocation().length; i++) {
View Full Code Here

TOP

Related Classes of com.lbslocal.cc.objects.v4.addressFinder.CityLocationInfo

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.