• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java EastNorth类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.openstreetmap.josm.data.coor.EastNorth的典型用法代码示例。如果您正苦于以下问题:Java EastNorth类的具体用法?Java EastNorth怎么用?Java EastNorth使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



EastNorth类属于org.openstreetmap.josm.data.coor包,在下文中一共展示了EastNorth类的17个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: getNearestWaySegment

import org.openstreetmap.josm.data.coor.EastNorth; //导入依赖的package包/类
/**
 * Selection of nearest way for stop position
 * @param platformCoord Platform coordinates
 * @param stopArea Stop area
 * @return Nearest way segment
 */
protected NearestWaySegment getNearestWaySegment(LatLon platformCoord, StopArea stopArea)
{
	
	Point p = Main.map.mapView.getPoint(platformCoord);
	Map<Double, List<WaySegment>> dist_waySegments = getNearestWaySegmentsImpl(p);
	for(Map.Entry<Double, List<WaySegment>> entry : dist_waySegments.entrySet())
	{
		for(WaySegment waySegment : entry.getValue())
		{
			if(testWay(waySegment.way, stopArea))
			{
				Node n = waySegment.getFirstNode();
				Node lastN = waySegment.getSecondNode();
		
        		EastNorth newPosition = Geometry.closestPointToSegment(n.getEastNorth(),
          			 lastN.getEastNorth(), Projections.project(platformCoord));
        		LatLon newNodePosition = Projections.inverseProject(newPosition);
            	Point2D lastN2D = Main.map.mapView.getPoint2D(lastN);
            	Point2D n2D = Main.map.mapView.getPoint2D(n);
        		Point2D newNodePosition2D = Main.map.mapView.getPoint2D(newNodePosition);
        		Double distCurrenNodes =lastN2D.distance(n2D); 
        		if((newNodePosition2D.distance(lastN2D) < distCurrenNodes) && (newNodePosition2D.distance(n2D) < distCurrenNodes))
        		{
    				return new NearestWaySegment(entry.getKey(), waySegment, new Node(newNodePosition));
        		}
			}
		}
	}
	return null;
}
 
开发者ID:bwr57,项目名称:CustomizePublicTransportStop,代码行数:37,代码来源:CreateNewStopPointOperation.java


示例2: getNewPointEN

import org.openstreetmap.josm.data.coor.EastNorth; //导入依赖的package包/类
public EastNorth getNewPointEN() {
    if (mod4) {
        return findEqualAngleEN();
    } else if (mousePos != null) {
        return mv.getEastNorth(mousePos.x, mousePos.y);
    } else {
        return null;
    }
}
 
开发者ID:kolesar-andras,项目名称:josm-plugin-improve-way,代码行数:10,代码来源:ImproveWayAccuracyAction.java


示例3: findEqualAngleEN

import org.openstreetmap.josm.data.coor.EastNorth; //导入依赖的package包/类
public EastNorth findEqualAngleEN() {
    int index1 = -1;
    int index2 = -1;
    int realNodesCount = targetWay.getRealNodesCount();

    for (int i=0; i<realNodesCount; i++) {
        Node node = targetWay.getNode(i);
        if (node == candidateNode) {
            index1 = i-1;
            index2 = i+1;
        }
        if (candidateSegment != null) {
            if (node == candidateSegment.getFirstNode()) index1 = i;
            if (node == candidateSegment.getSecondNode()) index2 = i;
        }
    }

    int i11 = fixIndex(realNodesCount, targetWay.isClosed(), index1-1);
    int i12 = fixIndex(realNodesCount, targetWay.isClosed(), index1);
    int i21 = fixIndex(realNodesCount, targetWay.isClosed(), index2);
    int i22 = fixIndex(realNodesCount, targetWay.isClosed(), index2+1);
    if (i11<0 || i12<0 || i21<0 || i22<0) return null;

    EastNorth p11 = targetWay.getNode(i11).getEastNorth();
    EastNorth p12 = targetWay.getNode(i12).getEastNorth();
    EastNorth p21 = targetWay.getNode(i21).getEastNorth();
    EastNorth p22 = targetWay.getNode(i22).getEastNorth();

    double a1 = Geometry.getSegmentAngle(p11, p12);
    double a2 = Geometry.getSegmentAngle(p21, p22);
    double a = fixHeading((a2-a1)*180/Math.PI)*Math.PI/180/3;

    EastNorth p1r = p11.rotate(p12, -a);
    EastNorth p2r = p22.rotate(p21, a);

    return Geometry.getLineLineIntersection(p1r, p12, p21, p2r);
}
 
