Skip to content

Commit

Permalink
Merge branch 'RevSnipplets' of https://github.com/NetTopologySuite/Ne…
Browse files Browse the repository at this point in the history
…tTopologySuite into RevSnipplets

# Conflicts:
#	NetTopologySuite.IO/NetTopologySuite.IO.GeoTools/NetTopologySuite.IO.GeoTools.csproj
#	NetTopologySuite.Samples.Console/NetTopologySuite.Samples.Console.csproj
#	NetTopologySuite/NetTopologySuite.csproj
  • Loading branch information
FObermaier committed Feb 1, 2016
2 parents 4daec36 + 0cbb7f6 commit 4251efc
Show file tree
Hide file tree
Showing 13 changed files with 92 additions and 72 deletions.
20 changes: 1 addition & 19 deletions NTS.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<requireLicenseAcceptance>true</requireLicenseAcceptance>
<description>
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.
This package contains Wintellect's PowerCollections and references GeoAPI.
This package references GeoAPI.
</description>
<summary>NTS Topology Suite is a direct-port of all the functionalities offered by JTS Topology Suite</summary>
<tags>NTS Topology OGC SFS</tags>
Expand All @@ -30,46 +30,28 @@
<file src="Release\v2.0\AnyCPU\NetTopologySuite.dll" target="lib\net20" />
<file src="Release\v2.0\AnyCPU\NetTopologySuite.pdb" target="lib\net20" />
<file src="Release\v2.0\AnyCPU\NetTopologySuite.xml" target="lib\net20" />
<file src="Release\v2.0\AnyCPU\PowerCollections.dll" target="lib\net20" />
<file src="Release\v2.0\AnyCPU\PowerCollections.pdb" target="lib\net20" />
<file src="Release\v2.0\AnyCPU\PowerCollections.xml" target="lib\net20" />

<file src="Release\v3.5\AnyCPU\NetTopologySuite.dll" target="lib\net35-client" />
<file src="Release\v3.5\AnyCPU\NetTopologySuite.pdb" target="lib\net35-client" />
<file src="Release\v3.5\AnyCPU\NetTopologySuite.xml" target="lib\net35-client" />
<file src="Release\v3.5\AnyCPU\PowerCollections.dll" target="lib\net35-client" />
<file src="Release\v3.5\AnyCPU\PowerCollections.pdb" target="lib\net35-client" />
<file src="Release\v3.5\AnyCPU\PowerCollections.xml" target="lib\net35-client" />

<file src="Release\v4.0\AnyCPU\NetTopologySuite.dll" target="lib\net40-client" />
<file src="Release\v4.0\AnyCPU\NetTopologySuite.pdb" target="lib\net40-client" />
<file src="Release\v4.0\AnyCPU\NetTopologySuite.xml" target="lib\net40-client" />
<file src="Release\v4.0\AnyCPU\PowerCollections.dll" target="lib\net40-client" />
<file src="Release\v4.0\AnyCPU\PowerCollections.pdb" target="lib\net40-client" />
<file src="Release\v4.0\AnyCPU\PowerCollections.xml" target="lib\net40-client" />

<file src="Release\v4.0.3\AnyCPU\NetTopologySuite.dll" target="lib\net403-client" />
<file src="Release\v4.0.3\AnyCPU\NetTopologySuite.pdb" target="lib\net403-client" />
<file src="Release\v4.0.3\AnyCPU\NetTopologySuite.xml" target="lib\net403-client" />
<file src="Release\v4.0.3\AnyCPU\PowerCollections.dll" target="lib\net403-client" />
<file src="Release\v4.0.3\AnyCPU\PowerCollections.pdb" target="lib\net403-client" />
<file src="Release\v4.0.3\AnyCPU\PowerCollections.xml" target="lib\net403-client" />

<file src="Release\v4.5\AnyCPU\NetTopologySuite.dll" target="lib\net45" />
<file src="Release\v4.5\AnyCPU\NetTopologySuite.pdb" target="lib\net45" />
<file src="Release\v4.5\AnyCPU\NetTopologySuite.xml" target="lib\net45" />
<file src="Release\v4.5\AnyCPU\PowerCollections.dll" target="lib\net45" />
<file src="Release\v4.5\AnyCPU\PowerCollections.pdb" target="lib\net45" />
<file src="Release\v4.5\AnyCPU\PowerCollections.xml" target="lib\net45" />

