Package org.openstreetmap.josm.data.gpx

Examples of org.openstreetmap.josm.data.gpx.WayPoint


   *
   * @param geometry
   * @return
   */
  public static WayPoint wktToWayPoint(String geometry) {
    WayPoint resultado = null;

    if (geometry != null) {
      log.trace("Vamos a convertir " + geometry);
      String[] componentes = StringUtils.split(geometry, "(");

      String tipo = componentes[0];
      GeometryType type = null;

      if (tipo.equals("LINESTRING"))
        type = GeometryType.LINESTRING;
      else if (tipo.equals("MULTILINESTRING"))
        type = GeometryType.MULTILINESTRING;
      else if (tipo.equals("POINT"))
        type = GeometryType.POINT;
      else if (tipo.equals("MULTIPOINT"))
        type = GeometryType.MULTIPOINT;
      else if (tipo.equals("POLYGON"))
        type = GeometryType.POLYGON;
      else if (tipo.equals("MULTIPOLYGON"))
        type = GeometryType.MULTIPOLYGON;
      else
        type = GeometryType.UNKNOWN;

      switch (type) {
      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);
              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


    for (Recurso r : allres) {
      HistoricoGPS h = r.getHistoricoGps();
      if (h == null) {
        continue;
      }
      WayPoint w = new WayPoint(new LatLon(h.getPosY(), h.getPosX()));
      String name = r.getNombre();

      if (r.getPatrullas() != null)
        name += " (" + r.getPatrullas().getNombre() + ")";
View Full Code Here

          final com.vividsolutions.jts.geom.Point centroid = i
              .getGeometria().getCentroid();
          if (centroid != null) {
            LatLon latlon = new LatLon(centroid.getCoordinate().y,
                centroid.getCoordinate().x);
            WayPoint w = new WayPoint(latlon);
            w.attr.put("name",
                i.getTitulo() + " (" + i.getPrioridad() + ")");
            w.attr.put(
                "symbol",
                LogicConstants.get(
View Full Code Here

          states.push(currentState);
          currentState = State.metadata;
        } else if (qName.equals("wpt")) {
          states.push(currentState);
          currentState = State.wpt;
          currentWayPoint = new WayPoint(parseLatLon(atts));
        } else if (qName.equals("rte")) {
          states.push(currentState);
          currentState = State.rte;
          currentRoute = new GpxRoute();
        } else if (qName.equals("trk")) {
          states.push(currentState);
          currentState = State.trk;
          currentTrack = new ArrayList<Collection<WayPoint>>();
          currentTrackAttr = new HashMap<String, Object>();
        } else if (qName.equals("extensions")) {
          states.push(currentState);
          currentState = State.ext;
        } else if (qName.equals("gpx")
            && atts.getValue("creator") != null
            && atts.getValue("creator").startsWith(
                "Nokia Sports Tracker")) {
          nokiaSportsTrackerBug = true;
        }
        break;
      case author:
        if (qName.equals("link")) {
          states.push(currentState);
          currentState = State.link;
          currentLink = new GpxLink(atts.getValue("href"));
        } else if (qName.equals("email")) {
          currentData.attr.put(GpxData.META_AUTHOR_EMAIL, atts
              .getValue("id")
              + "@" + atts.getValue("domain"));
        }
        break;
      case trk:
        if (qName.equals("trkseg")) {
          states.push(currentState);
          currentState = State.trkseg;
          currentTrackSeg = new ArrayList<WayPoint>();
        } else if (qName.equals("link")) {
          states.push(currentState);
          currentState = State.link;
          currentLink = new GpxLink(atts.getValue("href"));
        } else if (qName.equals("extensions")) {
          states.push(currentState);
          currentState = State.ext;
        }
        break;
      case metadata:
        if (qName.equals("author")) {
          states.push(currentState);
          currentState = State.author;
        } else if (qName.equals("extensions")) {
          states.push(currentState);
          currentState = State.ext;
        } else if (qName.equals("copyright")) {
          states.push(currentState);
          currentState = State.copyright;
          currentData.attr.put(GpxData.META_COPYRIGHT_AUTHOR, atts
              .getValue("author"));
        } else if (qName.equals("link")) {
          states.push(currentState);
          currentState = State.link;
          currentLink = new GpxLink(atts.getValue("href"));
        }
        break;
      case trkseg:
        if (qName.equals("trkpt")) {
          states.push(currentState);
          currentState = State.wpt;
          currentWayPoint = new WayPoint(parseLatLon(atts));
        }
        break;
      case wpt:
        if (qName.equals("link")) {
          states.push(currentState);
          currentState = State.link;
          currentLink = new GpxLink(atts.getValue("href"));
        } else if (qName.equals("extensions")) {
          states.push(currentState);
          currentState = State.ext;
        }
        break;
      case rte:
        if (qName.equals("link")) {
          states.push(currentState);
          currentState = State.link;
          currentLink = new GpxLink(atts.getValue("href"));
        } else if (qName.equals("rtept")) {
          states.push(currentState);
          currentState = State.wpt;
          currentWayPoint = new WayPoint(parseLatLon(atts));
        } else if (qName.equals("extensions")) {
          states.push(currentState);
          currentState = State.ext;
        }
        break;
View Full Code Here

          trk.trackSegs.add(trkseg);
        }
        if (!n.isTagged()) {
          doneNodes.add(n);
        }
        WayPoint wpt = new WayPoint(n.getCoor());
        if (!n.isTimestampEmpty()) {
          wpt.attr.put("time", DateUtils.fromDate(n.getTimestamp()));
          wpt.setTime();
        }
        trkseg.add(wpt);
      }
    }

    // what is this loop meant to do? it creates waypoints but never
    // records them?
    for (Node n : data.nodes) {
      if (n.incomplete || n.deleted || doneNodes.contains(n))
        continue;
      WayPoint wpt = new WayPoint(n.getCoor());
      if (!n.isTimestampEmpty()) {
        wpt.attr.put("time", DateUtils.fromDate(n.getTimestamp()));
        wpt.setTime();
      }
      if (n.keys != null && n.keys.containsKey("name")) {
        wpt.attr.put("name", n.keys.get("name"));
      }
    }
View Full Code Here

          new LinkedList<Collection<WayPoint>>(),
          new LinkedHashMap<String, Object>());
      LinkedList<WayPoint> linkedList = new LinkedList<WayPoint>();
      if (posiciones != null) {
        for (Posicion pos : posiciones) {
          WayPoint way = buildWay(pos, linea, showTime);
          linkedList.add(way);
        }
      } else {
        setError("No se encontraron posiciones");
      }
View Full Code Here

    }
    return file;
  }

  private WayPoint buildWay(Posicion pos, boolean linea, boolean showTime) {
    WayPoint way = new WayPoint(new LatLon(pos.getY(), pos.getX()));
    way.attr.put("time",
        dateFormat.format(pos.getMarcaTemporal().getTime()));
    String name = pos.getIdentificador();

    if (showTime) {
      name += " "
          + DateFormat.getDateTimeInstance(DateFormat.SHORT,
              DateFormat.MEDIUM, LOCALE).format(
              pos.getMarcaTemporal().getTime());
    }
    way.attr.put("name", name);

    way.setGarminCommentTime("time");
    way.drawLine = linea;
    return way;
  }