开发者ID:kolesar-andras,项目名称:josm-plugin-improve-way,代码行数:38,代码来源:ImproveWayAccuracyAction.java


示例4: actionPerformed

import org.openstreetmap.josm.data.coor.EastNorth; //导入依赖的package包/类
@Override
public void actionPerformed(ActionEvent e) {
    if (!isEnabled())
        return;
    final Collection<Command> commands = new LinkedList<>();
    final Collection<OsmPrimitive> sel = getLayerManager().getEditDataSet().getSelected();
    try {
        for (OsmPrimitive p : sel) {
            if (!(p instanceof Node)) throw new InvalidUserInputException("selected object is not a node");
            Node n = (Node) p;
            if (rememberMovements.containsKey(n)) {
                EastNorth tmp = rememberMovements.get(n);
                commands.add(new MoveCommand(n, -tmp.east(), -tmp.north()));
                rememberMovements.remove(n);
            }
        }
        if (!commands.isEmpty()) {
            Main.main.undoRedo.add(new SequenceCommand(tr("Orthogonalize / Undo"), commands));
        } else {
            throw new InvalidUserInputException("Commands are empty");
        }
    } catch (InvalidUserInputException ex) {
        Main.debug(ex);
        new Notification(
                tr("Orthogonalize Shape / Undo<br>"+
                "Please select nodes that were moved by the previous Orthogonalize Shape action!"))
                .setIcon(JOptionPane.INFORMATION_MESSAGE)
                .show();
    }
}
 
开发者ID:stefanocudini,项目名称:orthogonalize-js,代码行数:31,代码来源:OrthogonalizeAction.josm.java


示例5: calcDirections

import org.openstreetmap.josm.data.coor.EastNorth; //导入依赖的package包/类
/**
 * Estimate the direction of the segments, given the first segment points in the
 * direction <code>pInitialDirection</code>.
 * Then sum up all horizontal / vertical segments to have a good guess for the
 * heading of the entire way.
 * @param pInitialDirection initial direction
 * @throws InvalidUserInputException if selected ways have an angle different from 90 or 180 degrees
 */
public void calcDirections(Direction pInitialDirection) throws InvalidUserInputException {
    final EastNorth[] en = new EastNorth[nNode]; // alias: wayNodes.get(i).getEastNorth() ---> en[i]
    for (int i = 0; i < nNode; i++) {
        en[i] = wayNodes.get(i).getEastNorth();
    }
    Direction direction = pInitialDirection;
    segDirections[0] = direction;
    for (int i = 0; i < nSeg - 1; i++) {
        double h1 = EN.polar(en[i], en[i+1]);
        double h2 = EN.polar(en[i+1], en[i+2]);
        try {
            direction = direction.changeBy(angleToDirectionChange(h2 - h1, TOLERANCE1));
        } catch (RejectedAngleException ex) {
            throw new InvalidUserInputException(tr("Please select ways with angles of approximately 90 or 180 degrees."), ex);
        }
        segDirections[i+1] = direction;
    }

    // sum up segments
    EastNorth h = new EastNorth(0., 0.);
    EastNorth v = new EastNorth(0., 0.);
    for (int i = 0; i < nSeg; ++i) {
        EastNorth segment = EN.diff(en[i+1], en[i]);
        if (segDirections[i] == Direction.RIGHT) {
            h = EN.sum(h, segment);
        } else if (segDirections[i] == Direction.UP) {
            v = EN.sum(v, segment);
        } else if (segDirections[i] == Direction.LEFT) {
            h = EN.diff(h, segment);
        } else if (segDirections[i] == Direction.DOWN) {
            v = EN.diff(v, segment);
        } else throw new IllegalStateException();
    }
    // rotate the vertical vector by 90 degrees (clockwise) and add it to the horizontal vector
    segSum = EN.sum(h, new EastNorth(v.north(), -v.east()));
    this.heading = EN.polar(new EastNorth(0., 0.), segSum);
}
 
