Changeset 22230 in osm for applications/editors
- Timestamp:
- 2010-07-07T21:57:06+02:00 (14 years ago)
- Location:
- applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/Address.java
r22188 r22230 89 89 JLabel link = new JLabel(); 90 90 private Way selectedWay; 91 private Relation selectedRelation;91 //private Relation selectedRelation; 92 92 private boolean shift; 93 93 … … 146 146 } else { 147 147 // check if the node belongs to an associatedStreet relation 148 List<OsmPrimitive> l = currentMouseNode.getReferrers(); 149 boolean nodeBelongsToRelation = false; 150 for (OsmPrimitive osm : l) { 151 if (osm instanceof Relation && osm.hasKey("type") && osm.get("type").equals(relationAddrType)) { 152 for (RelationMember rm : ((Relation)osm).getMembers()) { 153 if (rm.getRole().equals(relationAddrStreetRole)) { 154 OsmPrimitive osp = rm.getMember(); 155 if (osp instanceof Way && osp.hasKey(tagHighwayName)) { 156 inputStreet.setText(osp.get(tagHighwayName)); 157 setSelectedWay((Way)osp, (Relation)osm); 158 nodeBelongsToRelation = true; 159 break; 160 } 161 } 162 } 163 } 164 } 165 if (!nodeBelongsToRelation) { 148 Way wayInRelationAddr = findWayInRelationAddr(currentMouseNode); 149 if (wayInRelationAddr == null) { 166 150 // node exists but doesn't carry address information : add tags like a new node 167 151 Collection<Command> cmds = new LinkedList<Command>(); 168 152 addAddrToPrimitive(currentMouseNode, cmds); 153 } else { 154 inputStreet.setText(wayInRelationAddr.get(tagHighwayName)); 155 setSelectedWay(wayInRelationAddr); 169 156 } 170 157 } … … 201 188 } 202 189 190 private Way findWayInRelationAddr(Node n) { 191 List<OsmPrimitive> l = n.getReferrers(); 192 for (OsmPrimitive osm : l) { 193 if (osm instanceof Relation && osm.hasKey("type") && osm.get("type").equals(relationAddrType)) { 194 for (RelationMember rm : ((Relation)osm).getMembers()) { 195 if (rm.getRole().equals(relationAddrStreetRole)) { 196 OsmPrimitive osp = rm.getMember(); 197 if (osp instanceof Way && osp.hasKey(tagHighwayName)) { 198 return (Way)osp; 199 } 200 } 201 } 202 } 203 } 204 return null; 205 } 206 203 207 private void addAddrToPolygon(List<Way> mouseOnExistingBuildingWays, Collection<Command> cmds) { 204 208 for (Way w:mouseOnExistingBuildingWays) { … … 221 225 cmds.add(new ChangePropertyCommand(osm, tagHouseStreet, inputStreet.getText())); 222 226 } else if (selectedWay != null) { 223 // add the node to its relation 224 if (selectedRelation != null) { 225 RelationMember rm = new RelationMember(relationMemberHouse, osm); 226 Relation newRel = new Relation(selectedRelation); 227 newRel.addMember(rm); 228 cmds.add(new ChangeCommand(selectedRelation, newRel)); 229 } else { 230 // create new relation 231 Relation newRel = new Relation(); 232 newRel.put("type", relationAddrType); 233 newRel.put(relationAddrName, selectedWay.get(tagHighwayName)); 234 newRel.addMember(new RelationMember(relationAddrStreetRole, selectedWay)); 235 newRel.addMember(new RelationMember(relationMemberHouse, osm)); 236 cmds.add(new AddCommand(newRel)); 237 } 227 Relation selectedRelation = findRelationAddr(selectedWay); 228 // add the node to its relation 229 if (selectedRelation != null) { 230 RelationMember rm = new RelationMember(relationMemberHouse, osm); 231 Relation newRel = new Relation(selectedRelation); 232 newRel.addMember(rm); 233 cmds.add(new ChangeCommand(selectedRelation, newRel)); 234 } else { 235 // create new relation 236 Relation newRel = new Relation(); 237 newRel.put("type", relationAddrType); 238 newRel.put(relationAddrName, selectedWay.get(tagHighwayName)); 239 newRel.addMember(new RelationMember(relationAddrStreetRole, selectedWay)); 240 newRel.addMember(new RelationMember(relationMemberHouse, osm)); 241 cmds.add(new AddCommand(newRel)); 242 } 238 243 } 239 244 try { … … 245 250 System.out.println("Unable to parse house number \"" + inputNumber.getText() + "\""); 246 251 } 252 } 253 254 private Relation findRelationAddr(Way w) { 255 List<OsmPrimitive> l = w.getReferrers(); 256 for (OsmPrimitive osm : l) { 257 if (osm instanceof Relation && osm.hasKey("type") && osm.get("type").equals(relationAddrType)) { 258 return (Relation)osm; 259 } 260 } 261 return null; 247 262 } 248 263 … … 480 495 private void setSelectedWay(Way w) { 481 496 this.selectedWay = w; 482 this.selectedRelation = null;483 497 if (w == null) { 484 498 link.setEnabled(false); 485 499 } else 486 500 link.setEnabled(true); 487 }488 489 private void setSelectedWay(Way w, Relation r) {490 setSelectedWay(w);491 this.selectedRelation = r;492 501 } 493 502 -
applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/CadastrePreferenceSetting.java
r22186 r22230 43 43 private JCheckBox autoFirstLayer = new JCheckBox(tr("Select first WMS layer in list.")); 44 44 45 private JCheckBox dontUseRelation = new JCheckBox(tr("Don't use relation for addresses (but \"addr:street\" on nodes)."));45 private JCheckBox dontUseRelation = new JCheckBox(tr("Don't use relation for addresses (but \"addr:street\" on elements).")); 46 46 47 47 private JRadioButton grabMultiplier1 = new JRadioButton("", true); -
applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/GeorefImage.java
r20390 r22230 57 57 this.orgCroppedRaster[2] = max; 58 58 this.orgCroppedRaster[3] = new EastNorth(max.east(), min.north()); 59 this.imageOriginalHeight = img.getHeight(); 60 this.imageOriginalWidth = img.getWidth(); 59 // img can be null for a hack used in overlapping detection 60 this.imageOriginalHeight = (img == null ? 1 : img.getHeight()); 61 this.imageOriginalWidth = (img == null ? 1 : img.getWidth()); 61 62 updatePixelPer(); 62 63 }
Note:
See TracChangeset
for help on using the changeset viewer.