<file src="Release\PCL\AnyCPU\NetTopologySuite.dll" target="lib\portable-net403+sl5+netcore45+wpa81+wp8+MonoAndroid10+XamariniOS10+MonoTouch10" />
<file src="Release\PCL\AnyCPU\NetTopologySuite.pdb" target="lib\portable-net403+sl5+netcore45+wpa81+wp8+MonoAndroid10+XamariniOS10+MonoTouch10" />
<file src="Release\PCL\AnyCPU\NetTopologySuite.xml" target="lib\portable-net403+sl5+netcore45+wpa81+wp8+MonoAndroid10+XamariniOS10+MonoTouch10" />
<file src="Release\PCL\AnyCPU\GeoAPI.Bootstrapper.NetTopologySuite.dll" target="lib\portable-net403+sl5+netcore45+wpa81+wp8+MonoAndroid10+XamariniOS10+MonoTouch10" />
<file src="Release\PCL\AnyCPU\GeoAPI.Bootstrapper.NetTopologySuite.pdb" target="lib\portable-net403+sl5+netcore45+wpa81+wp8+MonoAndroid10+XamariniOS10+MonoTouch10" />
<file src="Release\PCL\AnyCPU\GeoAPI.Bootstrapper.NetTopologySuite.xml" target="lib\portable-net403+sl5+netcore45+wpa81+wp8+MonoAndroid10+XamariniOS10+MonoTouch10" />
<file src="Release\PCL\AnyCPU\PowerCollections.dll" target="lib\portable-net403+sl5+netcore45+wpa81+wp8+MonoAndroid10+XamariniOS10+MonoTouch10" />
<file src="Release\PCL\AnyCPU\PowerCollections.pdb" target="lib\portable-net403+sl5+netcore45+wpa81+wp8+MonoAndroid10+XamariniOS10+MonoTouch10" />
<file src="Release\PCL\AnyCPU\PowerCollections.xml" target="lib\portable-net403+sl5+netcore45+wpa81+wp8+MonoAndroid10+XamariniOS10+MonoTouch10" />
</files>
</package>
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,6 @@
using GeoAPI.Geometries;
using NetTopologySuite.Algorithm;
using NetTopologySuite.Geometries;
/*
#if !NET35
using HS = Wintellect.PowerCollections.Set<int>;
#else
using HS = System.Collections.Generic.HashSet<int>;
#endif
*/
using HS = System.Collections.Generic.HashSet<int>;

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

var skippedList = new HS();
var skippedList = new HashSet<int>();

//var allPoints = new List<Coordinate>();
var buffer = new CoordinateBuffer(numPoints, NoDataBorderValue, true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
#if NET35
using System.Linq;
#endif
using HS = System.Collections.Generic.HashSet<int>;
using GeoAPI.Geometries;

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

var numPoints = buffer.Capacity;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile>Client</TargetFrameworkProfile>
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
<NeedsPowerCollections Condition=" '$(NeedsPowerCollections)' == '' ">False</NeedsPowerCollections>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@
<TargetFrameworkProfile>Client</TargetFrameworkProfile>
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\</SolutionDir>

<NeedsPowerCollections Condition=" '$(NeedsPowerCollections)' == '' ">False</NeedsPowerCollections>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,6 @@ public void ensure_ProjNet_assembly_is_strongly_named()
AssertStronglyNamedAssembly(typeof(Datum));
}

#if !NET35
[Test, Category("Issue174")]
public void ensure_PowerCollections_assembly_is_strongly_named()
{
AssertStronglyNamedAssembly(typeof(Wintellect.PowerCollections.OrderedSet<object>));
}
#endif

