Search in sources :

Example 1 with EntityAttribute

use of aimax.osm.data.entities.EntityAttribute in project aima-java by aimacode.

the class NodeElementProcessor method processTag.

/**
	 * This is called by child element processors when a tag object is
	 * encountered.
	 * 
	 * @param tag
	 *            The tag to be processed.
	 */
public void processTag(Tag tag) {
    String key = tag.getKey();
    String value = tag.getValue();
    if (key.equals("name")) {
        nodeName = value;
    } else {
        EntityAttribute att = EntityAttributeManager.instance().intern(new EntityAttribute(key, value));
        if (att != null)
            nodeAttributes.add(att);
    }
}
Also used : EntityAttribute(aimax.osm.data.entities.EntityAttribute)

Example 2 with EntityAttribute

use of aimax.osm.data.entities.EntityAttribute in project aima-java by aimacode.

the class MapPaneCtrl method showMapEntityInfoDialog.

/**
     * Finds the visible entity next to the specified view coordinates and shows
     * informations about it.
     *
     * @param debug
     *            Enables a more detailed view.
     */
private void showMapEntityInfoDialog(MapEntity entity, boolean debug) {
    List<MapEntity> entities = new ArrayList<>();
    if (entity.getName() != null || entity.getAttributes().length > 0 || debug)
        entities.add(entity);
    if (entity instanceof MapNode) {
        MapNode mNode = (MapNode) entity;
        for (WayRef ref : mNode.getWayRefs()) {
            MapEntity me = ref.getWay();
            if (me.getName() != null || me.getAttributes().length > 0 || debug)
                entities.add(me);
        }
    }
    for (MapEntity me : entities) {
        String header = (me.getName() != null) ? me.getName() : "";
        StringBuilder content = new StringBuilder();
        if (debug)
            header += " (" + ((me instanceof MapNode) ? "Node " : "Way ") + me.getId() + ")";
        if (me instanceof MapNode) {
            content.append("Lat: ").append(((MapNode) me).getLat()).append(" Lon: ").append(((MapNode) me).getLon()).append(" ");
        }
        if (me.getAttributes().length > 0) {
            EntityAttribute[] atts = me.getAttributes();
            content.append("Attributs: ");
            for (EntityAttribute att : atts) {
                content.append(att.getKey()).append("=").append(att.getValue()).append(" ");
            }
        }
        Alert alert = new Alert(Alert.AlertType.INFORMATION);
        alert.setTitle("Map Entity Info");
        alert.setHeaderText(header);
        alert.setContentText(content.toString());
        Optional<ButtonType> result = alert.showAndWait();
        if (!result.isPresent())
            break;
    }
}
Also used : WayRef(aimax.osm.data.entities.WayRef) EntityAttribute(aimax.osm.data.entities.EntityAttribute) ArrayList(java.util.ArrayList) Alert(javafx.scene.control.Alert) MapEntity(aimax.osm.data.entities.MapEntity) MapNode(aimax.osm.data.entities.MapNode) ButtonType(javafx.scene.control.ButtonType)

Example 3 with EntityAttribute

use of aimax.osm.data.entities.EntityAttribute in project aima-java by aimacode.

the class OsmWriter method addTags.

/*<way id="25264669" user="mimis" uid="59074" visible="true" version="4" changeset="1973025" timestamp="2009-07-29T08:54:03Z">
  <nd ref="275294269"/>
  <nd ref="275294230"/>
  <nd ref="275294794"/>
  <nd ref="275294203"/>
  <nd ref="275294281"/>
  <nd ref="275294351"/>
  <tag k="highway" v="tertiary"/>
  <tag k="name" v="xy"/>
 </way>*/
protected void addTags(StringBuffer text, String name, EntityAttribute[] atts) {
    if (name != null) {
        text.append("  <tag k=\"name\" v=\"");
        text.append(convertToXML(name));
        text.append("\"/>\n");
    }
    for (EntityAttribute att : atts) {
        text.append("  <tag k=\"");
        text.append(att.getKey());
        text.append("\" v=\"");
        text.append(convertToXML(att.getValue()));
        text.append("\"/>\n");
    }
}
Also used : EntityAttribute(aimax.osm.data.entities.EntityAttribute)

Example 4 with EntityAttribute

use of aimax.osm.data.entities.EntityAttribute in project aima-java by aimacode.

the class EntityAttributeManager method intern.

/**
	 * Checks whether <code>att</code> has to be ignored with respect to
	 * the attribute filter in use. Otherwise <code>att</code> is added to
	 * the internal hash tables and the interned version of it is returned.
	 */
public EntityAttribute intern(EntityAttribute att) {
    EntityAttribute result = null;
    //		return result;
    if (!ignoredAttKeys.contains(att.getKey()) && (!ignorePathKeys || !att.getKey().contains(":"))) {
        att.setKey(intern(att.getKey()));
        att.setValue(intern(att.getValue()));
        result = att;
    }
    return result;
}
Also used : EntityAttribute(aimax.osm.data.entities.EntityAttribute)

Example 5 with EntityAttribute

use of aimax.osm.data.entities.EntityAttribute in project aima-java by aimacode.

the class DefaultMap method addMarker.

/** {@inheritDoc} */
@Override
public MapNode addMarker(float lat, float lon) {
    long id = 1;
    for (MapNode node : markers) if (node.getId() >= id)
        id = node.getId() + 1;
    MapNode node = new DefaultMapNode(id);
    node.setName(Long.toString(id));
    List<EntityAttribute> atts = new ArrayList<EntityAttribute>(1);
    atts.add(new EntityAttribute("marker", "yes"));
    node.setAttributes(atts);
    node.setPosition(lat, lon);
    updateEntityViewInfo(node, false);
    markers.add(node);
    fireMapDataEvent(new MapEvent(this, MapEvent.Type.MARKER_ADDED, node.getId()));
    return node;
}
Also used : EntityAttribute(aimax.osm.data.entities.EntityAttribute) MapEvent(aimax.osm.data.MapEvent) ArrayList(java.util.ArrayList) MapNode(aimax.osm.data.entities.MapNode)

Aggregations

EntityAttribute (aimax.osm.data.entities.EntityAttribute)7 MapNode (aimax.osm.data.entities.MapNode)3 ArrayList (java.util.ArrayList)3 MapEntity (aimax.osm.data.entities.MapEntity)2 WayRef (aimax.osm.data.entities.WayRef)2 MapEvent (aimax.osm.data.MapEvent)1 Dimension (java.awt.Dimension)1 Alert (javafx.scene.control.Alert)1 ButtonType (javafx.scene.control.ButtonType)1 JScrollPane (javax.swing.JScrollPane)1 JTable (javax.swing.JTable)1