当前位置: 首页>>代码示例>>Java>>正文


Java Geo.distance方法代码示例

本文整理汇总了Java中com.bbn.openmap.geo.Geo.distance方法的典型用法代码示例。如果您正苦于以下问题:Java Geo.distance方法的具体用法?Java Geo.distance怎么用?Java Geo.distance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.bbn.openmap.geo.Geo的用法示例。


在下文中一共展示了Geo.distance方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getDist

import com.bbn.openmap.geo.Geo; //导入方法依赖的package包/类
/**
 * Return the distance between that lat/lons defined in radians. The
 * returned value is in radians.
 */
public float getDist(Geo g1, Geo g2) {
	switch (getLineType()) {
	case LINETYPE_STRAIGHT:
		float lonDist = ProjMath.lonDistance((float) g2.getLongitude(),
				(float) g1.getLongitude());
		float latDist = (float) g2.getLatitude() - (float) g1.getLatitude();
		return (float) Math.sqrt(lonDist * lonDist + latDist * latDist);
	case LINETYPE_RHUMB:
		Debug.error("Rhumb distance calculation not implemented.");
	case LINETYPE_GREATCIRCLE:
	case LINETYPE_UNKNOWN:
	default:
		return (float) g1.distance(g2);
	}
}
 
开发者ID:debrief,项目名称:deelite,代码行数:20,代码来源:DebriefDistance.java

示例2: getDist

import com.bbn.openmap.geo.Geo; //导入方法依赖的package包/类
/**
 * Return the distance between that lat/lons defined in radians. The returned
 * value is in radians.
 */
public float getDist(Geo g1, Geo g2) {
   switch (getLineType()) {
      case LINETYPE_STRAIGHT:
         float lonDist = ProjMath.lonDistance((float) g2.getLongitude(), (float) g1.getLongitude());
         float latDist = (float) g2.getLatitude() - (float) g1.getLatitude();
         return (float) Math.sqrt(lonDist * lonDist + latDist * latDist);
      case LINETYPE_RHUMB:
         Debug.error("Rhumb distance calculation not implemented.");
      case LINETYPE_GREATCIRCLE:
      case LINETYPE_UNKNOWN:
      default:
         return (float) g1.distance(g2);
   }
}
 
开发者ID:d2fn,项目名称:passage,代码行数:19,代码来源:OMDistance.java

示例3: projectionChanged

import com.bbn.openmap.geo.Geo; //导入方法依赖的package包/类
public void projectionChanged(ProjectionEvent pEvent) {

        if (sourceMapProjection == null)
            return;

        Projection proj = pEvent.getProjection();

        // Save the scale for use in the
        overviewScale = proj.getScale();

        boolean cylindrical = sourceMapProjection instanceof Cylindrical;

        double[] llarr = ProjMath.getProjectionScreenOutlineCoords(sourceMapProjection);

        if (llarr != null) {

            boolean northPoleVisible = ProjMath.isVisible(sourceMapProjection, new LatLonPoint.Double(90, 0));
            boolean southPoleVisible = ProjMath.isVisible(sourceMapProjection, new LatLonPoint.Double(-90, 0));

            if (northPoleVisible || southPoleVisible) {
                Point2D center = sourceMapProjection.getCenter();
                Point2D ul = sourceMapProjection.getUpperLeft();
                double dist = Geo.distance(center.getY(),  center.getX(), ul.getY(), ul.getX());
                poly = new OMCircle(center.getY(), center.getX(), dist, Length.RADIAN);
            } else {
                poly = new OMPoly(llarr, OMPoly.DECIMAL_DEGREES, cylindrical ? OMGraphic.LINETYPE_STRAIGHT
                        : OMGraphic.LINETYPE_GREATCIRCLE);
            }
            areaAttributes.setTo(poly);

            // And finally generate the poly
            poly.generate(proj);
        }
    }
 
开发者ID:d2fn,项目名称:passage,代码行数:35,代码来源:OverviewMapAreaLayer.java

示例4: handlePointsForOuterRing

import com.bbn.openmap.geo.Geo; //导入方法依赖的package包/类
/**
 * Takes a corner represented by the three geos, and adds OMGraphics to the
 * OMAreaList depending on which way the corner bends - for right turns,
 * it'll add an OMLine, OMArc and OMLine. The OMLines will go from half the
 * distance of the legs to the rounded corner. The left turn will have a
 * polygon added.
 * 
 * @param g1 point 1
 * @param g2 point 2
 * @param g3 point 3
 * @param dist buffer distance in radians
 * @param ret OMAreaList to add OMGraphics to.
 */
