Skip to content

Commit 4251efc

Browse files
committed
Merge branch 'RevSnipplets' of https://github.com/NetTopologySuite/NetTopologySuite into RevSnipplets
# Conflicts: # NetTopologySuite.IO/NetTopologySuite.IO.GeoTools/NetTopologySuite.IO.GeoTools.csproj # NetTopologySuite.Samples.Console/NetTopologySuite.Samples.Console.csproj # NetTopologySuite/NetTopologySuite.csproj
2 parents 4daec36 + 0cbb7f6 commit 4251efc

File tree

13 files changed

+92
-72
lines changed

13 files changed

+92
-72
lines changed

NTS.nuspec

+1-19
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<requireLicenseAcceptance>true</requireLicenseAcceptance>
1212
<description>
1313
The NTS Topology Suite is an API for modelling and manipulating 2-dimensional linear geometry. It provides numerous geometric predicates and functions. NTS conforms to the Simple Features Specification.
14-
This package contains Wintellect's PowerCollections and references GeoAPI.
14+
This package references GeoAPI.
1515
</description>
1616
<summary>NTS Topology Suite is a direct-port of all the functionalities offered by JTS Topology Suite</summary>
1717
<tags>NTS Topology OGC SFS</tags>
@@ -30,46 +30,28 @@
3030
<file src="Release\v2.0\AnyCPU\NetTopologySuite.dll" target="lib\net20" />
3131
<file src="Release\v2.0\AnyCPU\NetTopologySuite.pdb" target="lib\net20" />
3232
<file src="Release\v2.0\AnyCPU\NetTopologySuite.xml" target="lib\net20" />
33-
<file src="Release\v2.0\AnyCPU\PowerCollections.dll" target="lib\net20" />
34-
<file src="Release\v2.0\AnyCPU\PowerCollections.pdb" target="lib\net20" />
35-
<file src="Release\v2.0\AnyCPU\PowerCollections.xml" target="lib\net20" />
3633

3734
<file src="Release\v3.5\AnyCPU\NetTopologySuite.dll" target="lib\net35-client" />
3835
<file src="Release\v3.5\AnyCPU\NetTopologySuite.pdb" target="lib\net35-client" />
3936
<file src="Release\v3.5\AnyCPU\NetTopologySuite.xml" target="lib\net35-client" />
40-
<file src="Release\v3.5\AnyCPU\PowerCollections.dll" target="lib\net35-client" />
41-
<file src="Release\v3.5\AnyCPU\PowerCollections.pdb" target="lib\net35-client" />
42-
<file src="Release\v3.5\AnyCPU\PowerCollections.xml" target="lib\net35-client" />
4337

4438
<file src="Release\v4.0\AnyCPU\NetTopologySuite.dll" target="lib\net40-client" />
4539
<file src="Release\v4.0\AnyCPU\NetTopologySuite.pdb" target="lib\net40-client" />
4640
<file src="Release\v4.0\AnyCPU\NetTopologySuite.xml" target="lib\net40-client" />
47-
<file src="Release\v4.0\AnyCPU\PowerCollections.dll" target="lib\net40-client" />
48-
<file src="Release\v4.0\AnyCPU\PowerCollections.pdb" target="lib\net40-client" />
49-
<file src="Release\v4.0\AnyCPU\PowerCollections.xml" target="lib\net40-client" />
5041

5142
<file src="Release\v4.0.3\AnyCPU\NetTopologySuite.dll" target="lib\net403-client" />
5243
<file src="Release\v4.0.3\AnyCPU\NetTopologySuite.pdb" target="lib\net403-client" />
5344
<file src="Release\v4.0.3\AnyCPU\NetTopologySuite.xml" target="lib\net403-client" />
54-
<file src="Release\v4.0.3\AnyCPU\PowerCollections.dll" target="lib\net403-client" />
55-
<file src="Release\v4.0.3\AnyCPU\PowerCollections.pdb" target="lib\net403-client" />
56-
<file src="Release\v4.0.3\AnyCPU\PowerCollections.xml" target="lib\net403-client" />
5745

