Package org.openstreetmap.josm.data.osm

Examples of org.openstreetmap.josm.data.osm.Node


                  + 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


            .getCoordinates()) {
          Point p = f.createPoint(coordenada);
          p = (Point) JTS.transform(p,
              CRS.findMathTransform(targetCRS, sourceCRS));
          LatLon ll = new LatLon(p.getY(), p.getX());
          way.addNode(new Node(ll));
          // if (log.isTraceEnabled())
          // BasicWindow.showOnMap(ll, 1);
        }
        res.add(way);
      }
View Full Code Here

        && showHeadArrowOnly;
    int width = defaultSegmentWidth;
    int realWidth = 0; /* the real width of the element in meters */
    float dashed[] = new float[0];
    Color dashedColor = null;
    Node lastN;

    if (l != null) {
      if (l.color != null)
        color = l.color;
      width = l.width;
      realWidth = l.realWidth;
      dashed = l.dashed;
      dashedColor = l.dashedColor;
    }
    if (selected)
      color = selectedColor;
    if (realWidth > 0 && useRealWidth && !showDirection) {
      int tmpWidth = (int) (100 / (float) (circum / realWidth));
      if (tmpWidth > width)
        width = tmpWidth;

      /* if we have a "width" tag, try use it */
      /*
       * (this might be slow and could be improved by caching the value in
       * the Way, on the other hand only used if "real width" is enabled)
       */
      String widthTag = w.get("width");
      if (widthTag == null) {
        widthTag = w.get("est_width");
      }
      if (widthTag != null) {
        try {
          width = Integer.parseInt(widthTag);
        } catch (NumberFormatException nfe) {
        }
      }
    }

    if (w.highlighted)
      color = highlightColor;
    else if (w.selected)
      color = selectedColor;

    /* draw overlays under the way */
    if (l != null && l.overlays != null) {
      for (LineElemStyle s : l.overlays) {
        if (!s.over) {
          lastN = null;
          for (Node n : w.nodes) {
            if (lastN != null) {
              drawSeg(lastN, n,
                  s.color != null && !w.selected ? s.color
                      : color, false, s.getWidth(width),
                  s.dashed, s.dashedColor);
            }
            lastN = n;
          }
        }
      }
    }

    /* draw the way */
    lastN = null;
    Iterator<Node> it = w.nodes.iterator();
    while (it.hasNext()) {
      Node n = it.next();
      if (lastN != null)
        drawSeg(lastN, n, color, showOnlyHeadArrowOnly ? !it.hasNext()
            : showDirection, width, dashed, dashedColor);
      lastN = n;
    }
View Full Code Here

            else
              via = w;
          } else
            r.putError(tr("Unknown role ''{0}''.", m.role), true);
        } else if (m.member instanceof Node) {
          Node n = (Node) m.member;
          if ("via".equals(m.role)) {
            if (via != null)
              r
                  .putError(
                      tr("More than one \"via\" found."),
                      true);
            else
              via = n;
          } else
            r.putError(tr("Unknown role ''{0}''.", m.role), true);
        } else
          r.putError(tr("Unknown member type for ''{0}''.", m.member
              .getName()), true);
      }
    }

    if (fromWay == null) {
      r.putError(tr("No \"from\" way found."), true);
      return;
    }
    if (toWay == null) {
      r.putError(tr("No \"to\" way found."), true);
      return;
    }
    if (via == null) {
      r.putError(tr("No \"via\" node or way found."), true);
      return;
    }

    Node viaNode;
    if (via instanceof Node) {
      viaNode = (Node) via;
      if (!fromWay.isFirstLastNode(viaNode)) {
        r
            .putError(
                tr("The \"from\" way doesn't start or end at a \"via\" node."),
                true);
        return;
      }
      if (!toWay.isFirstLastNode(viaNode))
        r
            .putError(
                tr("The \"to\" way doesn't start or end at a \"via\" node."),
                true);
    } else {
      Way viaWay = (Way) via;
      Node firstNode = viaWay.firstNode();
      Node lastNode = viaWay.lastNode();
      if (fromWay.isFirstLastNode(firstNode))
        viaNode = firstNode;
      else if (fromWay.isFirstLastNode(lastNode))
        viaNode = firstNode;
      else {
        r
            .putError(
                tr("The \"from\" way doesn't start or end at the \"via\" way."),
                true);
        return;
      }
      if (!toWay.isFirstLastNode(viaNode == firstNode ? lastNode
          : firstNode))
        r
            .putError(
                tr("The \"to\" way doesn't start or end at the \"via\" way."),
                true);
    }

    /* find the "direct" nodes before the via node */
    Node fromNode = null;
    if (fromWay.firstNode() == via) {
      // System.out.println("From way heading away from via");
      fromNode = fromWay.nodes.get(1);
    } else {
      // System.out.println("From way heading towards via");
      fromNode = fromWay.nodes.get(fromWay.nodes.size() - 2);
    }

    Point pFrom = nc.getPoint(fromNode.getEastNorth());
    Point pVia = nc.getPoint(viaNode.getEastNorth());

    // if(restrictionDebug) {
    /* find the "direct" node after the via node */
    // Node toNode = null;
