Changeset 13670 in josm
- Timestamp:
- 2018-04-23T23:13:03+02:00 (7 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/OrthogonalizeAction.java
r13434 r13670 188 188 * @return a rectifying command 189 189 * @throws InvalidUserInputException if the selection is invalid 190 */ 191 static SequenceCommand orthogonalize(Iterable<OsmPrimitive> selection) throws InvalidUserInputException { 190 * @since 13670 191 */ 192 public static SequenceCommand orthogonalize(Iterable<OsmPrimitive> selection) throws InvalidUserInputException { 192 193 final List<Node> nodeList = new ArrayList<>(); 193 194 final List<WayData> wayDataList = new ArrayList<>(); … … 619 620 /** 620 621 * Exception: unsuited user input 621 */ 622 protected static class InvalidUserInputException extends Exception { 622 * @since 13670 623 */ 624 public static final class InvalidUserInputException extends Exception { 623 625 InvalidUserInputException(String message) { 624 626 super(message); -
trunk/src/org/openstreetmap/josm/data/osm/Way.java
r13665 r13670 16 16 import org.openstreetmap.josm.spi.preferences.Config; 17 17 import org.openstreetmap.josm.tools.CopyList; 18 import org.openstreetmap.josm.tools.Geometry; 18 19 import org.openstreetmap.josm.tools.Pair; 19 20 import org.openstreetmap.josm.tools.Utils; … … 780 781 } 781 782 } 783 784 /** 785 * Returns angles of vertices. 786 * @return angles of the way 787 * @since 13670 788 */ 789 public synchronized List<Pair<Double, Node>> getAngles() { 790 List<Pair<Double, Node>> angles = new ArrayList<>(); 791 792 for (int i = 1; i < nodes.length - 1; i++) { 793 Node n0 = nodes[i - 1]; 794 Node n1 = nodes[i]; 795 Node n2 = nodes[i + 1]; 796 797 double angle = Geometry.getNormalizedAngleInDegrees(Geometry.getCornerAngle( 798 n0.getEastNorth(), n1.getEastNorth(), n2.getEastNorth())); 799 angles.add(new Pair<>(angle, n1)); 800 } 801 802 angles.add(new Pair<>(Geometry.getNormalizedAngleInDegrees(Geometry.getCornerAngle( 803 nodes[nodes.length - 2].getEastNorth(), 804 nodes[0].getEastNorth(), 805 nodes[1].getEastNorth())), nodes[0])); 806 807 return angles; 808 } 782 809 } -
trunk/src/org/openstreetmap/josm/data/validation/OsmValidator.java
r13647 r13670 53 53 import org.openstreetmap.josm.data.validation.tests.PublicTransportRouteTest; 54 54 import org.openstreetmap.josm.data.validation.tests.RelationChecker; 55 import org.openstreetmap.josm.data.validation.tests.RightAngleBuildingTest; 55 56 import org.openstreetmap.josm.data.validation.tests.SelfIntersectingWay; 56 57 import org.openstreetmap.josm.data.validation.tests.SimilarNamedWays; … … 141 142 LongSegment.class, // 3500 .. 3599 142 143 PublicTransportRouteTest.class, // 3600 .. 3699 144 RightAngleBuildingTest.class, // 3700 .. 3799 143 145 }; 144 146 -
trunk/src/org/openstreetmap/josm/tools/Geometry.java
r13638 r13670 794 794 795 795 return result; 796 } 797 798 /** 799 * Get angles in radians and return it's value in range [0, 180]. 800 * 801 * @param angle the angle in radians 802 * @return normalized angle in degrees 803 * @since 13670 804 */ 805 public static double getNormalizedAngleInDegrees(double angle) { 806 return Math.abs(180 * angle / Math.PI); 796 807 } 797 808 -
trunk/test/unit/org/openstreetmap/josm/tools/GeometryTest.java
r12656 r13670 1 1 // License: GPL. For details, see LICENSE file. 2 2 package org.openstreetmap.josm.tools; 3 4 import static org.junit.Assert.assertEquals; 3 5 4 6 import java.io.FileInputStream; … … 10 12 import org.openstreetmap.josm.TestUtils; 11 13 import org.openstreetmap.josm.data.coor.EastNorth; 14 import org.openstreetmap.josm.data.coor.LatLon; 12 15 import org.openstreetmap.josm.data.osm.DataSet; 16 import org.openstreetmap.josm.data.osm.Node; 13 17 import org.openstreetmap.josm.data.osm.Relation; 14 18 import org.openstreetmap.josm.data.osm.Way; … … 109 113 } 110 114 } 115 116 /** 117 * Test of {@link Geometry#getNormalizedAngleInDegrees(double)} method. 118 */ 119 @Test 120 public void testRightAngle() { 121 Node n1 = new Node(1); 122 Node n2 = new Node(2); 123 Node n3 = new Node(3); 124 n1.setCoor(new LatLon(10.22873540462851, 6.169719398316592)); 125 n2.setCoor(new LatLon(10.229332494162811, 6.16978130985785)); 126 n3.setCoor(new LatLon(10.22924937004949, 6.17060908367496)); 127 128 double angle = Geometry.getNormalizedAngleInDegrees(Geometry.getCornerAngle(n1.getEastNorth(), 129 n2.getEastNorth(), n3.getEastNorth())); 130 assertEquals(90, angle, 1e-8); 131 angle = Geometry.getNormalizedAngleInDegrees(Geometry.getCornerAngle(n1.getEastNorth(), 132 n2.getEastNorth(), n1.getEastNorth())); 133 assertEquals(0, angle, 1e-8); 134 135 n1.setCoor(new LatLon(10.2295011, 6.1693106)); 136 n2.setCoor(new LatLon(10.2294958, 6.16930635)); 137 n3.setCoor(new LatLon(10.2294895, 6.1693039)); 138 139 angle = Geometry.getNormalizedAngleInDegrees(Geometry.getCornerAngle(n1.getEastNorth(), 140 n2.getEastNorth(), n3.getEastNorth())); 141 assertEquals(162.66381817961337, angle, 1e-5); 142 143 angle = Geometry.getNormalizedAngleInDegrees(Geometry.getCornerAngle(n3.getEastNorth(), 144 n2.getEastNorth(), n1.getEastNorth())); 145 assertEquals(162.66381817961337, angle, 1e-5); 146 } 111 147 }
Note:
See TracChangeset
for help on using the changeset viewer.