5846
<file src="Release\v4.5\AnyCPU\NetTopologySuite.dll" target="lib\net45" />
5947
<file src="Release\v4.5\AnyCPU\NetTopologySuite.pdb" target="lib\net45" />
6048
<file src="Release\v4.5\AnyCPU\NetTopologySuite.xml" target="lib\net45" />
61-
<file src="Release\v4.5\AnyCPU\PowerCollections.dll" target="lib\net45" />
62-
<file src="Release\v4.5\AnyCPU\PowerCollections.pdb" target="lib\net45" />
63-
<file src="Release\v4.5\AnyCPU\PowerCollections.xml" target="lib\net45" />
6449

6550
<file src="Release\PCL\AnyCPU\NetTopologySuite.dll" target="lib\portable-net403+sl5+netcore45+wpa81+wp8+MonoAndroid10+XamariniOS10+MonoTouch10" />
6651
<file src="Release\PCL\AnyCPU\NetTopologySuite.pdb" target="lib\portable-net403+sl5+netcore45+wpa81+wp8+MonoAndroid10+XamariniOS10+MonoTouch10" />
6752
<file src="Release\PCL\AnyCPU\NetTopologySuite.xml" target="lib\portable-net403+sl5+netcore45+wpa81+wp8+MonoAndroid10+XamariniOS10+MonoTouch10" />
6853
<file src="Release\PCL\AnyCPU\GeoAPI.Bootstrapper.NetTopologySuite.dll" target="lib\portable-net403+sl5+netcore45+wpa81+wp8+MonoAndroid10+XamariniOS10+MonoTouch10" />
6954
<file src="Release\PCL\AnyCPU\GeoAPI.Bootstrapper.NetTopologySuite.pdb" target="lib\portable-net403+sl5+netcore45+wpa81+wp8+MonoAndroid10+XamariniOS10+MonoTouch10" />
7055
<file src="Release\PCL\AnyCPU\GeoAPI.Bootstrapper.NetTopologySuite.xml" target="lib\portable-net403+sl5+netcore45+wpa81+wp8+MonoAndroid10+XamariniOS10+MonoTouch10" />
71-
<file src="Release\PCL\AnyCPU\PowerCollections.dll" target="lib\portable-net403+sl5+netcore45+wpa81+wp8+MonoAndroid10+XamariniOS10+MonoTouch10" />
72-
<file src="Release\PCL\AnyCPU\PowerCollections.pdb" target="lib\portable-net403+sl5+netcore45+wpa81+wp8+MonoAndroid10+XamariniOS10+MonoTouch10" />
73-
<file src="Release\PCL\AnyCPU\PowerCollections.xml" target="lib\portable-net403+sl5+netcore45+wpa81+wp8+MonoAndroid10+XamariniOS10+MonoTouch10" />
7456
</files>
7557
</package>

NetTopologySuite.IO/NetTopologySuite.IO.GeoTools/Handlers/PolygonHandler.cs

+1-9
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,6 @@
44
using GeoAPI.Geometries;
55
using NetTopologySuite.Algorithm;
66
using NetTopologySuite.Geometries;
7-
/*
8-
#if !NET35
9-
using HS = Wintellect.PowerCollections.Set<int>;
10-
#else
11-
using HS = System.Collections.Generic.HashSet<int>;
12-
#endif
13-
*/
14-
using HS = System.Collections.Generic.HashSet<int>;
157

