Package org.openstreetmap.josm.data.osm

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


        type = GeometryType.UNKNOWN;

      switch (type) {
      case LINESTRING:
        log.trace("Reconocido a LINESTRING");
        resultado = new Way();
        if (componentes[1].length() < 1) {
          log.error("componentes erroneas");
        } else {
          String[] coordenadas = StringUtils.split(componentes[1]
              .substring(0, componentes[1].length() - 1), ",");
View Full Code Here


    destino = (Point) JTS.transform(destino, transform).getCentroid();

    MultiLineString mls = RoutingConsultas.calculateRoute(origen, destino);
    if (mls != null) {
      for (int i = 0; i < mls.getNumGeometries(); i++) {
        Way way = new Way();
        for (Coordinate coordenada : ((LineString) mls.getGeometryN(i))
            .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

  public Collection<Way> joinWays(Collection<Way> join, OsmPrimitive errs) {
    Collection<Way> res = new LinkedList<Way>();
    Object[] joinArray = join.toArray();
    int left = join.size();
    while (left != 0) {
      Way w = null;
      Boolean selected = false;
      ArrayList<Node> n = null;
      Boolean joined = true;
      while (joined && left != 0) {
        joined = false;
        for (int i = 0; i < joinArray.length && left != 0; ++i) {
          if (joinArray[i] != null) {
            Way c = (Way) joinArray[i];
            if (w == null) {
              w = c;
              selected = w.selected;
              joinArray[i] = null;
              --left;
            } else {
              int mode = 0;
              int cl = c.nodes.size() - 1;
              int nl;
              if (n == null) {
                nl = w.nodes.size() - 1;
                if (w.nodes.get(nl) == c.nodes.get(0))
                  mode = 21;
                else if (w.nodes.get(nl) == c.nodes.get(cl))
                  mode = 22;
                else if (w.nodes.get(0) == c.nodes.get(0))
                  mode = 11;
                else if (w.nodes.get(0) == c.nodes.get(cl))
                  mode = 12;
              } else {
                nl = n.size() - 1;
                if (n.get(nl) == c.nodes.get(0))
                  mode = 21;
                else if (n.get(0) == c.nodes.get(cl))
                  mode = 12;
                else if (n.get(0) == c.nodes.get(0))
                  mode = 11;
                else if (n.get(nl) == c.nodes.get(cl))
                  mode = 22;
              }
              if (mode != 0) {
                joinArray[i] = null;
                joined = true;
                if (c.selected)
                  selected = true;
                --left;
                if (n == null)
                  n = new ArrayList<Node>(w.nodes);
                n.remove((mode == 21 || mode == 22) ? nl : 0);
                if (mode == 21)
                  n.addAll(c.nodes);
                else if (mode == 12)
                  n.addAll(0, c.nodes);
                else if (mode == 22) {
                  for (Node node : c.nodes)
                    n.add(nl, node);
                } else /* mode == 11 */
                {
                  for (Node node : c.nodes)
                    n.add(0, node);
                }
              }
            }
          }
        } /* for(i = ... */
      } /* while(joined) */
      if (n != null) {
        w = new Way(w);
        w.nodes.clear();
        w.nodes.addAll(n);
        w.selected = selected;
      }
      if (!w.isClosed()) {
View Full Code Here

  public void drawSelectedMember(OsmPrimitive osm, ElemStyle style,
      Boolean area, Boolean areaselected) {
    if (osm instanceof Way) {
      if (style instanceof AreaElemStyle) {
        Way way = (Way) osm;
        AreaElemStyle areaStyle = (AreaElemStyle) style;
        drawWay(way, areaStyle.line, selectedColor, true);
        if (area && (!areaStyle.closed || way.isClosed()))
          drawArea(way, areaselected ? selectedColor
              : areaStyle.color);
      } else {
        drawWay((Way) osm, (LineElemStyle) style, selectedColor, true);
      }
View Full Code Here

    // System.out.println("Restriction: " + r.keys.get("name") +
    // " restriction " + r.keys.get("restriction"));

    r.clearErrors();

    Way fromWay = null;
    Way toWay = null;
    OsmPrimitive via = null;

    /* find the "from", "via" and "to" elements */
    for (RelationMember m : r.members) {
      // if(restrictionDebug)
      // System.out.println("member " + m.member + " selected " +
      // r.selected);

      if (m.member == null)
        r.putError(tr("Empty member in relation."), true);
      else if (m.member.deleted)
        r.putError(tr("Deleted member ''{0}'' in relation.", m.member
            .getName()), true);
      else if (m.member.incomplete) {
        return;
      } else {
        if (m.member instanceof Way) {
          Way w = (Way) m.member;
          if (w.nodes.size() < 2) {
            r.putError(tr("Way ''{0}'' with less than two points.",
                w.getName()), true);
          } else if ("from".equals(m.role)) {
            if (fromWay != null)
              r.putError(tr("More than one \"from\" way found."),
                  true);
            else {
              fromWay = w;
            }
          } else if ("to".equals(m.role)) {
            if (toWay != null)
              r.putError(tr("More than one \"to\" way found."),
                  true);
            else {
              toWay = w;
            }
          } else if ("via".equals(m.role)) {
            if (via != null)
              r
                  .putError(
                      tr("More than one \"via\" found."),
                      true);
            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 {
View Full Code Here

            .getName()), true);
      else if (m.member.incomplete)
        incomplete = true;
      else {
        if (m.member instanceof Way) {
          Way w = (Way) m.member;
          if (w.nodes.size() < 2) {
            r.putError(tr("Way ''{0}'' with less than two points.",
                w.getName()), true);
          } else if ("inner".equals(m.role))
            inner.add(w);
          else if ("outer".equals(m.role))
            outer.add(w);
          else {
            r.putError(tr(
                "No useful role ''{0}'' for Way ''{1}''.",
                m.role == null ? "" : m.role, w.getName()),
                true);
            if (m.role == null || m.role.length() == 0)
              outer.add(w);
            else if (r.selected)
              drawSelectedMember(
                  m.member,
                  styles != null ? getPrimitiveStyle(m.member)
                      : null, true, true);
          }
        } else {
          r.putError(tr("Non-Way ''{0}'' in multipolygon.", m.member
              .getName()), true);
        }
      }
    }

    ElemStyle wayStyle = styles != null ? getPrimitiveStyle(r) : null;
    if (styles != null
        && (wayStyle == null || !(wayStyle instanceof AreaElemStyle))) {
      for (Way w : outer) {
        if (wayStyle == null || !(wayStyle instanceof AreaElemStyle))
          wayStyle = styles.get(w);
      }
      r.mappaintStyle = wayStyle;
    }

    if (wayStyle != null && wayStyle instanceof AreaElemStyle) {
      Boolean zoomok = isZoomOk(wayStyle);
      Boolean visible = false;
      Collection<Way> join = new LinkedList<Way>();

      drawn = true;
      for (Way w : outer) {
        if (w.isClosed())
          outerclosed.add(w);
        else
          join.add(w);
      }
      if (join.size() != 0) {
        for (Way w : joinWays(join, incomplete ? null : r))
          outerclosed.add(w);
      }

      join.clear();
      for (Way w : inner) {
        if (w.isClosed())
          innerclosed.add(w);
        else
          join.add(w);
      }
      if (join.size() != 0) {
View Full Code Here

            "Route Plan " + id_layer++, File.createTempFile(
                "planning", "route"));
        String way2 = plan.getWay();

        if (way2 != null) {
          Way way = new Way();
          LatLon info = null;

          MultiLineString multilinestring = (MultiLineString) wktReader
              .read(way2);
          multilinestring.getLength();
          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);
            way = new Way();
          }
          progressBar.setValue(progressBar.getValue() + 1);

          StopMarker marker = new StopMarker(info, (new Double(
              plan.getDistance())).toString().substring(0, 5)
View Full Code Here

                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

                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;
View Full Code Here

            referers.clear();
            for(OsmPrimitive o: n.getReferrers())
                if(ways.contains(o))
                    referers.add((Way) o);
            if(referers.size() == 1) {
                Way way = referers.get(0);
                if(n == way.firstNode() || n == way.lastNode()) continue;
                cmds.add(lines.get(way).projectionCommand(n));
            }
            else if(referers.size() == 2) {
                Command cmd = lines.get(referers.get(0)).intersectionCommand(n, lines.get(referers.get(1)));
                cmds.add(cmd);
View Full Code Here

TOP

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

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.