Changeset 13670 in josm for trunk/src


Ignore:
Timestamp:
2018-04-23T23:13:03+02:00 (6 years ago)
Author:
Don-vip
Message:

fix #16189 - Add "almost square check" for buildings (patch by marxin, modified)

Location:
trunk/src/org/openstreetmap/josm
Files:
1 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/actions/OrthogonalizeAction.java

    r13434 r13670  
    188188     * @return a rectifying command
    189189     * @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 {
    192193        final List<Node> nodeList = new ArrayList<>();
    193194        final List<WayData> wayDataList = new ArrayList<>();
     
    619620    /**
    620621     * Exception: unsuited user input
    621      */
    622     protected static class InvalidUserInputException extends Exception {
     622     * @since 13670
     623     */
     624    public static final class InvalidUserInputException extends Exception {
    623625        InvalidUserInputException(String message) {
    624626            super(message);
  • trunk/src/org/openstreetmap/josm/data/osm/Way.java

    r13665 r13670  
    1616import org.openstreetmap.josm.spi.preferences.Config;
    1717import org.openstreetmap.josm.tools.CopyList;
     18import org.openstreetmap.josm.tools.Geometry;
    1819import org.openstreetmap.josm.tools.Pair;
    1920import org.openstreetmap.josm.tools.Utils;
     
    780781        }
    781782    }
     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    }
    782809}
  • trunk/src/org/openstreetmap/josm/data/validation/OsmValidator.java

    r13647 r13670  
    5353import org.openstreetmap.josm.data.validation.tests.PublicTransportRouteTest;
    5454import org.openstreetmap.josm.data.validation.tests.RelationChecker;
     55import org.openstreetmap.josm.data.validation.tests.RightAngleBuildingTest;
    5556import org.openstreetmap.josm.data.validation.tests.SelfIntersectingWay;
    5657import org.openstreetmap.josm.data.validation.tests.SimilarNamedWays;
     
    141142        LongSegment.class, // 3500 .. 3599
    142143        PublicTransportRouteTest.class, // 3600 .. 3699
     144        RightAngleBuildingTest.class, // 3700 .. 3799
    143145    };
    144146
  • trunk/src/org/openstreetmap/josm/tools/Geometry.java

    r13638 r13670  
    794794
    795795        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);
    796807    }
    797808
Note: See TracChangeset for help on using the changeset viewer.