protected void handlePointsForOuterRing(Geo g1, Geo g2, Geo g3, double dist, OMAreaList ret) {
    int bend = bends(g1, g2, g3);

    Geo gret = g3;
    RibbonIterator leg1 = new RibbonIterator(g1, g2, dist);
    OMPoly poly1 = getHalfPoly(leg1, Ribbon.LEFT, false);

    RibbonIterator leg2 = new RibbonIterator(g2, g3, dist);
    OMPoly poly2 = getHalfPoly(leg2, Ribbon.LEFT, true);

    if (bend == STRAIGHT || g2.equals(g3)) {
        ret.add(poly1);
        ret.add(poly2);
    } else {
        if (bend == BENDS_LEFT) {
            // short, need to find intersection of two legs and remove
            // points
            // from polys to only go to intersection

            double dg12 = g1.distance(g2);
            double dg23 = g2.distance(g3);
            double legTestDist = dist * 2;

            if (dg12 < legTestDist || dg23 < legTestDist) {
                addShortLegPolyForIntersection(g1, g2, g3, Ribbon.LEFT, dist, ret);
            } else {
                addPolyForIntersection(poly1, poly2, dist, ret);
            }

        } else {
            OMGraphic omp = getPushbackPoly(poly1, dist);
            if (omp != null) {
                ret.add(omp);
            }
            // Add OMArc in the middle, rounding around a corner
            OMGraphic oma = getArc(g2, poly1, poly2);
            if (oma != null) {
                ret.add(oma);
            }
            omp = getPushbackPoly(poly2, dist);
            if (omp != null) {
                ret.add(omp);
            }
        }
    }

}
 
开发者ID:d2fn,项目名称:passage,代码行数:61,代码来源:RibbonMaker.java

示例5: getArc

import com.bbn.openmap.geo.Geo; //导入方法依赖的package包/类
/**
 * Given two polylines, with the end point of poly1 being the same distance
 * from a point as the starting point of poly2, create an arc that connects
 * them.
 * 
 * @param gc point
 * @param poly1 polyline where the last end point is used
 * @param poly2 polyline where the first end point is used.
 * @return OMArc
 */
public OMGraphic getArc(Geo gc, OMPoly poly1, OMPoly poly2) {

    double[] poly1Coords = poly1.getLatLonArray();
    Geo pt1 = new Geo(poly1Coords[poly1Coords.length - 2], poly1Coords[poly1Coords.length - 1], false);
    double radAngle1 = gc.azimuth(pt1);

    double[] poly2Coords = poly2.getLatLonArray();
    Geo pt2 = new Geo(poly2Coords[0], poly2Coords[1], false);
    double radAngle2 = gc.azimuth(pt2);

    double dist = gc.distance(pt1);

    if (radAngle2 < radAngle1) {
        radAngle2 += MoreMath.TWO_PI_D;
    }

    if (logger.isLoggable(Level.FINE)) {
        logger.fine(new StringBuilder("Making arg starting at ").append(Length.DECIMAL_DEGREE.fromRadians(radAngle1))
                                                                .append(", ")
                                                                .append(Length.DECIMAL_DEGREE.fromRadians(radAngle2 - radAngle1))
                                                                .toString());
    }

    List<Geo> points = new LinkedList<Geo>();
    double inc = Length.DECIMAL_DEGREE.toRadians(2.0);
    double angle = radAngle1 + inc;

    while (angle < radAngle2 - inc) {
        Geo g = gc.offset(dist, angle);
        if (!tooClose(g, dist)) {
            points.add(g);
        }
        angle += inc;
    }

    return getOMPolyFromGeos(points);
    // return new OMArc(gc.getLatitude(), gc.getLongitude(), dist,
    // Length.RADIAN, 100, Length.DECIMAL_DEGREE.fromRadians(radAngle1),
    // Length.DECIMAL_DEGREE.fromRadians(radAngle2 - radAngle1));

}
 
开发者ID:d2fn,项目名称:passage,代码行数:52,代码来源:RibbonMaker.java


注:本文中的com.bbn.openmap.geo.Geo.distance方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。