Package org.openstreetmap.josm.data.coor

Examples of org.openstreetmap.josm.data.coor.EastNorth


     * For dual align, calculates positions of new nodes, aligning them to neighboring segments.
     * Elsewhere, just adds the vetor returned by calculateBestMovement to {@link #initialN1en}{@link #initialN2en}.
     * @return best movement vector
     */
    private EastNorth calculateBestMovementAndNewNodes(EastNorth mouseEn) {
        EastNorth bestMovement = calculateBestMovement(mouseEn);
        EastNorth n1movedEn = initialN1en.add(bestMovement), n2movedEn;

        // find out the movement distance, in metres
        double distance = Main.getProjection().eastNorth2latlon(initialN1en).greatCircleDistance(Main.getProjection().eastNorth2latlon(n1movedEn));
        Main.map.statusLine.setDist(distance);
        updateStatusLine();

        if (dualAlignActive) {
            // new positions of selected segment's nodes, without applying dual alignment
            n1movedEn = initialN1en.add(bestMovement);
            n2movedEn = initialN2en.add(bestMovement);

            // calculate intersections of parallel shifted segment and the adjacent lines
            newN1en = Geometry.getLineLineIntersection(n1movedEn, n2movedEn, dualAlignSegment1.p1, dualAlignSegment1.p2);
            newN2en = Geometry.getLineLineIntersection(n1movedEn, n2movedEn, dualAlignSegment2.p1, dualAlignSegment2.p2);
            if (newN1en == null || newN2en == null) return bestMovement;
            if (keepSegmentDirection && isOppositeDirection(newN1en, newN2en, initialN1en, initialN2en)) {
                EastNorth collapsedSegmentPosition = Geometry.getLineLineIntersection(dualAlignSegment1.p1, dualAlignSegment1.p2, dualAlignSegment2.p1, dualAlignSegment2.p2);
                newN1en = collapsedSegmentPosition;
                newN2en = collapsedSegmentPosition;
                dualAlignSegmentCollapsed = true;
            } else {
                dualAlignSegmentCollapsed = false;
View Full Code Here


        }

        /* If mouse position is close to line at 15-30-45-... angle, remembers this direction
         */
        public void checkAngleSnapping(EastNorth currentEN, double baseHeading, double curHeading) {
            EastNorth p0 = currentBaseNode.getEastNorth();
            EastNorth snapPoint = currentEN;
            double angle = -1;

            double activeBaseHeading = (customBaseHeading>=0)? customBaseHeading : baseHeading;

            if (snapOn && (activeBaseHeading>=0)) {
                angle = curHeading - activeBaseHeading;
                if (angle < 0) {
                    angle+=360;
                }
                if (angle > 360) {
                    angle=0;
                }

                double nearestAngle;
                if (fixed) {
                    nearestAngle = lastAngle; // if direction is fixed use previous angle
                    active = true;
                } else {
                    nearestAngle = getNearestAngle(angle);
                    if (getAngleDelta(nearestAngle, angle) < snapAngleTolerance) {
                        active = (customBaseHeading>=0)? true : Math.abs(nearestAngle - 180) > 1e-3;
                        // if angle is to previous segment, exclude 180 degrees
                        lastAngle = nearestAngle;
                    } else {
                        active=false;
                    }
                }

                if (active) {
                    double phi;
                    e0 = p0.east();
                    n0 = p0.north();
                    buildLabelText((nearestAngle<=180) ? nearestAngle : nearestAngle-360);

                    phi = (nearestAngle + activeBaseHeading) * Math.PI / 180;
                    // (pe,pn) - direction of snapping line
                    pe = Math.sin(phi);
                    pn = Math.cos(phi);
                    double scale = 20 * Main.map.mapView.getDist100Pixel();
                    dir2 = new EastNorth(e0 + scale * pe, n0 + scale * pn);
                    snapPoint = getSnapPoint(currentEN);
                } else {
                    noSnapNow();
                }
            }
View Full Code Here

                    }
                    if (customBaseHeading >=0 ) {
                        pointsToProject.add(segmentPoint1);
                        pointsToProject.add(segmentPoint2);
                    }
                    EastNorth enOpt=null;
                    double dOpt=1e5;
                    for (EastNorth en: pointsToProject) { // searching for besht projection
                        double l1 = (en.east()-e0)*pe+(en.north()-n0)*pn;
                        double d1 = Math.abs(l1-l);
                        if (d1 < delta && d1 < dOpt) {
                            l=l1;
                            enOpt = en;
                            dOpt = d1;
                        }
                    }
                    if (enOpt!=null) {
                        projectionSource =  enOpt;
                    }
                }
            }
            return projected = new EastNorth(e0+l*pe, n0+l*pn);
        }
