Package org.openstreetmap.josm.data.coor

Examples of org.openstreetmap.josm.data.coor.LatLon


    /*
     * Converts from bounds used in josm to boxes used here
     */
    public static Box fromBounds(Bounds bbox) {
        LatLon min = bbox.getMin(), max = bbox.getMax();
        return new Box(toFpi(min.getX()), toFpi(min.getY()), toFpi(max.getX()),
                toFpi(max.getY()));
    }
View Full Code Here


            return new DownloadGpsTask();
        throw new IllegalArgumentException();
    }

    static protected Bounds extend(Bounds bbox, double amount) {
        LatLon min = bbox.getMin();
        LatLon max = bbox.getMax();

        double dLat = Math.abs(max.lat() - min.lat()) * amount;
        double dLon = Math.abs(max.lon() - min.lon()) * amount;

        return new Bounds(min.lat() - dLat, min.lon() - dLon, max.lat() + dLat, max.lon() + dLon);
    }
View Full Code Here

    parent = (CustomMapView) mv;

    int iMove = 0;

    zoom = mv.zoom();
    LatLon cen = Main.proj.eastNorth2latlon(mv.getCenter());

    center = new Point(OsmMercator.LonToX(cen.getX(), zoom), OsmMercator
        .LatToY(cen.getY(), zoom));

    int tilex = center.x / Tile.SIZE;
    int tiley = center.y / Tile.SIZE;
    int off_x = (center.x % Tile.SIZE);
    int off_y = (center.y % Tile.SIZE);