View Full Code Here

                    trk.add(trkseg);
                }
                if (!n.isTagged()) {
                    doneNodes.add(n);
                }
                WayPoint wpt = new WayPoint(n.getCoor());
                if (!n.isTimestampEmpty()) {
                    wpt.attr.put("time", DateUtils.fromDate(n.getTimestamp()));
                    wpt.setTime();
                }
                trkseg.add(wpt);
            }

            gpxData.tracks.add(new ImmutableGpxTrack(trk, trkAttr));
        }

        for (Node n : data.getNodes()) {
            if (n.isIncomplete() || n.isDeleted() || doneNodes.contains(n)) {
                continue;
            }
            WayPoint wpt = new WayPoint(n.getCoor());
            String name = n.get("name");
            if (name != null) {
                wpt.attr.put("name", name);
            }
            if (!n.isTimestampEmpty()) {
                wpt.attr.put("time", DateUtils.fromDate(n.getTimestamp()));
                wpt.setTime();
            }
            String desc = n.get("description");
            if (desc != null) {
                wpt.attr.put("desc", desc);
            }
View Full Code Here

        }

    }

    private LinkedList<WayPoint> listVisibleSegments(Bounds box) {
        WayPoint last = null;
        LinkedList<WayPoint> visibleSegments = new LinkedList<>();

        ensureTrackVisibilityLength();
        for (Collection<WayPoint> segment : data.getLinesIterable(trackVisibility)) {

            for(WayPoint pt : segment)
            {
                Bounds b = new Bounds(pt.getCoor());
                // last should never be null when this is true!
                if(pt.drawLine) {
                    b.extend(last.getCoor());
                }
                if(b.intersects(box))
                {
                    if(last != null && (visibleSegments.isEmpty()
                            || visibleSegments.getLast() != last)) {
                        if(last.drawLine) {
                            WayPoint l = new WayPoint(last);
                            l.drawLine = false;
                            visibleSegments.add(l);
                        } else {
                            visibleSegments.add(last);
                        }
View Full Code Here

    }

    public void calculateColors() {
        double minval = +1e10;
        double maxval = -1e10;
        WayPoint oldWp = null;

        if (colorModeDynamic) {
            if (colored == ColorMode.VELOCITY) {
                for (Collection<WayPoint> segment : data.getLinesIterable(null)) {
                    if(!forceLines) {
                        oldWp = null;
                    }
                    for (WayPoint trkPnt : segment) {
                        LatLon c = trkPnt.getCoor();
                        if (Double.isNaN(c.lat()) || Double.isNaN(c.lon())) {
                            continue;
                        }
                        if (oldWp != null && trkPnt.time > oldWp.time) {
                            double vel = c.greatCircleDistance(oldWp.getCoor())
                                    / (trkPnt.time - oldWp.time);
                            if(vel > maxval) {
                                maxval = vel;
                            }
                            if(vel < minval) {
                                minval = vel;
                            }
                        }
                        oldWp = trkPnt;
                    }
                }
                if (minval >= maxval) {
                    velocityScale.setRange(0, 120/3.6);
                } else {
                    velocityScale.setRange(minval, maxval);
                }
            } else if (colored == ColorMode.HDOP) {
                for (Collection<WayPoint> segment : data.getLinesIterable(null)) {
                    for (WayPoint trkPnt : segment) {
                        Object val = trkPnt.attr.get("hdop");
                        if (val != null) {
                            double hdop = ((Float) val).doubleValue();
                            if(hdop > maxval) {
                                maxval = hdop;
                            }
                            if(hdop < minval) {
                                minval = hdop;
                            }
                        }
                    }
                }
                if (minval >= maxval) {
                    hdopScale.setRange(0, 100);
                } else {
                    hdopScale.setRange(minval, maxval);
                }
            }
            oldWp = null;
        } else { // color mode not dynamic
            velocityScale.setRange(0, colorTracksTune);
            hdopScale.setRange(0, 1.0/hdopfactor);
        }
        double now = System.currentTimeMillis()/1000.0;
        if (colored == ColorMode.TIME) {
            Date[] bounds = data.getMinMaxTimeForAllTracks();
            if (bounds!=null) {
                minval = bounds[0].getTime()/1000.0;
                maxval = bounds[1].getTime()/1000.0;
            } else {
                minval = 0; maxval=now;
            }
            dateScale.setRange(minval, maxval);
        }


        // Now the colors for all the points will be assigned
        for (Collection<WayPoint> segment : data.getLinesIterable(null)) {
            if (!forceLines) { // don't draw lines between segments, unless forced to
                oldWp = null;
            }
            for (WayPoint trkPnt : segment) {
                LatLon c = trkPnt.getCoor();
                trkPnt.customColoring = neutralColor;
                if (Double.isNaN(c.lat()) || Double.isNaN(c.lon())) {
                    continue;
                }
                 // now we are sure some color will be assigned
                Color color = null;

                if (colored == ColorMode.HDOP) {
                    Float hdop = ((Float) trkPnt.attr.get("hdop"));
                    color = hdopScale.getColor(hdop);
                }
                if (oldWp != null) { // other coloring modes need segment for calcuation
                    double dist = c.greatCircleDistance(oldWp.getCoor());
                    boolean noDraw=false;
                    switch (colored) {
                    case VELOCITY:
                        double dtime = trkPnt.time - oldWp.time;
                        if(dtime > 0) {
                            color = velocityScale.getColor(dist / dtime);
                        } else {
                            color = velocityScale.getNoDataColor();
                        }
                        break;
                    case DIRECTION:
                        double dirColor = oldWp.getCoor().heading(trkPnt.getCoor());
                        color = directionScale.getColor(dirColor);
                        break;
                    case TIME:
                        double t=trkPnt.time;
                        if (t > 0 && t <= now && maxval - minval > minTrackDurationForTimeColoring) { // skip bad timestamps and very short tracks
                            color = dateScale.getColor(t);
                        } else {
                            color = dateScale.getNoDataColor();
                        }
                        break;
                    }
                    if (!noDraw && (maxLineLength == -1 || dist <= maxLineLength)) {
                        trkPnt.drawLine = true;
                        trkPnt.dir = (int) oldWp.getCoor().heading(trkPnt.getCoor());
                    } else {
                        trkPnt.drawLine = false;
                    }
                } else { // make sure we reset outdated data
                    trkPnt.drawLine = false;
View Full Code Here

TOP

Related Classes of org.openstreetmap.josm.data.gpx.WayPoint

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.