View Full Code Here

            return;

        requestFocusInMapView();
        updateKeyModifiers(ev);

        EastNorth en = Main.map.mapView.getEastNorth(ev.getX(), ev.getY());
        if (! shift) {
            playHeadMarker.reposition(en);
        } else {
            playHeadMarker.synchronize(en);
        }
View Full Code Here

                }


            } else if (candidateNode != null) {
                // Moving the highlighted node
                EastNorth nodeEN = candidateNode.getEastNorth();
                EastNorth cursorEN = mv.getEastNorth(mousePos.x, mousePos.y);

                Main.main.undoRedo.add(new MoveCommand(candidateNode, cursorEN.east() - nodeEN.east(), cursorEN.north()
                        - nodeEN.north()));
            }
        }

        mousePos = null;
View Full Code Here

                return;
            setMode(Mode.dragging);
        }

        // Calculate distance to the reference line
        EastNorth enp = mv.getEastNorth((int) p.getX(), (int) p.getY());
        EastNorth nearestPointOnRefLine = Geometry.closestPointToLine(referenceSegment.getFirstNode().getEastNorth(),
                referenceSegment.getSecondNode().getEastNorth(), enp);

        // Note: d is the distance in _projected units_
        double d = enp.distance(nearestPointOnRefLine);
        double realD = mv.getProjection().eastNorth2latlon(enp).greatCircleDistance(mv.getProjection().eastNorth2latlon(nearestPointOnRefLine));
View Full Code Here

    private void tryToMoveNodeOnIntersection(List<WaySegment> wss, Node n) {
        if (wss.isEmpty())
            return;
        WaySegment ws = wss.get(0);
        EastNorth p1=ws.getFirstNode().getEastNorth();
        EastNorth p2=ws.getSecondNode().getEastNorth();
        if (snapHelper.dir2!=null && currentBaseNode!=null) {
            EastNorth xPoint = Geometry.getSegmentSegmentIntersection(p1, p2, snapHelper.dir2, currentBaseNode.getEastNorth());
            if (xPoint!=null) {
                n.setEastNorth(xPoint);
            }
        }
    }
View Full Code Here

        if (ll == null) {
            ll = new LatLon(0,0);
        }
        this.latLonCoordinates = ll;
        tfLatLon.setText(ll.latToString(CoordinateFormat.getDefaultFormat()) + " " + ll.lonToString(CoordinateFormat.getDefaultFormat()));
        EastNorth en = Main.getProjection().latlon2eastNorth(ll);
        tfEastNorth.setText(en.east()+" "+en.north());
        setOkEnabled(true);
    }
View Full Code Here

            setOkEnabled(true);
        }
    }

    protected void parseEastNorthUserInput() {
        EastNorth en;
        try {
            en = parseEastNorth(tfEastNorth.getText());
        } catch (IllegalArgumentException e) {
            en = null;
        }
View Full Code Here

        String[] en = s.split("[;, ]+");
        if (en.length != 2) return null;
        try {
            double east = Double.parseDouble(en[0]);
            double north = Double.parseDouble(en[1]);
            return new EastNorth(east, north);
        } catch (NumberFormatException nfe) {
            return null;
        }
    }
View Full Code Here

TOP

Related Classes of org.openstreetmap.josm.data.coor.EastNorth

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.