[Test, Category("Issue174")]
public void ensure_NetTopologySuite_assembly_is_strongly_named()
{
Expand Down
7 changes: 1 addition & 6 deletions NetTopologySuite/Index/Strtree/AbstractSTRtree.cs
Original file line number Diff line number Diff line change
Expand Up @@ -112,12 +112,7 @@ protected virtual IList<IBoundable<T, TItem>> CreateParentBoundables(IList<IBoun
parentBoundables.Add(CreateNode(newLevel));

// JTS does a stable sort here. List<T>.Sort is not stable.
#if NET35
var sortedChildBoundables = childBoundables.OrderBy(x => x, GetComparer());
#else
var sortedChildBoundables = new List<IBoundable<T, TItem>>(childBoundables);
sortedChildBoundables.Sort(GetComparer());
#endif
var sortedChildBoundables = CollectionUtil.StableSort(childBoundables, GetComparer());

foreach (IBoundable<T, TItem> childBoundable in sortedChildBoundables)
{
Expand Down
1 change: 0 additions & 1 deletion NetTopologySuite/NetTopologySuite.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@
<UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>false</BootstrapperEnabled>
<TargetFrameworkProfile>Client</TargetFrameworkProfile>
<NeedsPowerCollections Condition=" '$(NeedsPowerCollections)' == '' ">False</NeedsPowerCollections>
</PropertyGroup>
<PropertyGroup Condition=" '$(TargetFrameworkVersion)' == 'v2.0' ">
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
Expand Down
7 changes: 1 addition & 6 deletions NetTopologySuite/Planargraph/DirectedEdgeStar.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,7 @@ private void SortEdges()
if (!_sorted)
{
// JTS does a stable sort here. List<T>.Sort is not stable.
#if NET35
var inSortedOrder = new List<DirectedEdge>(_outEdges.OrderBy(x => x));
#else
var inSortedOrder = new List<DirectedEdge>(_outEdges);
inSortedOrder.Sort(Comparer<DirectedEdge>.Default);
#endif
var inSortedOrder = new List<DirectedEdge>(CollectionUtil.StableSort(_outEdges));
_outEdges.Clear();
_outEdges.AddRange(inSortedOrder);
_sorted = true;
Expand Down
13 changes: 5 additions & 8 deletions NetTopologySuite/Triangulate/QuadEdge/QuadEdgeSubdivision.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@
using NetTopologySuite.IO;
using NetTopologySuite.Utilities;

using HashSetQ = System.Collections.Generic.HashSet<NetTopologySuite.Triangulate.QuadEdge.QuadEdge>;
using HashSetV = System.Collections.Generic.HashSet<NetTopologySuite.Triangulate.QuadEdge.Vertex>;

namespace NetTopologySuite.Triangulate.QuadEdge
{
/// <summary>
Expand Down Expand Up @@ -494,7 +491,7 @@ public bool IsVertexOfEdge(QuadEdge e, Vertex v)
/// <see cref="GetVertexUniqueEdges"/>
public IEnumerable<Vertex> GetVertices(bool includeFrame)
{
var vertices = new HashSetV();
var vertices = new HashSet<Vertex>();

foreach (var qe in _quadEdges)
{
Expand Down Expand Up @@ -536,7 +533,7 @@ public IEnumerable<Vertex> GetVertices(bool includeFrame)
public IList<QuadEdge> GetVertexUniqueEdges(bool includeFrame)
{
var edges = new List<QuadEdge>();
var visitedVertices = new HashSetV();
var visitedVertices = new HashSet<Vertex>();

foreach (var qe in _quadEdges)
{
Expand Down Expand Up @@ -587,7 +584,7 @@ public IList<QuadEdge> GetPrimaryEdges(bool includeFrame)
var edgeStack = new Stack<QuadEdge>();
edgeStack.Push(_startingEdge);

var visitedEdges = new HashSetQ();
var visitedEdges = new HashSet<QuadEdge>();

while (edgeStack.Count > 0)
{
Expand Down Expand Up @@ -648,7 +645,7 @@ public void VisitTriangles(ITriangleVisitor triVisitor,
var edgeStack = new Stack<QuadEdge>();
edgeStack.Push(_startingEdge);

var visitedEdges = new HashSetQ();
var visitedEdges = new HashSet<QuadEdge>();

while (edgeStack.Count > 0)
{
Expand Down Expand Up @@ -683,7 +680,7 @@ public void VisitTriangles(ITriangleVisitor triVisitor,
/// or <value>null</value> if the triangle should not be visited (for instance, if it is outer)
/// </returns>
private QuadEdge[] FetchTriangleToVisit(QuadEdge edge, Stack<QuadEdge> edgeStack, bool includeFrame,
HashSetQ visitedEdges)
HashSet<QuadEdge> visitedEdges)
{
QuadEdge curr = edge;
int edgeCount = 0;
Expand Down
80 changes: 76 additions & 4 deletions NetTopologySuite/Utilities/CollectionUtil.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
using System.Collections;
using System.Collections.Generic;
#if NET35
using System.Linq;
#endif
#if PCL
using ArrayList = System.Collections.Generic.List<object>;
#endif
Expand All @@ -12,7 +15,7 @@ namespace NetTopologySuite.Utilities
/// </summary>
public class CollectionUtil
{

/// <summary>
///
/// </summary>
Expand Down Expand Up @@ -40,7 +43,7 @@ public class CollectionUtil
public static IList Transform(ICollection coll, FunctionDelegate<object> func)
{
IList result = new ArrayList();
foreach(object obj in coll)
foreach(object obj in coll)
result.Add(func(obj));
return result;
}
Expand Down Expand Up @@ -140,10 +143,10 @@ public static void Apply<T>(IEnumerable<T> coll, FunctionDelegate<T> func)
/// <returns></returns>
public static IList Select(ICollection coll, FunctionDelegate<object, bool> func)
{
IList result = new ArrayList();
IList result = new ArrayList();
foreach (object obj in coll)
if (func(obj))
result.Add(obj);
result.Add(obj);
return result;
}

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

internal static IEnumerable<T> StableSort<T>(IEnumerable<T> items)
{
return StableSort(items, Comparer<T>.Default);
}

internal static IEnumerable<T> StableSort<T>(IEnumerable<T> items, IComparer<T> comparer)
{
#if NET35
// LINQ's OrderBy is guaranteed to be a stable sort.
return items.OrderBy(x => x, comparer);
#else

// otherwise, tag each item with the index and sort the wrappers.
// if we're given a collection (and we always are), use its count
// to prevent unnecessary array copies.
var itemCollection = items as ICollection<T>;
var taggedItems = itemCollection == null
? new List<IndexTaggedItem<T>>()
: new List<IndexTaggedItem<T>>(itemCollection.Count);

int index = 0;
foreach (var item in items)
{
taggedItems.Add(new IndexTaggedItem<T>(item, index++));
}

taggedItems.Sort(new IndexAwareComparer<T>(comparer));

var sorted = new List<T>(taggedItems.Count);
foreach (var taggedItem in taggedItems)
{
sorted.Add(taggedItem.Item);
}

return sorted;
#endif
}

#if !NET35
private sealed class IndexTaggedItem<T>
{
internal readonly T Item;
internal readonly int Index;

internal IndexTaggedItem(T item, int index)
{
this.Item = item;
this.Index = index;
}
}

private sealed class IndexAwareComparer<T> : Comparer<IndexTaggedItem<T>>
{
private readonly IComparer<T> primaryComparer;

internal IndexAwareComparer(IComparer<T> primaryComparer)
{
this.primaryComparer = primaryComparer;
}

public override int Compare(IndexTaggedItem<T> x, IndexTaggedItem<T> y)
{
int cmp = this.primaryComparer.Compare(x.Item, y.Item);

// compare equal elements by their index.
return cmp == 0 ? x.Index.CompareTo(y.Index) : cmp;
}
}
#endif
}
}
1 change: 0 additions & 1 deletion Sandcastle/NetTopologySuite.shfbproj
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
<DocumentationSource sourceFile="..\GeoAPI\GeoAPI\GeoAPI.csproj" configuration="Release" platform="AnyCPU" />
<DocumentationSource sourceFile="..\NetTopologySuite\Geometries\Geometries.xml" />
<DocumentationSource sourceFile="..\NetTopologySuite\NetTopologySuite.csproj" configuration="Release" platform="AnyCPU" />
<DocumentationSource sourceFile="..\PowerCollections\PowerCollections\PowerCollections.csproj" configuration="Release" platform="AnyCPU" />
<DocumentationSource sourceFile="..\NetTopologySuite\Triangulate\QuadEdge\QuadEdgeSummary.xml" />
<DocumentationSource sourceFile="..\NetTopologySuite\Triangulate\TriangulateSummary.xml" />
</DocumentationSources>
Expand Down
Loading

0 comments on commit 4251efc

Please sign in to comment.