168
namespace NetTopologySuite.IO.Handlers
179
{
@@ -59,7 +51,7 @@ public override IGeometry Read(BigEndianBinaryReader file, int totalRecordLength
5951
for (var i = 0; i < numParts; i++)
6052
partOffsets[i] = ReadInt32(file, totalRecordLength, ref totalRead);
6153

62-
var skippedList = new HS();
54+
var skippedList = new HashSet<int>();
6355

6456
//var allPoints = new List<Coordinate>();
6557
var buffer = new CoordinateBuffer(numPoints, NoDataBorderValue, true);

NetTopologySuite.IO/NetTopologySuite.IO.GeoTools/Handlers/ShapeHandler.cs

+2-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
#if NET35
55
using System.Linq;
66
#endif
7-
using HS = System.Collections.Generic.HashSet<int>;
87
using GeoAPI.Geometries;
98

109
namespace NetTopologySuite.IO.Handlers
@@ -443,10 +442,10 @@ protected double GetMValue(BigEndianBinaryReader file)
443442
/// <param name="currentlyReadBytes">How many bytes are read from this record</param>
444443
/// <param name="buffer">The coordinate buffer</param>
445444
/// <param name="skippedList">A list of indices which have not been added to the buffer</param>
446-
protected void GetZMValues(BigEndianBinaryReader file, int totalRecordLength, ref int currentlyReadBytes, ICoordinateBuffer buffer, HS skippedList = null)
445+
protected void GetZMValues(BigEndianBinaryReader file, int totalRecordLength, ref int currentlyReadBytes, ICoordinateBuffer buffer, HashSet<int> skippedList = null)
447446
{
448447
if (skippedList == null)
449-
skippedList = new HS();
448+
skippedList = new HashSet<int>();
450449

451450
var numPoints = buffer.Capacity;
452451

NetTopologySuite.IO/NetTopologySuite.IO.GeoTools/NetTopologySuite.IO.GeoTools.csproj

-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
<FileAlignment>512</FileAlignment>
1717
<TargetFrameworkProfile>Client</TargetFrameworkProfile>
1818
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
19-
<NeedsPowerCollections Condition=" '$(NeedsPowerCollections)' == '' ">False</NeedsPowerCollections>
2019
</PropertyGroup>
2120
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
2221
<DebugSymbols>true</DebugSymbols>

NetTopologySuite.Samples.Console/NetTopologySuite.Samples.Console.csproj

-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@
4545
<TargetFrameworkProfile>Client</TargetFrameworkProfile>
4646
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\</SolutionDir>
4747

48-
<NeedsPowerCollections Condition=" '$(NeedsPowerCollections)' == '' ">False</NeedsPowerCollections>
4948
</PropertyGroup>
5049
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
5150
<DebugSymbols>true</DebugSymbols>

NetTopologySuite.Samples.Console/Tests/Various/Issue174TestFixture.cs

-8
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,6 @@ public void ensure_ProjNet_assembly_is_strongly_named()
3232
AssertStronglyNamedAssembly(typeof(Datum));
3333
}
3434

35-
#if !NET35
36-
[Test, Category("Issue174")]
37-
public void ensure_PowerCollections_assembly_is_strongly_named()
38-
{
39-
AssertStronglyNamedAssembly(typeof(Wintellect.PowerCollections.OrderedSet<object>));
40-
}
41-
#endif
42-
4335
[Test, Category("Issue174")]
4436
public void ensure_NetTopologySuite_assembly_is_strongly_named()
4537
{

NetTopologySuite/Index/Strtree/AbstractSTRtree.cs

+1-6
Original file line numberDiff line numberDiff line change
@@ -112,12 +112,7 @@ protected virtual IList<IBoundable<T, TItem>> CreateParentBoundables(IList<IBoun
112112
parentBoundables.Add(CreateNode(newLevel));
113113

114114
// JTS does a stable sort here. List<T>.Sort is not stable.
115-
#if NET35
116-
var sortedChildBoundables = childBoundables.OrderBy(x => x, GetComparer());
117-
#else
118-
var sortedChildBoundables = new List<IBoundable<T, TItem>>(childBoundables);
119-
sortedChildBoundables.Sort(GetComparer());
120-
#endif
115+
var sortedChildBoundables = CollectionUtil.StableSort(childBoundables, GetComparer());
121116

122117
foreach (IBoundable<T, TItem> childBoundable in sortedChildBoundables)
123118
{

NetTopologySuite/NetTopologySuite.csproj

-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@
4545
<UseApplicationTrust>false</UseApplicationTrust>
4646
<BootstrapperEnabled>false</BootstrapperEnabled>
4747
<TargetFrameworkProfile>Client</TargetFrameworkProfile>
48-
<NeedsPowerCollections Condition=" '$(NeedsPowerCollections)' == '' ">False</NeedsPowerCollections>
4948
</PropertyGroup>
5049
<PropertyGroup Condition=" '$(TargetFrameworkVersion)' == 'v2.0' ">
5150
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>

NetTopologySuite/Planargraph/DirectedEdgeStar.cs

+1-6
Original file line numberDiff line numberDiff line change
@@ -98,12 +98,7 @@ private void SortEdges()
9898
if (!_sorted)
9999
{
100100
// JTS does a stable sort here. List<T>.Sort is not stable.
101-
#if NET35
102-
var inSortedOrder = new List<DirectedEdge>(_outEdges.OrderBy(x => x));
103-
#else
104-
var inSortedOrder = new List<DirectedEdge>(_outEdges);
105-
inSortedOrder.Sort(Comparer<DirectedEdge>.Default);
106-
#endif
101+
var inSortedOrder = new List<DirectedEdge>(CollectionUtil.StableSort(_outEdges));
107102
_outEdges.Clear();
108103
_outEdges.AddRange(inSortedOrder);
109104
_sorted = true;

NetTopologySuite/Triangulate/QuadEdge/QuadEdgeSubdivision.cs

+5-8
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@
66
using NetTopologySuite.IO;
77
using NetTopologySuite.Utilities;
88

9-
using HashSetQ = System.Collections.Generic.HashSet<NetTopologySuite.Triangulate.QuadEdge.QuadEdge>;
10-
using HashSetV = System.Collections.Generic.HashSet<NetTopologySuite.Triangulate.QuadEdge.Vertex>;
11-
129
namespace NetTopologySuite.Triangulate.QuadEdge
1310
{
1411
/// <summary>
@@ -494,7 +491,7 @@ public bool IsVertexOfEdge(QuadEdge e, Vertex v)
494491
/// <see cref="GetVertexUniqueEdges"/>
495492
public IEnumerable<Vertex> GetVertices(bool includeFrame)
496493
{
497-
var vertices = new HashSetV();
494+
var vertices = new HashSet<Vertex>();
498495

499496
foreach (var qe in _quadEdges)
500497
{
@@ -536,7 +533,7 @@ public IEnumerable<Vertex> GetVertices(bool includeFrame)
536533
public IList<QuadEdge> GetVertexUniqueEdges(bool includeFrame)
537534
{
538535
var edges = new List<QuadEdge>();
539-
var visitedVertices = new HashSetV();
536+
var visitedVertices = new HashSet<Vertex>();
540537

541538
foreach (var qe in _quadEdges)
542539
{
@@ -587,7 +584,7 @@ public IList<QuadEdge> GetPrimaryEdges(bool includeFrame)
587584
var edgeStack = new Stack<QuadEdge>();
588585
edgeStack.Push(_startingEdge);
589586

590-
var visitedEdges = new HashSetQ();
587+
var visitedEdges = new HashSet<QuadEdge>();
591588

592589
while (edgeStack.Count > 0)
593590
{
@@ -648,7 +645,7 @@ public void VisitTriangles(ITriangleVisitor triVisitor,
648645
var edgeStack = new Stack<QuadEdge>();
649646
edgeStack.Push(_startingEdge);
650647

651-
var visitedEdges = new HashSetQ();
648+
var visitedEdges = new HashSet<QuadEdge>();
652649

653650
while (edgeStack.Count > 0)
654651
{
@@ -683,7 +680,7 @@ public void VisitTriangles(ITriangleVisitor triVisitor,
683680
/// or <value>null</value> if the triangle should not be visited (for instance, if it is outer)
684681
/// </returns>
685682
private QuadEdge[] FetchTriangleToVisit(QuadEdge edge, Stack<QuadEdge> edgeStack, bool includeFrame,
686-
HashSetQ visitedEdges)
683+
HashSet<QuadEdge> visitedEdges)
687684
{
688685
QuadEdge curr = edge;
689686
int edgeCount = 0;

NetTopologySuite/Utilities/CollectionUtil.cs

+76-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
using System.Collections;
22
using System.Collections.Generic;
3+
#if NET35
4+
using System.Linq;
5+
#endif
36
#if PCL
47
using ArrayList = System.Collections.Generic.List<object>;
58
#endif
@@ -12,7 +15,7 @@ namespace NetTopologySuite.Utilities
1215
/// </summary>
1316
public class CollectionUtil
1417
{
15-
18+
1619
/// <summary>
1720
///
1821
/// </summary>
@@ -40,7 +43,7 @@ public class CollectionUtil
4043
public static IList Transform(ICollection coll, FunctionDelegate<object> func)
4144
{
4245
IList result = new ArrayList();
43-
foreach(object obj in coll)
46+
foreach(object obj in coll)
4447
result.Add(func(obj));
4548
return result;
4649
}
@@ -140,10 +143,10 @@ public static void Apply<T>(IEnumerable<T> coll, FunctionDelegate<T> func)
140143
/// <returns></returns>
141144
public static IList Select(ICollection coll, FunctionDelegate<object, bool> func)
142145
{
143-
IList result = new ArrayList();
146+
IList result = new ArrayList();
144147
foreach (object obj in coll)
145148
if (func(obj))
146-
result.Add(obj);
149+
result.Add(obj);
147150
return result;
148151
}
149152

@@ -177,5 +180,74 @@ public static TOut[] Cast<TIn,TOut>(TIn[] array)
177180
return res;
178181
}
179182

183+
internal static IEnumerable<T> StableSort<T>(IEnumerable<T> items)
184+
{
185+
return StableSort(items, Comparer<T>.Default);
186+
}
187+
188+
internal static IEnumerable<T> StableSort<T>(IEnumerable<T> items, IComparer<T> comparer)
189+
{
190+
#if NET35
191+
// LINQ's OrderBy is guaranteed to be a stable sort.
192+
return items.OrderBy(x => x, comparer);
193+
#else
194+
195+
// otherwise, tag each item with the index and sort the wrappers.
196+
// if we're given a collection (and we always are), use its count
197+
// to prevent unnecessary array copies.
198+
var itemCollection = items as ICollection<T>;
199+
var taggedItems = itemCollection == null
200+
? new List<IndexTaggedItem<T>>()
201+
: new List<IndexTaggedItem<T>>(itemCollection.Count);
202+
203+
int index = 0;
204+
foreach (var item in items)
205+
{
206+
taggedItems.Add(new IndexTaggedItem<T>(item, index++));
207+
}
208+
209+
taggedItems.Sort(new IndexAwareComparer<T>(comparer));
210+
211+
var sorted = new List<T>(taggedItems.Count);
212+
foreach (var taggedItem in taggedItems)
213+
{
214+
sorted.Add(taggedItem.Item);
215+
}
216+
217+
return sorted;
218+
#endif
219+
}
220+
221+
#if !NET35
222+
private sealed class IndexTaggedItem<T>
223+
{
224+
internal readonly T Item;
225+
internal readonly int Index;
226+
227+
internal IndexTaggedItem(T item, int index)
228+
{
229+
this.Item = item;
230+
this.Index = index;
231+
}
232+
}
233+
234+
private sealed class IndexAwareComparer<T> : Comparer<IndexTaggedItem<T>>
235+
{
236+
private readonly IComparer<T> primaryComparer;
237+
238+
internal IndexAwareComparer(IComparer<T> primaryComparer)
239+
{
240+
this.primaryComparer = primaryComparer;
241+
}
242+
243+
public override int Compare(IndexTaggedItem<T> x, IndexTaggedItem<T> y)
244+
{
245+
int cmp = this.primaryComparer.Compare(x.Item, y.Item);
246+
247+
// compare equal elements by their index.
248+
return cmp == 0 ? x.Index.CompareTo(y.Index) : cmp;
249+
}
250+
}
251+
#endif
180252
}
181253
}

Sandcastle/NetTopologySuite.shfbproj

-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
<DocumentationSource sourceFile="..\GeoAPI\GeoAPI\GeoAPI.csproj" configuration="Release" platform="AnyCPU" />
2525
<DocumentationSource sourceFile="..\NetTopologySuite\Geometries\Geometries.xml" />
2626
<DocumentationSource sourceFile="..\NetTopologySuite\NetTopologySuite.csproj" configuration="Release" platform="AnyCPU" />
27-
<DocumentationSource sourceFile="..\PowerCollections\PowerCollections\PowerCollections.csproj" configuration="Release" platform="AnyCPU" />
2827
<DocumentationSource sourceFile="..\NetTopologySuite\Triangulate\QuadEdge\QuadEdgeSummary.xml" />
2928
<DocumentationSource sourceFile="..\NetTopologySuite\Triangulate\TriangulateSummary.xml" />
3029
</DocumentationSources>

0 commit comments

Comments
 (0)