Changeset 1947 in josm for trunk/src/org/openstreetmap
- Timestamp:
- 2009-08-10T12:46:51+02:00 (15 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/AlignInCircleAction.java
r1912 r1947 30 30 * @author Matthew Newton 31 31 * @author Petr Dlouhý 32 * @author Teemu Koskinen 32 33 */ 33 34 public final class AlignInCircleAction extends JosmAction { … … 142 143 } 143 144 145 // Reorder the nodes if they didn't come from a single way 146 if (ways.size() != 1) { 147 // First calculate the average point 148 149 BigDecimal east = new BigDecimal(0); 150 BigDecimal north = new BigDecimal(0); 151 152 for (Node n : nodes) { 153 BigDecimal x = new BigDecimal(n.getEastNorth().east()); 154 BigDecimal y = new BigDecimal(n.getEastNorth().north()); 155 east = east.add(x, MathContext.DECIMAL128); 156 north = north.add(y, MathContext.DECIMAL128); 157 } 158 BigDecimal nodesSize = new BigDecimal(nodes.size()); 159 east = east.divide(nodesSize, MathContext.DECIMAL128); 160 north = north.divide(nodesSize, MathContext.DECIMAL128); 161 162 EastNorth average = new EastNorth(east.doubleValue(), north.doubleValue()); 163 List<Node> newNodes = new LinkedList<Node>(); 164 165 // Then reorder them based on heading from the average point 166 while (!nodes.isEmpty()) { 167 double maxHeading = -1.0; 168 Node maxNode = null; 169 for (Node n : nodes) { 170 double heading = average.heading(n.getEastNorth()); 171 if (heading > maxHeading) { 172 maxHeading = heading; 173 maxNode = n; 174 } 175 } 176 newNodes.add(maxNode); 177 nodes.remove(maxNode); 178 } 179 180 nodes = newNodes; 181 } 182 144 183 if (center == null) { 145 184 // Compute the centroid of nodes 146 185 147 BigDecimal area = new BigDecimal( "0");148 BigDecimal north = new BigDecimal( "0");149 BigDecimal east = new BigDecimal( "0");186 BigDecimal area = new BigDecimal(0); 187 BigDecimal north = new BigDecimal(0); 188 BigDecimal east = new BigDecimal(0); 150 189 151 190 // See http://en.wikipedia.org/w/index.php?title=Centroid&oldid=294224857#Centroid_of_polygon for the equation used here … … 167 206 } 168 207 169 BigDecimal d = new BigDecimal("2"); 170 area = area.divide(d, MathContext.DECIMAL128); 171 d = new BigDecimal("6"); 172 north = north.divide(d.multiply(area, MathContext.DECIMAL128), MathContext.DECIMAL128); 173 east = east.divide(d.multiply(area, MathContext.DECIMAL128), MathContext.DECIMAL128); 208 BigDecimal d = new BigDecimal(3, MathContext.DECIMAL128); // 1/2 * 6 = 3 209 area = area.multiply(d, MathContext.DECIMAL128); 210 north = north.divide(area, MathContext.DECIMAL128); 211 east = east.divide(area, MathContext.DECIMAL128); 174 212 175 213 center = new EastNorth(east.doubleValue(), north.doubleValue()); -
trunk/src/org/openstreetmap/josm/data/projection/Lambert.java
r1909 r1947 146 146 147 147 public String toCode() { 148 return "EPSG:"+(27571+currentZone -1);148 return "EPSG:"+(27571+currentZone); 149 149 } 150 150 -
trunk/src/org/openstreetmap/josm/io/GpxWriter.java
r1724 r1947 1 1 // License: GPL. Copyright 2007 by Immanuel Scholz and others 2 2 package org.openstreetmap.josm.io; 3 4 import static org.openstreetmap.josm.tools.I18n.tr; 3 5 4 6 import java.io.BufferedWriter; … … 235 237 break; 236 238 default: 237 throw new RuntimeException( "Bug detected. Please report this!");239 throw new RuntimeException(tr("Unknown mode {0}.", mode)); 238 240 } 239 241 if (pnt != null) { 240 LatLon c = pnt.getCoor();242 LatLon c = pnt.getCoor(); 241 243 openAtt(type, "lat=\"" + c.lat() + "\" lon=\"" + c.lon() + "\""); 242 244 writeAttr(pnt.attr);
Note:
See TracChangeset
for help on using the changeset viewer.