开发者ID:stefanocudini,项目名称:orthogonalize-js,代码行数:46,代码来源:OrthogonalizeAction.josm.java


示例6: rotateCC

import org.openstreetmap.josm.data.coor.EastNorth; //导入依赖的package包/类
/**
 * Rotate counter-clock-wise.
 * @param pivot pivot
 * @param en original east/north
 * @param angle angle, in radians
 * @return new east/north
 */
public static EastNorth rotateCC(EastNorth pivot, EastNorth en, double angle) {
    double cosPhi = Math.cos(angle);
    double sinPhi = Math.sin(angle);
    double x = en.east() - pivot.east();
    double y = en.north() - pivot.north();
    double nx = cosPhi * x - sinPhi * y + pivot.east();
    double ny = sinPhi * x + cosPhi * y + pivot.north();
    return new EastNorth(nx, ny);
}
 
开发者ID:stefanocudini,项目名称:orthogonalize-js,代码行数:17,代码来源:OrthogonalizeAction.josm.java


示例7: pointToLatLon

import org.openstreetmap.josm.data.coor.EastNorth; //导入依赖的package包/类
private static LatLon pointToLatLon(final Point point) {
    final int width = Main.map.mapView.getWidth();
    final int height = Main.map.mapView.getHeight();
    final EastNorth center = Main.map.mapView.getCenter();
    final double scale = Main.map.mapView.getScale();
    final EastNorth eastNorth = new EastNorth(center.east() + (point.getX() - width / 2.0) * scale,
            center.north() - (point.getY() - height / 2.0) * scale);
    return Main.map.mapView.getProjection().eastNorth2latlon(eastNorth);
}
 
开发者ID:Telenav,项目名称:improve-osm-plugin,代码行数:10,代码来源:Util.java


示例8: rotate

import org.openstreetmap.josm.data.coor.EastNorth; //导入依赖的package包/类
/**
 * Command for rotating a way regarding a center point, by a specified angle
 * @param way to be rotated
 * @param angle in degrees
 * @param center EastNort coordinates of the center-point
 * @return a Collection of Commands
 */
private static Collection<Command> rotate(Way way, double angle, EastNorth center) {
    Set<Node> nodesSet = new HashSet<>();
    List<Node> wayNodes = way.getNodes();
    for (Node node : wayNodes) {
        nodesSet.add(node);
    }
    EastNorth allNodesCenter = getCentroid(nodesSet);
    Iterator<Node> it = nodesSet.iterator();
    Collection<Command> totalCommands = new ArrayList<>();
    while (it.hasNext()) {
        totalCommands.add(rotate(it.next(), angle, allNodesCenter));
    }
    return totalCommands;
}
 
开发者ID:JOSM,项目名称:ShapeTools,代码行数:22,代码来源:ShapeMath.java


示例9: getRotation

import org.openstreetmap.josm.data.coor.EastNorth; //导入依赖的package包/类
/**
 * @return EastNorth coordinates after rotation is applied
 */
