Package aimax.osm.data

Examples of aimax.osm.data.Position


  /** Returns the distance in KM. */
  public float getTravelDistance() {
    float result = 0f;
    int size = Math.abs(toIndex-fromIndex)+1;
    List<MapNode> nodes = way.getNodes();
    Position pos = new Position(nodes.get(fromIndex));
    for (int i = 1; i < size; i++) {
      MapNode next =
        nodes.get(fromIndex < toIndex ? fromIndex+i : fromIndex-i);
      result+= pos.getDistKM(next);
      pos = new Position(next);
    }
    return result;
  }
View Full Code Here


  }

  private Position getPosition(MapEntity entity) {
    if (entity instanceof MapNode) {
      MapNode node = (MapNode) entity;
      return new Position(node.getLat(), node.getLon());
    } else if (entity instanceof MapWay) {
      MapNode node = ((MapWay) entity).getNodes().get(0);
      return new Position(node.getLat(), node.getLon());
    }
    return null;
  }
View Full Code Here

  @Override
  public void actionPerformed(ActionEvent e) {
    if (e.getSource() == findButton) {
      entityFinder = view.getMap().getEntityFinder();
      Position pos = view.getCenterPosition();
      String pattern = findField.getText();
      switch (typeCombo.getSelectedIndex()) {
      case 0:
        entityFinder.findEntity(pattern, pos);
        break;
View Full Code Here

  /** Creates markers for selected result items. */
  @Override
  public void valueChanged(ListSelectionEvent event) {
    clearMarkers(false);
    for (MapEntity entity : getSelectedEntities()) {
      Position pos = getPosition(entity);
      if (pos != null) {
        currMarkers.add(view.getMap().addMarker(pos.getLat(),
            pos.getLon()));
        view.adjustToCenter(pos.getLat(), pos.getLon());
      }
    }
    updateEnabledState();
  }
View Full Code Here

    public void setValue(Object value) {
      if (value instanceof MapNode || value instanceof MapWay) {
        MapEntity entity = (MapEntity) value;
        String text = entity.getName() != null ? entity.getName()
            : "ID=" + entity.getId();
        Position pos = entityFinder.getRefPosition();
        if (pos != null) {
          DecimalFormat f1 = new DecimalFormat("#0.00");
          text += " (" + f1.format(pos.getDistKM(entity)) + " km)";
        }
        setValue(text);
      } else {
        super.setValue(value);
      }
View Full Code Here

              + " km";
          if (nodes.size() > 1) {
            DecimalFormat f2 = new DecimalFormat("#000");
            MapNode m1 = nodes.get(nodes.size() - 2);
            MapNode m2 = nodes.get(nodes.size() - 1);
            int course = new Position(m1).getCourseTo(m2);
            info += "; Course " + f2.format(course);
          }
          infoField.setText(info);
        }
      } else {
View Full Code Here

TOP

Related Classes of aimax.osm.data.Position

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.