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

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


          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

    return ext;
  }

  public MapInfo renderMap(String routeId, String routeResponse, Extent extent, MapOptions mo, int idLicenca, int methodID) throws Exception {
    try {
      return getMap(routeId, routeResponse, new Point[0], extent, mo, new Point(), idLicenca, methodID, "png");
    } catch (Exception ex) {
      throw (ex);
    }
  }
View Full Code Here

        if (parts[x].indexOf("VR=") >= 0) {
          String[] co = parts[x].toString().replace("|", "").replace("\0", "").split(",");

          for (int z = 1; z < co.length; z++) {
            if ((co[z + 1].toString().replace("|", "").length() < 8)) {
              Point pt = new Point();
              pt.setY(ptList.get(y).getY() + Integer.parseInt(co[z]) * Math.pow(10, -5));
              pt.setX(ptList.get(y).getX() + Integer.parseInt(co[z + 1]) * Math.pow(10, -5));

              ptList.add(pt);

              y++;
            } else {
              Point pt = new Point();
              pt.setY(Integer.parseInt(co[z]) * Math.pow(10, -5));
              pt.setX(Integer.parseInt(co[z + 1]) * Math.pow(10, -5));

              ptList.add(pt);
            }

            z++;
View Full Code Here

 

  private MapInfo renderMap(String routeId, String routeResponse, Extent extent, MapOptions mo, int idLicenca, int methodID, String mapType) throws Exception {
    try {
      return getMap(routeId, routeResponse, new Point[0], extent, mo, new Point(), idLicenca, methodID, mapType);
    } catch (Exception ex) {
      throw (ex);
    }
  }
View Full Code Here

  public MapInfo getZoomFullExtent(String routeId, MapOptions mo, int idLicenca, int methodID) throws Exception {
    MapInfo mi = new MapInfo();

    try {
      Point point = new Point(-62.9569009522848, -21.3320991286825);

      Extent ext = Functions.CalcRadius(3800045, point);

      mi = renderMap(routeId, "", ext, mo, idLicenca, methodID);
    } catch (Exception ex) {
View Full Code Here

    return tabelaRuas;
  }

  public static Point getGeocodeSQL(int lf, int lt, int rf, int rt, String numero, String coords) {
    LinePoint[] line;
    Point pOrigem, pFim, pFinal = null;
    String format = "0.00000";

    Encrypt ce = new Encrypt();
    if ((!(coords.indexOf(" ") > 0)) && (!(coords.indexOf(",") > 0)) && (!(coords.indexOf(";") > 0)))
      coords = ce.Decode(coords);

    // -2551100,-4924916,-118,59,42,103,-20,10,-115,58
    if (!(coords.indexOf(';') > 0)) {
      format = "0.0000000";
      coords = convertFromDecarta(7, coords);
    }

    boolean blnPar, blnInverse, blnLeftPar = true;
    int L_F_ADD, L_T_ADD, R_F_ADD, R_T_ADD, houseNumber = 0, to, from, intAux;
    int i, z = 0;

    double totalLenght = 0, percentLine = 0, angle;

    if (!numero.equals(""))
      houseNumber = Integer.parseInt(numero); // Atribui valor ao inteiro
    if (houseNumber % 2 == 0)
      blnPar = true;
    else
      blnPar = false; // Buscar por Par ou �mpar

    L_F_ADD = lf;
    L_T_ADD = lt;
    R_F_ADD = rf;
    R_T_ADD = rt;

    to = L_T_ADD;
    from = L_F_ADD;

    if (coords.lastIndexOf(';') == coords.length())
      coords = coords.substring(0, coords.length() - 1);

    if (coords.substring(coords.length() - 1).equals(";"))
      coords = coords.substring(0, coords.length() - 1);

    // Qual lado � par - Left � default
    if (L_F_ADD != 0) {
      if (L_F_ADD % 2 != 0)
        blnLeftPar = false;
    }
    if (R_F_ADD != 0) {
      if (R_F_ADD % 2 == 0)
        blnLeftPar = false;
    }

    // Atribu to / from caso necessario - to e from default left
    if (blnPar) {
      if (!blnLeftPar) {
        to = R_T_ADD;
        from = R_F_ADD;
      }
    } else {
      if (blnLeftPar) {
        to = R_T_ADD;
        from = R_F_ADD;
      }
    }

    // verifica leitura inversa
    if (from > to) {
      intAux = from;
      from = to;
      to = intAux;
      blnInverse = true;
    } else
      blnInverse = false;

    line = new LinePoint[coords.split(";").length];

    // l� inversamente caso necess�rio
    if (!blnInverse) {
      for (i = 0; i < line.length; i++) {
        line[i] = new LinePoint();
        line[i].setPoint(new Point());
        line[i].getPoint().setX(Double.parseDouble(coords.split(";")[i].split(" ")[0].toString()));
        line[i].getPoint().setY(Double.parseDouble(coords.split(";")[i].split(" ")[1].toString()));
      }
    } else {
      for (i = line.length - 1; i > -1; i--) {
        line[z] = new LinePoint();
        line[z].setPoint(new Point());
        line[z].getPoint().setX(Double.parseDouble(coords.split(";")[i].split(" ")[0].toString()));
        line[z].getPoint().setY(Double.parseDouble(coords.split(";")[i].split(" ")[1].toString()));
        z++;
      }
    }

    // Tamanho Total / Parcial
    for (i = 0; i < line.length; i++) {
      if (i + 1 < line.length) {
        line[i].setLength(Math.sqrt(Math.pow((line[i].getPoint().getX() - line[i + 1].getPoint().getX()), 2)
            + Math.pow((line[i].getPoint().getY() - line[i + 1].getPoint().getY()), 2)));
        totalLenght += line[i].getLength();
      }
    }

    // Numero na linha
    if (to - from != 0)
      percentLine = ((houseNumber - from) * totalLenght) / (to - from);

    // Escolhe o segmento
    for (i = 0; i < line.length - 1; i++) {
      if (line[i].getLength() >= percentLine)
        break;
      else
        percentLine -= line[i].getLength();
    }

    // Caso de perda de precis�o
    if (i == line.length - 1) {
      i--;
      percentLine += line[i].getLength();
    }

    pFinal = new Point();
    pFinal.setX(0);
    pFinal.setY(0);

    pOrigem = line[i].getPoint();
    pFim = line[i + 1].getPoint();

    if ((pOrigem.getX() - pFim.getX()) == 0 || (pOrigem.getY() - pFim.getY()) == 0)
      angle = 0;
    else {
      angle = Math.abs(Math.atan((pOrigem.getY() - pFim.getY()) / (pOrigem.getX() - pFim.getX())));
    }

    // 1 Quadrante
    if (pOrigem.getX() < pFim.getX() && pOrigem.getY() < pFim.getY()) {
      pFinal.setX(pOrigem.getX() + percentLine * Math.cos(angle));
      pFinal.setY(pOrigem.getY() + percentLine * Math.sin(angle));
    }

    // 2 Quadrante
    if (pOrigem.getX() > pFim.getX() && pOrigem.getY() < pFim.getY()) {
      pFinal.setX(pOrigem.getX() - percentLine * Math.cos(angle));
      pFinal.setY(pOrigem.getY() + percentLine * Math.sin(angle));
    }

    // 3 Quadrante
    if (pOrigem.getX() > pFim.getX() && pOrigem.getY() > pFim.getY()) {
      pFinal.setX(pOrigem.getX() - percentLine * Math.cos(angle));
      pFinal.setY(pOrigem.getY() - percentLine * Math.sin(angle));
    }

    // 4 Quadrante
    if (pOrigem.getX() < pFim.getX() && pOrigem.getY() > pFim.getY()) {
      pFinal.setX(pOrigem.getX() + percentLine * Math.cos(angle));
      pFinal.setY(pOrigem.getY() - percentLine * Math.sin(angle));
    }

    if (pFinal.getX() == 0 || pFinal.getY() == 0) {
      // 0 ou 360 graus
      if (pOrigem.getX() < pFim.getX() && pOrigem.getY() == pFim.getY()) {
        pFinal.setX(pOrigem.getX() + percentLine);
        pFinal.setY(pOrigem.getY());
      }

      // 90 graus
      if (pOrigem.getX() == pFim.getX() && pOrigem.getY() < pFim.getY()) {
        pFinal.setX(pOrigem.getX());
        pFinal.setY(pOrigem.getY() + percentLine);
      }

      // 180 graus
      if (pOrigem.getX() > pFim.getX() && pOrigem.getY() == pFim.getY()) {
        pFinal.setX(pOrigem.getX() - percentLine);
        pFinal.setY(pOrigem.getY());
      }

      // 270 graus
      if (pOrigem.getX() == pFim.getX() && pOrigem.getY() > pFim.getY()) {
        pFinal.setX(pOrigem.getX());
        pFinal.setY(pOrigem.getY() - percentLine);
      }
    }

    if (pFinal.getX() == 0 && pOrigem.getX() != 0) {
      pFinal = pOrigem;
    }

    if (pFinal.getX() == 0 && pFim.getX() != 0) {
      pFinal = pFim;
View Full Code Here

      if (((co[z + 1]).toString().replace("|", "").length() < (precision + 2))) {
        DecimalFormat df = new DecimalFormat(format.replace("0", "#"));
        df.setMinimumFractionDigits(precision);

        Point pt = new Point();
        pt.setY(Double.parseDouble(df.format(
            (Integer.parseInt(df.format(ptList.get(y).getY()).replace(",", "").replace(".", "")) + Integer.parseInt(co[z]))
                * Math.pow(10, -precision)).replace(",", ".")));
        pt.setX(Double.parseDouble(df.format(
            (Integer.parseInt(df.format(ptList.get(y).getX()).replace(",", "").replace(".", "")) + Integer.parseInt(co[z + 1]))
                * Math.pow(10, -precision)).replace(",", ".")));

        ptList.add(pt);

        y++;
      } else {
        DecimalFormat df = new DecimalFormat(format.replace("0", "#"));
        df.setMinimumFractionDigits(precision);

        Point pt = new Point();
        pt.setY(Double.parseDouble(df.format(Integer.parseInt(co[z]) * Math.pow(10, -precision)).replace(",", ".")));
        pt.setX(Double.parseDouble(df.format(Integer.parseInt(co[z + 1]) * Math.pow(10, -precision)).replace(",", ".")));

        ptList.add(pt);
      }

      z++;
View Full Code Here

      if (((co[z + 1]).toString().replace("|", "").length() < (precision + 2))) {
        DecimalFormat df = new DecimalFormat(format.replace("0", "#"));
        df.setMinimumFractionDigits(precision);

        Point pt = new Point();
        pt.setY(Double.parseDouble(df.format(
            (Integer.parseInt(df.format(ptList.get(y).getY()).replace(",", "").replace(".", "")) + Integer.parseInt(co[z]))
                * Math.pow(10, -precision)).replace(",", ".")));
        pt.setX(Double.parseDouble(df.format(
            (Integer.parseInt(df.format(ptList.get(y).getX()).replace(",", "").replace(".", "")) + Integer.parseInt(co[z + 1]))
                * Math.pow(10, -precision)).replace(",", ".")));

        ptList.add(pt);

        y++;
      } else {
        DecimalFormat df = new DecimalFormat(format.replace("0", "#"));
        df.setMinimumFractionDigits(precision);

        Point pt = new Point();
        pt.setY(Double.parseDouble(df.format(Integer.parseInt(co[z]) * Math.pow(10, -precision)).replace(",", ".")));
        pt.setX(Double.parseDouble(df.format(Integer.parseInt(co[z + 1]) * Math.pow(10, -precision)).replace(",", ".")));

        ptList.add(pt);
      }

      z++;
View Full Code Here

TOP

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

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.