View Full Code Here

          int numGeometries = multilinestring.getNumGeometries();
          for (int i = 0; i < numGeometries; i++) {
            for (Coordinate coordenada : multilinestring
                .getGeometryN(i).getCoordinates()) {
              LatLon ll = new LatLon(coordenada.y, coordenada.x);
              way.addNode(new Node(ll));
              if (info == null)
                info = ll;
            }
            way.mappaintStyle = ls;
            layer.data.ways.add(way);
View Full Code Here

        Map<Double, List<Node>> nlists = getNearestNodesImpl(p, predicate);
        if (nlists.isEmpty()) return null;

        if (preferredRefs != null && preferredRefs.isEmpty()) preferredRefs = null;
        Node ntsel = null, ntnew = null, ntref = null;
        boolean useNtsel = useSelected;
        double minDistSq = nlists.keySet().iterator().next();

        for (Entry<Double, List<Node>> entry : nlists.entrySet()) {
            Double distSq = entry.getKey();
View Full Code Here

            for (Way w : ds.searchWays(getBBox(p, Main.pref.getInteger("mappaint.segment.snap-distance", 10)))) {
                if (!predicate.evaluate(w)) {
                    continue;
                }
                Node lastN = null;
                int i = -2;
                for (Node n : w.getNodes()) {
                    i++;
                    if (n.isDeleted() || n.isIncomplete()) { //FIXME: This shouldn't happen, raise exception?
                        continue;
View Full Code Here

            type = src.getType();
            relId = 0;
            coor = new ArrayList<>();

            if (src.isNode()) {
                Node r = src.getNode();
                tags = r.getKeys();
                coor = new ArrayList<>(1);
                coor.add(r.getCoor());
            }
            if (src.isWay()) {
                Way r = src.getWay();
                tags = r.getKeys();
                List<Node> wNodes = r.getNodes();
                coor = new ArrayList<>(wNodes.size());
                for (Node wNode : wNodes) {
                    coor.add(wNode.getCoor());
                }
            }
            if (src.isRelation()) {
                Relation r = src.getRelation();
                tags = r.getKeys();
                relId = r.getId();
                coor = new ArrayList<>();
            }
        }
View Full Code Here

     */
    private void nodePairFurthestApart(List<Node> nodes, Node[] resultOut) {
        if(resultOut.length < 2)
            throw new IllegalArgumentException();

        Node nodea = null;
        Node nodeb = null;

        // Intersection of all ways referred by each node
        HashSet<Way> waysRef = null;
        for(Node n: nodes) {
            Collection<Way> ref = OsmPrimitive.getFilteredList(n.getReferrers(), Way.class);
            if(waysRef == null)
                waysRef = new HashSet<>(ref);
            else
                waysRef.retainAll(ref);
        }
        if(waysRef.size() == 1) {
            // All nodes are part of the same way. See #9605
            HashSet<Node> remainNodes = new HashSet<>(nodes);
            Way way = waysRef.iterator().next();
            for(Node n: way.getNodes()) {
                if(!remainNodes.contains(n)) continue;
                if(nodea == null) nodea = n;
                if(remainNodes.size() == 1) {
                    nodeb = remainNodes.iterator().next();
                    break;
                }
                remainNodes.remove(n);
            }
        } else {
            // Find from the selected nodes two that are the furthest apart.
            // Let's call them A and B.
            double distance = 0;
            for (int i = 0; i < nodes.size()-1; i++) {
                Node n = nodes.get(i);
                for (int j = i+1; j < nodes.size(); j++) {
                    Node m = nodes.get(j);
                    double dist = Math.sqrt(n.getEastNorth().distance(m.getEastNorth()));
                    if (dist > distance) {
                        nodea = n;
                        nodeb = m;
                        distance = dist;
                    }
View Full Code Here

            if(selectedNodes.isEmpty() && !selectedWays.isEmpty()) {
                cmd = alignMultiWay(selectedWays);
            }
            /// Only 1 node selected -> align this node relative to referers way
            else if(selectedNodes.size() == 1) {
                Node selectedNode = selectedNodes.get(0);
                List<Way> involvedWays = null;
                if(selectedWays.isEmpty())
                    /// No selected way, all way containing this node are used
                    involvedWays = OsmPrimitive.getFilteredList(selectedNode.getReferrers(), Way.class);
                else
                    /// Selected way, use only these ways
                    involvedWays = selectedWays;
                List<Line> lines = getInvolvedLines(selectedNode, involvedWays);
                if(lines.size() > 2 || lines.isEmpty())
View Full Code Here

TOP

Related Classes of org.openstreetmap.josm.data.osm.Node

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.