public static EastNorth getRotation(EastNorth originalPoint, double angle, EastNorth center) {
    double x = Math.cos(angle) * (originalPoint.getX() - center.getX())
             - Math.sin(angle) * (originalPoint.getY() - center.getY()) + center.getX();
    double y = Math.sin(angle) * (originalPoint.getX() - center.getX())
             + Math.cos(angle) * (originalPoint.getY() - center.getY()) + center.getY();
    return new EastNorth(x, y);
}
 
开发者ID:JOSM,项目名称:ShapeTools,代码行数:11,代码来源:ShapeMath.java


示例10: computeAngle

import org.openstreetmap.josm.data.coor.EastNorth; //导入依赖的package包/类
private static double computeAngle(Node n1, Node n2, Node n3, Node n4) {
    EastNorth en1 = n1.getEastNorth();
    EastNorth en2 = n2.getEastNorth();
    EastNorth en3 = n3.getEastNorth();
    EastNorth en4 = n4.getEastNorth();
    double x1 = en1.getX();
    double x2 = en2.getX();
    double x3 = en3.getX();
    double x4 = en4.getX();
    double y1 = en1.getY();
    double y2 = en2.getY();
    double y3 = en3.getY();
    double y4 = en4.getY();
    return Math.atan2(y2 - y1, x2 - x1) - Math.atan2(y4 - y3, x4 - x3);
}
 
开发者ID:JOSM,项目名称:ShapeTools,代码行数:16,代码来源:ShapeMath.java


示例11: setAppletZoom

import org.openstreetmap.josm.data.coor.EastNorth; //导入依赖的package包/类
public static void setAppletZoom() {

		KatApplet applet = KaporMenuActionListener.applet;
		if (Main.map != null && applet != null) {
			EastNorth center = Main.map.mapView.getCenter();
			LatLon centerLatLon = Main.map.mapView.getProjection()
					.eastNorth2latlon(center);

			Bounds b = Main.map.mapView.getRealBounds();
			LatLon p1 = b.getMin(), p2 = b.getMax();

			double x = centerLatLon.getX();
			double y = centerLatLon.getY();

			if (16 < x && x < 24 && 47 < y && y < 50) {
				Coordinate newcenter = new Coordinate();
				Coordinate newp1 = new Coordinate(), newp2 = new Coordinate();

				try {
					// Ignore difference between S-JTSK and S-JTSK/03
					JTS.transform(new Coordinate(x, y), newcenter, 
							Projection.etrs89_to_s_jtsk_03);

					JTS.transform(new Coordinate(p1.getX(), p1.getY()), newp1,
							Projection.etrs89_to_s_jtsk_03);
					JTS.transform(new Coordinate(p2.getX(), p2.getY()), newp2,
							Projection.etrs89_to_s_jtsk_03);
				} catch (TransformException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}

				double width = Math.abs(newp1.x - newp2.x);
				if (width < 1)
					width = 1;

				applet.zoomWidth(-newcenter.x, -newcenter.y, width, "M");
			}
		}
	}
 
开发者ID:MilanNobonn,项目名称:freemapKaPor,代码行数:41,代码来源:KaporZoomChangeListener.java


示例12: findCandidateNode

import org.openstreetmap.josm.data.coor.EastNorth; //导入依赖的package包/类
/**
 * Returns the nearest node to cursor. All nodes that are “behind” segments
 * are neglected. This is to avoid way self-intersection after moving the
 * candidateNode to a new place.
 *
 * @param mv the current map view
 * @param w the way to check
 * @param p the cursor position
 * @return nearest node to cursor
 */
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();

        if (nEN == null) {
            // Might happen if lat/lon for that point are not known.
            continue;
        }

        currentDistance = pEN.distance(nEN);

        if (currentDistance < bestDistance) {
            // Making sure this candidate is not behind any segment.
            for (Pair<Node, Node> wpp : wpps) {
                if (!wpp.a.equals(n)
                        && !wpp.b.equals(n)
                        && Geometry.getSegmentSegmentIntersection(
                        wpp.a.getEastNorth(), wpp.b.getEastNorth(),
                        pEN, nEN) != null) {
                    continue mainLoop;
                }
            }
            result = n;
            bestDistance = currentDistance;
        }
    }

    return result;
}
 
