diff --git a/.gitignore b/.gitignore index a968d2f..2a67424 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,6 @@ packages bin -obj \ No newline at end of file +obj +.vs +*.user +*.bak \ No newline at end of file diff --git a/TurfCS/Helpers.cs b/TurfCS/Helpers.cs index 6287502..8f4fdd0 100644 --- a/TurfCS/Helpers.cs +++ b/TurfCS/Helpers.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using GeoJSON.Net.Feature; using GeoJSON.Net.Geometry; +using GeographicPosition= GeoJSON.Net.Geometry.Position; namespace TurfCS { diff --git a/TurfCS/Joins.cs b/TurfCS/Joins.cs index 1f82406..6abf472 100644 --- a/TurfCS/Joins.cs +++ b/TurfCS/Joins.cs @@ -1,8 +1,10 @@ using System; using System.Collections.Generic; +using System.Linq; using GeoJSON.Net; using GeoJSON.Net.Feature; using GeoJSON.Net.Geometry; +using GeographicPosition= GeoJSON.Net.Geometry.Position; namespace TurfCS { @@ -36,7 +38,7 @@ static public bool Inside(Feature point, Feature poly) if (type == GeoJSONObjectType.Polygon) return Inside_(Turf.GetCoord(point), new List() { (Polygon)poly.Geometry }); else if (type == GeoJSONObjectType.MultiPolygon) - return Inside_(Turf.GetCoord(point), ((MultiPolygon)poly.Geometry).Coordinates); + return Inside_(Turf.GetCoord(point), ((MultiPolygon)poly.Geometry).Coordinates.ToList()); else throw new Exception("2nd argument must be Polygon or MultiPolygon"); } diff --git a/TurfCS/Measurement.cs b/TurfCS/Measurement.cs index 7accc49..ee04bc8 100644 --- a/TurfCS/Measurement.cs +++ b/TurfCS/Measurement.cs @@ -4,6 +4,7 @@ using GeoJSON.Net; using GeoJSON.Net.Feature; using GeoJSON.Net.Geometry; +using GeographicPosition= GeoJSON.Net.Geometry.Position; namespace TurfCS { @@ -564,7 +565,7 @@ public static double LineDistance(IGeoJSONObject line, string units = "kilometer if (geometry.Type == GeoJSONObjectType.LineString) { - return Length(((LineString)geometry).Coordinates, units); + return Length(((LineString)geometry).Coordinates.ToList(), units); } else if (geometry.Type == GeoJSONObjectType.Polygon || geometry.Type == GeoJSONObjectType.MultiLineString) { @@ -574,7 +575,7 @@ public static double LineDistance(IGeoJSONObject line, string units = "kilometer for (var i = 0; i < lines.Count; i++) { var points = ((LineString)lines[i]).Coordinates; - d += Length(points, units); + d += Length(points.ToList(), units); } return d; } @@ -588,7 +589,7 @@ public static double LineDistance(IGeoJSONObject line, string units = "kilometer for (var j = 0; j < lines.Count; j++) { var points = ((LineString)lines[j]).Coordinates; - d += Length(points, units); + d += Length(points.ToList(), units); } } return d; diff --git a/TurfCS/Meta.cs b/TurfCS/Meta.cs index 9ba9ed7..f295a0d 100644 --- a/TurfCS/Meta.cs +++ b/TurfCS/Meta.cs @@ -4,6 +4,7 @@ using GeoJSON.Net; using GeoJSON.Net.Feature; using GeoJSON.Net.Geometry; +using GeographicPosition= GeoJSON.Net.Geometry.Position; namespace TurfCS { @@ -110,7 +111,7 @@ static private void CoordEach(IGeometryObject layer, Action else if (geometry.Type == GeoJSONObjectType.LineString || geometry.Type == GeoJSONObjectType.MultiPoint) { var coords = geometry.Type == GeoJSONObjectType.LineString ? - ((LineString)layer).Coordinates : + ((LineString)layer).Coordinates.ToList() : ((MultiPoint)layer).Coordinates.Select(x => x.Coordinates).ToList(); for (var j = 0; j < coords.Count; j++) callback((GeographicPosition)coords[j]); } @@ -188,7 +189,7 @@ static public object CoordReduce(IGeoJSONObject layer, Func, int> callback) + static public void PropEach(IGeoJSONObject layer, Action, int> callback) { if (layer.Type == GeoJSONObjectType.FeatureCollection) { diff --git a/TurfCS/Misc.cs b/TurfCS/Misc.cs index 39237f6..c750d54 100644 --- a/TurfCS/Misc.cs +++ b/TurfCS/Misc.cs @@ -1,8 +1,7 @@ -using System; -using System.Collections.Generic; +using System.Collections.Generic; using GeoJSON.Net; using GeoJSON.Net.Feature; -using GeoJSON.Net.Geometry; +using GeographicPosition= GeoJSON.Net.Geometry.Position; namespace TurfCS { diff --git a/TurfCS/Properties/AssemblyInfo.cs b/TurfCS/Properties/AssemblyInfo.cs deleted file mode 100644 index 7a24a02..0000000 --- a/TurfCS/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,26 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; - -// Information about this assembly is defined by the following attributes. -// Change them to the values specific to your project. - -[assembly: AssemblyTitle("Turf")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("")] -[assembly: AssemblyCopyright("(c) Ko-hei OHTSUKA")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}". -// The form "{Major}.{Minor}.*" will automatically update the build and revision, -// and "{Major}.{Minor}.{Build}.*" will update just the revision. - -[assembly: AssemblyVersion("1.0.*")] - -// The following attributes are used to specify the signing key for the assembly, -// if desired. See the Mono documentation for more information about signing. - -//[assembly: AssemblyDelaySign(false)] -//[assembly: AssemblyKeyFile("")] diff --git a/TurfCS/Tin.cs b/TurfCS/Tin.cs index 77c82eb..8320c19 100644 --- a/TurfCS/Tin.cs +++ b/TurfCS/Tin.cs @@ -3,6 +3,7 @@ using System.Linq; using GeoJSON.Net.Feature; using GeoJSON.Net.Geometry; +using GeographicPosition= GeoJSON.Net.Geometry.Position; namespace TurfCS { diff --git a/TurfCS/TurfCS.csproj b/TurfCS/TurfCS.csproj index 2aeee34..6387e32 100644 --- a/TurfCS/TurfCS.csproj +++ b/TurfCS/TurfCS.csproj @@ -1,52 +1,14 @@ - - + + - Debug - AnyCPU - {95641025-2C48-4B98-9345-97D91AB40BBA} - {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - Library TurfCS TurfCS - v4.5 - Profile111 + netstandard2.0 + preview - - true - full - false - bin\Debug - DEBUG; - prompt - 4 - - - true - bin\Release - prompt - 4 - - - - - - - - - - - - - - - ..\packages\GeoJSON.Net.0.1.51\lib\portable-net40+sl5+wp80+win8+wpa81\GeoJSON.Net.dll - - - ..\packages\Newtonsoft.Json.9.0.1\lib\portable-net45+wp80+win8+wpa81\Newtonsoft.Json.dll - - + - + - - \ No newline at end of file + + diff --git a/TurfCS/packages.config b/TurfCS/packages.config deleted file mode 100644 index 459e47a..0000000 --- a/TurfCS/packages.config +++ /dev/null @@ -1,5 +0,0 @@ - - - - - \ No newline at end of file diff --git a/TurfCSTest/AssertionsTest.cs b/TurfCSTest/AssertionsTest.cs index ac192c9..f35df27 100644 --- a/TurfCSTest/AssertionsTest.cs +++ b/TurfCSTest/AssertionsTest.cs @@ -1,81 +1,81 @@ -using System; -using GeoJSON.Net.Feature; +using GeoJSON.Net.Feature; using GeoJSON.Net.Geometry; using Newtonsoft.Json; using NUnit.Framework; using TurfCS; +using Assert= NUnit.Framework.Legacy.ClassicAssert; namespace TurfCSTest { [TestFixture()] - public class AssertionsTest - { - [Test()] - public void Bbox() - { - var fc = JsonConvert.DeserializeObject(Tools.GetResource("bbox.FeatureCollection.geojson")); - var pt = JsonConvert.DeserializeObject(Tools.GetResource("bbox.Point.geojson")); - var line = JsonConvert.DeserializeObject(Tools.GetResource("bbox.LineString.geojson")); - var poly = JsonConvert.DeserializeObject(Tools.GetResource("bbox.Polygon.geojson")); - var multiLine = JsonConvert.DeserializeObject(Tools.GetResource("bbox.MultiLineString.geojson")); - var multiPoly = JsonConvert.DeserializeObject(Tools.GetResource("bbox.MultiPolygon.geojson")); + public class AssertionsTest + { + [Test()] + public void Bbox() + { + var fc = JsonConvert.DeserializeObject(Tools.GetResource("bbox.FeatureCollection.geojson")); + var pt = JsonConvert.DeserializeObject(Tools.GetResource("bbox.Point.geojson")); + var line = JsonConvert.DeserializeObject(Tools.GetResource("bbox.LineString.geojson")); + var poly = JsonConvert.DeserializeObject(Tools.GetResource("bbox.Polygon.geojson")); + var multiLine = JsonConvert.DeserializeObject(Tools.GetResource("bbox.MultiLineString.geojson")); + var multiPoly = JsonConvert.DeserializeObject(Tools.GetResource("bbox.MultiPolygon.geojson")); - // FeatureCollection + // FeatureCollection var fcExtent = Turf.Bbox(fc); Assert.AreEqual(fcExtent[0], 20); Assert.AreEqual(fcExtent[1], -10); Assert.AreEqual(fcExtent[2], 130); Assert.AreEqual(fcExtent[3], 4); - // Point - var ptExtent = Turf.Bbox(pt); + // Point + var ptExtent = Turf.Bbox(pt); Assert.AreEqual(ptExtent[0], 102); Assert.AreEqual(ptExtent[1], 0.5); Assert.AreEqual(ptExtent[2], 102); Assert.AreEqual(ptExtent[3], 0.5); - // Line - var lineExtent = Turf.Bbox(line); + // Line + var lineExtent = Turf.Bbox(line); Assert.AreEqual(lineExtent[0], 102); Assert.AreEqual(lineExtent[1], -10); Assert.AreEqual(lineExtent[2], 130); Assert.AreEqual(lineExtent[3], 4); - // Polygon - var polyExtent = Turf.Bbox(poly); + // Polygon + var polyExtent = Turf.Bbox(poly); Assert.AreEqual(polyExtent[0], 100); Assert.AreEqual(polyExtent[1], 0); Assert.AreEqual(polyExtent[2], 101); Assert.AreEqual(polyExtent[3], 1); - // MultiLineString - var multiLineExtent = Turf.Bbox(multiLine); + // MultiLineString + var multiLineExtent = Turf.Bbox(multiLine); Assert.AreEqual(multiLineExtent[0], 100); Assert.AreEqual(multiLineExtent[1], 0); Assert.AreEqual(multiLineExtent[2], 103); Assert.AreEqual(multiLineExtent[3], 3); - // MultiPolygon - var multiPolyExtent = Turf.Bbox(multiPoly); + // MultiPolygon + var multiPolyExtent = Turf.Bbox(multiPoly); Assert.AreEqual(multiPolyExtent[0], 100); Assert.AreEqual(multiPolyExtent[1], 0); Assert.AreEqual(multiPolyExtent[2], 103); Assert.AreEqual(multiPolyExtent[3], 3); - } + } - [Test()] - public void Circle() - { - var center = Turf.Point(new double[] { -75.343, 39.984 }); - double radius = 5; - int steps = 10; + [Test()] + public void Circle() + { + var center = Turf.Point(new double[] { -75.343, 39.984 }); + double radius = 5; + int steps = 10; - var polygon = Turf.Circle(center, radius, steps, "kilometers"); - var point1 = Turf.Destination(center, radius - 1, 45, "kilometers"); - var point2 = Turf.Destination(center, radius + 1, 135, "kilometers"); + var polygon = Turf.Circle(center, radius, steps, "kilometers"); + var point1 = Turf.Destination(center, radius - 1, 45, "kilometers"); + var point2 = Turf.Destination(center, radius + 1, 135, "kilometers"); Assert.AreEqual(Turf.Inside(point1, polygon), true, "point is inside the polygon"); Assert.AreEqual(Turf.Inside(point2, polygon), false, "point is outside the polygon"); - } - } + } + } } diff --git a/TurfCSTest/ClassificationTest.cs b/TurfCSTest/ClassificationTest.cs index a59c608..8e7f329 100644 --- a/TurfCSTest/ClassificationTest.cs +++ b/TurfCSTest/ClassificationTest.cs @@ -5,6 +5,9 @@ using Newtonsoft.Json; using NUnit.Framework; using TurfCS; +using GeographicPosition= GeoJSON.Net.Geometry.Position; +using Assert= NUnit.Framework.Legacy.ClassicAssert; + namespace TurfCSTest { diff --git a/TurfCSTest/JoinsTest.cs b/TurfCSTest/JoinsTest.cs index dbaf5a5..f0c912e 100644 --- a/TurfCSTest/JoinsTest.cs +++ b/TurfCSTest/JoinsTest.cs @@ -6,6 +6,8 @@ using GeoJSON.Net.Feature; using TurfCS; using System.Linq; +using GeographicPosition= GeoJSON.Net.Geometry.Position; +using Assert= NUnit.Framework.Legacy.ClassicAssert; namespace TurfCSTest { diff --git a/TurfCSTest/MeasurementTest.cs b/TurfCSTest/MeasurementTest.cs index 3ce29ea..198bd88 100644 --- a/TurfCSTest/MeasurementTest.cs +++ b/TurfCSTest/MeasurementTest.cs @@ -6,6 +6,8 @@ using Newtonsoft.Json; using NUnit.Framework; using TurfCS; +using GeographicPosition= GeoJSON.Net.Geometry.Position; +using Assert= NUnit.Framework.Legacy.ClassicAssert; namespace TurfCSTest { diff --git a/TurfCSTest/MetaTest.cs b/TurfCSTest/MetaTest.cs index ec12db4..966db47 100644 --- a/TurfCSTest/MetaTest.cs +++ b/TurfCSTest/MetaTest.cs @@ -1,10 +1,11 @@ using System; using System.Collections.Generic; -using GeoJSON.Net; using GeoJSON.Net.Feature; using GeoJSON.Net.Geometry; using NUnit.Framework; using TurfCS; +using GeographicPosition= GeoJSON.Net.Geometry.Position; +using Assert= NUnit.Framework.Legacy.ClassicAssert; namespace TurfCSTest { @@ -120,7 +121,7 @@ public void CoordEach() [Test()] public void PropEach() { - Action, int> callback = (Dictionaryobj, int i) => + Action, int> callback = (IDictionaryobj, int i) => { Assert.AreEqual(obj, new Dictionary() { { "a", 1 } }); Assert.AreEqual(i, 0); diff --git a/TurfCSTest/TinTest.cs b/TurfCSTest/TinTest.cs index 08135af..ab763bb 100644 --- a/TurfCSTest/TinTest.cs +++ b/TurfCSTest/TinTest.cs @@ -4,6 +4,7 @@ using Newtonsoft.Json; using NUnit.Framework; using TurfCS; +using Assert= NUnit.Framework.Legacy.ClassicAssert; namespace TurfCSTest { diff --git a/TurfCSTest/Tools.cs b/TurfCSTest/Tools.cs index 5b472e1..541e20c 100644 --- a/TurfCSTest/Tools.cs +++ b/TurfCSTest/Tools.cs @@ -22,7 +22,7 @@ public static string GetResource(string resourceName) { string path = Names.First(x => x.EndsWith("." + resourceName, StringComparison.CurrentCultureIgnoreCase)); var stream = Assembly.GetManifestResourceStream(path); - using (var reader = new StreamReader(stream, Encoding.UTF8)) + using (var reader = new StreamReader(stream!, Encoding.UTF8)) { return reader.ReadToEnd(); } diff --git a/TurfCSTest/TurfCSTest.csproj b/TurfCSTest/TurfCSTest.csproj index 0fbc2d9..d7a0fdc 100644 --- a/TurfCSTest/TurfCSTest.csproj +++ b/TurfCSTest/TurfCSTest.csproj @@ -1,61 +1,23 @@ - - + + - Debug - AnyCPU - {909CB9ED-FC28-4FC4-91DB-26F492D0BE3F} - Library TurfCSTest TurfCSTest - v4.5 + net9.0 + preview - - true - full - false - bin\Debug - DEBUG; - prompt - 4 - - - true - bin\Release - prompt - 4 - - - - - ..\packages\GeoJSON.Net.0.1.51\lib\portable-net40+sl5+wp80+win8+wpa81\GeoJSON.Net.dll - - - ..\packages\Newtonsoft.Json.9.0.1\lib\net45\Newtonsoft.Json.dll - - - ..\packages\NUnit.3.5.0\lib\net45\nunit.framework.dll - - + - - - - - - - - + + + + - + + - - - - - - @@ -65,28 +27,21 @@ + + + + + + - - - - + + + + + - - - - - - - - - - - {95641025-2C48-4B98-9345-97D91AB40BBA} - TurfCS - - - + \ No newline at end of file diff --git a/TurfCSTest/packages.config b/TurfCSTest/packages.config deleted file mode 100644 index cc9206d..0000000 --- a/TurfCSTest/packages.config +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file