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


C# GeoCoordinate.DistanceEstimate方法代码示例

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


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

示例1: Weight

        /// <summary>
        /// Returns the weight between two points on an edge with the given tags for the vehicle.
        /// </summary>
        /// <param name="tags"></param>
        /// <param name="from"></param>
        /// <param name="to"></param>
        /// <returns></returns>
        public virtual float Weight(TagsCollection tags, GeoCoordinate from, GeoCoordinate to)
        {
            var distance = from.DistanceEstimate(to).Value;

            return (float)(distance / (this.ProbableSpeed(tags).Value) * 3.6);
        }
开发者ID:jboneng,项目名称:OsmSharp,代码行数:13,代码来源:Vehicle.cs

示例2: Weight

 /// <summary>
 /// Returns the weight between two points on an edge with the given tags for the vehicle.
 /// </summary>
 /// <param name="tags"></param>
 /// <param name="from"></param>
 /// <param name="to"></param>
 /// <returns></returns>
 public virtual float Weight(TagsCollectionBase tags, GeoCoordinate from, GeoCoordinate to)
 {
     var distance = (float)from.DistanceEstimate(to).Value;
     return this.Weight(tags, distance);
 }
开发者ID:kochizufan,项目名称:OsmSharp,代码行数:12,代码来源:Vehicle.cs

示例3: Contract


//.........这里部分代码省略.........
                for (int y = 0; y < edgesForContractions.Count; y++)
                { // loop over all elements.
                    var yEdge = edgesForContractions[y];

                    // add the combinations of these edges.
                    if (yEdge.EdgeData.Forward &&
                        xEdge.Neighbour != yEdge.Neighbour)
                    { // there is a connection from x to y and there is no witness path.
                        // create x-to-y data and edge.
                        var forward = (xEdge.EdgeData.Backward && yEdge.EdgeData.Forward) && !witnesses[y];

                        if (forward)
                        { // add the edge if there is usefull info or if there needs to be a neighbour relationship.
                            // calculate the total weight.
                            var forwardWeight = xEdge.EdgeData.BackwardWeight + yEdge.EdgeData.ForwardWeight;

                            CHEdgeData data;
                            if (_target.GetEdge(xEdge.Neighbour, yEdge.Neighbour, out data))
                            { // there already is an edge; evaluate for each direction.
                                if (forward && data.ForwardWeight > forwardWeight)
                                { // replace forward edge.
                                    ICoordinateCollection shape;
                                    if (data.RepresentsNeighbourRelations &&
                                        _target.GetEdgeShape(xEdge.Neighbour, yEdge.Neighbour, out shape) &&
                                        shape != null && shape.Count > 0)
                                    { // an edge that represents a relation between two neighbours and has shapes should never be replaced.
                                        // TODO: keep existing edge by inserting a dummy vertex for one of the shapes.
                                        // TODO: check if this is still needed because these case are supposed to be remove in osm->graph conversions.
                                        // WARNING: The assumption here is that the weight is in direct relation with the distance.
                                        var shapeCoordinates = new List<GeoCoordinateSimple>(shape.ToSimpleArray());
                                        float latitude, longitude;
                                        _target.GetVertex(xEdge.Neighbour, out latitude, out longitude);
                                        var previousCoordinate = new GeoCoordinate(shapeCoordinates[0]);
                                        var distanceFirst = (new GeoCoordinate(latitude, longitude)).DistanceEstimate(previousCoordinate).Value;
                                        var totalDistance = distanceFirst;
                                        for(int idx = 1; idx < shapeCoordinates.Count; idx++)
                                        {
                                            var currentCoordinate = new GeoCoordinate(shapeCoordinates[idx]);
                                            totalDistance = totalDistance + currentCoordinate.DistanceEstimate(previousCoordinate).Value;

                                            previousCoordinate = currentCoordinate;
                                        }
                                        _target.GetVertex(yEdge.Neighbour, out latitude, out longitude);
                                        totalDistance = totalDistance + previousCoordinate.DistanceEstimate(new GeoCoordinate(latitude, longitude)).Value;

                                        // calculate the new edge data's.
                                        float firstPartRatio = (float)(distanceFirst / totalDistance);
                                        float secondPartRatio = 1 - firstPartRatio;
                                        // REMARK: the edge being split can never have contracted id's because it would not have a shape.
                                        var firstPartEdgeData = new CHEdgeData()
                                        {
                                            BackwardContractedId = data.BackwardContractedId,
                                            BackwardWeight = data.BackwardWeight,
                                            ForwardContractedId = data.ForwardContractedId,
                                            ForwardWeight = data.ForwardWeight,
                                            Tags = data.Tags,
                                            TagsForward = data.TagsForward
                                        };
                                        var secondPartEdgeData = new CHEdgeData()
                                        {
                                            BackwardContractedId = data.BackwardContractedId,
                                            BackwardWeight = data.BackwardWeight,
                                            ForwardContractedId = data.ForwardContractedId,
                                            ForwardWeight = data.ForwardWeight,
                                            Tags = data.Tags,
                                            TagsForward = data.TagsForward
开发者ID:kochizufan,项目名称:OsmSharp,代码行数:67,代码来源:CHPreProcessor.cs


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