开发者ID:kolesar-andras,项目名称:josm-plugin-improve-way,代码行数:53,代码来源:ImproveWayAccuracyHelper.java


示例13: findCandidateSegment

import org.openstreetmap.josm.data.coor.EastNorth; //导入依赖的package包/类
/**
 * Returns the nearest way segment to cursor. The distance to segment ab is
 * the length of altitude from p to ab (say, c) or the minimum distance from
 * p to a or b if c is out of ab.
 *
 * The priority is given to segments where c is in ab. Otherwise, a segment
 * with the largest angle apb is chosen.
 *
 * @param mv the current map view
 * @param w the way to check
 * @param p the cursor position
 * @return nearest way segment to cursor
 */
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;

        EastNorth a = wpp.a.getEastNorth();
        EastNorth b = wpp.b.getEastNorth();

        // Finding intersection of the segment with its altitude from p
        EastNorth altitudeIntersection = Geometry.closestPointToSegment(a, b, pEN);
        currentDistance = pEN.distance(altitudeIntersection);

        if (!altitudeIntersection.equals(a) && !altitudeIntersection.equals(b)) {
            // If the segment intersects with the altitude from p,
            // make an angle too big to let this candidate win any others
            // having the same distance.
            currentAngle = Double.MAX_VALUE;
        } else {
            // Otherwise measure the angle
            currentAngle = Math.abs(Geometry.getCornerAngle(a, pEN, b));
        }

        if (currentDistance < bestDistance
                || (currentAngle > bestAngle && currentDistance < bestDistance * 1.0001 /*
                 * equality
                 */)) {
            candidate = i;
            bestAngle = currentAngle;
            bestDistance = currentDistance;
        }

    }
    return candidate != -1 ? new WaySegment(w, candidate) : null;
}
 
开发者ID:kolesar-andras,项目名称:josm-plugin-improve-way,代码行数:63,代码来源:ImproveWayAccuracyHelper.java


示例14: sum

import org.openstreetmap.josm.data.coor.EastNorth; //导入依赖的package包/类
public static EastNorth sum(EastNorth en1, EastNorth en2) {
    return new EastNorth(en1.east() + en2.east(), en1.north() + en2.north());
}
 
开发者ID:stefanocudini,项目名称:orthogonalize-js,代码行数:4,代码来源:OrthogonalizeAction.josm.java


示例15: diff

import org.openstreetmap.josm.data.coor.EastNorth; //导入依赖的package包/类
public static EastNorth diff(EastNorth en1, EastNorth en2) {
    return new EastNorth(en1.east() - en2.east(), en1.north() - en2.north());
}
 
开发者ID:stefanocudini,项目名称:orthogonalize-js,代码行数:4,代码来源:OrthogonalizeAction.josm.java


示例16: polar

import org.openstreetmap.josm.data.coor.EastNorth; //导入依赖的package包/类
public static double polar(EastNorth en1, EastNorth en2) {
    return Math.atan2(en2.north() - en1.north(), en2.east() - en1.east());
}
 
开发者ID:stefanocudini,项目名称:orthogonalize-js,代码行数:4,代码来源:OrthogonalizeAction.josm.java


示例17: getCentroid

import org.openstreetmap.josm.data.coor.EastNorth; //导入依赖的package包/类
private static EastNorth getCentroid(List<Node> wayNodes) {
    EastNorth center = Geometry.getCenter(wayNodes);
    return center != null ? center : Geometry.getCentroid(wayNodes);
}
 
开发者ID:JOSM,项目名称:ShapeTools,代码行数:5,代码来源:ShapeMath.java



注:本文中的org.openstreetmap.josm.data.coor.EastNorth类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java NativeImageHelper类代码示例发布时间:2022-05-22
下一篇:
Java AddCachePoolOp类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap