diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..1ff0c42 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,63 @@ +############################################################################### +# Set default behavior to automatically normalize line endings. +############################################################################### +* text=auto + +############################################################################### +# Set default behavior for command prompt diff. +# +# This is need for earlier builds of msysgit that does not have it on by +# default for csharp files. +# Note: This is only used by command line +############################################################################### +#*.cs diff=csharp + +############################################################################### +# Set the merge driver for project and solution files +# +# Merging from the command prompt will add diff markers to the files if there +# are conflicts (Merging from VS is not affected by the settings below, in VS +# the diff markers are never inserted). Diff markers may cause the following +# file extensions to fail to load in VS. An alternative would be to treat +# these files as binary and thus will always conflict and require user +# intervention with every merge. To do so, just uncomment the entries below +############################################################################### +#*.sln merge=binary +#*.csproj merge=binary +#*.vbproj merge=binary +#*.vcxproj merge=binary +#*.vcproj merge=binary +#*.dbproj merge=binary +#*.fsproj merge=binary +#*.lsproj merge=binary +#*.wixproj merge=binary +#*.modelproj merge=binary +#*.sqlproj merge=binary +#*.wwaproj merge=binary + +############################################################################### +# behavior for image files +# +# image files are treated as binary by default. +############################################################################### +#*.jpg binary +#*.png binary +#*.gif binary + +############################################################################### +# diff behavior for common document formats +# +# Convert binary document formats to text before diffing them. This feature +# is only available from the command line. Turn it on by uncommenting the +# entries below. +############################################################################### +#*.doc diff=astextplain +#*.DOC diff=astextplain +#*.docx diff=astextplain +#*.DOCX diff=astextplain +#*.dot diff=astextplain +#*.DOT diff=astextplain +#*.pdf diff=astextplain +#*.PDF diff=astextplain +#*.rtf diff=astextplain +#*.RTF diff=astextplain diff --git a/Directory.Build.props b/Directory.Build.props new file mode 100644 index 0000000..d2277af --- /dev/null +++ b/Directory.Build.props @@ -0,0 +1,5 @@ + + + + + diff --git a/SbnSharp.sln b/SbnSharp.sln index 5824a2f..e69de29 100644 --- a/SbnSharp.sln +++ b/SbnSharp.sln @@ -1,57 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 15 -VisualStudioVersion = 15.0.28010.2016 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Spec", "Spec", "{B0E9CDB7-0722-40CB-A2C5-3544EB1B2863}" - ProjectSection(SolutionItems) = preProject - Spec\sbn_format.pdf = Spec\sbn_format.pdf - Spec\sbx_format.pdf = Spec\sbx_format.pdf - EndProjectSection -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Build", "Build", "{BDE9A125-7B3D-42E1-B519-0637568A1423}" - ProjectSection(SolutionItems) = preProject - SharpSbn.GeoAPI.nuspec = SharpSbn.GeoAPI.nuspec - SharpSbn.GeoAPI.targets = SharpSbn.GeoAPI.targets - SharpSbn.nuspec = SharpSbn.nuspec - SharpSbn.targets = SharpSbn.targets - EndProjectSection -EndProject -Project("{888888A0-9F3D-457C-B088-3A5042F75D52}") = "hasbeen", "hasbeen.pyproj", "{86B250BB-F515-45E8-93BD-15810BC4CF49}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SharpSbn", "SharpSbn\SharpSbn.csproj", "{E28F8461-D075-4DA6-8FBB-4DDE75D1E396}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SharpSbn.Test", "test\SharpSbn.Test.csproj", "{C05CE679-851D-4542-98B9-051A7F46F2BF}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - ReleaseGeoAPI|Any CPU = ReleaseGeoAPI|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {86B250BB-F515-45E8-93BD-15810BC4CF49}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {86B250BB-F515-45E8-93BD-15810BC4CF49}.Release|Any CPU.ActiveCfg = Release|Any CPU - {86B250BB-F515-45E8-93BD-15810BC4CF49}.ReleaseGeoAPI|Any CPU.ActiveCfg = Release|Any CPU - {E28F8461-D075-4DA6-8FBB-4DDE75D1E396}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {E28F8461-D075-4DA6-8FBB-4DDE75D1E396}.Debug|Any CPU.Build.0 = Debug|Any CPU - {E28F8461-D075-4DA6-8FBB-4DDE75D1E396}.Release|Any CPU.ActiveCfg = Release|Any CPU - {E28F8461-D075-4DA6-8FBB-4DDE75D1E396}.Release|Any CPU.Build.0 = Release|Any CPU - {E28F8461-D075-4DA6-8FBB-4DDE75D1E396}.ReleaseGeoAPI|Any CPU.ActiveCfg = ReleaseGeoAPI|Any CPU - {E28F8461-D075-4DA6-8FBB-4DDE75D1E396}.ReleaseGeoAPI|Any CPU.Build.0 = ReleaseGeoAPI|Any CPU - {C05CE679-851D-4542-98B9-051A7F46F2BF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {C05CE679-851D-4542-98B9-051A7F46F2BF}.Debug|Any CPU.Build.0 = Debug|Any CPU - {C05CE679-851D-4542-98B9-051A7F46F2BF}.Release|Any CPU.ActiveCfg = Release|Any CPU - {C05CE679-851D-4542-98B9-051A7F46F2BF}.Release|Any CPU.Build.0 = Release|Any CPU - {C05CE679-851D-4542-98B9-051A7F46F2BF}.ReleaseGeoAPI|Any CPU.ActiveCfg = Release|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {5B679E3C-8F5E-4577-BA97-18925AB34CBC} - EndGlobalSection - GlobalSection(NDepend) = preSolution - Project = "" - EndGlobalSection -EndGlobal diff --git a/SharpSbn.Common.props b/SharpSbn.Common.props new file mode 100644 index 0000000..3c22d80 --- /dev/null +++ b/SharpSbn.Common.props @@ -0,0 +1,24 @@ + + + + .NETFramework + Client + v4.0 + + + + $(SolutionDir)$(Configuration)\$(Platform) + 1.2.0 + true + Copyright (c) Felix Obermaier 2013-2018 + Felix Obermaier + + git + https://github.com/fobermaier/SbnSharp.git + + https://raw.githubusercontent.com/FObermaier/SbnSharp/master/LICENSE.txt + https://github.com/fobermaier/SbnSharp + SharpSbn + + + diff --git a/SharpSbn.GeoAPI/SharpSbn.GeoAPI.csproj b/SharpSbn.GeoAPI/SharpSbn.GeoAPI.csproj new file mode 100644 index 0000000..9279271 --- /dev/null +++ b/SharpSbn.GeoAPI/SharpSbn.GeoAPI.csproj @@ -0,0 +1,47 @@ + + + + + + + net40-client;netstandard1.3 + SharpSbn.GeoAPI + SharpSbn.GeoAPI + SharpSbn.GeoAPI + $(OutputPath)\$(TargetFramework)\$(AssemblyName).xml + + + + $(BaseIntermediateOutputPath)$(Configuration)\ + + + + TRACE;UseGeoAPI + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/SharpSbn.sln b/SharpSbn.sln new file mode 100644 index 0000000..d8af33e --- /dev/null +++ b/SharpSbn.sln @@ -0,0 +1,52 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +VisualStudioVersion = 15.0.28010.2016 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Common", "Common", "{7B7C8ABC-15AF-45AE-A589-84EE4D5ECFE6}" + ProjectSection(SolutionItems) = preProject + SharpSbn.Common.props = SharpSbn.Common.props + EndProjectSection +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Spec", "Spec", "{ABB16554-3F14-4E7E-A1A7-FC72FF3DF9D8}" + ProjectSection(SolutionItems) = preProject + Spec\sbn_format.pdf = Spec\sbn_format.pdf + Spec\sbx_format.pdf = Spec\sbx_format.pdf + EndProjectSection +EndProject +Project("{888888A0-9F3D-457C-B088-3A5042F75D52}") = "hasbeen", "hasbeen.pyproj", "{86B250BB-F515-45E8-93BD-15810BC4CF49}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SharpSbn", "SharpSbn\SharpSbn.csproj", "{E3304F5C-2C53-497D-B621-847F9D007D67}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SharpSbn.Test", "test\SharpSbn.Test.csproj", "{C05CE679-851D-4542-98B9-051A7F46F2BF}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SharpSbn.GeoAPI", "SharpSbn.GeoAPI\SharpSbn.GeoAPI.csproj", "{33887FA2-09CE-4920-BC95-0DAEB00CCD20}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {86B250BB-F515-45E8-93BD-15810BC4CF49}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {86B250BB-F515-45E8-93BD-15810BC4CF49}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E3304F5C-2C53-497D-B621-847F9D007D67}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E3304F5C-2C53-497D-B621-847F9D007D67}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E3304F5C-2C53-497D-B621-847F9D007D67}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E3304F5C-2C53-497D-B621-847F9D007D67}.Release|Any CPU.Build.0 = Release|Any CPU + {C05CE679-851D-4542-98B9-051A7F46F2BF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C05CE679-851D-4542-98B9-051A7F46F2BF}.Debug|Any CPU.Build.0 = Debug|Any CPU + {C05CE679-851D-4542-98B9-051A7F46F2BF}.Release|Any CPU.ActiveCfg = Release|Any CPU + {C05CE679-851D-4542-98B9-051A7F46F2BF}.Release|Any CPU.Build.0 = Release|Any CPU + {33887FA2-09CE-4920-BC95-0DAEB00CCD20}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {33887FA2-09CE-4920-BC95-0DAEB00CCD20}.Debug|Any CPU.Build.0 = Debug|Any CPU + {33887FA2-09CE-4920-BC95-0DAEB00CCD20}.Release|Any CPU.ActiveCfg = Release|Any CPU + {33887FA2-09CE-4920-BC95-0DAEB00CCD20}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {5E479A7C-2A17-43FA-83B7-55BB991EC3EE} + EndGlobalSection +EndGlobal diff --git a/SharpSbn/FrameworkReplacements.cs b/SharpSbn/FrameworkReplacements.cs deleted file mode 100644 index 8583e9b..0000000 --- a/SharpSbn/FrameworkReplacements.cs +++ /dev/null @@ -1,77 +0,0 @@ -using System; -using System.Collections.Generic; - - -// ReSharper disable once CheckNamespace -namespace FrameworkReplacements -{ -#if !(NET40 || NET45) - /// - /// A framework replacement for System.Tuple<T1, T2>. - /// - /// The type of the first item - /// The type of the second item - public class Tuple - { - /// - /// Gets or sets a value indicating the first item - /// - public T1 Item1 { get; set; } - /// - /// Gets or sets a value indicating the second item - /// - public T2 Item2 { get; set; } - } - - /// - /// A utility class to create items. - /// - public static class Tuple - { - /// - /// A Factory method to create items. - /// - /// The type of the first item - /// The type of the second item - /// The first item - /// The second item - /// - public static Tuple Create(T1 item1, T2 item2) - { - return new Tuple {Item1 = item1, Item2 = item2}; - } - } -#endif - - namespace Linq - { - internal static class Enumerable - { -#if !(NET40 || NET45) - public static IEnumerable Skip(IEnumerable items, int count) - { - var i = 0; - foreach (var item in items) - { - if (i >= count) - yield return item; - i++; - } - } -#endif - internal static IEnumerable GetRange(IList list, int start, int count) - { - for (var i = 0; i < count; i++) - yield return list[start + i]; - } - - internal static T[] GetRange(T[] list, int start, int count) - { - var res = new T[count]; - Array.Copy(list, start, res, 0, count); - return res; - } - } - } -} - diff --git a/SharpSbn/Properties/AssemblyInfo.cs b/SharpSbn/Properties/AssemblyInfo.cs index 16da903..a8aa88f 100644 --- a/SharpSbn/Properties/AssemblyInfo.cs +++ b/SharpSbn/Properties/AssemblyInfo.cs @@ -1,42 +1 @@ -using System; -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// Allgemeine Informationen über eine Assembly werden über die folgenden -// Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern, -// die mit einer Assembly verknüpft sind. -[assembly: AssemblyTitle("SharpSbn")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("SharpSbn")] -[assembly: AssemblyCopyright("Copyright © Felix Obermaier 2013-2015")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -#if !PCL -// Durch Festlegen von ComVisible auf "false" werden die Typen in dieser Assembly unsichtbar -// für COM-Komponenten. Wenn Sie auf einen Typ in dieser Assembly von -// COM zugreifen müssen, legen Sie das ComVisible-Attribut für diesen Typ auf "true" fest. -[assembly: ComVisible(false)] -// Die folgende GUID bestimmt die ID der Typbibliothek, wenn dieses Projekt für COM verfügbar gemacht wird -[assembly: Guid("82daf214-e442-4608-8d60-cfb7d0f15a95")] -#endif - -// Versionsinformationen für eine Assembly bestehen aus den folgenden vier Werten: -// -// Hauptversion -// Nebenversion -// Buildnummer -// Revision -// -// Sie können alle Werte angeben oder die standardmäßigen Build- und Revisionsnummern -// übernehmen, indem Sie "*" eingeben: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.1.0.0")] -[assembly: AssemblyFileVersion("1.1.0.0")] -[assembly: InternalsVisibleTo("SharpSbn.Test")] -#if !PCL -[assembly: CLSCompliant(true)] -#endif \ No newline at end of file +[assembly: System.Runtime.CompilerServices.InternalsVisibleTo("SharpSbn.Test")] \ No newline at end of file diff --git a/SharpSbn/SbnException.cs b/SharpSbn/SbnException.cs index 09675f9..b70cb0c 100644 --- a/SharpSbn/SbnException.cs +++ b/SharpSbn/SbnException.cs @@ -1,12 +1,14 @@ using System; +#if !NETSTANDARD using System.Runtime.Serialization; +#endif namespace SharpSbn { /// /// Exception for all related exceptions /// -#if !PCL +#if !(NETSTANDARD || PCL) [Serializable] #endif public class SbnException : Exception @@ -29,7 +31,7 @@ public SbnException(string message, Exception innerException) : base(message, innerException) { } -#if !PCL +#if !(NETSTANDARD || PCL) /// /// Creates an instance of this class /// diff --git a/SharpSbn/SbnFeature.cs b/SharpSbn/SbnFeature.cs index efd92fb..8a6b323 100644 --- a/SharpSbn/SbnFeature.cs +++ b/SharpSbn/SbnFeature.cs @@ -102,7 +102,6 @@ internal bool Intersects(byte minX, byte maxX, byte minY, byte maxY) /// /// Gets the id of this feature /// - [CLSCompliant(false)] public uint Fid { get { return _fid; } } /// diff --git a/SharpSbn/SbnTree.cs b/SharpSbn/SbnTree.cs index fc5d1e4..bc8d068 100644 --- a/SharpSbn/SbnTree.cs +++ b/SharpSbn/SbnTree.cs @@ -2,23 +2,7 @@ using System.Collections.Generic; using System.Diagnostics; using System.IO; -//#if !(NET40 || NET45 || PCL) -//using FrameworkReplacemets; -//#if !NET35 -//using FrameworkReplacemets.Linq; -//#endif -//using Enumerable = System.Linq.Enumerable; -//#else -//using System.Linq; -//#endif -#if !NET35 -using Enumerable = FrameworkReplacements.Linq.Enumerable; -#else using Enumerable = System.Linq.Enumerable; -#endif -#if !(NET40 || NET45 || PCL) -using FrameworkReplacements; -#endif #if UseGeoAPI using Interval = GeoAPI.DataStructures.Interval; using GeoAPI.Geometries; @@ -27,7 +11,6 @@ using Envelope = SharpSbn.DataStructures.Envelope; #endif using System.Threading; -using SbnEnumerable = FrameworkReplacements.Linq.Enumerable; namespace SharpSbn { @@ -299,7 +282,6 @@ protected virtual void OnRebuildRequired(SbnTreeRebuildRequiredEventArgs e) /// /// The feature's id /// The feature's geometry - [CLSCompliant(false)] public void Insert(uint fid, GeoAPI.Geometries.IGeometry geometry) { Interval x, y, z, m; @@ -735,7 +717,7 @@ public int FeaturesInLevel(int level) var start = (int)Math.Pow(2, level - 1); var end = 2 * start - 1; var featureCount = 0; - foreach (var n in SbnEnumerable.GetRange(Nodes, start, end - start + 1)) + foreach (var n in NumPySlicing.GetRange(Nodes, start, end - start + 1)) featureCount += n.FeatureCount; return featureCount; } @@ -751,9 +733,9 @@ public void DescribeTree(TextWriter @out) throw new ArgumentNullException("out"); @out.WriteLine("#Description"); - @out.WriteLine("# f=full [0, 1]"); - @out.WriteLine("# sf=features on seam"); - @out.WriteLine("# h=holdfeatures"); + @out.WriteLine("# f=full [0, 1]"); + @out.WriteLine("# sf=features on seam"); + @out.WriteLine("# h=holdfeatures"); @out.WriteLine("#level node f sf h"); for (var i = 1; i <= NumLevels; i++) { @@ -940,14 +922,14 @@ private void CompactSeamFeatures() foreach (var node in NumPySlicing.GetRange(Nodes, start, end, -1)) { var id = node.Nid; - var children = SbnEnumerable.GetRange(Nodes, id * 2, 2); + var children = NumPySlicing.GetRange(Nodes, id * 2, 2); foreach (var child in children) { // There are no items to pull up if (child.FeatureCount == 0) continue; var cid = child.Nid; - var grandchildren = SbnEnumerable.GetRange(Nodes, cid * 2, 2); + var grandchildren = NumPySlicing.GetRange(Nodes, cid * 2, 2); var gccount = 0; foreach (var gcnode in grandchildren) gccount += gcnode.FeatureCount; diff --git a/SharpSbn/SbnTreeRebuildRequiredEventArgs.cs b/SharpSbn/SbnTreeRebuildRequiredEventArgs.cs index 1927fa0..e3e895a 100644 --- a/SharpSbn/SbnTreeRebuildRequiredEventArgs.cs +++ b/SharpSbn/SbnTreeRebuildRequiredEventArgs.cs @@ -33,7 +33,6 @@ public SbnTreeRebuildRequiredEventArgs(uint fid, Envelope geometry, Interval? zR /// /// The feature's id /// - [CLSCompliant(false)] public uint Fid { get; private set; } /// diff --git a/SharpSbn/SharpSbn.csproj b/SharpSbn/SharpSbn.csproj index 2be0ebc..89cbf03 100644 --- a/SharpSbn/SharpSbn.csproj +++ b/SharpSbn/SharpSbn.csproj @@ -1,107 +1,17 @@ - - - + + + + - Debug - ..\ - AnyCPU - {E28F8461-D075-4DA6-8FBB-4DDE75D1E396} - Library - Properties - SharpSbn + net40-client;netstandard1.3 + SharpSbn + SharpSbn SharpSbn - v4.0 - 512 - Client - no + $(OutputPath)\$(TargetFramework)\$(AssemblyName).xml - - true - full - false - bin\Debug\ - TRACE;DEBUG;NET35;NET40 - prompt - 4 - false + + + TRACE - - pdbonly - true - bin\Release\ - TRACE;NET20 - prompt - 4 - false - bin\Release\SharpSbn.XML - - - yes - bin\ReleaseGeoAPI\ - UseGeoAPI;TRACE;NET20 - bin\Release\SharpSbn.XML - true - pdbonly - AnyCPU - prompt - MinimumRecommendedRules.ruleset - net20 - SharpSbn.GeoAPI - false - - - yes - true - bin\DebugGeoAPI\ - UseGeoAPI;TRACE;DEBUG;NET20 - full - AnyCPU - prompt - MinimumRecommendedRules.ruleset - net20 - SharpSbn.GeoAPI - false - - - - ..\packages\GeoAPI.1.7.2\lib\net40-client\GeoAPI.dll - True - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file + + diff --git a/SharpSbn/packages.config b/SharpSbn/packages.config deleted file mode 100644 index 1cc9471..0000000 --- a/SharpSbn/packages.config +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/hasbeen.pyproj b/hasbeen.pyproj index cee8cd0..96370d1 100644 --- a/hasbeen.pyproj +++ b/hasbeen.pyproj @@ -18,6 +18,7 @@ False + Global|PythonCore|2.7 @@ -29,7 +30,9 @@ - + + + \ No newline at end of file diff --git a/test/SbnTest.cs b/test/SbnTest.cs index a99babe..0f67b12 100644 --- a/test/SbnTest.cs +++ b/test/SbnTest.cs @@ -1,47 +1,41 @@ using System; using System.Collections.Generic; -using System.Collections.ObjectModel; using System.Diagnostics; -using System.Diagnostics.Contracts; using System.IO; -using System.Linq; -using System.Runtime.InteropServices; -using System.Text; -using System.Threading; using GeoAPI.DataStructures; using GeoAPI.Geometries; using NUnit.Framework; -using SharpMap.Data; -using SharpMap.Data.Providers; using SharpSbn; namespace SbnSharp.Test { public class SbnTest { +#if Use_SbnSharp_GeoAPI + private static Envelope ToSbn(Envelope envelope) + { + return envelope; + } + private static Interval ToSbn(Interval interval) + { + return interval; + } +#else + private static SharpSbn.DataStructures.Envelope ToSbn(Envelope envelope) + { + return new SharpSbn.DataStructures.Envelope(envelope.MinX, envelope.MaxX, envelope.MinY, envelope.MaxY); + } + private static Interval ToSbn(Interval interval) + { + return new SharpSbn.DataStructures.Interval(interval.Min, interval.Max); + } +#endif + public SbnTest() { GeoAPI.GeometryServiceProvider.Instance = NetTopologySuite.NtsGeometryServices.Instance; - } - //[Ignore] - //[TestCase("data\\riksgrs.sbn")] - //[TestCase("data\\road_r.sbn")] - //public void OldTest(string sbnFile) - //{ - // Sbn sbn = null; - // Assert.DoesNotThrow(() => sbn = Sbn.Load(sbnFile)); - // Assert.IsNotNull(sbn); - - // var sbnTestFile = Path.ChangeExtension(sbnFile, null) + "_test.sbn"; - // Assert.DoesNotThrow(() => sbn.Save(sbnTestFile)); - // var fiO = new FileInfo(sbnFile); - // var fiT = new FileInfo(sbnTestFile); - - // Assert.AreEqual(fiO.Length, fiT.Length); - //} - [TestCase("data\\riksgrs.sbn")] [TestCase("data\\road_r.sbn")] [TestCase("data\\S2_jarnvag_besk_polyline.sbn")] @@ -64,45 +58,7 @@ public void Test(string sbnFile) Assert.AreEqual(fiO.Length, fiT.Length); } - ///// - ///// - ///// - ///// - //[TestCase("data\\road_r.shp")] - //[TestCase("data\\S2_jarnvag_besk_polyline.shp")] - //public void OldTestCreateSbn(string shpFile) - //{ - // using (var p = new ShapeFile(shpFile, false)) - // { - // p.Open(); - // var extent = p.GetExtents(); - - // var fds = new FeatureDataSet(); - // p.ExecuteIntersectionQuery(extent, fds); - // p.Close(); - - // var fdt = fds.Tables[0]; - // var tree = OldSbnTree.Create(GetFeaturesBox(fdt)); - - // Console.WriteLine(tree.FeaturesInLevel(1)); - // Console.WriteLine(tree.FeaturesInLevel(2)); - // Console.WriteLine(tree.FeaturesInLevel(3)); - - // Assert.AreEqual(fdt.Rows.Count, tree.Root.Count); - - // Assert.AreEqual(fdt.Rows.Count, tree.QueryFeatureIds(extent).Count()); - // var shrunk = extent.Grow(-0.2*extent.Width, - 0.2*extent.Height); - // Assert.Less(tree.QueryFeatureIds(shrunk).Count(), fdt.Rows.Count); - - // Console.WriteLine(); - // tree.DescribeTree(Console.Out); - // } - //} - - /// - /// - /// - /// + /* [TestCase("data\\road_r.shp")] [TestCase("data\\S2_jarnvag_besk_polyline.shp")] [TestCase("data\\rivers.shp")] @@ -173,18 +129,18 @@ public void TestCreateSbn(string shpFile) SbnTree.SbnToText(sbn, new StreamWriter(File.OpenWrite(Path.ChangeExtension(sbn, ".createdsbn.txt")))); } - [Pure] - private static SharpSbn.DataStructures.Envelope ToSbn(Envelope extent) + private static Envelope ToSbn(Envelope extent) { - return new SharpSbn.DataStructures.Envelope(extent.MinX, extent.MaxX, extent.MinY, extent.MaxY); + return new Envelope(extent.MinX, extent.MaxX, extent.MinY, extent.MaxY); } [Pure] - private static SharpSbn.DataStructures.Interval ToSbn(Interval interval) + private static Interval ToSbn(Interval interval) { - return SharpSbn.DataStructures.Interval.Create(interval.Min, interval.Max); + return Interval.Create(interval.Min, interval.Max); } + */ [TestCase("data\\riksgrs.sbn")] [TestCase("data\\road_r.sbn")] @@ -206,8 +162,8 @@ public void TestToText(string sbnFile) Assert.DoesNotThrow(() => SbnTree.SbnToText(sbnTestFile, new StreamWriter(File.OpenWrite(Path.ChangeExtension(sbnTestFile, ".sbn.txt"))))); } - [TestCase("data\\road_r.sbn")] - [TestCase("data\\road_r_modified.sbn")] + [TestCase("data\\road_R.sbn")] + [TestCase("data\\road_R_modified.sbn")] public void TestQueryTime(string sbnFile) { if (!File.Exists(sbnFile)) @@ -243,8 +199,8 @@ public void TestQueryTime(string sbnFile) } } - [TestCase("data\\road_r.sbn")] - [TestCase("data\\road_r_modified.sbn")] + [TestCase("data\\road_R.sbn")] + [TestCase("data\\road_R_modified.sbn")] public void TestQueryTime2(string sbnFile) { if (!File.Exists(sbnFile)) @@ -280,10 +236,11 @@ public void TestQueryTime2(string sbnFile) Console.WriteLine("Querying part in {0:N0} ticks ({1} ids)", sw.ElapsedTicks, fids.Count); } } +#if HAS_SHARPMAP #if NET20 - private static ICollection> GetFeatures(FeatureDataTable fdt) + private static ICollection> GetFeatures(FeatureDataTable fdt) { - var res = new List>(fdt.Count); + var res = new List>(fdt.Count); foreach (FeatureDataRow fdr in fdt.Rows) { var env = fdr.Geometry.EnvelopeInternal; @@ -292,9 +249,9 @@ public void TestQueryTime2(string sbnFile) return res; } #else - private static ICollection> GetFeatures(FeatureDataTable fdt) + private static ICollection> GetFeatures(FeatureDataTable fdt) { - var res = new List>(fdt.Count); + var res = new List>(fdt.Count); foreach (FeatureDataRow fdr in fdt.Rows) { var env = fdr.Geometry.EnvelopeInternal; @@ -302,6 +259,7 @@ public void TestQueryTime2(string sbnFile) } return res; } +#endif #endif [Test] @@ -356,15 +314,15 @@ public void TestGetNodeLevel() //} #if NET20 - private ICollection> _data; - private static ICollection> CreateSampleData(int featureCount, SharpSbn.DataStructures.Envelope extent, uint offset = 0) + private ICollection> _data; + private static ICollection> CreateSampleData(int featureCount, Envelope extent, uint offset = 0) { - var res = new List>(); + var res = new List>(); #else - private ICollection> _data; - private static ICollection> CreateSampleData(int featureCount, SharpSbn.DataStructures.Envelope extent, uint offset = 0) + private ICollection> _data; + private static ICollection> CreateSampleData(int featureCount, Envelope extent, uint offset = 0) { - var res = new List>(); + var res = new List>(); #endif var rnd = new Random(5432); for (uint i = 1; i <= featureCount; i++) @@ -375,9 +333,9 @@ public void TestGetNodeLevel() var y2 = y1 + rnd.NextDouble()*(extent.MaxY - y1); res.Add( #if NET20 - FrameworkReplacements.Tuple.Create(offset + i, new SharpSbn.DataStructures.Envelope(x1, x2, y1, y2)) + FrameworkReplacements.Tuple.Create(offset + i, new Envelope(x1, x2, y1, y2)) #else - Tuple.Create(offset+i, new SharpSbn.DataStructures.Envelope(x1, x2, y1, y2)) + Tuple.Create(offset+i, new Envelope(x1, x2, y1, y2)) #endif ); } @@ -385,28 +343,28 @@ public void TestGetNodeLevel() } private static readonly System.Random IntervalRandom = new Random(4326); - private static SharpSbn.DataStructures.Interval CreateInterval(SharpSbn.DataStructures.Interval range) + private static Interval CreateInterval(Interval range) { var lo = range.Min + IntervalRandom.NextDouble()*(range.Max - range.Min); var hi = lo + IntervalRandom.NextDouble()*(range.Max - lo); - return SharpSbn.DataStructures.Interval.Create(lo, hi); + return Interval.Create(lo, hi); } [Test] public void TestCreateAndExtend() { - _data = CreateSampleData(50000, new SharpSbn.DataStructures.Envelope(-100, 100, - 100, 100)); + _data = CreateSampleData(50000, new Envelope(-100, 100, - 100, 100)); var tree = SbnTree.Create(_data, null, null); tree.RebuildRequried += HandleRebuildRequired; _rebuildRequiredFired = false; - tree.Insert(500002, new SharpSbn.DataStructures.Envelope(-110, -100, -110, -100), null, null); + tree.Insert(500002, new Envelope(-110, -100, -110, -100), null, null); Assert.IsTrue(_rebuildRequiredFired); tree = SbnTree.Create(_data, tree.ZRange, tree.MRange); Assert.IsTrue(tree.FeatureCount == 50001); - Assert.IsTrue(new SharpSbn.DataStructures.Envelope(-110, 100, -110, 100).Contains(tree.Extent)); + Assert.IsTrue(new Envelope(-110, 100, -110, 100).Contains(tree.Extent)); - //tree = SbnTree.Create(new List>(tree.QueryFids(tree.Extent))) + //tree = SbnTree.Create(new List>(tree.QueryFids(tree.Extent))) } private bool _rebuildRequiredFired; @@ -425,10 +383,10 @@ private void HandleRebuildRequired(object sender, SbnTreeRebuildRequiredEventArg [Test] public void TestCreateAndExtendByMassiveNumber() { - _data = CreateSampleData(50000, new SharpSbn.DataStructures.Envelope(-100, 100, -100, 100)); + _data = CreateSampleData(50000, new Envelope(-100, 100, -100, 100)); var tree = SbnTree.Create(_data, null, null); Assert.That(tree.FeatureCount == 50000); - foreach (var tuple in CreateSampleData(50000, new SharpSbn.DataStructures.Envelope(-100, 100, -100, 100), 50001)) + foreach (var tuple in CreateSampleData(50000, new Envelope(-100, 100, -100, 100), 50001)) tree.Insert(tuple.Item1, tuple.Item2, null, null); Assert.IsTrue(tree.FeatureCount == 100000); } @@ -436,40 +394,41 @@ public void TestCreateAndExtendByMassiveNumber() [Test] public void TestCreateAndExtendByMassiveNumberZ() { - _data = CreateSampleData(50000, new SharpSbn.DataStructures.Envelope(-100, 100, -100, 100)); - var zRange = SharpSbn.DataStructures.Interval.Create(1, 10); + _data = CreateSampleData(50000, new Envelope(-100, 100, -100, 100)); + var zRange = Interval.Create(1, 10); var tree = SbnTree.Create(_data, zRange, null); Assert.AreEqual(zRange, tree.ZRange); - foreach (var tuple in CreateSampleData(50000, new SharpSbn.DataStructures.Envelope(-100, 100, -100, 100), 50001)) - tree.Insert(tuple.Item1, tuple.Item2, CreateInterval(SharpSbn.DataStructures.Interval.Create(0, 20)), null); + foreach (var tuple in CreateSampleData(50000, new Envelope(-100, 100, -100, 100), 50001)) + tree.Insert(tuple.Item1, tuple.Item2, CreateInterval(Interval.Create(0, 20)), null); Assert.IsTrue(tree.FeatureCount == 100000); Assert.IsTrue(tree.ZRange.Min < 1d); Assert.IsTrue(tree.ZRange.Max > 10d); - Assert.IsTrue(SharpSbn.DataStructures.Interval.Create(0, 20).Contains(tree.ZRange)); + Assert.IsTrue(Interval.Create(0, 20).Contains(tree.ZRange)); } [Test] public void TestCreateAndExtendByMassiveNumberZM() { - _data = CreateSampleData(50000, new SharpSbn.DataStructures.Envelope(-100, 100, -100, 100)); - var zRange = SharpSbn.DataStructures.Interval.Create(1, 10); - var mRange = SharpSbn.DataStructures.Interval.Create(10, 100); + _data = CreateSampleData(50000, new Envelope(-100, 100, -100, 100)); + var zRange = Interval.Create(1, 10); + var mRange = Interval.Create(10, 100); var tree = SbnTree.Create(_data, zRange, mRange); Assert.AreEqual(zRange, tree.ZRange); Assert.AreEqual(mRange, tree.MRange); - foreach (var tuple in CreateSampleData(50000, new SharpSbn.DataStructures.Envelope(-100, 100, -100, 100), 50001)) + foreach (var tuple in CreateSampleData(50000, new Envelope(-100, 100, -100, 100), 50001)) tree.Insert(tuple.Item1, tuple.Item2, - CreateInterval(SharpSbn.DataStructures.Interval.Create(0, 20)), - CreateInterval(SharpSbn.DataStructures.Interval.Create(9, 200))); + CreateInterval(Interval.Create(0, 20)), + CreateInterval(Interval.Create(9, 200))); Assert.IsTrue(tree.FeatureCount == 100000); Assert.IsTrue(tree.ZRange.Min < 1d); Assert.IsTrue(tree.ZRange.Max > 10d); - Assert.IsTrue(SharpSbn.DataStructures.Interval.Create(0, 20).Contains(tree.ZRange)); + Assert.IsTrue(Interval.Create(0, 20).Contains(tree.ZRange)); Assert.IsTrue(tree.MRange.Min < 10d); Assert.IsTrue(tree.MRange.Max > 100d); - Assert.IsTrue(SharpSbn.DataStructures.Interval.Create(9, 200).Contains(tree.MRange)); + Assert.IsTrue(Interval.Create(9, 200).Contains(tree.MRange)); } } } + diff --git a/test/SharpSbn.Test.csproj b/test/SharpSbn.Test.csproj index 35a9047..b54ba7d 100644 --- a/test/SharpSbn.Test.csproj +++ b/test/SharpSbn.Test.csproj @@ -1,5 +1,6 @@  + Debug @@ -9,16 +10,19 @@ Properties SbnSharp.Test SbnSharp.Test - v4.0 + v4.5.2 512 - Client + + + + true full false bin\Debug\ - TRACE;DEBUG;NET35;NET40;NET45 + TRACE;DEBUG;NET35;NET40;NET45;Use_SbnSharp_GeoAPI prompt 4 false @@ -33,76 +37,18 @@ false - - ..\packages\BruTile.0.7.4.4\lib\net40\BruTile.dll - True - - - ..\packages\BruTile.0.7.4.4\lib\net40\BruTile.Desktop.dll - True - - - ..\packages\BruTile.0.7.4.4\lib\net40\BruTile.MbTiles.dll - True - - - ..\packages\BruTile.0.7.4.4\lib\net40\BruTile.Serialization.dll - True - - - ..\packages\Common.Logging.2.0.0\lib\2.0\Common.Logging.dll - True - - - ..\packages\GeoAPI.1.7.2\lib\net40-client\GeoAPI.dll - True - - - ..\packages\NetTopologySuite.1.13.2\lib\net40-client\NetTopologySuite.dll - True - - - ..\packages\NetTopologySuite.IO.1.13.2\lib\net40-client\NetTopologySuite.IO.GeoTools.dll - True + + ..\packages\GeoAPI.Core.1.7.5\lib\net45\GeoAPI.dll - - ..\packages\NetTopologySuite.IO.1.13.2\lib\net40-client\NetTopologySuite.IO.MsSqlSpatial.dll + + ..\packages\NetTopologySuite.Core.1.15.1\lib\net45\NetTopologySuite.dll True - - ..\packages\NetTopologySuite.IO.1.13.2\lib\net40-client\NetTopologySuite.IO.PostGis.dll - True - - - ..\packages\Newtonsoft.Json.4.5.11\lib\net40\Newtonsoft.Json.dll - True - - - ..\packages\NUnit.2.6.3\lib\nunit.framework.dll - True - - - ..\packages\NetTopologySuite.1.13.2\lib\net40-client\PowerCollections.dll - True - - - ..\packages\ProjNET4GeoAPI.1.3.0.3\lib\net40-client\ProjNet.dll - True - - - ..\packages\SharpMap.1.1.0\lib\net40-client\SharpMap.dll - True + + ..\packages\NUnit.3.10.1\lib\net45\nunit.framework.dll - - ..\packages\System.Data.SQLite.MSIL.1.0.86.0\lib\net40\System.Data.SQLite.dll - True - - - ..\packages\System.Data.SQLite.MSIL.1.0.86.0\lib\net40\System.Data.SQLite.Linq.dll - True - @@ -190,12 +136,18 @@ - - {e28f8461-d075-4da6-8fbb-4dde75d1e396} - SharpSbn + + {33887fa2-09ce-4920-bc95-0daeb00ccd20} + SharpSbn.GeoAPI + + + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + +