Changeset 7776 in josm
 Timestamp:
 20141209T17:59:09+01:00 (8 years ago)
 Location:
 trunk/src/org/openstreetmap/josm
 Files:

 2 edited
Legend:
 Unmodified
 Added
 Removed

trunk/src/org/openstreetmap/josm/actions/mapmode/ImproveWayAccuracyHelper.java
r6830 r7776 143 143 ++i; 144 144 145 // Finding intersection of the segment with its altitude from p (c) 146 EastNorth altitudeIntersection = Geometry.getSegmentAltituteIntersection(wpp.a.getEastNorth(), 147 wpp.b.getEastNorth(), pEN); 148 149 if (altitudeIntersection != null) { 150 // If the segment intersects with the altitude from p 151 currentDistance = pEN.distance(altitudeIntersection); 152 153 // Making an angle too big to let this candidate win any others 145 EastNorth a = wpp.a.getEastNorth(); 146 EastNorth b = wpp.b.getEastNorth(); 147 148 // Finding intersection of the segment with its altitude from p 149 EastNorth altitudeIntersection = Geometry.closestPointToSegment(a, b, pEN); 150 currentDistance = pEN.distance(altitudeIntersection); 151 152 if (!altitudeIntersection.equals(a) && !altitudeIntersection.equals(b)) { 153 // If the segment intersects with the altitude from p, 154 // make an angle too big to let this candidate win any others 154 155 // having the same distance. 155 156 currentAngle = Double.MAX_VALUE; 156 157 157 } else { 158 // Otherwise: Distance is equal to the shortest distance from p 159 // to a or b 160 currentDistance = Math.min(pEN.distance(wpp.a.getEastNorth()), 161 pEN.distance(wpp.b.getEastNorth())); 162 163 // Measuring the angle 164 currentAngle = Math.abs(Geometry.getCornerAngle( 165 wpp.a.getEastNorth(), pEN, wpp.b.getEastNorth())); 158 // Otherwise measure the angle 159 currentAngle = Math.abs(Geometry.getCornerAngle(a, pEN, b)); 166 160 } 167 161 
trunk/src/org/openstreetmap/josm/tools/Geometry.java
r7509 r7776 824 824 double yC = inv12*b1 + inv22*b2; 825 825 return new EastNorth(xC, yC); 826 }827 828 /**829 * Returns the coordinate of intersection of segment sp1sp2 and an altitude830 * to it starting at point ap. If the line defined with sp1sp2 intersects831 * its altitude out of sp1sp2, null is returned.832 *833 * @param sp1834 * @param sp2835 * @param ap836 * @return Intersection coordinate or null837 */838 public static EastNorth getSegmentAltituteIntersection(EastNorth sp1, EastNorth sp2, EastNorth ap) {839 840 CheckParameterUtil.ensureValidCoordinates(sp1, "sp1");841 CheckParameterUtil.ensureValidCoordinates(sp2, "sp2");842 CheckParameterUtil.ensureValidCoordinates(ap, "ap");843 844 Double segmentLenght = sp1.distance(sp2);845 Double altitudeAngle = getSegmentAngle(sp1, sp2) + Math.PI / 2;846 847 // Taking a random point on the altitude line (angle is known).848 EastNorth ap2 = new EastNorth(ap.east() + 1000849 * Math.cos(altitudeAngle), ap.north() + 1000850 * Math.sin(altitudeAngle));851 852 // Finding the intersection of two lines853 EastNorth resultCandidate = Geometry.getLineLineIntersection(sp1, sp2,854 ap, ap2);855 856 // Filtering result857 if (resultCandidate != null858 && resultCandidate.distance(sp1) * .999 < segmentLenght859 && resultCandidate.distance(sp2) * .999 < segmentLenght) {860 return resultCandidate;861 } else {862 return null;863 }864 826 } 865 827
Note: See TracChangeset
for help on using the changeset viewer.