Changeset 16290 in osm for applications/editors/josm/plugins/czechaddress/src
- Timestamp:
- 2009-07-03T12:34:14+02:00 (16 years ago)
- Location:
- applications/editors/josm/plugins/czechaddress/src/org/openstreetmap/josm/plugins/czechaddress
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/czechaddress/src/org/openstreetmap/josm/plugins/czechaddress/MapUtils.java
r15585 r16290 3 3 import java.util.Collection; 4 4 import org.openstreetmap.josm.Main; 5 import org.openstreetmap.josm. data.osm.Node;5 import org.openstreetmap.josm.actions.AutoScaleAction; 6 6 import org.openstreetmap.josm.data.osm.OsmPrimitive; 7 import org.openstreetmap.josm.data.osm.Way;8 import org.openstreetmap.josm.data.osm.visitor.BoundingXYVisitor;9 import org.openstreetmap.josm.gui.MapView;10 7 11 8 /** … … 21 18 22 19 /** 23 * Zoom level used for zooming to a single node.24 */25 public static final double NODE_ZOOM_LEVEL = 0.00000007;26 27 28 /**29 20 * Selects and zooms the JOSM viewport to given primitives. 30 *31 * <p>It does so by calculating the center of given primitives and32 * then it zooms to it.</p>33 *34 * <p><b>WARNING and TODO:</b> The method {@code zoomTo()} currently35 * checks for damaged {@link Node}s, whose {@code eastNorth} is set to36 * null. This property is not accessed in this method and therefore37 * no checking is done. However the "mad GUI" problem may still arise.38 * Therefore please be careful.</p>39 *40 * @see BoundingXYVisitor41 * @see MapView42 21 */ 43 22 public static void zoomToMany(Collection<OsmPrimitive> primitives) { 44 BoundingXYVisitor visitor = new BoundingXYVisitor();45 for (OsmPrimitive op : primitives) {46 if (op instanceof Node)47 ((Node) op).visit(visitor);48 49 else if (op instanceof Way)50 ((Way) op).visit(visitor);51 }52 Main.map.mapView.zoomTo(53 visitor.min.interpolate(visitor.max, 0.5),54 NODE_ZOOM_LEVEL);55 23 Main.ds.setSelected(primitives); 24 (new AutoScaleAction("selection")).actionPerformed(null); 56 25 } 57 26 58 27 /** 59 28 * Selects and zooms the JOSM viewport to given primitive. 60 *61 * <p><b>TODO:</b> There is an error in JOSM, which makes the whole62 * GUI totally mad if we zoom to a {@link Node}, whose {@code eastNorth}63 * is set null. Currently zooming to such a node is ignored, but the64 * question is where so such damaged nodes come from?</p>65 *66 * @see BoundingXYVisitor67 * @see MapView68 29 */ 69 30 public static void zoomTo(OsmPrimitive primitive) { 70 BoundingXYVisitor visitor = new BoundingXYVisitor();71 72 if (primitive instanceof Node && ((Node) primitive).eastNorth != null)73 Main.map.mapView.zoomTo(((Node) primitive).eastNorth, NODE_ZOOM_LEVEL);74 75 else if (primitive instanceof Way) {76 ((Way) primitive).visit(visitor);77 Main.map.mapView.zoomTo(78 visitor.min.interpolate(visitor.max, 0.5),79 NODE_ZOOM_LEVEL);80 }81 82 31 Main.ds.setSelected(primitive); 32 (new AutoScaleAction("selection")).actionPerformed(null); 83 33 } 84 34 } -
applications/editors/josm/plugins/czechaddress/src/org/openstreetmap/josm/plugins/czechaddress/addressdatabase/AddressElement.java
r15585 r16290 97 97 98 98 if (prim instanceof Node) 99 result += " " + StringUtils.latLonToString(((Node) prim). coor);99 result += " " + StringUtils.latLonToString(((Node) prim).getCoor()); 100 100 else if (prim instanceof Way) 101 result += " " + StringUtils.latLonToString(((Way) prim).firstNode(). coor);101 result += " " + StringUtils.latLonToString(((Way) prim).firstNode().getCoor()); 102 102 103 103 return result; -
applications/editors/josm/plugins/czechaddress/src/org/openstreetmap/josm/plugins/czechaddress/gui/LocationSelector.java
r15649 r16290 40 40 LocationSelector ls = new LocationSelector(); 41 41 ls.setVisible(true); 42 42 43 43 if (ls.getValue() == 1) 44 44 return ls.selectedElement; … … 50 50 super(Main.parent, "Výběr umístění", 51 51 new String[] { "OK", "Zrušit"}, true); 52 52 53 53 initComponents(); 54 54 setupDialog(mainPanel, new String[] { "ok.png", "cancel.png"}); … … 68 68 * Hardly ever working method for autodetecting the current location. 69 69 * 70 * @deprecated 70 * @deprecated 71 71 */ 72 72 private void autodetectLocation() { … … 93 93 94 94 try { 95 Bounds bounds = visitor.getBounds(); 96 LatLon max = bounds.max; 97 LatLon min = bounds.min; 98 center = new LatLon( 99 (max.getX() + min.getX()) / 2, 100 (max.getY() + min.getY()) / 2); 101 95 center = Main.proj.eastNorth2latlon(visitor.getBounds().getCenter()); 102 96 } catch (Exception e) { 103 97 System.err.println("AUTO: No bounds to determine autolocation."); … … 128 122 } 129 123 130 double currLen = multiplicator * (node. coor.distance(center));124 double currLen = multiplicator * (node.getCoor().distance(center)); 131 125 132 126 … … 138 132 139 133 if (bestFit != null) { 140 134 141 135 if (assertions) 142 136 System.out.println("AUTO: Best fit " + bestFit.getName() 143 137 + "\t " + bestFit.get("name")); 144 138 145 139 for (Region oblast : Database.getInstance().regions) { 146 140 for (ViToCi obec : oblast.getViToCis()) { … … 263 257 ItemEvent event = new ItemEvent(this, 264 258 ItemEvent.DESELECTED, selectedElement, ItemEvent.DESELECTED); 265 259 266 260 for (ItemListener i : listeners) 267 261 i.itemStateChanged(event); … … 271 265 event = new ItemEvent(this, 272 266 ItemEvent.SELECTED, selectedElement, ItemEvent.SELECTED); 273 267 274 268 for (ItemListener i : listeners) 275 269 i.itemStateChanged(event); … … 323 317 else if (oblastComboBox.getSelectedItem() != null) 324 318 selectedElement = ((ElementWithStreets) oblastComboBox.getSelectedItem()); 325 319 326 320 }//GEN-LAST:event_suburbComboBoxItemStateChanged 327 321 -
applications/editors/josm/plugins/czechaddress/src/org/openstreetmap/josm/plugins/czechaddress/proposal/ExtractAddressIntoNodeProposal.java
r15166 r16290 51 51 if (!isApplicable(primitive)) 52 52 return; 53 53 54 54 Way way = (Way) primitive; 55 55 56 56 BoundingXYVisitor visitor = new BoundingXYVisitor(); 57 57 way.visit(visitor); 58 LatLon center = new LatLon( 59 (visitor.getBounds().max.lat() + visitor.getBounds().min.lat())/2, 60 (visitor.getBounds().max.lon() + visitor.getBounds().min.lon())/2 61 ); 62 63 Node addrNode = new Node(center); 58 59 Node addrNode = new Node(visitor.getBounds().getCenter()); 64 60 65 61 for (String key : way.keySet()) … … 75 71 /** 76 72 * Returns textual representation of this proposal. 77 * 73 * 78 74 * Currently the string is in Czech language (see {@link CzechAddressPlugin}). 79 75 */ … … 83 79 } 84 80 85 81 86 82 87 83 }
Note:
See TracChangeset
for help on using the changeset viewer.