forked from powerfun/udpservice
39 lines
1.1 KiB
C#
39 lines
1.1 KiB
C#
|
|
using GeoJSON.Net.Geometry;
|
|||
|
|
using System;
|
|||
|
|
using System.Collections.Generic;
|
|||
|
|
using System.Text;
|
|||
|
|
using TurfCS;
|
|||
|
|
using System.Linq;
|
|||
|
|
|
|||
|
|
namespace OnlineUserPool.Unility
|
|||
|
|
{
|
|||
|
|
public class TurfHelper
|
|||
|
|
{
|
|||
|
|
private LineString _line;
|
|||
|
|
/// <summary>
|
|||
|
|
///
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="points">坐标(lat,lon)</param>
|
|||
|
|
public TurfHelper(IEnumerable<double[]> points)
|
|||
|
|
{
|
|||
|
|
//var list = new GeoJSON.Net.Geometry.GeographicPosition();
|
|||
|
|
var list = points.Select(p => new GeoJSON.Net.Geometry.GeographicPosition(p[0], p[1]));
|
|||
|
|
|
|||
|
|
_line = new LineString(list);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
///
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="distance">km</param>
|
|||
|
|
public GeographicPosition Along(double distance)
|
|||
|
|
{
|
|||
|
|
var pt1 = Turf.Along(_line, distance);
|
|||
|
|
return ((GeographicPosition)((GeoJSON.Net.Geometry.Point)pt1.Geometry).Coordinates);
|
|||
|
|
//new LineString()
|
|||
|
|
//new GeoJSON.Net.Geometry.Point(new GeoJSON.Net.Geometry.GeographicPosition())
|
|||
|
|
//pt1.BoundingBoxes
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|