Changeset 35976 in osm for applications/editors/josm/plugins/tracer
- Timestamp:
- 2022-06-14T20:11:21+02:00 (3 years ago)
- Location:
- applications/editors/josm/plugins/tracer/src/org/openstreetmap/josm/plugins/tracer
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/tracer/src/org/openstreetmap/josm/plugins/tracer/ConnectWays.java
r35975 r35976 49 49 LatLon ll = n.getCoor(); 50 50 BBox bbox = new BBox( 51 ll.getX() - MIN_DISTANCE,52 ll.getY() - MIN_DISTANCE,53 ll.getX() + MIN_DISTANCE,54 ll.getY() + MIN_DISTANCE);51 n.lon() - MIN_DISTANCE, 52 n.lat() - MIN_DISTANCE, 53 n.lon() + MIN_DISTANCE, 54 n.lat() + MIN_DISTANCE); 55 55 56 56 // bude se node slucovat s jinym? … … 129 129 LatLon ll = node.getCoor(); 130 130 BBox bbox = new BBox( 131 ll.getX() - MIN_DISTANCE_TW,132 ll.getY() - MIN_DISTANCE_TW,133 ll.getX() + MIN_DISTANCE_TW,134 ll.getY() + MIN_DISTANCE_TW);131 node.lon() - MIN_DISTANCE_TW, 132 node.lat() - MIN_DISTANCE_TW, 133 node.lon() + MIN_DISTANCE_TW, 134 node.lat() + MIN_DISTANCE_TW); 135 135 136 136 // node nebyl slouceny s jinym … … 188 188 while (i < way.getNodesCount()) { 189 189 // usecka n1, n2 190 LatLonn1 = way.getNodes().get(i).getCoor();191 LatLonn2 = way.getNodes().get((i + 1) % way.getNodesCount()).getCoor();190 Node n1 = way.getNodes().get(i); 191 Node n2 = way.getNodes().get((i + 1) % way.getNodesCount()); 192 192 System.out.println(way.getNodes().get(i) + "-----" + way.getNodes().get((i + 1) % way.getNodesCount())); 193 193 double minDistanceSq = MIN_DISTANCE_SQ; 194 194 //double maxAngle = MAX_ANGLE; 195 195 List<Node> nodes = MainApplication.getLayerManager().getEditDataSet().searchNodes(new BBox( 196 Math.min(n1. getX(), n2.getX()) - minDistanceSq,197 Math.min(n1. getY(), n2.getY()) - minDistanceSq,198 Math.max(n1. getX(), n2.getX()) + minDistanceSq,199 Math.max(n1. getY(), n2.getY()) + minDistanceSq196 Math.min(n1.lon(), n2.lon()) - minDistanceSq, 197 Math.min(n1.lat(), n2.lat()) - minDistanceSq, 198 Math.max(n1.lon(), n2.lon()) + minDistanceSq, 199 Math.max(n1.lat(), n2.lat()) + minDistanceSq 200 200 )); 201 201 Node nearestNode = null; … … 204 204 continue; 205 205 } 206 LatLon nn = nod.getCoor(); 207 double dist = TracerGeometry.distanceFromSegment(nn, n1, n2); 208 double angle = TracerGeometry.angleOfLines(n1, nn, nn, n2); 206 double dist = TracerGeometry.distanceFromSegment(nod, n1, n2); 207 double angle = TracerGeometry.angleOfLines(n1, nod, nod, n2); 209 208 System.out.println("Angle: " + angle + " distance: " + dist + " Node: " + nod); 210 if (!n1.equalsEpsilon(n n, ILatLon.MAX_SERVER_PRECISION)211 && !n2.equalsEpsilon(n n, ILatLon.MAX_SERVER_PRECISION) && dist < minDistanceSq) { // && Math.abs(angle) < maxAngle) {209 if (!n1.equalsEpsilon(nod, ILatLon.MAX_SERVER_PRECISION) 210 && !n2.equalsEpsilon(nod, ILatLon.MAX_SERVER_PRECISION) && dist < minDistanceSq) { // && Math.abs(angle) < maxAngle) { 212 211 //maxAngle = angle; 213 212 nearestNode = nod; -
applications/editors/josm/plugins/tracer/src/org/openstreetmap/josm/plugins/tracer/TracerGeometry.java
r19881 r35976 7 7 package org.openstreetmap.josm.plugins.tracer; 8 8 9 import org.openstreetmap.josm.data.coor.LatLon; 9 import org.openstreetmap.josm.data.coor.ILatLon; 10 10 11 public class TracerGeometry { 11 public final class TracerGeometry { 12 private TracerGeometry() { 13 // Hide constructor 14 } 12 15 13 16 /** … … 19 22 * @return Angle in degrees. 20 23 */ 21 static public double angleOfLines(LatLon a, LatLon b, LatLon c, LatLon d) {24 public static double angleOfLines(ILatLon a, ILatLon b, ILatLon c, ILatLon d) { 22 25 return (Math.abs( 23 26 Math.atan2(a.lat() - b.lat(), a.lon() - b.lon()) - … … 33 36 * @return Distance. 34 37 */ 35 static public double distanceFromSegment(LatLon c, LatLon a, LatLon b) {38 public static double distanceFromSegment(ILatLon c, ILatLon a, ILatLon b) { 36 39 return distanceFromSegment( 37 c. getX(), c.getY(),38 a. getX(), a.getY(),39 b. getX(), b.getY()40 c.lon(), c.lat(), 41 a.lon(), a.lat(), 42 b.lon(), b.lat() 40 43 ); 41 44 } 42 45 43 staticprivate double distanceFromSegment(double cx, double cy, double ax, double ay, double bx, double by) {46 private static double distanceFromSegment(double cx, double cy, double ax, double ay, double bx, double by) { 44 47 double r_numerator = (cx - ax) * (bx - ax) + (cy - ay) * (by - ay); 45 48 double r_denomenator = (bx - ax) * (bx - ax) + (by - ay) * (by - ay);
Note:
See TracChangeset
for help on using the changeset viewer.