- Timestamp:
- 2018-05-08T14:41:28+02:00 (7 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/osm/DefaultNameFormatter.java
r13564 r13717 140 140 if (osm instanceof INode) { 141 141 return format((INode) osm); 142 } else if (osm instanceof IWay ) {143 return format((IWay ) osm);142 } else if (osm instanceof IWay<?>) { 143 return format((IWay<?>) osm); 144 144 } else if (osm instanceof IRelation) { 145 145 return format((IRelation) osm); … … 214 214 215 215 @Override 216 public String format(IWay way) {216 public String format(IWay<?> way) { 217 217 StringBuilder name = new StringBuilder(); 218 218 … … 298 298 } 299 299 300 private final Comparator<IWay > wayComparator = (w1, w2) -> format(w1).compareTo(format(w2));301 302 @Override 303 public Comparator<IWay > getWayComparator() {300 private final Comparator<IWay<?>> wayComparator = (w1, w2) -> format(w1).compareTo(format(w2)); 301 302 @Override 303 public Comparator<IWay<?>> getWayComparator() { 304 304 return wayComparator; 305 305 } -
trunk/src/org/openstreetmap/josm/data/osm/IWay.java
r13665 r13717 2 2 package org.openstreetmap.josm.data.osm; 3 3 4 import java.util.List; 5 4 6 /** 5 7 * IWay captures the common functions of {@link Way} and {@link WayData}. 8 * @param <N> type of OSM node 6 9 * @since 4098 7 10 */ 8 public interface IWay extends IPrimitive {11 public interface IWay<N extends INode> extends IPrimitive { 9 12 10 13 /** … … 31 34 32 35 /** 36 * Replies the node at position <code>index</code>. 37 * 38 * @param index the position 39 * @return the node at position <code>index</code> 40 * @throws ArrayIndexOutOfBoundsException if <code>index</code> < 0 41 * or <code>index</code> >= {@link #getNodesCount()} 42 * @since 1862 43 * @since 13717 (IWay) 44 */ 45 N getNode(int index); 46 47 /** 48 * Returns the list of nodes in this way. 49 * @return the list of nodes in this way 50 * @since 1862 51 * @since 13717 (IWay) 52 */ 53 List<N> getNodes(); 54 55 /** 56 * Returns the list of node ids in this way. 57 * @return the list of node ids in this way 58 * @since 13717 59 */ 60 List<Long> getNodeIds(); 61 62 /** 33 63 * Returns id of the node at given index. 34 64 * @param idx node index … … 47 77 if (o instanceof IRelation) 48 78 return 1; 49 return o instanceof IWay ? Long.compare(getUniqueId(), o.getUniqueId()) : -1;79 return o instanceof IWay<?> ? Long.compare(getUniqueId(), o.getUniqueId()) : -1; 50 80 } 51 81 -
trunk/src/org/openstreetmap/josm/data/osm/NameFormatter.java
r13564 r13717 26 26 * @since 13564 (signature) 27 27 */ 28 String format(IWay way);28 String format(IWay<?> way); 29 29 30 30 /** … … 57 57 * @since 13564 (signature) 58 58 */ 59 Comparator<IWay > getWayComparator();59 Comparator<IWay<?>> getWayComparator(); 60 60 61 61 /** -
trunk/src/org/openstreetmap/josm/data/osm/NameFormatterHook.java
r12663 r13717 31 31 * @return The corrected format if needed, null otherwise. 32 32 */ 33 String checkFormat(IWay way, String defaultName);33 String checkFormat(IWay<?> way, String defaultName); 34 34 35 35 /** -
trunk/src/org/openstreetmap/josm/data/osm/OsmPrimitiveType.java
r12018 r13717 86 86 public static OsmPrimitiveType from(IPrimitive obj) { 87 87 if (obj instanceof INode) return NODE; 88 if (obj instanceof IWay ) return WAY;88 if (obj instanceof IWay<?>) return WAY; 89 89 if (obj instanceof IRelation) return RELATION; 90 90 throw new IllegalArgumentException("Unknown type: "+obj); -
trunk/src/org/openstreetmap/josm/data/osm/Way.java
r13670 r13717 10 10 import java.util.Map; 11 11 import java.util.Set; 12 import java.util.stream.Collectors; 12 13 13 14 import org.openstreetmap.josm.data.coor.LatLon; … … 26 27 * @since 64 27 28 */ 28 public final class Way extends OsmPrimitive implements IWay {29 public final class Way extends OsmPrimitive implements IWay<Node> { 29 30 30 31 /** 31 32 * All way nodes in this way 32 *33 33 */ 34 34 private Node[] nodes = new Node[0]; 35 35 private BBox bbox; 36 36 37 /** 38 * 39 * You can modify returned list but changes will not be propagated back 40 * to the Way. Use {@link #setNodes(List)} to update this way 41 * @return Nodes composing the way 42 * @since 1862 43 */ 37 @Override 44 38 public List<Node> getNodes() { 45 39 return new CopyList<>(nodes); … … 105 99 } 106 100 107 /** 108 * Replies the node at position <code>index</code>. 109 * 110 * @param index the position 111 * @return the node at position <code>index</code> 112 * @throws ArrayIndexOutOfBoundsException if <code>index</code> < 0 113 * or <code>index</code> >= {@link #getNodesCount()} 114 * @since 1862 115 */ 101 @Override 116 102 public Node getNode(int index) { 117 103 return nodes[index]; … … 121 107 public long getNodeId(int idx) { 122 108 return nodes[idx].getUniqueId(); 109 } 110 111 @Override 112 public List<Long> getNodeIds() { 113 return Arrays.stream(nodes).map(Node::getId).collect(Collectors.toList()); 123 114 } 124 115 … … 277 268 278 269 List<Node> newNodes = new ArrayList<>(wayData.getNodes().size()); 279 for (Long nodeId : wayData.getNode s()) {270 for (Long nodeId : wayData.getNodeIds()) { 280 271 Node node = (Node) getDataSet().getPrimitiveById(nodeId, OsmPrimitiveType.NODE); 281 272 if (node != null) { … … 296 287 saveCommonAttributes(data); 297 288 for (Node node:nodes) { 298 data.getNode s().add(node.getUniqueId());289 data.getNodeIds().add(node.getUniqueId()); 299 290 } 300 291 return data; -
trunk/src/org/openstreetmap/josm/data/osm/WayData.java
r12193 r13717 10 10 * The data (tags and node ids) that is stored for a way in the database 11 11 */ 12 public class WayData extends PrimitiveData implements IWay {12 public class WayData extends PrimitiveData implements IWay<NodeData> { 13 13 14 14 private static final long serialVersionUID = 106944939313286415L; … … 37 37 public WayData(WayData data) { 38 38 super(data); 39 nodes.addAll(data.getNode s());39 nodes.addAll(data.getNodeIds()); 40 40 } 41 41 42 /** 43 * Gets a list of nodes the way consists of 44 * @return The ids of the nodes 45 */ 46 public List<Long> getNodes() { 42 @Override 43 public List<NodeData> getNodes() { 44 throw new UnsupportedOperationException("Use getNodeIds() instead"); 45 } 46 47 @Override 48 public NodeData getNode(int index) { 49 throw new UnsupportedOperationException("Use getNodeId(int) instead"); 50 } 51 52 @Override 53 public List<Long> getNodeIds() { 47 54 return nodes; 48 55 } -
trunk/src/org/openstreetmap/josm/data/osm/visitor/PrimitiveVisitor.java
r13623 r13717 22 22 * @param w The way to inspect. 23 23 */ 24 void visit(IWay w);24 void visit(IWay<?> w); 25 25 26 26 /** -
trunk/src/org/openstreetmap/josm/gui/datatransfer/importers/PrimitiveDataPaster.java
r13654 r13717 126 126 private static void updateNodes(Map<Long, Long> newNodeIds, PrimitiveData data) { 127 127 List<Long> newNodes = new ArrayList<>(); 128 for (Long oldNodeId : ((WayData) data).getNode s()) {128 for (Long oldNodeId : ((WayData) data).getNodeIds()) { 129 129 Long newNodeId = newNodeIds.get(oldNodeId); 130 130 if (newNodeId != null) { -
trunk/src/org/openstreetmap/josm/io/OsmWriter.java
r13559 r13717 19 19 import org.openstreetmap.josm.data.osm.DataSet; 20 20 import org.openstreetmap.josm.data.osm.DownloadPolicy; 21 import org.openstreetmap.josm.data.osm.UploadPolicy;22 21 import org.openstreetmap.josm.data.osm.INode; 23 22 import org.openstreetmap.josm.data.osm.IPrimitive; … … 28 27 import org.openstreetmap.josm.data.osm.Relation; 29 28 import org.openstreetmap.josm.data.osm.Tagged; 29 import org.openstreetmap.josm.data.osm.UploadPolicy; 30 30 import org.openstreetmap.josm.data.osm.Way; 31 31 import org.openstreetmap.josm.data.osm.visitor.PrimitiveVisitor; … … 229 229 } 230 230 231 /** 232 * Writes data sources with their respective bounds. 233 * @param ds data set 234 */ 231 235 public void writeDataSources(DataSet ds) { 232 236 for (DataSource s : ds.getDataSources()) { … … 263 267 264 268 @Override 265 public void visit(IWay w) {269 public void visit(IWay<?> w) { 266 270 if (w.isIncomplete()) return; 267 271 addCommon(w, "way"); … … 295 299 } 296 300 301 /** 302 * Visiting call for changesets. 303 * @param cs changeset 304 */ 297 305 public void visit(Changeset cs) { 298 306 out.print(" <changeset id='"+cs.getId()+'\'');
Note:
See TracChangeset
for help on using the changeset viewer.