Changeset 35976 in osm for applications/editors/josm/plugins/tracer2/src
- Timestamp:
- 2022-06-14T20:11:21+02:00 (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/tracer2/src/org/openstreetmap/josm/plugins/tracer2/ConnectWays.java
r35975 r35976 82 82 } 83 83 84 private static double calcAlpha(LatLon oP1, Node n) { 85 LatLon oP2 = n.getCoor(); 86 87 double dAlpha = Math.atan((oP2.getY() - oP1.getY()) / (oP2.getX() - oP1.getX())) * 180 / Math.PI + (oP1.getX() > oP2.getX() ? 180 : 0); 84 private static double calcAlpha(LatLon oP1, Node oP2) { 85 86 double dAlpha = Math.atan((oP2.lat() - oP1.lat()) / (oP2.lon() - oP1.lon())) * 180 / Math.PI + (oP1.lon() > oP2.lon() ? 180 : 0); 88 87 return checkAlpha(dAlpha); 89 88 } … … 333 332 //List<Command> cmds = new LinkedList<Command>(); 334 333 335 LatLon ll = node.getCoor(); 334 //LatLon ll = node.getCoor(); 336 335 //BBox bbox = new BBox( 337 336 // ll.getX() - MIN_DISTANCE_TW, … … 358 357 for (Pair<Node, Node> np : ww.getNodePairs(false)) { 359 358 //double dist1 = TracerGeometry.distanceFromSegment(ll, np.a.getCoor(), np.b.getCoor()); 360 double dist = distanceFromSegment2( ll, np.a.getCoor(), np.b.getCoor());359 double dist = distanceFromSegment2(node, np.a, np.b); 361 360 //System.out.println(" distance: " + dist1 + " " + dist); 362 361 … … 381 380 } 382 381 383 private static double distanceFromSegment2(LatLon c, LatLon a, LatLon b) { 382 private static double distanceFromSegment2(ILatLon c, ILatLon a, ILatLon b) { 384 383 double x; 385 384 double y; 386 385 387 386 StraightLine oStraightLine1 = new StraightLine( 388 new Point2D.Double(a. getX(), a.getY()),389 new Point2D.Double(b. getX(), b.getY()));387 new Point2D.Double(a.lon(), a.lat()), 388 new Point2D.Double(b.lon(), b.lat())); 390 389 StraightLine oStraightLine2 = new StraightLine( 391 new Point2D.Double(c. getX(), c.getY()),392 new Point2D.Double(c. getX() + (a.getY()-b.getY()), c.getY() - (a.getX()-b.getX())));390 new Point2D.Double(c.lon(), c.lat()), 391 new Point2D.Double(c.lon() + (a.lat()-b.lat()), c.lat() - (a.lon()-b.lon()))); 393 392 Point2D.Double oPoint = oStraightLine1.GetIntersectionPoint(oStraightLine2); 394 393 395 if ((oPoint.x > a. getX() && oPoint.x > b.getX()) || (oPoint.x < a.getX() && oPoint.x < b.getX()) ||396 (oPoint.y > a. getY() && oPoint.y > b.getY()) || (oPoint.y < a.getY() && oPoint.y < b.getY())) {394 if ((oPoint.x > a.lon() && oPoint.x > b.lon()) || (oPoint.x < a.lon() && oPoint.x < b.lon()) || 395 (oPoint.y > a.lat() && oPoint.y > b.lat()) || (oPoint.y < a.lat() && oPoint.y < b.lat())) { 397 396 return 100000; 398 397 } 399 398 400 x = c. getX()-oPoint.getX();401 y = c. getY()-oPoint.getY();399 x = c.lon()-oPoint.getX(); 400 y = c.lat()-oPoint.getY(); 402 401 403 402 return Math.sqrt((x*x)+(y*y)); … … 421 420 while (i < way.getNodesCount()) { 422 421 // usecka n1, n2 423 LatLon n1 = way.getNodes().get(i ).getCoor();424 LatLon n2 = way.getNodes().get((i + 1) % way.getNodesCount() ).getCoor();422 ILatLon n1 = way.getNodes().get(i); 423 ILatLon n2 = way.getNodes().get((i + 1) % way.getNodesCount()); 425 424 System.out.println(way.getNodes().get(i) + "-----" + way.getNodes().get((i + 1) % way.getNodesCount())); 426 425 double minDistanceSq = Double.MAX_VALUE; … … 438 437 continue; 439 438 } 440 LatLon nn = nod.getCoor(); 441 //double dist = TracerGeometry.distanceFromSegment(nn, n1, n2); 442 double dist = distanceFromSegment2(nn, n1, n2); 443 // double angle = TracerGeometry.angleOfLines(n1, nn, nn, n2); 439 //double dist = TracerGeometry.distanceFromSegment(nod, n1, n2); 440 double dist = distanceFromSegment2(nod, n1, n2); 441 // double angle = TracerGeometry.angleOfLines(n1, nod, nod, n2); 444 442 //System.out.println("Angle: " + angle + " distance: " + dist + " Node: " + nod); 445 if (!n1.equalsEpsilon(n n, ILatLon.MAX_SERVER_PRECISION)446 && !n2.equalsEpsilon(n n, ILatLon.MAX_SERVER_PRECISION) && dist < minDistanceSq) { // && Math.abs(angle) < maxAngle) {443 if (!n1.equalsEpsilon(nod, ILatLon.MAX_SERVER_PRECISION) 444 && !n2.equalsEpsilon(nod, ILatLon.MAX_SERVER_PRECISION) && dist < minDistanceSq) { // && Math.abs(angle) < maxAngle) { 447 445 minDistanceSq = dist; 448 446 // maxAngle = angle;
Note:
See TracChangeset
for help on using the changeset viewer.