View Full Code Here

  public void setPositions(LatLon[] newPositions) {
    int fold = 10;
    positions = new LatLon[newPositions.length * fold];
    for (int i = 0; i < newPositions.length; i++) {
      LatLon p0 = newPositions[i];
      LatLon p1 = newPositions[0];
      if (i + 1 != newPositions.length)
        p1 = newPositions[i + 1];
      double dx = p1.lon() - p0.lon();
      double dy = p1.lat() - p0.lat();
      for (int j = 0; j < fold; j++) {
        positions[i * fold + j] = new LatLon(p0.lat()
            + (dy * (j / ((double) fold))), p0.lon()
            + (dx * (j / ((double) fold))));
      }
    }
    currentPositionIndex = 0;
View Full Code Here

    posPanel.add(posField);
    view.addMouseMotionListener(new MouseMotionListener() {

      @Override
      public void mouseMoved(MouseEvent e) {
        LatLon ll = ((ICustomMapView) e.getSource()).getLatLon(e.getX(),
            e.getY());
        String position = "";
        String format = LogicConstants.get("FORMATO_COORDENADAS_MAPA",
            "UTM");
        if (format.equals(LogicConstants.COORD_UTM)) {
          UTM u = new UTM(LogicConstants.getInt("ZONA_UTM"));
          EastNorth en = u.latlon2eastNorth(ll);
          position = String.format("x: %.1f y: %.1f", en.getX(), en
              .getY());
        } else {
          position = String.format("Lat: %.4f Lon: %.4f", ll.lat(),
              ll.lon());
        }

        posField.setText(position);
        validate();
      }
View Full Code Here

          String format = LogicConstants.get(
              "FORMATO_COORDENADAS_MAPA", "UTM");
          if (format.equals(LogicConstants.COORD_UTM)) {
            UTM u = new UTM(LogicConstants.getInt("ZONA_UTM"));
            LatLon ll = u.eastNorth2latlon(new EastNorth(x, y));
            view.zoomTo(Main.proj.latlon2eastNorth(ll), view
                .getScale());
          } else {
            // en el latlong la x y la y van al reves
            view.zoomTo(Main.proj
                .latlon2eastNorth(new LatLon(x, y)), view
                .getScale());
          }
        } else if (centerOptions.getSelectedItem().equals(
            i18n.getString("map.street"))) {
          Routing r = RoutingConsultas.find(street.getText());
          if (r != null && r.getGeometria() != null) {
            Point center = r.getGeometria().getCentroid()
                .getCentroid();
            view
                .zoomTo(Main.proj.latlon2eastNorth(new LatLon(
                    center.getY(), center.getX())), view
                    .getScale());
          }

        } else if (centerOptions.getSelectedItem().equals(
            i18n.getString("map.incidence"))) {

          final Object incidencia = incidences.getSelectedItem();
          if (incidencia == null) {
            return null;
          }

          Incidencia i = null;
          if (incidencia instanceof Incidencia) {
            i = (Incidencia) incidencia;
          } else {
            i = IncidenciaConsultas.find(incidencia.toString());
          }

          Geometry geom = i.getGeometria();
          if (geom == null) {
            return null;
          }

          Point center = geom.getCentroid();
          view.zoomTo(Main.proj.latlon2eastNorth(new LatLon(center
              .getY(), center.getX())), view.getScale());
          return null;

        } else if (centerOptions.getSelectedItem().equals(
            i18n.getString("map.resource"))) {
          final Object selectedItem = resources.getSelectedItem();
          if (selectedItem == null) {
            return null;
          }
          if (selectedItem instanceof Recurso) {
            Recurso r = (Recurso) selectedItem;
            HistoricoGPS h = null;
            if (r.getId() != null) {
              h = HistoricoGPSConsultas.lastGPSForRecurso(r);
            } else
              try {
                h = r.getHistoricoGps();
              } catch (Throwable t) {
                h = null;
              }
            if (h == null) {
              return null;
            }
            view.zoomTo(Main.proj.latlon2eastNorth(new LatLon(h
                .getPosY(), h.getPosX())), view.getScale());
          } else if (selectedItem instanceof String) {
            String r = (String) selectedItem;
            HistoricoGPS h = HistoricoGPSConsultas
                .lastGPSForRecurso(r);
            if (h == null) {
              return null;
            }
            view.zoomTo(Main.proj.latlon2eastNorth(new LatLon(h
                .getPosY(), h.getPosX())), view.getScale());
          } else if (selectedItem instanceof GpxLayer) {
            MyGpxLayer r = (MyGpxLayer) selectedItem;
            if (r == null || r.getLatLon() == null) {
              return null;
View Full Code Here

      angle = ((RotatableView) mv).getAngle();

    int iMove = 0;

    zoom = mv.zoom();
    LatLon cen = Main.proj.eastNorth2latlon(mv.getCenter());
    center = new Point(OsmMercator.LonToX(cen.getX(), zoom), OsmMercator
        .LatToY(cen.getY(), zoom));

    int tilex = center.x / Tile.SIZE;
    int tiley = center.y / Tile.SIZE;
    int off_x = (center.x % Tile.SIZE);
    int off_y = (center.y % Tile.SIZE);
View Full Code Here

    @Override
    public void actionPerformed(ActionEvent e) {
      Routing r = RoutingConsultas.find(this.name);
      if (r != null && r.getGeometria() != null) {
        Point center = r.getGeometria().getCentroid().getCentroid();
        view.zoomTo(Main.proj.latlon2eastNorth(new LatLon(
            center.getY(), center.getX())), view.getScale());
      }
    }
View Full Code Here

            if (numeros.length != 2)
              log.error("Numero de dimensiones incorrecto: "
                  + numeros.length);
            else {
              try {
                LatLon latlon = extractLatLon(numeros);
                log.trace(latlon);
                Node n = new Node(id++);
                n.setCoor(latlon);
                ((Way) resultado).addNode(n);
              } catch (Exception e) {
                log.error("Error calculando el nodo", e);
              }
            }
          }
        }
        break;
      case POINT:
        log.trace("Reconocido a POINT");
        if (componentes[1].length() < 1) {
          log.error("componentes erroneas");
        } else {
          String coordenada = componentes[1].substring(0,
              componentes[1].length() - 1);
          if (coordenada.length() == 0)
            log.trace("No hay coordenadas, ¿geometria vacia?");
          log.trace("coordenadas: " + coordenada);
          String[] numeros = StringUtils.split(coordenada, " ");
          if (numeros.length != 2)
            log.error("Numero de dimensiones incorrecto: "
                + numeros.length);
          else {
            try {
              LatLon latlon = extractLatLon(numeros);
              resultado = new Node(latlon);
            } catch (Exception e) {
              log.error("Error calculando el nodo", e);
              e.printStackTrace();
            }
View Full Code Here

          if (numeros.length != 2)
            log.error("Numero de dimensiones incorrecto: "
                + numeros.length);
          else {
            try {
              LatLon latlon = extractLatLon(numeros);
              log.trace("LatLon del nuevo marcador: " + latlon);
              resultado = new WayPoint(latlon);
            } catch (Exception e) {
              log.error("Error calculando el nodo", e);
              e.printStackTrace();
View Full Code Here

TOP

Related Classes of org.openstreetmap.josm.data.coor.LatLon

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.