You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
101 lines
3.7 KiB
101 lines
3.7 KiB
using ESRI.ArcGIS.Geometry; |
|
using System; |
|
using System.Collections.Generic; |
|
using System.Linq; |
|
using System.Text; |
|
using System.Threading.Tasks; |
|
|
|
namespace KGIS.PlatformPlugin.Commands.Tools.TraceTool |
|
{ |
|
public static class PointCollectionEx |
|
{ |
|
public static System.Collections.Generic.Dictionary<int, System.Collections.Generic.List<IPoint>> Sort(this IPointCollection pPointCollection, IPoint pPointRelation) |
|
{ |
|
if (pPointCollection == null) |
|
{ |
|
return null; |
|
} |
|
int num = 1; |
|
System.Collections.Generic.Dictionary<int, System.Collections.Generic.List<IPoint>> dictionary = new System.Collections.Generic.Dictionary<int, System.Collections.Generic.List<IPoint>>(); |
|
System.Collections.Generic.List<IPoint> list = new System.Collections.Generic.List<IPoint>(); |
|
int i = 0; |
|
int pointCount = pPointCollection.PointCount; |
|
while (i < pointCount) |
|
{ |
|
IPoint point = pPointCollection.get_Point(i); |
|
if (list.Count > 0 && point.IsSamePoint(list[0], 0.001)) |
|
{ |
|
dictionary.Add(num, list); |
|
list = new System.Collections.Generic.List<IPoint>(); |
|
num++; |
|
} |
|
else |
|
{ |
|
list.Add(point); |
|
} |
|
i++; |
|
} |
|
int j = 1; |
|
int count = dictionary.Count; |
|
while (j <= count) |
|
{ |
|
System.Collections.Generic.List<double> list2 = new System.Collections.Generic.List<double>(); |
|
list = dictionary[j]; |
|
int num2 = 0; |
|
while (list.Count > num2) |
|
{ |
|
IPoint other = list[num2]; |
|
double item = (pPointRelation as IProximityOperator).ReturnDistance(other); |
|
list2.Add(item); |
|
num2++; |
|
} |
|
int num3 = list2.IndexOf(list2.Min()); |
|
System.Collections.Generic.List<IPoint> list3 = new System.Collections.Generic.List<IPoint>(); |
|
int k = 0; |
|
int count2 = list.Count; |
|
while (k < count2) |
|
{ |
|
int index; |
|
if (k + num3 >= count2) |
|
{ |
|
index = k + num3 - count2; |
|
} |
|
else |
|
{ |
|
index = k + num3; |
|
} |
|
list3.Add(list[index]); |
|
k++; |
|
} |
|
dictionary.Remove(j); |
|
dictionary.Add(j, list3); |
|
j++; |
|
} |
|
return dictionary; |
|
} |
|
public static int GetLongestLineSegmentStartPoint(this IPointCollection pPointCollection) |
|
{ |
|
if (pPointCollection != null && pPointCollection.PointCount >= 2) |
|
{ |
|
int result = -1; |
|
double num = 0.0; |
|
int i = 0; |
|
int pointCount = pPointCollection.PointCount; |
|
while (i < pointCount - 1) |
|
{ |
|
IProximityOperator proximityOperator = pPointCollection.get_Point(i) as IProximityOperator; |
|
IPoint other = pPointCollection.get_Point(i + 1); |
|
double num2 = proximityOperator.ReturnDistance(other); |
|
if (num < num2) |
|
{ |
|
num = num2; |
|
result = i; |
|
} |
|
i++; |
|
} |
|
return result; |
|
} |
|
return -1; |
|
} |
|
} |
|
}
|
|
|