Changeset 36102 in osm for applications/editors/josm/plugins
- Timestamp:
- 2023-07-24T15:55:23+02:00 (16 months ago)
- Location:
- applications/editors/josm/plugins/reltoolbox/src/relcontext
- Files:
-
- 27 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/reltoolbox/src/relcontext/ChosenRelation.java
r34130 r36102 11 11 import java.awt.geom.GeneralPath; 12 12 import java.util.HashSet; 13 import java.util.Objects; 13 14 import java.util.Set; 14 15 … … 41 42 public class ChosenRelation implements ActiveLayerChangeListener, MapViewPaintable, DataSetListener { 42 43 protected Relation chosenRelation = null; 43 private Set<ChosenRelationListener> chosenRelationListeners = new HashSet<>();44 private final Set<ChosenRelationListener> chosenRelationListeners = new HashSet<>(); 44 45 45 46 public void set(Relation rel) { 46 if ( rel == chosenRelation || (rel != null && chosenRelation != null && rel.equals(chosenRelation)))47 if (Objects.equals(rel, chosenRelation)) 47 48 return; // new is the same as old 48 49 Relation oldRel = chosenRelation; … … 73 74 return false; 74 75 else 75 return chosenRelation != null &&r.equals(chosenRelation);76 return r.equals(chosenRelation); 76 77 } 77 78 … … 150 151 g.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.3f * opacity)); 151 152 152 drawRelations(g, mv, bbox, chosenRelation, new HashSet< Relation>());153 drawRelations(g, mv, bbox, chosenRelation, new HashSet<>()); 153 154 154 155 g.setComposite(oldComposite); … … 178 179 } 179 180 g.draw(b); 180 } break; 181 } 182 break; 181 183 case RELATION: 182 184 Color oldColor = g.getColor(); … … 195 197 @Override 196 198 public void relationMembersChanged(RelationMembersChangedEvent event) { 197 if ( chosenRelation != null &&event.getRelation().equals(chosenRelation)) {199 if (event.getRelation().equals(chosenRelation)) { 198 200 fireRelationChanged(chosenRelation); 199 201 } … … 202 204 @Override 203 205 public void tagsChanged(TagsChangedEvent event) { 204 if ( chosenRelation != null &&event.getPrimitive().equals(chosenRelation)) {206 if (event.getPrimitive().equals(chosenRelation)) { 205 207 fireRelationChanged(chosenRelation); 206 208 } -
applications/editors/josm/plugins/reltoolbox/src/relcontext/ChosenRelationComponent.java
r32398 r36102 61 61 62 62 StringBuilder sb = new StringBuilder(); 63 sb.append(type. substring(0, 1));63 sb.append(type.charAt(0)); 64 64 if (type.equals("boundary") && rel.hasKey("admin_level")) { 65 65 sb.append(rel.get("admin_level")); -
applications/editors/josm/plugins/reltoolbox/src/relcontext/RelContextDialog.java
r35829 r36102 14 14 import java.awt.event.ActionListener; 15 15 import java.awt.event.ItemEvent; 16 import java.awt.event.ItemListener;17 16 import java.awt.event.KeyEvent; 18 17 import java.awt.event.MouseAdapter; … … 112 111 113 112 private final DefaultTableModel relationsData; 114 private ChosenRelation chosenRelation;115 private JPanel chosenRelationPanel;116 private ChosenRelationPopupMenu popupMenu;117 private MultipolygonSettingsPopup multiPopupMenu;118 private RoleComboBoxModel roleBoxModel;119 private SortAndFixAction sortAndFixAction;113 private final ChosenRelation chosenRelation; 114 private final JPanel chosenRelationPanel; 115 private final ChosenRelationPopupMenu popupMenu; 116 private final MultipolygonSettingsPopup multiPopupMenu; 117 private final RoleComboBoxModel roleBoxModel; 118 private final SortAndFixAction sortAndFixAction; 120 119 // actions saved for unregistering on dialog destroying 121 120 private final EnterRoleAction enterRoleAction; … … 149 148 roleBox.setModel(roleBoxModel); 150 149 roleBox.addMouseListener(relationMouseAdapter); 151 roleBox.addItemListener(new ItemListener() { 152 @Override 153 public void itemStateChanged(ItemEvent e) { 154 if (e.getStateChange() == ItemEvent.DESELECTED) return; 155 String memberRole = roleBoxModel.getSelectedMembersRole(); 156 String selectedRole = roleBoxModel.isAnotherRoleSelected() ? askForRoleName() : roleBoxModel.getSelectedRole(); 157 if (memberRole != null && selectedRole != null && !memberRole.equals(selectedRole)) { 158 applyRoleToSelection(selectedRole.trim()); 159 } 150 roleBox.addItemListener(e -> { 151 if (e.getStateChange() == ItemEvent.DESELECTED) return; 152 String memberRole = roleBoxModel.getSelectedMembersRole(); 153 String selectedRole = roleBoxModel.isAnotherRoleSelected() ? askForRoleName() : roleBoxModel.getSelectedRole(); 154 if (memberRole != null && selectedRole != null && !memberRole.equals(selectedRole)) { 155 applyRoleToSelection(selectedRole.trim()); 160 156 } 161 157 }); … … 652 648 private List<String> roles = new ArrayList<>(); 653 649 private int selectedIndex = -1; 654 private JComboBox<String> combobox;650 private final JComboBox<String> combobox; 655 651 private String membersRole; 656 652 private final String EMPTY_ROLE = tr("<empty>"); … … 709 705 710 706 public String getSelectedMembersRole() { 711 return membersRole == EMPTY_ROLE? "" : membersRole;707 return EMPTY_ROLE.equals(membersRole) ? "" : membersRole; 712 708 } 713 709 … … 756 752 @Override 757 753 public void setSelectedItem(Object anItem) { 758 int newIndex = anItem == null ? -1 : roles.indexOf(anItem);754 int newIndex = anItem instanceof String ? roles.indexOf((String) anItem) : -1; 759 755 if (newIndex != selectedIndex) { 760 756 selectedIndex = newIndex; -
applications/editors/josm/plugins/reltoolbox/src/relcontext/RelContextPlugin.java
r33530 r36102 7 7 import org.openstreetmap.josm.plugins.PluginInformation; 8 8 9 /** 10 * The entry-point for the reltoolbox plugin 11 */ 9 12 public class RelContextPlugin extends Plugin { 10 private RelContextDialog dialog;11 13 12 14 public RelContextPlugin(PluginInformation info) { … … 19 21 if (oldFrame == null && newFrame != null) { 20 22 // if (dialog!=null) dialog.destroy(); 21 dialog = new RelContextDialog();23 RelContextDialog dialog = new RelContextDialog(); 22 24 newFrame.addToggleDialog(dialog); 23 25 } -
applications/editors/josm/plugins/reltoolbox/src/relcontext/actions/AddRemoveMemberAction.java
r34551 r36102 35 35 */ 36 36 public class AddRemoveMemberAction extends JosmAction implements ChosenRelationListener { 37 private ChosenRelation rel;38 private SortAndFixAction sortAndFix;37 private final ChosenRelation rel; 38 private final SortAndFixAction sortAndFix; 39 39 40 40 public AddRemoveMemberAction(ChosenRelation rel, SortAndFixAction sortAndFix) { -
applications/editors/josm/plugins/reltoolbox/src/relcontext/actions/ClearChosenRelationAction.java
r32395 r36102 16 16 17 17 public class ClearChosenRelationAction extends AbstractAction implements ChosenRelationListener { 18 private ChosenRelation rel;18 private final ChosenRelation rel; 19 19 20 20 public ClearChosenRelationAction(ChosenRelation rel) { -
applications/editors/josm/plugins/reltoolbox/src/relcontext/actions/CreateMultipolygonAction.java
r34551 r36102 71 71 72 72 public static boolean getDefaultPropertyValue(String property) { 73 if (property.equals("boundary")) 74 return false; 75 else if (property.equals("boundaryways")) 76 return true; 77 else if (property.equals("tags")) 78 return true; 79 else if (property.equals("alltags")) 80 return false; 81 else if (property.equals("single")) 82 return true; 83 else if (property.equals("allowsplit")) 84 return false; 73 switch (property) { 74 case "boundary": 75 case "alltags": 76 case "allowsplit": 77 return false; 78 case "boundaryways": 79 case "tags": 80 case "single": 81 return true; 82 } 85 83 throw new IllegalArgumentException(property); 86 84 } … … 274 272 } 275 273 276 public static final List<String> DEFAULT_LINEAR_TAGS = Arrays.asList(new String[] {"barrier", "source"}); 277 278 private static final Set<String> REMOVE_FROM_BOUNDARY_TAGS = new TreeSet<>(Arrays.asList(new String[] { 279 "boundary", "boundary_type", "type", "admin_level" 280 })); 274 public static final List<String> DEFAULT_LINEAR_TAGS = Arrays.asList("barrier", "source"); 275 276 private static final Set<String> REMOVE_FROM_BOUNDARY_TAGS = 277 new TreeSet<>(Arrays.asList("boundary", "boundary_type", "type", "admin_level")); 281 278 282 279 /** -
applications/editors/josm/plugins/reltoolbox/src/relcontext/actions/CreateRelationAction.java
r35829 r36102 7 7 import java.awt.GridBagLayout; 8 8 import java.awt.event.ActionEvent; 9 import java.awt.event.ActionListener;10 9 import java.awt.event.KeyEvent; 11 10 import java.util.Arrays; … … 93 92 94 93 // Thanks to TagInfo for the list 95 private static final List<String> RELATION_TYPES = Arrays.asList(new String[] { 96 "multipolygon", "boundary", "route", "site", "restriction", "associatedStreet", "public_transport", 97 "street", "collection", "address", "enforcement", "destination_sign", "route_master", "junction", 98 "waterway", "bridge", "tunnel", "surveillance" 99 }); 94 private static final List<String> RELATION_TYPES = Arrays.asList("multipolygon", "boundary", "route", "site", 95 "restriction", "associatedStreet", "public_transport", "street", "collection", "address", "enforcement", 96 "destination_sign", "route_master", "junction", "waterway", "bridge", "tunnel", "surveillance"); 100 97 101 98 private String askForType() { … … 122 119 dlg.setModalityType(ModalityType.DOCUMENT_MODAL); 123 120 124 keys.getEditor().addActionListener(new ActionListener() { 125 @Override 126 public void actionPerformed(ActionEvent e) { 127 dlg.setVisible(false); 128 optionPane.setValue(JOptionPane.OK_OPTION); 129 } 121 keys.getEditor().addActionListener(e -> { 122 dlg.setVisible(false); 123 optionPane.setValue(JOptionPane.OK_OPTION); 130 124 }); 131 125 -
applications/editors/josm/plugins/reltoolbox/src/relcontext/actions/DeleteChosenRelationAction.java
r34551 r36102 19 19 20 20 public class DeleteChosenRelationAction extends AbstractAction implements ChosenRelationListener { 21 private ChosenRelation rel;21 private final ChosenRelation rel; 22 22 23 23 public DeleteChosenRelationAction(ChosenRelation rel) { -
applications/editors/josm/plugins/reltoolbox/src/relcontext/actions/DownloadChosenRelationAction.java
r33530 r36102 28 28 */ 29 29 public class DownloadChosenRelationAction extends AbstractAction implements ChosenRelationListener { 30 private ChosenRelation rel;30 private final ChosenRelation rel; 31 31 32 32 public DownloadChosenRelationAction(ChosenRelation rel) { … … 74 74 protected void downloadIncomplete(Relation rel) { 75 75 if (rel.isNew()) return; 76 Set<OsmPrimitive> ret = new HashSet<>(); 77 ret.addAll(rel.getIncompleteMembers()); 76 Set<OsmPrimitive> ret = new HashSet<>(rel.getIncompleteMembers()); 78 77 if (ret.isEmpty()) return; 79 78 MainApplication.worker.submit( -
applications/editors/josm/plugins/reltoolbox/src/relcontext/actions/DownloadParentsAction.java
r33530 r36102 30 30 */ 31 31 public class DownloadParentsAction extends AbstractAction implements ChosenRelationListener { 32 private ChosenRelation rel;32 private final ChosenRelation rel; 33 33 34 34 public DownloadParentsAction(ChosenRelation rel) { … … 66 66 protected void downloadIncomplete(Relation rel) { 67 67 if (rel.isNew()) return; 68 Set<OsmPrimitive> ret = new HashSet<>(); 69 ret.addAll(rel.getIncompleteMembers()); 68 Set<OsmPrimitive> ret = new HashSet<>(rel.getIncompleteMembers()); 70 69 if (ret.isEmpty()) return; 71 70 MainApplication.worker.submit( -
applications/editors/josm/plugins/reltoolbox/src/relcontext/actions/EditChosenRelationAction.java
r35529 r36102 22 22 */ 23 23 public class EditChosenRelationAction extends AbstractAction implements ChosenRelationListener { 24 private ChosenRelation rel;24 private final ChosenRelation rel; 25 25 26 26 public EditChosenRelationAction(ChosenRelation rel) { -
applications/editors/josm/plugins/reltoolbox/src/relcontext/actions/FindRelationAction.java
r35196 r36102 8 8 import java.awt.Dimension; 9 9 import java.awt.event.ActionEvent; 10 import java.awt.event.ActionListener;11 10 import java.awt.event.KeyAdapter; 12 11 import java.awt.event.KeyEvent; … … 15 14 import java.util.ArrayList; 16 15 import java.util.Collection; 17 import java.util.Collections;18 16 import java.util.List; 19 17 … … 87 85 }); 88 86 89 searchField.addActionListener(new ActionListener() { 90 @Override 91 public void actionPerformed(ActionEvent e) { 92 if (!relationsList.isSelectionEmpty()) { 93 dlg.setVisible(false); 94 optionPane.setValue(JOptionPane.OK_OPTION); 95 } 87 searchField.addActionListener(e1 -> { 88 if (!relationsList.isSelectionEmpty()) { 89 dlg.setVisible(false); 90 optionPane.setValue(JOptionPane.OK_OPTION); 96 91 } 97 92 }); … … 100 95 @Override 101 96 public void keyTyped(KeyEvent e) { 102 SwingUtilities.invokeLater(new Runnable() { 103 @Override 104 public void run() { 105 updateRelationData(relationsData, searchField.getText()); 106 } 107 }); 97 SwingUtilities.invokeLater(() -> updateRelationData(relationsData, searchField.getText())); 108 98 } 109 99 … … 196 186 } 197 187 198 Collections.sort(relations,DefaultNameFormatter.getInstance().getRelationComparator());188 relations.sort(DefaultNameFormatter.getInstance().getRelationComparator()); 199 189 data.setRelations(relations); 200 190 } … … 214 204 protected static class FindRelationListModel extends AbstractListModel<Relation> { 215 205 private final ArrayList<Relation> relations = new ArrayList<>(); 216 private DefaultListSelectionModel selectionModel;206 private final DefaultListSelectionModel selectionModel; 217 207 218 208 public FindRelationListModel(DefaultListSelectionModel selectionModel) { -
applications/editors/josm/plugins/reltoolbox/src/relcontext/actions/PublicTransportHelper.java
r34095 r36102 8 8 /** 9 9 * @author freeExec 10 * @see https://wiki.openstreetmap.org/wiki/Key:public_transport10 * @see <a href="https://wiki.openstreetmap.org/wiki/Key:public_transport">osmwiki:Key:public_transport</a> 11 11 */ 12 12 public final class PublicTransportHelper { … … 49 49 if (p.hasKey(PUBLIC_TRANSPORT)) { 50 50 String pt = p.get(PUBLIC_TRANSPORT); 51 if (STOP_POSITION.equals(pt)) return true;51 return STOP_POSITION.equals(pt); 52 52 } else if (p.hasKey(RAILWAY)) { 53 53 String rw = p.get(RAILWAY); 54 if (RAILWAY_HALT.equals(rw) || RAILWAY_STATION.equals(rw)) return true;54 return RAILWAY_HALT.equals(rw) || RAILWAY_STATION.equals(rw); 55 55 } 56 56 } … … 66 66 if (p.hasKey(PUBLIC_TRANSPORT)) { 67 67 String pt = p.get(PUBLIC_TRANSPORT); 68 if (PLATFORM.equals(pt)) return true;68 return PLATFORM.equals(pt); 69 69 } else if (p.hasKey(HIGHWAY)) { 70 70 String hw = p.get(HIGHWAY); 71 71 if (BUS_STOP.equals(hw)) return true; 72 else if (PLATFORM.equals(hw)) return true;72 else return PLATFORM.equals(hw); 73 73 } else if (p.hasKey(RAILWAY)) { 74 74 String rw = p.get(RAILWAY); 75 if (PLATFORM.equals(rw)) return true;75 return PLATFORM.equals(rw); 76 76 } 77 77 } … … 87 87 if (p.hasKey(PUBLIC_TRANSPORT)) { 88 88 String pt = p.get(PUBLIC_TRANSPORT); 89 if (PLATFORM.equals(pt)) return true;89 return PLATFORM.equals(pt); 90 90 } else if (p.hasKey(HIGHWAY)) { 91 91 String hw = p.get(HIGHWAY); 92 if (PLATFORM.equals(hw)) return true;92 return PLATFORM.equals(hw); 93 93 } else if (p.hasKey(RAILWAY)) { 94 94 String rw = p.get(RAILWAY); 95 if (PLATFORM.equals(rw)) return true;95 return PLATFORM.equals(rw); 96 96 } 97 97 } … … 124 124 } 125 125 } 126 return result;126 return null; 127 127 } 128 128 } -
applications/editors/josm/plugins/reltoolbox/src/relcontext/actions/ReconstructPolygonAction.java
r35829 r36102 10 10 import java.util.Collections; 11 11 import java.util.HashSet; 12 import java.util.Iterator;13 12 import java.util.List; 14 13 import java.util.Map; … … 44 43 */ 45 44 public class ReconstructPolygonAction extends JosmAction implements ChosenRelationListener { 46 private ChosenRelation rel; 47 48 private static final List<String> IRRELEVANT_KEYS = Arrays.asList(new String[] { 49 "source", "created_by", "note"}); 45 private final ChosenRelation rel; 46 47 private static final List<String> IRRELEVANT_KEYS = Arrays.asList("source", "created_by", "note"); 50 48 51 49 public ReconstructPolygonAction(ChosenRelation rel) { … … 109 107 // this ring has inner rings, so we leave a multipolygon in 110 108 // place and don't reconstruct the rings. 111 Relation n = null;109 Relation n; 112 110 if (relationReused) { 113 111 n = new Relation(); … … 153 151 } 154 152 List<OsmPrimitive> referrers = w.getReferrers(); 155 for (Iterator<OsmPrimitive> ref1 = relations.iterator(); ref1.hasNext();) { 156 if (!referrers.contains(ref1.next())) { 157 ref1.remove(); 158 } 159 } 153 relations.removeIf(osmPrimitive -> !referrers.contains(osmPrimitive)); 160 154 } 161 155 tags.putAll(r.getKeys()); … … 169 163 Set<String> keys = new HashSet<>(w.keySet()); 170 164 keys.removeAll(tags.keySet()); 171 keys.removeAll(IRRELEVANT_KEYS);165 IRRELEVANT_KEYS.forEach(keys::remove); 172 166 if (keys.isEmpty()) { 173 167 if (candidateWay == null) { … … 211 205 212 206 private boolean isSuitableRelation(Relation newRelation) { 213 if (newRelation == null || !"multipolygon".equals(newRelation.get("type")) || newRelation.getMembersCount() == 0) 214 return false; 215 else 216 return true; 207 return newRelation != null && "multipolygon".equals(newRelation.get("type")) && newRelation.getMembersCount() != 0; 217 208 } 218 209 } -
applications/editors/josm/plugins/reltoolbox/src/relcontext/actions/ReconstructRouteAction.java
r34551 r36102 9 9 import java.util.List; 10 10 import java.util.Map; 11 import java.util.Objects; 11 12 12 13 import javax.swing.AbstractAction; … … 96 97 if (routeMembers.size() > 2) { 97 98 Way nextWay = (Way) routeMembers.get(rIndex + 1).getMember(); 98 if ( w.lastNode().equals(nextWay.lastNode()) || w.lastNode().equals(nextWay.firstNode())) {99 if (Objects.equals(w.lastNode(), nextWay.lastNode()) || Objects.equals(w.lastNode(), nextWay.firstNode())) { 99 100 dirForward = true; 100 101 lastNode = w.lastNode(); -
applications/editors/josm/plugins/reltoolbox/src/relcontext/actions/SelectInRelationPanelAction.java
r33530 r36102 16 16 17 17 public class SelectInRelationPanelAction extends AbstractAction implements ChosenRelationListener { 18 private ChosenRelation rel;18 private final ChosenRelation rel; 19 19 20 20 public SelectInRelationPanelAction(ChosenRelation rel) { -
applications/editors/josm/plugins/reltoolbox/src/relcontext/actions/SelectMembersAction.java
r33530 r36102 5 5 6 6 import java.awt.event.ActionEvent; 7 import java.util.Collections; 7 8 8 9 import javax.swing.AbstractAction; … … 16 17 17 18 public class SelectMembersAction extends AbstractAction implements ChosenRelationListener { 18 private ChosenRelation rel;19 private final ChosenRelation rel; 19 20 20 21 public SelectMembersAction(ChosenRelation rel) { … … 28 29 @Override 29 30 public void actionPerformed(ActionEvent e) { 30 MainApplication.getLayerManager().getEditLayer().data.setSelected(rel.get() == null ? null : rel.get().getMemberPrimitives()); 31 MainApplication.getLayerManager().getEditLayer().data.setSelected( 32 rel.get() == null ? Collections.emptyList() : rel.get().getMemberPrimitives()); 31 33 } 32 34 -
applications/editors/josm/plugins/reltoolbox/src/relcontext/actions/SelectRelationAction.java
r33530 r36102 16 16 17 17 public class SelectRelationAction extends AbstractAction implements ChosenRelationListener { 18 private ChosenRelation rel;18 private final ChosenRelation rel; 19 19 20 20 public SelectRelationAction(ChosenRelation rel) { -
applications/editors/josm/plugins/reltoolbox/src/relcontext/actions/SortAndFixAction.java
r34551 r36102 28 28 public class SortAndFixAction extends AbstractAction implements ChosenRelationListener { 29 29 private static final long serialVersionUID = 1L; 30 private ChosenRelation rel;31 private List<RelationFixer> fixers;30 private final ChosenRelation rel; 31 private final List<RelationFixer> fixers; 32 32 33 33 public SortAndFixAction(ChosenRelation rel) { -
applications/editors/josm/plugins/reltoolbox/src/relcontext/actions/SplittingMultipolygons.java
r35976 r36102 12 12 import java.util.List; 13 13 import java.util.Map; 14 import java.util.Objects; 14 15 15 16 import org.openstreetmap.josm.command.AddCommand; … … 19 20 import org.openstreetmap.josm.data.UndoRedoHandler; 20 21 import org.openstreetmap.josm.data.coor.EastNorth; 21 import org.openstreetmap.josm.data.coor.LatLon;22 22 import org.openstreetmap.josm.data.osm.DataSet; 23 23 import org.openstreetmap.josm.data.osm.DefaultNameFormatter; 24 import org.openstreetmap.josm.data.osm.INode; 24 25 import org.openstreetmap.josm.data.osm.Node; 25 26 import org.openstreetmap.josm.data.osm.OsmPrimitive; … … 206 207 for (int i = 0; i < rel.getMembersCount(); i++) { 207 208 if (rel.getMember(i).getMember().equals(w)) { 208 references.put(rel, Integer.valueOf(i));209 references.put(rel, i); 209 210 } 210 211 } … … 253 254 return null; 254 255 256 final Node segmentFirstNode = segment.firstNode(); 257 final Node segmentLastNode = segment.lastNode(); 258 259 if (segmentLastNode == null || segmentFirstNode == null) { 260 return null; 261 } 262 255 263 List<Way> ways = intersection( 256 Utils.filteredCollection(segment .firstNode().getReferrers(), Way.class),257 Utils.filteredCollection(segment .lastNode().getReferrers(), Way.class));264 Utils.filteredCollection(segmentFirstNode.getReferrers(), Way.class), 265 Utils.filteredCollection(segmentLastNode.getReferrers(), Way.class)); 258 266 ways.remove(segment); 259 267 for (Iterator<Way> iter = ways.iterator(); iter.hasNext();) { 260 268 boolean save = false; 261 269 for (OsmPrimitive ref : iter.next().getReferrers()) { 262 if (ref instanceof Relation && ((Relation) ref).isMultipolygon() && !ref.isDeleted()) {270 if (ref instanceof Relation && ref.isMultipolygon() && !ref.isDeleted()) { 263 271 save = true; 264 272 } … … 292 300 293 301 // now split the way, at last 294 List<Way> newWays = new ArrayList<>(splitWay(target, segment .firstNode(), segment.lastNode(), commands));302 List<Way> newWays = new ArrayList<>(splitWay(target, segmentFirstNode, segmentLastNode, commands)); 295 303 296 304 Way addingWay = null; … … 303 311 } else { 304 312 for (Way w : newWays) { 305 if ((w.firstNode().equals(segment.firstNode()) && w.lastNode().equals(segment.lastNode())) 306 || (w.firstNode().equals(segment.lastNode()) && w.lastNode().equals(segment.firstNode()))) { 313 final INode wFirstNode = w.firstNode(); 314 final INode wLastNode = w.lastNode(); 315 if ((Objects.equals(wFirstNode, segmentFirstNode) && Objects.equals(wLastNode, segmentLastNode)) 316 || (Objects.equals(wFirstNode, segmentLastNode) && Objects.equals(wLastNode, segmentFirstNode))) { 307 317 addingWay = w; 308 318 break; … … 341 351 if (p instanceof Way && !p.equals(ring)) { 342 352 for (OsmPrimitive r : p.getReferrers()) { 343 if (r instanceof Relation && ((Relation) r).hasKey("type") && ((Relation) r).get("type").equals("multipolygon")) {353 if (r instanceof Relation && r.hasKey("type") && r.get("type").equals("multipolygon")) { 344 354 if (touchingWays.containsKey(p)) { 345 355 touchingWays.put((Way) p, Boolean.TRUE); -
applications/editors/josm/plugins/reltoolbox/src/relcontext/actions/TheRing.java
r34551 r36102 37 37 private static final String PREF_MULTIPOLY = "reltoolbox.multipolygon."; 38 38 39 private Way source;40 private List<RingSegment> segments;39 private final Way source; 40 private final List<RingSegment> segments; 41 41 private Relation relation = null; 42 42 … … 277 277 278 278 // rearrange references 279 for (int i = 0; i < rings.size(); i++) { 280 TheRing ring = rings.get(i); 279 for (TheRing ring : rings) { 281 280 if (ring.countNonReferenceSegments() == 0) { 282 281 // need to find one non-reference segment … … 331 330 Way sourceCopy = new Way(source); 332 331 if (createMultipolygon) { 333 Collection<String> linearTags = Config.getPref().getList(PREF_MULTIPOLY + "lineartags", CreateMultipolygonAction.DEFAULT_LINEAR_TAGS); 332 Collection<String> linearTags = Config.getPref().getList(PREF_MULTIPOLY + "lineartags", 333 CreateMultipolygonAction.DEFAULT_LINEAR_TAGS); 334 334 relation = new Relation(); 335 335 relation.put("type", "multipolygon"); … … 351 351 for (OsmPrimitive p : source.getReferrers()) { 352 352 if (p instanceof Relation) { 353 Relation rel = null;353 Relation rel; 354 354 if (relationChangeMap != null) { 355 355 if (relationChangeMap.containsKey(p)) { … … 365 365 for (int i = 0; i < rel.getMembersCount(); i++) { 366 366 if (rel.getMember(i).getMember().equals(source)) { 367 referencingRelations.put(rel, Integer.valueOf(i));367 referencingRelations.put(rel, i); 368 368 } 369 369 } -
applications/editors/josm/plugins/reltoolbox/src/relcontext/relationfix/AssociatedStreetFixer.java
r33708 r36102 155 155 */ 156 156 // return results 157 if (commandList. size() == 0)157 if (commandList.isEmpty()) { 158 158 return null; 159 if (commandList.size() == 1) 160 return commandList.get(0); 161 return new SequenceCommand(tr("fix associatedStreet relation"), commandList); 159 } 160 return SequenceCommand.wrapIfNeeded(tr("fix associatedStreet relation"), commandList); 162 161 } 163 162 } -
applications/editors/josm/plugins/reltoolbox/src/relcontext/relationfix/BoundaryFixer.java
r34095 r36102 12 12 import org.openstreetmap.josm.gui.MainApplication; 13 13 14 15 14 /** 16 * @see https://wiki.openstreetmap.org/wiki/Relation:boundary 15 * Fix multipolygon boundaries 16 * @see <a href="https://wiki.openstreetmap.org/wiki/Relation:boundary">osmwiki:Relation:boundary</a> 17 17 */ 18 18 public class BoundaryFixer extends MultipolygonFixer { … … 25 25 * For boundary relations both "boundary" and "multipolygon" types are applicable, but 26 26 * it should also have key boundary=administrative to be fully boundary. 27 * @see https://wiki.openstreetmap.org/wiki/Relation:boundary27 * @see <a href="https://wiki.openstreetmap.org/wiki/Relation:boundary">osmwiki:Relation:boundary</a> 28 28 */ 29 29 @Override -
applications/editors/josm/plugins/reltoolbox/src/relcontext/relationfix/MultipolygonFixer.java
r34095 r36102 20 20 21 21 /** 22 * @see https://wiki.openstreetmap.org/wiki/Relation:multipolygon22 * @see <a href="https://wiki.openstreetmap.org/wiki/Relation:multipolygon">osmwiki:Relation:multipolygon</a> 23 23 */ 24 24 public class MultipolygonFixer extends RelationFixer { … … 69 69 Set<Way> outerWays = new HashSet<>(); 70 70 for (MultipolygonBuilder.JoinedPolygon poly : mpc.outerWays) { 71 for (Way w : poly.ways) { 72 outerWays.add(w); 73 } 71 outerWays.addAll(poly.ways); 74 72 } 75 73 Set<Way> innerWays = new HashSet<>(); 76 74 for (MultipolygonBuilder.JoinedPolygon poly : mpc.innerWays) { 77 for (Way w : poly.ways) { 78 innerWays.add(w); 79 } 75 innerWays.addAll(poly.ways); 80 76 } 81 77 for (int i = 0; i < r.getMembersCount(); i++) { 82 78 RelationMember m = r.getMember(i); 83 79 if (m.isWay()) { 80 final Way way = m.getWay(); 84 81 String role = null; 85 if (outerWays.contains( m.getMember())) {82 if (outerWays.contains(way)) { 86 83 role = "outer"; 87 } else if (innerWays.contains( m.getMember())) {84 } else if (innerWays.contains(way)) { 88 85 role = "inner"; 89 86 } 90 87 if (role != null && !role.equals(m.getRole())) { 91 r.setMember(i, new RelationMember(role, m.getMember()));88 r.setMember(i, new RelationMember(role, way)); 92 89 fixed = true; 93 90 } -
applications/editors/josm/plugins/reltoolbox/src/relcontext/relationfix/PublicTransportFixer.java
r34095 r36102 14 14 15 15 /** 16 * @see https://wiki.openstreetmap.org/wiki/Key:public_transport17 */18 19 /**20 16 * Helper function for determinate role in public_transport relation 21 17 * @author freeExec 18 * @see <a href="https://wiki.openstreetmap.org/wiki/Key:public_transport">osmwiki:Key:public_transport</a> 22 19 */ 23 20 public class PublicTransportFixer extends RelationFixer { -
applications/editors/josm/plugins/reltoolbox/src/relcontext/relationfix/RelationFixer.java
r34551 r36102 17 17 public abstract class RelationFixer { 18 18 19 private List<String> applicableTypes;19 private final List<String> applicableTypes; 20 20 private SortAndFixAction sortAndFixAction; 21 21
Note:
See TracChangeset
for help on using the changeset viewer.