Package org.openstreetmap.josm.data.coor

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


                w.getNode(1) != null &&
                w.getNode(2) != null &&
                w.firstNode() == w.lastNode()) {
            /** do some simple determinant / cross pruduct test on the first 3 nodes
                to see, if the roundabout goes clock wise or ccw */
            EastNorth en1 = w.getNode(0).getEastNorth();
            EastNorth en2 = w.getNode(1).getEastNorth();
            EastNorth en3 = w.getNode(2).getEastNorth();
            if (en1 != null && en2 != null && en3 != null) {
                en1 = en1.sub(en2);
                en2 = en2.sub(en3);
                return en1.north() * en2.east() - en2.north() * en1.east() > 0 ? ROUNDABOUT_LEFT : ROUNDABOUT_RIGHT;
            }
View Full Code Here


        Element viewportEl = doc.createElement("viewport");
        root.appendChild(viewportEl);
        Element centerEl = doc.createElement("center");
        viewportEl.appendChild(centerEl);
        EastNorth center = Main.map.mapView.getCenter();
        LatLon centerLL = Projections.inverseProject(center);
        centerEl.setAttribute("lat", Double.toString(centerLL.lat()));
        centerEl.setAttribute("lon", Double.toString(centerLL.lon()));
        Element scale = doc.createElement("scale");
        viewportEl.appendChild(scale);
View Full Code Here

                            found.values().remove(m.getWay());
                        }
                    }
                    // estimate multipolygon size by its bounding box area
                    BBox bBox = r.getBBox();
                    EastNorth en1 = Main.map.mapView.getProjection().latlon2eastNorth(bBox.getTopLeft());
                    EastNorth en2 = Main.map.mapView.getProjection().latlon2eastNorth(bBox.getBottomRight());
                    double s = Math.abs((en1.east() - en2.east()) * (en1.north() - en2.north()));
                    if (s == 0) s = 1e8;
                    found.put(s, r);
                }
            }
        }
View Full Code Here

            initialMoveThresholdExceeded = true; //no more ingnoring uintil nex mouse press
        }
        if (e.getPoint().equals(lastMousePos))
            return;

        EastNorth currentEN = mv.getEastNorth(e.getX(), e.getY());

        if (virtualManager.hasVirtualWaysToBeConstructed()) {
            virtualManager.createMiddleNodeFromVirtual(currentEN);
        } else {
            if (!updateCommandWhileDragging(currentEN)) return;
View Full Code Here

    public static Node findCandidateNode(MapView mv, Way w, Point p) {
        if (mv == null || w == null || p == null) {
            return null;
        }

        EastNorth pEN = mv.getEastNorth(p.x, p.y);

        Double bestDistance = Double.MAX_VALUE;
        Double currentDistance;
        List<Pair<Node, Node>> wpps = w.getNodePairs(false);

        Node result = null;

        mainLoop:
        for (Node n : w.getNodes()) {
            EastNorth nEN = n.getEastNorth();
            currentDistance = pEN.distance(nEN);

            if (currentDistance < bestDistance) {
                // Making sure this candidate is not behind any segment.
                for (Pair<Node, Node> wpp : wpps) {
View Full Code Here

    public static WaySegment findCandidateSegment(MapView mv, Way w, Point p) {
        if (mv == null || w == null || p == null) {
            return null;
        }

        EastNorth pEN = mv.getEastNorth(p.x, p.y);

        Double currentDistance;
        Double currentAngle;
        Double bestDistance = Double.MAX_VALUE;
        Double bestAngle = 0.0;

        int candidate = -1;

        List<Pair<Node, Node>> wpps = w.getNodePairs(true);

        int i = -1;
        for (Pair<Node, Node> wpp : wpps) {
            ++i;

            // Finding intersection of the segment with its altitude from p (c)
            EastNorth altitudeIntersection = Geometry.getSegmentAltituteIntersection(wpp.a.getEastNorth(),
                    wpp.b.getEastNorth(), pEN);

            if (altitudeIntersection != null) {
                // If the segment intersects with the altitude from p
                currentDistance = pEN.distance(altitudeIntersection);
View Full Code Here

        nodeCount = sortedNodes.size();
        pts = new EastNorth[nodeCount];
        normals = new EastNorth[nodeCount - 1];
        int i = 0;
        for (Node n : sortedNodes) {
            EastNorth t = n.getEastNorth();
            pts[i] = t;
            i++;
        }
        for (i = 0; i < nodeCount - 1; i++) {
            double dx = pts[i + 1].getX() - pts[i].getX();
            double dy = pts[i + 1].getY() - pts[i].getY();
            double len = Math.sqrt(dx * dx + dy * dy);
            normals[i] = new EastNorth(-dy / len, dx / len);
        }
    }
View Full Code Here

         * Simple and probably not even close to optimal performance wise
         */

        EastNorth[] ppts = new EastNorth[nodeCount];

        EastNorth prevA = pts[0].add(normals[0].scale(d));
        EastNorth prevB = pts[1].add(normals[0].scale(d));
        for (int i = 1; i < nodeCount - 1; i++) {
            EastNorth A = pts[i].add(normals[i].scale(d));
            EastNorth B = pts[i + 1].add(normals[i].scale(d));
            if (Geometry.segmentsParallel(A, B, prevA, prevB)) {
                ppts[i] = A;
            } else {
                ppts[i] = Geometry.getLineLineIntersection(A, B, prevA, prevB);
            }
            prevA = A;
            prevB = B;
        }
        if (isClosedPath()) {
            EastNorth A = pts[0].add(normals[0].scale(d));
            EastNorth B = pts[1].add(normals[0].scale(d));
            if (Geometry.segmentsParallel(A, B, prevA, prevB)) {
                ppts[0] = A;
            } else {
                ppts[0] = Geometry.getLineLineIntersection(A, B, prevA, prevB);
            }
View Full Code Here

            List<Node> wayNodes = w.getNodes();
            for (Integer segmentIndex : segmentIndexes) {
                final Set<Node> nodesInSegment = innerEntry.get(segmentIndex);
                if (joinWayToNode) {
                    for (Node node : nodesInSegment) {
                        EastNorth newPosition = Geometry.closestPointToSegment(w.getNode(segmentIndex).getEastNorth(),
                                                                            w.getNode(segmentIndex+1).getEastNorth(),
                                                                            node.getEastNorth());
                        cmds.add(new MoveCommand(node, Projections.inverseProject(newPosition)));
                    }
                }
View Full Code Here

            refPoint2 = referenceNode2.getEastNorth();
            projectToSegment = projectFirst;
        }
        @Override
        public int compare(Node first, Node second) {
            EastNorth firstPosition = first.getEastNorth();
            EastNorth secondPosition = second.getEastNorth();

            if (projectToSegment) {
                firstPosition = Geometry.closestPointToSegment(refPoint, refPoint2, firstPosition);
                secondPosition = Geometry.closestPointToSegment(refPoint, refPoint2, secondPosition);
            }

            double distanceFirst = firstPosition.distance(refPoint);
            double distanceSecond = secondPosition.distance(refPoint);
            double difference =  distanceFirst - distanceSecond;

            if (difference > 0.0) return 1;
            if (difference < 0.0) return -1;
            return 0;
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.