public static void main(string[] args)
        {
            // read a point from a WKT string (using the default point factory)
            IGeometry g1 = new WKTReader().Read("LINESTRING (0 0, 10 10, 20 20)");

            Console.WriteLine("Geometry 1: " + g1);

            // create a point by specifying the coordinates directly
            var coordinates = new [] { new Coordinate(0, 0),
                                       new Coordinate(10, 10), new Coordinate(20, 20) };
            // use the default factory, which gives full double-precision
            IGeometry g2 = new GeometryFactory().CreateLineString(coordinates);

            Console.WriteLine("Geometry 2: " + g2);

            // compute the intersection of the two geometries
            IGeometry g3 = g1.Intersection(g2);

            Console.WriteLine("G1 intersection G2: " + g3);
        }
        private static void CheckUnion(string wktA, string wktB, bool isCheckOptimized)
        {
            var pm       = new PrecisionModel();
            var geomFact = new GeometryFactory(pm);
            var rdr      = new WKTReader(geomFact);

            var a = rdr.Read(wktA);
            var b = rdr.Read(wktB);

            var union  = new OverlapUnion(a, b);
            var result = union.Union();

            if (isCheckOptimized)
            {
                bool isOptimized = union.IsUnionOptimized;
                Assert.IsTrue(isOptimized, "Union was not performed using combine");
            }

            Assert.IsTrue(result.IsValid, "OverlapUnion result is invalid");
        }
Exemple #3
0
        public void TestGoogleGroupPostBuffer0()
        {
            const string wkt    = @"POLYGON((487143.12056915415 4419332.297027817,487148.4826128975 4419333.241,487151.35381619935 4419331.6704359865,487145.873 4419330.326,487143.12056915415 4419332.297027817),(487240.64452267956 4419362.611054949,487240.093271455 4419355.237630927,487240.47771515214 4419355.457643805,487241.94552018255 4419356.297652398,487242.63676261925 4419356.693242803,487240.64452267956 4419362.611054949),(487175.0756521084 4419364.959860701,487175.514 4419365.097,487175.8617072951 4419364.1606901605,487176.279 4419363.037,487177.09182983835 4419363.294358757,487180.268 4419364.3,487182.201 4419358.304,487189.416 4419355.979,487190.104 4419354.183,487192.074 4419354.709,487192.777 4419352.591,487194.799 4419353.305,487195.406 4419351.194,487199.626 4419352.569,487200.544 4419350.67,487204.165 4419351.89,487204.876 4419349.797,487206.885 4419350.371,487208.855 4419344.411,487211.013 4419345.043,487213.198 4419337.699,487213.36468920583 4419337.247749596,487205.238 4419334.864,487203.3936632555 4419335.653620839,487195.9874482669 4419338.824463534,487195.957 4419341.536221268,487195.4493840775 4419343.353497175,487195.085 4419344.658,487192.317 4419343.764,487188.25 4419343.986,487187.546558571 4419345.1252605785,487185.611 4419348.26,487183.293 4419350.626,487180.353 4419352.759,487177.159 4419353.95,487175.95143943216 4419354.21729031,487175.3101193474 4419354.359244798,487173.73 4419354.709,487170.15 4419354.429,487167.027 4419353.693,487163.84 4419352.327,487161.166 4419350.415,487159.5639734854 4419348.730000001,487158.405 4419347.511,487155.867 4419356.501,487159.799 4419357.949,487159.218 4419359.983,487163.269 4419361.291,487162.635 4419363.231,487172.594 4419366.279,487173.577 4419364.491,487174.69657750975 4419364.841265343,487175.0756521084 4419364.959860701),(487090.689 4419453.346,487093.221 4419453.426,487104.096 4419451.142,487112.485 4419449.120999999,487109.93799999997 4419444.844999999,487113.2089999999 4419441.893999999,487118.689 4419441.779999999,487120.1429999999 4419444.486,487118.547 4419447.416999999,487122.35 4419447.132999999,487124.3169999999 4419431.821999999,487128.289 4419429.159,487134.1209999999 4419430.511,487134.52799999993 4419425.936999999,487138.728 4419425.66,487146.397 4419420.229,487149.961 4419420.378999999,487149.13399999996 4419424.014999999,487155.29999999993 4419427.981999999,487154.191 4419433.241,487152.382 4419435.3719999995,487142.1109999999 4419434.286999999,487137.027 4419440.228,487135.032 4419440.968,487133.029 4419440.173,487129.60899999994 4419445.427999999,487139.251 4419443.576,487149.961 4419441.321,487159.627 4419439.173,487167.814 4419437.268,487176.754 4419435.019,487181.545 4419434.043,487192.034 4419432.048,487202.054 4419429.431,487216.038 4419426.432,487227.184 4419423.946999999,487225.20199999993 4419421.466,487229.51399999997 4419419.196,487231.294 4419423.124,487236.017 4419422.061,487242.17 4419420.477,487236.429 4419418.401999999,487235.667 4419414.301999999,487238.45199999993 4419411.365,487245.2459999999 4419411.522,487245.59699999995 4419408.173,487248.623 4419405.480999999,487253.58699999994 4419409.336999999,487254.05849364935 4419409.976328004,487253.41298833094 4419412.235596618,487249.98374132684 4419416.592757516,487248.2892898661 4419418.401999999,487242.17 4419420.477,487248.229 4419419.35,487251.042 4419418.623,487255.394 4419413.277,487258.946 4419409.267,487264.575 4419402.803,487269.266 4419397.003,487271.669 4419393.13,487272.67 4419388.676,487271.756 4419384.824,487268.282 4419381.132,487263.159 4419378.92,487255.442 4419378.024,487247.066 4419378.678,487241.9420360908 4419377.615097525,487238.478053108 4419373.445893751,487238.1110360908 4419369.630097525,487240.1595282578 4419364.013622161,487236.948 4419366.184999999,487231.929 4419363.116999999,487232.248 4419357.979,487240.0892311838 4419355.235318725,487238.544 4419354.351,487235.314 4419352.431,487232.129 4419350.271,487228.246 4419347.718,487224.804 4419345.386,487222.421 4419341.462,487221.58823457133 4419339.659909387,487219.7643316328 4419339.124915642,487219.348 4419341.637,487224.039 4419346.357999999,487222.927 4419354.040999999,487219.196 4419360.759,487213.583 4419363.649,487204.201 4419360.686999999,487195.419 4419369.007999999,487189.606 4419380.0879999995,487185.13399999996 4419393.3149999995,487176.20199999993 4419394.361,487167.46499999997 4419386.572999999,487157.89099999995 4419380.85,487156.2679999999 4419369.515999999,487151.571 4419365.407,487146.57499999995 4419367.395,487141.218 4419354.488,487146.4719860089 4419346.646,487142.19331776694 4419339.936531815,487140.37365706515 4419337.083084224,487139.4620796622 4419335.65362084,487139.30299999996 4419335.418,487138.777 4419331.527999999,487139.30469432415 4419331.6678643515,487139.30299999996 4419331.624955887,487140.7938153163 4419331.887409581,487140.652 4419331.837,487138.835 4419331.492,487135.447 4419330.403,487125.902 4419326.4,487124.249 4419323.995,487118.848 4419320.768,487110.985 4419316.503,487101.806 4419311.852,487095.617 4419310.26,487091.624 4419310.697,487083.801 4419314.506,487076.314 4419319.193,487072.487 4419323.131,487070.105 4419328.084,487068.908 4419334.019,487068.526 4419342.436,487068.956 4419348.73,487070.22 4419350.535,487080.047 4419357.288,487089.283 4419364.727,487095.165 4419370.622,487099.913 4419377.189,487103.385 4419383.969,487105.666 4419390.028,487106.822 4419395.725,487106.412 4419400.548,487104.009 4419406.577,487100.781 4419410.21,487094.047 4419412.879,487087.88357091264 4419413.864999999,487079.368 4419415.239,487067.54 4419417.309,487064.898 4419419.844,487064.626 4419423.569,487066.972 4419427.824,487072.199 4419433.709,487078.761 4419439.073,487086.99779043987 4419448.624936048,487090.472 4419445.771,487093.982 4419443.66,487098.752 4419441.745,487109.195 4419439.578,487109.878 4419444.187,487101.804 4419445.899,487101.59483467275 4419445.970602643,487096.429 4419447.739,487093.283 4419449.512,487090.83 4419451.989,487090.689 4419453.346),(487124.64365867176 4419390.962,487125.8259149815 4419391.775457458,487124.98469414574 4419392.696,487124.32535889605 4419391.957343044,487124.64365867176 4419390.962),(487107.6137447421 4419374.699731413,487108.8612673502 4419375.62,487107.26868529734 4419376.663915945,487106.684 4419375.62,487106.684 4419375.0447908575,487107.6137447421 4419374.699731413),(487105.3575868339 4419365.617099826,487105.3575868339 4419367.002251491,487103.87117691786 4419367.321,487103.6588326441 4419366.099788327,487104.7205540127 4419365.383126403,487105.3575868339 4419365.617099826),(487110.2680481636 4419370.689,487110.4073990933 4419372.071971025,487109.07361162396 4419372.2046861965,487108.2242345291 4419371.4349382045,487108.8612673502 4419370.689,487109.57792927406 4419370.689,487109.92298871884 4419370.689,487110.2680481636 4419370.689),(487104.42858063633 4419359.8356322525,487105.3575868339 4419360.56,487104.7205540127 4419361.746730716,487103.6588326441 4419361.614015545,487103.216 4419360.56,487104.42858063633 4419359.8356322525),(487118.194 4419390.102,487119.33615201013 4419391.287878595,487117.711 4419392.239,487117.0057429381 4419391.373137464,487117.0057429381 4419390.962,487118.194 4419390.102),(487114.3556754327 4419372.071971025,487114.3397385907 4419373.841217059,487112.6370139674 4419373.691096112,487112.5523651692 4419372.2046861965,487113.7186426116 4419372.2046861965,487114.3556754327 4419372.071971025),(487102.9687137545 4419374.699731413,487103.87117691786 4419376.126,487102.27859486494 4419376.663915945,487100.8718140515 4419375.563,487101.649 4419375.0447908575,487102.9687137545 4419374.699731413),(487121.1961215923 4419393.838598896,487122.39656646067 4419393.420262048,487122.837 4419393.65671331,487123.6515770048 4419394.275124303,487123.269617274 4419395.179,487121.8299303264 4419395.390002534,487121.25068726816 4419394.620706916,487121.1961215923 4419393.838598896),(487112.6370139674 4419380.623804862,487113.2740467885 4419382.322559051,487112.5042987963 4419383.649710762,487111.3894913593 4419383.516995591,487110.4073990933 4419382.597,487110.897 4419381.552811059,487111.4425774277 4419381.340466785,487112.02652418043 4419380.85,487112.6370139674 4419380.623804862),(487114.12 4419386.812,487116.468 4419385.691,487117.711 4419386.812,487116.468 4419388.387,487115.58335901 4419388.387,487114.12 4419386.812),(487117.23891252436 4419383.114287995,487118.999 4419380.85,487120.116 4419382.597,487120.116 4419384.04,487118.194 4419384.04,487117.711 4419384.04,487117.23891252436 4419383.114287995),(487163.35152467916 4419432.2105301125,487163.595 4419432.904,487164.19236438896 4419433.070905788,487165.406 4419433.41,487166.845 4419432.802,487166.906 4419430.77,487163.035 4419431.309,487163.35152467916 4419432.2105301125),(487158.978 4419436.193,487160.818 4419436.646,487162.056 4419435.738,487162.3353371833 4419434.031699095,487162.342 4419433.991,487162.2549905827 4419434.003131414,487158.053 4419434.589,487158.978 4419436.193),(487164.4592575609 4419402.517779068,487167.46499999997 4419401.193017091,487168.9933020763 4419399.812279254,487171.41892259894 4419400.390696456,487171.263 4419402.573754926,487171.7734363676 4419405.932306419,487171.0830674496 4419407.9101200765,487169.441108942 4419407.9101200765,487168.0230538672 4419405.633768509,487165.6907264416 4419404.887423732,487164.218 4419403.599978994,487164.4592575609 4419402.517779068),(487133.769053152 4419347.730531702,487137.65097190597 4419348.261392387,487140.748 4419350.451192709,487139.30299999996 4419352.209668726,487136.2242838169 4419353.238211301,487134.0344834942 4419354.830793355,487132.141 4419354.685533253,487132.418 4419350.841,487133.769053152 4419347.730531702),(487086.07999999996 4419329.768999999,487092.51 4419326.384,487094.59699999995 4419317.739,487086.8879999999 4419319.624,487086.07999999996 4419329.768999999),(487099.25457906607 4419326.699,487099.95133371424 4419323.866660701,487102.2406704152 4419321.776396756,487105.7576224487 4419321.9422907205,487108.27921069914 4419322.231,487109.7722563737 4419320.615139009,487112.9574204795 4419320.449245046,487112.8578841012 4419322.506,487110.66808377847 4419324.828845691,487109.1750381039 4419327.748579455,487106.78616502456 4419328.232,487104.96133142227 4419326.384,487102.2406704152 4419327.027028695,487100.0508700925 4419327.549506698,487099.25457906607 4419326.699),(487149.404 4419406.194,487155.5 4419401.255999999,487152.456 4419395.398,487145.172 4419390.753999999,487140.51099999994 4419393.604,487136.662 4419390.102,487130.502 4419392.696,487132.404 4419395.779999999,487131.2899999999 4419401.765999999,487141.38899999997 4419401.973999999,487149.404 4419406.194),(487122.196 4419398.057,487114.12 4419395.179,487107.511 4419399.542767949,487107.511 4419403.913,487104.41 4419406.265,487104.41 4419410.236,487108.83111372095 4419413.65,487116.468 4419414.943,487118.877 4419413.65,487118.194 4419408.836,487121.44191549026 4419406.603,487122.837 4419402.727,487122.196 4419398.057),(487094.68499999994 4419366.138,487099.65099999995 4419364.669,487100.199 4419360.935999999,487103.216 4419357.589,487110.44999999995 4419360.411,487111.914 4419357.725,487109.044 4419351.74,487112.23 4419349.147,487110.753 4419347.068,487104.19499999995 4419347.361,487103.348 4419350.364,487095.43499999994 4419352.355,487094.091 4419348.926999999,487090.56499999994 4419347.591,487087.223 4419349.163999999,487084.31999999995 4419355.784,487085.75899999996 4419357.764,487089.82699999993 4419358.507999999,487091.56499999994 4419363.631999999,487094.68499999994 4419366.138),(487231.294 4419367.294,487235.667 4419368.571,487237.81819702766 4419372.049,487238.45199999993 4419375.487941678,487236.948 4419379.286,487238.646 4419381.281,487242.348 4419382.887734613,487243.641 4419386.463418942,487240.721 4419390.686,487239.82 4419395.897,487235.667 4419398.129,487230.62206811795 4419395.897,487226.447 4419392.697,487223.123 4419390.828,487224.039 4419385.243,487224.039 4419380.0879999995,487221.4571869594 4419375.352165661,487222.927 4419370.059,487231.294 4419367.294),(487187.382 4419430.243999999,487191.6429999999 4419429.851,487192.561 4419425.966,487198.794 4419428.882999999,487213.44499999995 4419425.209999999,487225.93299999996 4419419.388,487225.22899999993 4419415.541999999,487220.32699999993 4419415.734999999,487214.519 4419411.373,487205.108 4419413.150999999,487197.08699999994 4419416.037999999,487195.252 4419413.631999999,487189.726 4419414.943,487187.598 4419421.733999999,487184.55499999993 4419427.772,487187.382 4419430.243999999))";
            WKTReader    reader = new WKTReader(GeometryFactory.Default);
            IGeometry    geom   = reader.Read(wkt);

            Assert.That(geom, Is.Not.Null);
            Assert.That(geom.IsValid, Is.False);

            IGeometry normalizedGeom = geom.Normalized();

            Assert.That(normalizedGeom, Is.Not.Null);
            Assert.That(normalizedGeom.IsValid, Is.False);

            IGeometry fixedGeom = normalizedGeom.Buffer(0);

            Assert.That(fixedGeom, Is.Not.Null);
            Assert.That(fixedGeom.IsValid, Is.True);
            Console.WriteLine(fixedGeom);
        }
        private static void RunDelaunay(string sitesWKT, bool computeTriangles, string expectedWKT)
        {
            WKTReader reader = new WKTReader();
            IGeometry sites  = reader.Read(sitesWKT);

            DelaunayTriangulationBuilder builder = new DelaunayTriangulationBuilder();

            builder.SetSites(sites);

            IGeometryFactory geomFact = GeometryFactory.Default;
            IGeometry        result   = computeTriangles ? builder.GetTriangles(geomFact) : builder.GetEdges(geomFact);

            Assert.IsNotNull(result);

            IGeometry expected = reader.Read(expectedWKT);

            result.Normalize();
            expected.Normalize();
            Assert.IsTrue(expected.EqualsExact(result, ComparisonTolerance));
        }
        private static void RunVoronoi(string sitesWKT, string expectedWKT)
        {
            var reader = new WKTReader();
            var sites  = reader.Read(sitesWKT);

            var builder = new DelaunayTriangulationBuilder();

            builder.SetSites(sites);

            var       subdiv = builder.GetSubdivision();
            IGeometry result = subdiv.GetVoronoiDiagram(GeometryFactory.Default);

            Assert.IsNotNull(result);

            var expectedEdges = reader.Read(expectedWKT);

            result.Normalize();
            expectedEdges.Normalize();
            Assert.IsTrue(expectedEdges.EqualsExact(result, ComparisonTolerance));
        }
        public void TestIndexedPointOnLine()
        {
            var reader = new WKTReader();
            var geom   = reader.Read("LINESTRING (0 0, 0 10, 10 10)");

            geom = InsertPoint(geom, new Coordinate(1, 5));
            Assert.AreEqual("LINESTRING (0 0, 1 5, 0 10, 10 10)", geom.AsText());
            geom = InsertPoint(geom, new Coordinate(6, 9));
            Assert.AreEqual("LINESTRING (0 0, 1 5, 0 10, 6 9, 10 10)", geom.AsText());
            geom = InsertPoint(geom, new Coordinate(0, 0));
            Assert.AreEqual("LINESTRING (0 0, 1 5, 0 10, 6 9, 10 10)", geom.AsText());
            geom = InsertPoint(geom, new Coordinate(10, 10));
            Assert.AreEqual("LINESTRING (0 0, 1 5, 0 10, 6 9, 10 10)", geom.AsText());
            geom = InsertPoint(geom, new Coordinate(1, 5));
            Assert.AreEqual("LINESTRING (0 0, 1 5, 0 10, 6 9, 10 10)", geom.AsText());
            geom = InsertPoint(geom, new Coordinate(0, -2));
            Assert.AreEqual("LINESTRING (0 -2, 0 0, 1 5, 0 10, 6 9, 10 10)", geom.AsText());
            geom = InsertPoint(geom, new Coordinate(10, 13));
            Assert.AreEqual("LINESTRING (0 -2, 0 0, 1 5, 0 10, 6 9, 10 10, 10 13)", geom.AsText());
        }
Exemple #7
0
        public void Fixing_invalid_polygon_with_Buffer_0_returns_empty_polygon()
        {
            //arrange
            var rdr = new WKTReader();

            rdr.RepairRings = true;
            var poly = rdr.Read(
                @"POLYGON ((1.4749999999994841 -5.15,  30 -5.15,  48.9 -2,
108.1997 -2,  130.25148787313435 0.75647348414179227,
130.25148787313435 0.75647348414179161,  130 0.75,
126.3 0.72,  122.9 0.7,  119.2 0.42,  115.2 0.45,
111 0.29,  106.9 0.23,  102.8 0.2,  98.8 0.12,  94.8 0.04,
90.7 -0.08,  86.5 -0.2,  82.4 -0.42,  78.3 -0.57,  74.1 -0.69,
69.9 -0.78,  65.8 -0.87,  61.7 -1.07,  57.7 -1.09,  53.7 -1.229,
49.5 -1.289,  45.3 -1.369,  41.2 -1.719,  37 -2.409,  32.8 -3.219,
28.6 -3.769,  24.5 -4.089,  20.4 -4.429,  16.3 -4.599,  12.1 -4.759,
8 -4.889,  4 -5.049,  1.4749999999994841 -5.15))");

            //act
            var gpr   = new NetTopologySuite.Precision.GeometryPrecisionReducer(new PrecisionModel(1e10));
            var poly1 = gpr.Reduce(poly);
            var poly2 = poly.Buffer(0);
            var shell = poly.Factory.CreatePolygon(((IPolygon)poly).Shell.CoordinateSequence.Reversed()).Buffer(0);

            ToImage(0, poly, poly1, poly2);

            var isValidOp = new IsValidOp(poly);

            if (!isValidOp.IsValid)
            {
                Debug.WriteLine(isValidOp.ValidationError);
            }
            Debug.WriteLine(poly1.AsText());
            // assert
            //Assert.That(poly.IsValid,  Is.True,  "poly.IsValid");
            Assert.That(poly1.IsValid, Is.True, "poly1.IsValid");
            Assert.That(poly2, Is.Not.Null, "poly2 != null");

            //Known to fail
            //Assert.That(poly2.IsEmpty,  Is.False,  "poly2.IsEmpty");
        }
Exemple #8
0
        public void Issue469GeometryCollection()
        {
            int srid     = 31370;
            var geometry = new WKTReader(new NtsGeometryServices(new PrecisionModel(), srid)).Read("GEOMETRYCOLLECTION (POINT (40 10), LINESTRING(10 10, 20 20, 10 40), POLYGON((40 40, 20 45, 45 30, 40 40)))");

            var gmlWriter = new GMLWriter();
            var reader    = gmlWriter.Write(geometry);
            var document  = XDocument.Load(reader);

            document.Validate(CreateSchemaSet(), (sender, args) =>
            {
                Assert.Fail(args.Message);
            });

            var element   = document.Element(XName.Get("MultiGeometry", "http://www.opengis.net/gml"));
            var attribute = element.Attribute(XName.Get("srsName"));

            Assert.IsNotNull(attribute);
            Assert.AreEqual(attribute.Value, $"EPSG:{geometry.Factory.SRID}");
            Assert.AreEqual(attribute.Value, $"EPSG:{srid}");
        }
        //[ExpectedException(typeof(TopologyException))]
        public void FailedUnionTest()
        {
            var reader = new WKTReader(GeometryFactory.Fixed);

            Assert.IsNotNull(reader);

            var g1 = reader.Read(s1);

            Assert.IsNotNull(g1);
            Assert.IsFalse(g1.IsValid);
            g1 = g1.Buffer(0);

            var g2 = reader.Read(s2).Buffer(0d);

            Assert.IsNotNull(g2);

            var result = g1.Union(g2);

            Assert.IsNotNull(result);
            Debug.WriteLine(result);
        }
Exemple #10
0
        public void Issue469MultiPoint()
        {
            int srid     = 31370;
            var geometry = new WKTReader(new NtsGeometryServices(new PrecisionModel(), srid)).Read("MULTIPOINT (10 40, 40 30, 20 20, 30 10)");

            var gmlWriter = new GMLWriter();
            var reader    = gmlWriter.Write(geometry);
            var document  = XDocument.Load(reader);

            document.Validate(CreateSchemaSet(), (sender, args) =>
            {
                Assert.Fail(args.Message);
            });

            var element   = document.Element(XName.Get($"{geometry.GeometryType}", "http://www.opengis.net/gml"));
            var attribute = element.Attribute(XName.Get("srsName"));

            Assert.IsNotNull(attribute);
            Assert.AreEqual(attribute.Value, $"EPSG:{geometry.Factory.SRID}");
            Assert.AreEqual(attribute.Value, $"EPSG:{srid}");
        }
Exemple #11
0
        public void LineIsValid_ShouldReturnFalse_OnEdgeDistanceMoreLessTolerance()
        {
            //  Line end 0.023 from edge is not ok
            //
            //              S
            //              |
            //|--E < 0.007 >|
            //|             |
            //|             |
            //|-------------|

            var logger = A.Fake <ILogger <RouteSegmentValidator> >();
            var applicationSettings = A.Fake <IOptions <ApplicationSetting> >();

            A.CallTo(() => applicationSettings.Value).Returns(new ApplicationSetting {
                Tolerance = 0.01
            });

            var line = new WKTReader().Read("LINESTRING(578257.898582255 6179230.84377762,578248.38610886 6179230.74258109,578248.487305386 6179238.43351703,578257.79738573 6179238.3323205,578256.811707854 6179230.83918227)") as LineString;

            // Assert that distance from end point to edge is 0.007
            Coordinate[] linePointsMinusOne = new Coordinate[line.NumPoints - 1];

            for (int i = 0; i < line.NumPoints - 1; i++)
            {
                linePointsMinusOne[i] = line.GetPointN(i).Coordinate;
            }

            var newLine = new LineString(linePointsMinusOne);

            var endPointToEdgeDistance = Math.Round(line.EndPoint.Distance(newLine), 3);

            var routeSegmentValidator = new RouteSegmentValidator(logger, applicationSettings);

            var result = routeSegmentValidator.LineIsValid(line);

            // Assert that distance from end point to edge is 0.007
            endPointToEdgeDistance.Should().Be(0.007);
            result.Should().BeFalse();
        }
        internal void Run()
        {
            var reader  = new WKTReader();
            var polygon = reader.Read("POLYGON((0 0, 0 100, 100 100, 100 0, 0 0), (10 10, 90 10, 90 90, 10 90, 10 10))");

            var lineWkts = new[]
            {
                "LINESTRING(50 -10, 50 110)",
                "LINESTRING(5 -10, 5 110)",
                "LINESTRING(5 -10, 5 95, 110 95)",
                "LINESTRING(5 -10, 5 110, 110 50)"
            };

            Console.WriteLine(string.Format("Splitting\n{0}", polygon));
            foreach (var lineWkt in lineWkts)
            {
                var line = reader.Read(lineWkt);
                Console.WriteLine(string.Format("\nwith\n{0}", lineWkt));
                var splitPolygons = SplitPolygon(polygon, line);
                Console.WriteLine(string.Format("results in:\n{0}", splitPolygons));
            }
        }
Exemple #13
0
        /// <summary>
        /// Reads WKT from the <paramref name="str"/> via NTS's <see cref="WKTReader"/>.
        /// </summary>
        /// <param name="str"></param>
        /// <param name="reader"><c>new WKTReader(ctx.GeometryFactory)</c></param>
        /// <returns>Non-Null</returns>
        protected virtual IShape ParseIfSupported(string str, WKTReader reader)
        {
            try
            {
                IGeometry geom = reader.Read(str);

                //Normalizes & verifies coordinates
                CheckCoordinates(geom);

                if (geom is NetTopologySuite.Geometries.Point)
                {
                    NetTopologySuite.Geometries.Point ptGeom = (NetTopologySuite.Geometries.Point)geom;
                    if (m_ctx.UseNtsPoint)
                    {
                        return(new NtsPoint(ptGeom, m_ctx));
                    }
                    else
                    {
                        return(m_ctx.MakePoint(ptGeom.X, ptGeom.Y));
                    }
                }
                else if (geom.IsRectangle)
                {
                    return(base.MakeRectFromPoly(geom));
                }
                else
                {
                    return(base.MakeShapeFromGeometry(geom));
                }
            }
            catch (InvalidShapeException e)
            {
                throw e;
            }
            catch (Exception e)
            {
                throw new InvalidShapeException("error reading WKT: " + e.ToString(), e);
            }
        }
Exemple #14
0
        private void InsertDataTemporary(List <JsonObject> batch, string topic, string[] columns, NpgsqlConnection conn)
        {
            var tableColumns    = new StringBuilder();
            var geometryFactory = new GeometryFactory();
            var rdr             = new WKTReader(geometryFactory);

            foreach (var column in columns)
            {
                tableColumns.Append(column + ",");
            }
            tableColumns = tableColumns.Remove(tableColumns.Length - 1, 1);

            var comand = @$ "COPY  {topic}   (  {tableColumns} ) FROM STDIN (FORMAT BINARY)";

            using (var writer = conn.BeginBinaryImport(comand))
            {
                foreach (var document in batch)
                {
                    writer.StartRow();
                    foreach (var column in columns)
                    {
                        if (column == "position")
                        {
                            // TODO add environment variable
                            rdr.DefaultSRID = 25832;
                            var c = rdr.Read((string)document[column]);
                            writer.Write(c);
                        }
                        else
                        {
                            writer.Write((string)document[column]);
                        }
                    }
                }

                writer.Complete();
                batch.Clear();
            }
        }
Exemple #15
0
        public void TestIssue177()
        {
            var reader = new WKTReader();
            var g1     = reader.Read("MULTIPOLYGON (((30 20, 45 40, 10 40, 30 20)),((15 5, 40 10, 10 20, 5 10, 15 5)))");
            var g2     = reader.Read("MULTIPOLYGON (((40 40, 20 45, 45 30, 40 40)),((20 35, 10 30, 10 10, 30 5, 45 20, 20 35),(30 20, 20 15, 20 25, 30 20)))");

            IGeometry res = null;

            //                                                                                     |
            //                                                             Some cruel scale factor V
            Assert.DoesNotThrow(() => res = SnapRoundOverlayFunctions.SnappedIntersection(g1, g2, 0.1));
            Assert.That(res, Is.Not.Null);
            Assert.That(res.IsValid, Is.True);

            ToImage(0, g1, g2, res);

            // To show that the result is correct:
            var r1 = new GeometryPrecisionReducer(new PrecisionModel(0.1)).Reduce(g1);
            var r2 = new GeometryPrecisionReducer(new PrecisionModel(0.1)).Reduce(g2);

            ToImage(0, r1, r2, res);
        }
        //[Test]
        //public void TestClip()
        //{
        //    RunClip();
        //}

        internal void Run()
        {
            var reader  = new WKTReader();
            var polygon = reader.Read("POLYGON((0 0, 0 100, 100 100, 100 0, 0 0), (10 10, 90 10, 90 90, 10 90, 10 10))");

            string[] lineWkts = new[]
            {
                "MULTILINESTRING((50 -10, 50 20),(50 110, 50 80))",
                "LINESTRING(50 20, 50 -10, 110 -10, 110 110, 50 110, 50 80)",
                "LINESTRING(50 -10, 50 48, 51 49, 49 51, 50 52, 50 110)",
                "LINESTRING(49 -10, 51 50, 49 110)",
                "LINESTRING(50 -10, 50 110)",
                "LINESTRING(5 -10, 5 110)",
                "LINESTRING(5 -10, 5 95, 110 95)",
                "LINESTRING(5 -10, 5 110, 110 50)"
            };

            foreach (string lineWkt in lineWkts)
            {
                DoSplitTest(polygon, lineWkt);
            }
        }
        public void FixedUnionTest()
        {
            string s1 = "MULTIPOLYGON(((267225 195936,267063 195904,266895 195872,266825 195858,266822 195891,266850 196044,266934 196203,267047 196249,267352 196374,267281 196302,267255 196275,267222 196244,267166 196191,267160 196153,267157 196139,267196 196136,267225 195936)),((265704 193056,265703 193055,265692 193057,265678 193060,265663 193056,265659 193055,265655 193053,265653 193053,265651 193052,265648 193052,265646 193052,265631 193058,265616 193064,265612 193066,265609 193068,265605 193071,265603 193076,265595 193089,265596 193103,265597 193107,265623 193128,265631 193130,265630 193130,265609 193142,265608 193153,265608 193157,265607 193161,265607 193163,265606 193164,265603 193169,265619 193172,265623 193173,265619 193183,265618 193185,265618 193187,265613 193209,265618 193209,265622 193209,265620 193220,265626 193220,265626 193230,265617 193230,265616 193235,265616 193237,265615 193238,265604 193252,265606 193257,265607 193259,265607 193262,265607 193264,265607 193266,265607 193270,265607 193274,265607 193279,265606 193284,265605 193289,265602 193294,265595 193312,265598 193318,265600 193322,265601 193326,265602 193330,265602 193334,265602 193336,265602 193337,265599 193344,265610 193360,265611 193361,265612 193364,265613 193369,265615 193375,265615 193377,265615 193380,265613 193393,265609 193392,265607 193392,265605 193393,265587 193403,265588 193412,265589 193419,265610 193422,265629 193424,265631 193418,265633 193409,265637 193402,265642 193392,265659 193409,265661 193410,265662 193414,265662 193416,265663 193418,265664 193419,265664 193420,265665 193422,265665 193424,265666 193426,265666 193428,265665 193452,265657 193455,265652 193457,265640 193441,265636 193435,265623 193444,265642 193493,265645 193490,265649 193487,265665 193513,265673 193526,265681 193532,265683 193534,265684 193536,265685 193540,265686 193544,265687 193545,265687 193546,265690 193576,265682 193584,265655 193612,265667 193624,265668 193624,265670 193627,265679 193624,265683 193623,265693 193623,265692 193632,265692 193633,265693 193635,265695 193642,265693 193642,265692 193643,265691 193644,265690 193644,265689 193644,265679 193645,265679 193655,265678 193655,265677 193673,265676 193682,265670 193684,265659 193688,265654 193700,265652 193704,265631 193701,265629 193701,265628 193703,265619 193718,265617 193718,265616 193709,265612 193683,265614 193678,265609 193678,265571 193681,265551 193657,265495 193716,265492 193726,265481 193765,265481 193774,265480 193846,265479 193902,265478 193936,265526 193966,265563 193990,265548 194006,265547 194006,265546 194005,265544 194004,265543 194003,265542 194003,265541 194002,265540 194002,265540 194003,265521 194040,265525 194046,265527 194049,265527 194050,265528 194059,265528 194061,265543 194059,265544 194059,265544 194060,265549 194064,265554 194068,265555 194070,265557 194073,265558 194073,265558 194074,265559 194077,265561 194079,265564 194084,265567 194088,265568 194090,265570 194090,265581 194093,265569 194117,265567 194120,265567 194124,265567 194125,265568 194126,265569 194127,265569 194128,265570 194129,265571 194130,265572 194131,265573 194132,265574 194133,265575 194134,265576 194134,265577 194135,265596 194153,265583 194158,265540 194205,265530 194216,265473 194277,265462 194289,265461 194290,265451 194299,265432 194314,265410 194332,265394 194348,265372 194370,265371 194369,265359 194355,265362 194353,265362 194352,265367 194342,265342 194356,265341 194357,265340 194358,265339 194358,265338 194359,265337 194360,265336 194361,265335 194362,265335 194363,265334 194363,265333 194364,265332 194365,265331 194366,265330 194367,265325 194347,265308 194363,265302 194369,265326 194391,265308 194398,265306 194400,265304 194401,265303 194402,265302 194402,265301 194402,265300 194402,265294 194402,265288 194404,265286 194404,265286 194405,265285 194406,265284 194407,265283 194408,265282 194409,265282 194410,265281 194411,265280 194412,265279 194413,265278 194414,265277 194415,265276 194416,265275 194418,265275 194419,265274 194420,265273 194421,265272 194422,265272 194423,265271 194424,265270 194425,265269 194426,265268 194428,265268 194429,265267 194430,265266 194431,265266 194432,265265 194433,265264 194434,265263 194435,265262 194435,265261 194436,265260 194438,265258 194438,265253 194438,265254 194450,265254 194452,265253 194453,265252 194454,265251 194455,265243 194464,265234 194454,265238 194471,265238 194473,265237 194473,265235 194475,265234 194476,265232 194477,265231 194478,265230 194478,265229 194478,265228 194477,265227 194477,265226 194476,265225 194475,265224 194474,265224 194473,265223 194472,265222 194472,265222 194471,265221 194470,265220 194469,265217 194466,265216 194465,265166 194437,265165 194447,265164 194476,265158 194508,265158 194511,265173 194549,265176 194555,265199 194612,265205 194606,265214 194603,265238 194592,265244 194601,265246 194605,265257 194601,265263 194598,265265 194598,265266 194599,265268 194601,265270 194602,265272 194604,265274 194604,265278 194605,265281 194605,265282 194605,265283 194605,265292 194603,265290 194595,265284 194577,265320 194599,265336 194580,265351 194590,265302 194548,265300 194546,265298 194545,265295 194542,265295 194541,265298 194536,265285 194522,265285 194521,265284 194520,265283 194519,265282 194518,265281 194517,265280 194516,265279 194514,265279 194512,265247 194500,265262 194484,265277 194470,265278 194469,265287 194460,265304 194444,265306 194442,265325 194424,265330 194429,265370 194431,265371 194430,265372 194429,265374 194428,265376 194427,265377 194426,265378 194425,265379 194425,265380 194424,265381 194423,265382 194423,265383 194422,265384 194421,265385 194420,265386 194419,265387 194419,265388 194418,265389 194417,265390 194417,265390 194416,265391 194415,265392 194415,265393 194414,265395 194413,265396 194412,265398 194411,265399 194409,265401 194408,265402 194407,265403 194406,265404 194405,265405 194405,265406 194404,265407 194403,265408 194402,265409 194402,265410 194401,265411 194400,265412 194399,265413 194398,265414 194398,265414 194397,265416 194396,265417 194396,265418 194395,265419 194394,265420 194393,265421 194393,265422 194392,265423 194391,265424 194390,265425 194390,265426 194389,265427 194388,265428 194387,265429 194387,265430 194386,265431 194385,265432 194384,265433 194383,265434 194383,265435 194382,265436 194381,265437 194381,265438 194380,265439 194379,265440 194379,265441 194378,265442 194377,265443 194376,265444 194376,265445 194375,265446 194374,265447 194373,265448 194373,265448 194372,265449 194371,265450 194370,265451 194370,265451 194368,265453 194363,265466 194371,265467 194372,265467 194373,265468 194374,265469 194375,265469 194376,265470 194377,265471 194378,265471 194379,265471 194380,265469 194381,265469 194382,265468 194382,265466 194384,265462 194386,265425 194414,265430 194411,265430 194410,265428 194412,265433 194418,265448 194406,265463 194421,265464 194421,265465 194421,265466 194421,265467 194422,265487 194442,265507 194463,265548 194465,265548 194473,265578 194475,265578 194477,265579 194477,265602 194498,265595 194503,265594 194505,265593 194507,265592 194510,265590 194513,265590 194514,265589 194515,265589 194516,265589 194517,265588 194518,265587 194520,265587 194521,265586 194523,265585 194525,265585 194526,265582 194536,265579 194545,265578 194547,265577 194548,265576 194550,265575 194552,265574 194553,265573 194555,265572 194556,265571 194557,265570 194558,265570 194560,265569 194561,265569 194562,265568 194563,265568 194565,265567 194566,265566 194569,265565 194572,265565 194574,265564 194575,265562 194579,265560 194583,265559 194585,265557 194588,265557 194590,265556 194591,265555 194592,265555 194593,265554 194594,265553 194596,265553 194597,265552 194598,265552 194599,265551 194601,265551 194602,265550 194603,265549 194605,265548 194606,265548 194607,265548 194609,265547 194623,265538 194624,265508 194628,265508 194629,265501 194629,265461 194633,265456 194639,265458 194655,265462 194682,265463 194689,265491 194705,265527 194725,265534 194729,265561 194745,265575 194752,265589 194755,265593 194755,265598 194755,265603 194755,265607 194752,265630 194734,265651 194712,265652 194710,265654 194708,265656 194707,265657 194705,265658 194704,265658 194703,265659 194702,265659 194701,265659 194700,265659 194698,265660 194697,265660 194696,265663 194693,265666 194689,265666 194688,265666 194686,265666 194683,265666 194678,265666 194677,265667 194676,265671 194671,265675 194667,265678 194663,265682 194660,265689 194653,265698 194650,265714 194645,265700 194593,265699 194589,265701 194586,265704 194583,265706 194580,265711 194573,265716 194567,265724 194559,265730 194551,265734 194547,265737 194543,265739 194539,265742 194535,265747 194528,265749 194519,265752 194507,265754 194495,265755 194490,265757 194486,265769 194467,265779 194448,265780 194447,265780 194445,265780 194444,265780 194443,265780 194442,265780 194441,265779 194440,265779 194439,265779 194437,265779 194436,265780 194435,265780 194434,265779 194433,265780 194431,265780 194430,265779 194429,265779 194428,265779 194427,265779 194426,265779 194424,265779 194423,265779 194422,265778 194421,265778 194419,265777 194418,265777 194417,265777 194416,265777 194414,265777 194413,265777 194411,265777 194410,265777 194409,265778 194408,265784 194399,265791 194390,265791 194389,265791 194388,265790 194387,265790 194386,265790 194385,265789 194384,265789 194383,265789 194381,265788 194380,265788 194379,265788 194378,265787 194376,265787 194375,265787 194374,265786 194373,265786 194372,265786 194371,265786 194370,265785 194364,265785 194358,265785 194357,265785 194356,265784 194355,265784 194353,265784 194352,265783 194351,265783 194350,265783 194348,265782 194347,265782 194346,265782 194341,265783 194336,265783 194335,265783 194334,265783 194332,265783 194331,265783 194330,265784 194328,265784 194327,265785 194326,265785 194325,265786 194323,265787 194321,265788 194319,265788 194318,265787 194318,265785 194317,265785 194318,265775 194318,265775 194313,265768 194310,265748 194302,265754 194293,265761 194282,265765 194272,265773 194252,265780 194235,265781 194231,265780 194230,265778 194225,265775 194219,265775 194218,265775 194216,265774 194215,265774 194213,265770 194202,265767 194190,265767 194189,265767 194187,265768 194181,265802 194173,265813 194153,265814 194148,265834 194139,265836 194138,265838 194136,265840 194135,265841 194135,265842 194134,265843 194133,265845 194132,265847 194130,265848 194130,265849 194129,265850 194129,265851 194128,265852 194127,265853 194127,265854 194126,265857 194121,265858 194115,265859 194113,265860 194110,265860 194108,265862 194107,265876 194093,265869 194090,265868 194089,265868 194088,265867 194087,265867 194085,265866 194084,265866 194083,265866 194082,265865 194081,265865 194079,265865 194078,265864 194077,265864 194076,265864 194075,265863 194073,265863 194071,265862 194069,265862 194068,265861 194068,265849 194059,265853 194017,265853 194016,265852 194014,265852 194013,265852 194011,265851 194010,265851 194009,265851 194008,265850 194007,265849 194004,265848 194002,265848 194000,265847 193997,265845 193992,265845 193991,265845 193989,265853 193957,265844 193964,265806 193997,265780 194074,265743 193975,265748 193972,265748 193971,265746 193968,265740 193965,265731 193960,265727 193957,265732 193952,265733 193950,265734 193948,265735 193947,265734 193946,265734 193944,265734 193943,265734 193942,265734 193940,265734 193939,265734 193938,265734 193936,265734 193935,265734 193934,265733 193932,265733 193930,265732 193928,265726 193922,265732 193902,265732 193900,265732 193897,265730 193879,265723 193879,265716 193879,265714 193873,265744 193875,265749 193874,265715 193833,265717 193832,265717 193824,265718 193817,265718 193816,265763 193761,265764 193762,265767 193773,265768 193780,265775 193785,265783 193791,265773 193814,265770 193821,265768 193829,265766 193839,265762 193848,265759 193856,265758 193862,265758 193872,265763 193881,265768 193889,265781 193866,265790 193850,265794 193845,265840 193774,265837 193806,265837 193809,265831 193827,265860 193838,265882 193774,265905 193718,266059 193881,266139 193966,266196 193861,266170 193795,266180 193724,266194 193619,266209 193557,266221 193508,266225 193492,266224 193475,266222 193325,266223 193318,266225 193297,266227 193280,266228 193266,266234 193210,266137 193221,266121 193247,266068 193233,266066 193191,266066 193188,266064 193152,266039 193057,266035 193043,266025 192991,266019 192991,266019 192981,266023 192981,266021 192972,265989 192940,266005 192938,266006 192953,266064 192989,266071 192986,266087 192979,266104 192977,266228 192963,266223 192995,266219 193016,266270 193017,266400 192817,266413 192797,266561 192570,266615 192536,266620 192553,266632 192599,266607 192635,266547 192722,266661 192907,266693 192959,266872 192896,266899 192887,266926 192889,266972 192892,266968 192741,266967 192695,266871 192667,266737 192629,266764 192622,266727 192409,266717 192352,266808 192287,266885 192231,266873 192268,266868 192283,266894 192340,266987 192540,267003 192550,267304 192739,267285 192641,267270 192566,266933 192196,266928 192191,266906 192166,266889 192142,266873 192118,266813 192175,266797 192190,266763 192137,266358 192253,266369 192237,266370 192235,266367 192235,266296 192224,266281 192203,266023 191829,266016 191826,266005 191816,266002 191816,265998 191816,265991 191822,265991 191829,265991 191834,265989 191839,265987 191844,265983 191847,265980 191850,265976 191851,265974 191852,265969 191850,265969 191842,265967 191837,265966 191834,265964 191831,265960 191827,265958 191826,265950 191829,265949 191862,265932 191858,265932 191853,265931 191849,265929 191845,265925 191841,265922 191838,265899 191861,265888 191860,265886 191858,265883 191854,265881 191850,265880 191847,265879 191840,265866 191833,265859 191846,265852 191842,265846 191839,265840 191837,265838 191837,265837 191839,265835 191844,265834 191850,265835 191858,265834 191859,265831 191862,265828 191864,265825 191864,265821 191864,265818 191862,265802 191848,265800 191847,265796 191847,265790 191847,265785 191849,265768 191855,265765 191856,265761 191855,265755 191852,265742 191848,265739 191834,265725 191801,265720 191793,265715 191789,265709 191785,265705 191783,265696 191780,265684 191778,265681 191779,265680 191780,265679 191782,265679 191784,265683 191799,265681 191831,265677 191841,265663 191836,265652 191833,265648 191836,265643 191839,265638 191840,265632 191839,265631 191838,265629 191821,265626 191817,265624 191818,265623 191818,265620 191825,265618 191834,265615 191841,265612 191848,265608 191854,265603 191859,265597 191864,265592 191868,265589 191869,265586 191869,265579 191868,265575 191868,265567 191865,265559 191865,265556 191865,265552 191867,265548 191870,265543 191876,265537 191874,265533 191873,265528 191873,265523 191874,265515 191877,265491 191878,265479 191881,265468 191886,265456 191883,265445 191877,265413 191877,265399 191875,265389 191874,265372 191875,265360 191874,265334 191870,265329 191869,265398 192004,265565 192332,265564 192333,265557 192337,265556 192341,265555 192343,265555 192344,265556 192345,265559 192363,265563 192381,265564 192384,265565 192386,265580 192409,265596 192429,265599 192432,265603 192434,265610 192436,265616 192438,265621 192440,265626 192442,265648 192448,265670 192455,265673 192456,265676 192457,265679 192458,265682 192460,265694 192468,265708 192475,265717 192479,265726 192483,265729 192484,265731 192485,265734 192487,265738 192488,265748 192491,265759 192494,265772 192498,265784 192504,265807 192515,265824 192531,265847 192551,265855 192574,265865 192601,265864 192627,265864 192659,265802 192646,265842 192760,265835 192794,265823 192853,265779 192863,265804 192879,265823 192892,265812 192890,265808 192890,265807 192890,265806 192891,265805 192892,265803 192900,265801 192908,265800 192916,265800 192924,265800 192927,265772 192935,265767 192936,265765 192936,265764 192931,265761 192923,265760 192923,265757 192924,265756 192923,265729 192905,265724 192909,265715 192914,265704 192914,265698 192914,265698 192916,265695 192916,265687 192942,265704 192951,265719 192954,265715 192957,265710 192960,265706 192962,265706 192974,265707 192976,265705 192978,265704 192979,265704 192981,265701 192987,265698 192994,265695 192994,265691 192993,265687 192994,265680 192994,265677 193008,265676 193010,265685 193012,265712 193020,265712 193017,265713 193015,265711 193012,265711 193010,265726 193011,265725 193038,265721 193041,265704 193056),(265681 194364,265681 194367,265671 194367,265671 194358,265671 194357,265681 194357,265681 194364),(265672 194259,265672 194252,265682 194252,265682 194261,265682 194262,265672 194262,265672 194259),(265660 194241,265669 194241,265669 194251,265659 194251,265659 194249,265659 194241,265660 194241),(265730 193180,265761 193187,265770 193167,265773 193196,265778 193238,265780 193284,265780 193290,265781 193296,265781 193300,265781 193305,265781 193310,265781 193315,265737 193357,265704 193365,265692 193357,265689 193334,265698 193344,265699 193335,265701 193319,265703 193305,265718 193219,265723 193191,265728 193192,265730 193180),(265829 193249,265833 193249,265833 193259,265828 193259,265823 193259,265823 193250,265823 193249,265829 193249),(265892 193510,265906 193514,266004 193467,265951 193602,265890 193576,265899 193549,265892 193510),(266286 192856,266219 192756,266168 192757,266168 192748,266169 192722,266220 192689,266281 192648,266286 192670,266318 192815,266290 192850,266286 192856),(266044 192606,266037 192606,266037 192596,266047 192596,266047 192603,266047 192606,266044 192606),(266039 192790,266039 192800,266029 192800,266029 192790,266037 192790,266039 192790),(265749 192996,265749 192986,265759 192986,265759 192996,265749 192996),(265848 192834,265848 192824,265858 192824,265858 192834,265848 192834),(265978 192980,265978 192970,265988 192970,265988 192980,265978 192980),(266088 192809,266088 192813,266080 192813,266078 192813,266078 192803,266088 192803,266088 192809),(265981 192800,265981 192790,265991 192790,265991 192800,265981 192800),(265951 192844,265951 192834,265961 192834,265961 192844,265951 192844),(265917 193026,265917 193016,265927 193016,265927 193026,265917 193026),(265926 193055,265926 193045,265936 193045,265936 193055,265926 193055),(265966 192746,265966 192736,265976 192736,265976 192746,265966 192746),(266046 192708,266046 192698,266056 192698,266056 192708,266046 192708),(265692 193744,265687 193751,265684 193755,265682 193756,265667 193763,265635 193732,265630 193728,265650 193718,265652 193717,265662 193716,265673 193718,265676 193718,265679 193718,265681 193718,265682 193719,265683 193723,265687 193723,265687 193733,265692 193744),(265611 193820,265611 193810,265621 193810,265621 193820,265611 193820),(265731 193735,265731 193725,265741 193725,265741 193735,265731 193735),(265708 193562,265708 193552,265718 193552,265718 193562,265708 193562),(265650 193477,265640 193477,265640 193467,265648 193467,265650 193467,265650 193477),(265680 193109,265680 193099,265690 193099,265690 193109,265680 193109),(265611 193335,265611 193325,265621 193325,265621 193335,265611 193335),(265610 194005,265610 193995,265620 193995,265620 194005,265610 194005),(265570 193944,265570 193934,265580 193934,265580 193944,265570 193944),(265643 193872,265643 193862,265653 193862,265653 193872,265643 193872),(265909 193141,265909 193131,265919 193131,265919 193141,265909 193141),(265800 193015,265800 193005,265810 193005,265810 193015,265800 193015),(265728 194212,265728 194202,265738 194202,265738 194212,265728 194212),(265691 194370,265691 194360,265701 194360,265701 194370,265691 194370)),((265057 193097,265050 193096,265044 193093,265043 193093,265041 193093,265038 193093,265037 193093,265035 193093,265029 193092,265031 193093,265035 193094,265060 193099,265076 193103,265058 193097,265057 193097)),((265246 193239,265266 193230,265268 193230,265279 193209,265282 193211,265281 193210,265290 193199,265273 193188,265269 193196,265260 193213,265249 193234,265246 193239)),((265525 192957,265525 192962,265524 192965,265526 192968,265530 192975,265533 192983,265536 192990,265540 192993,265562 193014,265575 193011,265609 193004,265606 192991,265602 192978,265607 192966,265613 192953,265573 192946,265533 192939,265527 192954,265525 192957)),((265345 192929,265348 192937,265349 192941,265371 192945,265372 192945,265373 192938,265374 192935,265374 192934,265364 192919,265363 192920,265345 192929)))";
            string s2 = "POLYGON((265433 194418,265428 194412,265430 194410,265430 194411,265425 194414,265462 194386,265466 194384,265468 194382,265469 194382,265469 194381,265471 194380,265471 194379,265471 194378,265470 194377,265469 194376,265469 194375,265468 194374,265467 194373,265467 194372,265466 194371,265453 194363,265451 194368,265451 194370,265450 194370,265449 194371,265448 194372,265448 194373,265447 194373,265446 194374,265445 194375,265444 194376,265443 194376,265442 194377,265441 194378,265440 194379,265439 194379,265438 194380,265437 194381,265436 194381,265435 194382,265434 194383,265433 194383,265432 194384,265431 194385,265430 194386,265429 194387,265428 194387,265427 194388,265426 194389,265425 194390,265424 194390,265423 194391,265422 194392,265421 194393,265420 194393,265419 194394,265418 194395,265417 194396,265416 194396,265414 194397,265414 194398,265413 194398,265412 194399,265411 194400,265410 194401,265409 194402,265408 194402,265407 194403,265406 194404,265405 194405,265404 194405,265403 194406,265402 194407,265402 194407,265401 194408,265399 194409,265398 194411,265396 194412,265395 194413,265393 194414,265392 194415,265391 194415,265390 194416,265390 194417,265389 194417,265388 194418,265387 194419,265386 194419,265385 194420,265384 194421,265383 194422,265382 194423,265381 194423,265380 194424,265379 194425,265378 194425,265377 194426,265376 194427,265374 194428,265372 194429,265371 194430,265370 194431,265330 194429,265369 194467,265379 194477,265422 194481,265427 194484,265433 194488,265467 194515,265469 194508,265487 194442,265467 194422,265466 194421,265465 194421,265464 194421,265463 194421,265448 194406,265433 194418))";

            var reader = new WKTReader(GeometryFactory.Fixed);

            Assert.IsNotNull(reader);

            var g1 = reader.Read(s1).Buffer(0);

            Assert.IsNotNull(g1);

            var g2 = reader.Read(s2).Buffer(0);

            Assert.IsNotNull(g2);

            var result = g1.Union(g2);

            Assert.IsNotNull(result);
            Debug.WriteLine(result);
        }
Exemple #18
0
        private IReadOnlyList <ILineString> MakeGeometries()
        {
            /*
             * (p2) (p3) ----- (e1) : (p1) -> (p2) ----------------------------------------------------
             * - \ / --------- (e2) : (p3) -> (p1) ----------------------------------------------------
             * | (p1) | ------ (e3) : (p4) -> (p1) ----------------------------------------------------
             * - / \ --------- (e4) : (p1) -> (p5) ----------------------------------------------------
             * (p4) (p5) ----- (e5) : (p2) -> (p4) ----------------------------------------------------
             * --------------- (e6) : (p5) -> (p3) ----------------------------------------------------
             */
            String p1     = "11.3441505 48.0839963";
            String p2     = "11.3421209 48.0850624";
            String p3     = "11.3460348 48.0850108";
            String p4     = "11.3427522 48.0832129";
            String p5     = "11.3469701 48.0825356";
            var    reader = new WKTReader();

            ILineString readAsLineString(string wkt) => reader.Read("SRID=4326;" + wkt) as ILineString;

            var geometries = new ILineString[] {
                readAsLineString("LINESTRING(" + p1 + "," + p2 + ")"),
                readAsLineString("LINESTRING(" + p3 + "," + p1 + ")"),
                readAsLineString("LINESTRING(" + p4 + "," + p1 + ")"),
                readAsLineString("LINESTRING(" + p1 + "," + p5 + ")"),
                readAsLineString("LINESTRING(" + p2 + "," + p4 + ")"),
                readAsLineString("LINESTRING(" + p5 + "," + p3 + ")"),
            };

            var geoms = new List <ILineString>();

            for (int i = 0; i < geometries.Length; i++)
            {
                var g = geometries[i];
                g.UserData = i;
                geoms.Add(g);
            }

            return(geoms);
        }
        private static void RunDelaunay(string sitesWKT, string constraintsWKT, bool computeTriangles, string expectedWKT)
        {
            var reader      = new WKTReader();
            var sites       = reader.Read(sitesWKT);
            var constraints = reader.Read(constraintsWKT);

            var builder = new ConformingDelaunayTriangulationBuilder();

            builder.SetSites(sites);
            builder.Constraints = constraints;

            var      geomFact = GeometryFactory.Default;
            Geometry result   = computeTriangles ? builder.GetTriangles(geomFact) : builder.GetEdges(geomFact);

            Assert.IsNotNull(result);

            var expectedEdges = reader.Read(expectedWKT);

            result.Normalize();
            expectedEdges.Normalize();
            Assert.IsTrue(expectedEdges.EqualsExact(result, ComparisonTolerance));
        }
        public void TestSeptPolygones()
        {
            const string wktGeom9 =
                "MULTIPOLYGON ( " +
                "((-73.8706030450129 45.425307895968558, -73.8691180248536 45.425712901466682, -73.862907940551338 45.425949154673731, -73.862739188260548 45.423181617104319, -73.864662964375952 45.423384119853267, -73.8654729753718 45.42220285381751, -73.865979232244342 45.421730347403241, -73.866822993698463 45.42088658594912, -73.866485489116826 45.420481580450996, -73.865202971706537 45.42041407953468, -73.864629213917681 45.421325341905117, -73.864156707503412 45.422236604275611, -73.863481698340081 45.422405356566514, -73.863414197423765 45.421899099693974, -73.863414197423765 45.421190340072485, -73.8635491992564 45.4200765749531, -73.864122957045254 45.419165312582606, -73.864797966208585 45.419064061208076, -73.866316736825922 45.419030310749974, -73.867092997363727 45.419266563957194, -73.867295500112789 45.419536567622515, -73.867396751487263 45.420751584116317, -73.867092997363727 45.421527844654122, -73.866384237742238 45.422506607941045, -73.866046733160658 45.423215367562364, -73.8669579955311 45.423721624434904, -73.868881771646556 45.423485371227684, -73.8694555294353 45.423417870311312, -73.8700630376822 45.423991628100168, -73.870434292722109 45.424497884972709, -73.8706030450129 45.425307895968558), " +
                "(-73.86921927622808 45.425139143677825, -73.868983023020974 45.424464134514437, -73.868544267064863 45.423991628100168, -73.86813926156691 45.423991628100168, -73.867092997363727 45.423991628100168, -73.86533797353917 45.423620373060317, -73.864966718499375 45.424059129016484, -73.864966718499375 45.424497884972709, -73.865304223081068 45.42534164642683, -73.866451738658668 45.425409147343146, -73.86756550377811 45.425274145510514, -73.86921927622808 45.425139143677825), " +
                "(-73.865937695291677 45.419884197388171, -73.865599517078863 45.419585804847259, -73.86432637557175 45.4198046260438, -73.864167232883347 45.4205605538138, -73.864565089604355 45.420500875305606, -73.865937695291677 45.419884197388171)), " +
                "((-73.868038010192436 45.424869140012561, -73.866620490949458 45.424869140012561, -73.865844230411653 45.424970391386921, -73.865742979037179 45.42436288314002, -73.865979232244342 45.42402537855844, -73.866687991865717 45.424295382223704, -73.867869257901532 45.424396633598121, -73.868038010192436 45.424869140012561), " +
                "(-73.86744733356926 45.424703767127937, -73.867371896498639 45.42446991220919, -73.867002254852821 45.424454824795021, -73.866232796733016 45.424432193673908, -73.866345952338861 45.4246509611786, -73.86744733356926 45.424703767127937)), " +
                "((-73.86512208901371 45.419923983060187, -73.864604875276427 45.420301946945074, -73.8644059469159 45.420043340076518, -73.86512208901371 45.419923983060187)))";

            IGeometryFactory factory   = GeometryFactory.Default; //new GeometryFactory(new PrecisionModel(Math.Pow(10, 13)));
            WKTReader        wktReader = new WKTReader(factory);
            List <IGeometry> polys     = new List <IGeometry>();

            using (ShapefileDataReader reader = new ShapefileDataReader("sept_polygones", factory))
            {
                int index = 0;
                while (reader.Read())
                {
                    IGeometry geom = reader.Geometry;
                    Assert.IsNotNull(geom);
                    Assert.IsTrue(geom.IsValid);
                    geom.Normalize();
                    Debug.WriteLine(String.Format("Geom {0}: {1}", ++index, geom));
                    polys.Add(geom);
                }
            }

            IGeometry expected = wktReader.Read(wktGeom9);

            expected.Normalize();

            Envelope e1 = expected.EnvelopeInternal;
            Envelope e2 = polys[8].EnvelopeInternal;

            Assert.IsTrue(e1.Equals(e2), string.Format("{0}\ndoes not match\n{1}", e1, e2));
            Assert.IsTrue(expected.EqualsTopologically(polys[8]), string.Format("{0}\ndoes not match\n{1}", expected, polys[8]));
        }
        public void TestSimplifyBadPoly()
        {
            var geom = new WKTReader().Read("POLYGON ((1 1, 1 1, 1 1, 1 1, 1 1))");

            var geom2 = new Polygon(new LinearRing(new Coordinate[]
            {
                new Coordinate(1, 1),
                new Coordinate(1, 1),
                new Coordinate(1, 1),
                new Coordinate(1, 1),
                new Coordinate(1, 1)
            }));

            Debug.WriteLine("Bad polygon: " + geom);
            var simple = DouglasPeuckerSimplifier.Simplify(geom, 0.1);

            Debug.WriteLine("Simple bad polygon: " + simple);
            Assert.AreEqual(geom.GetType(), simple.GetType());
            Assert.AreNotEqual(geom, simple, "Simplify didn't do anything to this invalid polygon.");
            // This happens with JTS 1.9.0, 1.8.0 still returns GeometryCollection.Empty
            Assert.AreEqual(geom.GetType(), Polygon.Empty);
        }
        internal static Geometry readWKTFile(string wktFile)
        {
            File      f         = new File(TEST_GEOMETRIES_RESOURCES_DIR, wktFile);
            WKTReader wktReader = new WKTReader(geometryFactory);

            System.IO.StreamReader reader = null;
            try
            {
                reader = new System.IO.StreamReader(f);
                return(wktReader.read(reader));
            }
            catch (FileNotFoundException e)
            {
                Console.WriteLine(e.ToString());
                Console.Write(e.StackTrace);
                return(null);
            }
            catch (ParseException e)
            {
                Console.WriteLine(e.ToString());
                Console.Write(e.StackTrace);
                return(null);
            }
            finally
            {
                if (reader != null)
                {
                    try
                    {
                        reader.Close();
                    }
                    catch (IOException)
                    {
                        // nothing to do
                    }
                }
            }
        }
        public static string ToGeoJson(this SqlGeometry geometry, KeyValuePair <string, object>[] attributes = null)
        {
            var wkt       = new string(geometry.STAsText().Value);
            var wktReader = new WKTReader();
            var geom      = wktReader.Read(wkt);

            var attributesTable = new AttributesTable();

            if (attributes != null)
            {
                foreach (var attribute in attributes)
                {
                    attributesTable.AddAttribute(attribute.Key, attribute.Value);
                }
            }

            var feature           = new Feature(geom, attributesTable);
            var featureCollection = new FeatureCollection()
            {
                CRS      = new NamedCRS(string.Format("EPSG:{0}", geometry.STSrid)),
                Features = { feature }
            };

            var sb = new StringBuilder();

            using (var sw = new StringWriter(sb))
            {
                var serializer = new GeoJsonSerializer()
                {
                    Formatting = Newtonsoft.Json.Formatting.None
                };

                serializer.Serialize(sw, featureCollection);
                sw.Close();
            }

            return(sb.ToString());
        }
        public HabitatMap LoadHabitatMap(string rootFilePath)
        {
            var pathGenerator = new HabitatMapFileManagerPathsGenerator(rootFilePath);
            var infoJson      = JsonUtility.FromJson <HabitatMapInfoJson>(File.ReadAllText(pathGenerator.MainInfoFilePath()));

            var gridCellsCount = infoJson.GridCellsCount;
            var treesArray     = new MyQuadtree <HabitatFieldInTree> [gridCellsCount.X, gridCellsCount.Y];
            var wktReader      = new WKTReader();

            for (int x = 0; x < gridCellsCount.X; x++)
            {
                for (int y = 0; y < gridCellsCount.Y; y++)
                {
                    var gridInfoFile = JsonUtility.FromJson <HabitatFieldsTypeInfoJson>(File.ReadAllText(pathGenerator.GridInfoFile(x, y)));

                    string oneCellFilePath = pathGenerator.GridWrtFile(x, y);
                    var    tree            = new MyQuadtree <HabitatFieldInTree>();
                    var    geoCollection   = wktReader.Read(File.ReadAllText(oneCellFilePath)) as GeometryCollection;

                    int i = 0;
                    foreach (var type in gridInfoFile.TypesList)
                    {
                        tree.Add(new HabitatFieldInTree()
                        {
                            Field = new HabitatField()
                            {
                                Geometry = geoCollection.GetGeometryN(i),
                                Type     = type
                            }
                        });
                        i++;
                    }
                    treesArray[x, y] = tree;
                }
            }

            return(new HabitatMap(infoJson.MapStartPosition, infoJson.MapGridSize, infoJson.GridCellsCount, treesArray));
        }
        public void GeometryTransformScaleTest()
        {
            var wktReader = new WKTReader(new GeometryFactory(new PrecisionModel(1000)));
            var geometry  = wktReader.Read("POLYGON((0 -3,5 -3,5 -7,0 -7,0 -3))");

            var scale = 5.0;

            var scaledGeometry = SharpMap.CoordinateSystems.Transformations.GeometryTransform.Scale(geometry, scale);

            Assert.AreEqual(scaledGeometry.Coordinates.Length, geometry.Coordinates.Length);
            Assert.AreEqual(scaledGeometry.Centroid, geometry.Centroid);

            Assert.AreEqual(-10.0, scaledGeometry.Coordinates[0].X);
            Assert.AreEqual(5.0, scaledGeometry.Coordinates[0].Y);
            Assert.AreEqual(15.0, scaledGeometry.Coordinates[1].X);
            Assert.AreEqual(5.0, scaledGeometry.Coordinates[1].Y);
            Assert.AreEqual(15.0, scaledGeometry.Coordinates[2].X);
            Assert.AreEqual(-15.0, scaledGeometry.Coordinates[2].Y);
            Assert.AreEqual(-10.0, scaledGeometry.Coordinates[3].X);
            Assert.AreEqual(-15.0, scaledGeometry.Coordinates[3].Y);
            Assert.AreEqual(-10.0, scaledGeometry.Coordinates[4].X);
            Assert.AreEqual(5.0, scaledGeometry.Coordinates[4].Y);
        }
Exemple #26
0
        public void intersection_between_linestrings_gives_topology_error()
        {
            const string ls1Wkt = @"LINESTRING (51055.227410858584 52102.041513978584, 51073.39084032347 52096.46568847251, 51183.32738708461 52062.71727093575, 51280.83632421188 52032.78389190314, 51415.62809024075 51991.40539735807, 51575.27507553736 51942.39682580468, 51669.91610274913 51913.34384027303, 51745.43773052417 51890.16014474777, 51765.32190593836 51884.05608314112, 51855.59683603979 51952.36411358454, 51916.20234851714 51998.2222846924, 52004.718294372215 52065.199350389405, 52004.718294372215 52065.199350389405, 52033.42616870359 52086.921641966816, 52046.98266491563 52097.17939076726, 52057.349397313075 52105.02355161466, 52075.69053924701 52118.901682344665, 52119.54979169772 52152.08851669904, 52122.739555512315 52154.502104652085, 52133.10628790976 52162.34626549949, 52137.89093363166 52165.96664742906, 52137.89093363166 52165.96664742906, 52143.4730203072 52170.19042634689, 52227.20432044038 52233.54711011433, 52300.56888817612 52289.05963303437, 52392.2745978458 52358.45028668442, 52402.64133024324 52366.294447531815, 52415.40038550163 52375.948799344, 52428.95688171367 52386.20654814444, 52645.86082110629 52550.33052895152, 52739.95885363691 52621.53137356636, 52805.34901183616 52671.00992660379)";
            const string ls2Wkt = @"LINESTRING (51313.564671633 52022.73691510973, 51331.728101097884 52017.16108960366, 51441.66464785903 51983.412672066894, 51539.173584986296 51953.47929303429, 51673.96535101517 51912.10079848921, 51833.61233631178 51863.09222693583, 51928.253363523545 51834.03924140418, 52003.77499129859 51810.85554587893, 52131.874967524614 51771.53130283609, 52204.52868538415 51749.228000811796, 52310.64135225795 51716.653441276314, 52345.05627124405 51706.08871926481, 52361.30776076527 51701.09982275937, 52373.73537039913 51697.284784255215, 52391.03842688936 51691.973076799426, 52394.74473141134 51690.83531218692, 52397.82849878731 51693.16869616807, 52441.687751238016 51726.35553052244, 52444.87751505261 51728.76911847549, 52455.24424745006 51736.61327932289, 52460.028893171955 51740.23366125246, 52465.6109798475 51744.45744017029, 52521.20645015943 51786.52467937298, 52522.57757869049 51819.852573264536, 52526.35931204718 51911.77481482129, 52531.08647874304 52026.677616767236, 52531.62085410866 52039.666629161125, 52532.27854686634 52055.65310595361, 52532.97734542138 52072.63873754562, 52544.158122302026 52344.40884301777, 52549.00860638995 52462.30910936231, 52552.37928177309 52544.23980292377)";

            var reader = new WKTReader();
            var ls1    = reader.Read(ls1Wkt);

            Assert.That(ls1, Is.Not.Null);
            Assert.That(ls1.IsValid, Is.True);
            Assert.That(ls1, Is.InstanceOf <LineString>());

            var ls2 = reader.Read(ls2Wkt);

            Assert.That(ls2, Is.Not.Null);
            Assert.That(ls2.IsValid, Is.True);
            Assert.That(ls2, Is.InstanceOf <LineString>());

            var intersection = ls1.Intersection(ls2);

            Assert.That(intersection, Is.Not.Null);
            Assert.That(intersection.IsValid, Is.True);
        }
        public void TestPolygonWithHoles()
        {
            const string wkt  = "POLYGON((2 2, 2 98, 98 98, 98 2, 2 2), (5 90, 10 90, 10 95, 5 95, 5 90))";
            var          geom = new WKTReader().Read(wkt);

            var gpw = new GraphicsPathWriter();
            var res = gpw.ToShape(geom);

            var b = new Bitmap(100, 100);

            using (var g = Graphics.FromImage(b))
            {
                //g.Transform = new Matrix(1f, 0f, -0f, -1f, 0f, 100f);
                g.SmoothingMode = SmoothingMode.HighQuality;
                g.Clear(Color.White);
                g.FillPath(new SolidBrush(Color.FromArgb(180, Color.Red)), res);
                g.DrawPath(Pens.Red, res);
            }
            b.Save("PolygonWithHoles.png", ImageFormat.Png);

            var reverse = GraphicsPathReader.Read(res, 0d, GeometryFactory.Default);
            //Assert.AreEqual(geom, reverse);
        }
Exemple #28
0
        public void check_difference_results_with_fixed_precision()
        {
            var gs     = new NtsGeometryServices(new PrecisionModel(100));
            var reader = new WKTReader(gs);
            var p1     = reader.Read(@"POLYGON ((504927.9 6228865.64, 504969.88 6228833.89, 504980.82 6228861.76, 504927.9 6228865.64))");
            var p2     = reader.Read(@"POLYGON ((504927.9 6228865.64, 504951.14 6228848.06, 504957.42 6228863.47, 504927.9 6228865.64))");
            var test   = p1.Difference(p2);

            Assert.That(test, Is.Not.Null);
            Assert.That(test.IsEmpty, Is.False);

            const string expected = @"POLYGON ((504927.9 6228865.64, 504980.82 6228861.76, 504969.88 6228833.89, 504951.14 6228848.06, 504957.42 6228863.47, 504927.9 6228865.64))";
            var          res      = reader.Read(expected);

            res.Normalize();
            test.Normalize();
            Console.WriteLine(test.AsText());
            Console.WriteLine(res.AsText());
            var    hd   = new HausdorffSimilarityMeasure();
            double resD = hd.Measure(test, res);

            Assert.That(1 - resD, Is.LessThan(1e7));
        }
        public void TestTransform()
        {
            CoordinateSystemFactory csFactory   = new CoordinateSystemFactory();
            const string            sourceCsWkt = "GEOGCS[\"WGS 84\",DATUM[\"WGS_1984\",SPHEROID[\"WGS 84\",6378137,298.257223563,AUTHORITY[\"EPSG\",\"7030\"]],AUTHORITY[\"EPSG\",\"6326\"]],PRIMEM[\"Greenwich\",0,AUTHORITY[\"EPSG\",\"8901\"]],UNIT[\"degree\",0.01745329251994328,AUTHORITY[\"EPSG\",\"9122\"]],AUTHORITY[\"EPSG\",\"4326\"]]";
            ICoordinateSystem       sourceCs    = csFactory.CreateFromWkt(sourceCsWkt);

            Assert.That(sourceCs, Is.Not.Null);
            const string      targetCsWkt = "PROJCS[\"WGS 84 / Australian Antarctic Lambert\",GEOGCS[\"WGS 84\",DATUM[\"WGS_1984\",SPHEROID[\"WGS 84\",6378137,298.257223563,AUTHORITY[\"EPSG\",\"7030\"]],AUTHORITY[\"EPSG\",\"6326\"]],PRIMEM[\"Greenwich\",0,AUTHORITY[\"EPSG\",\"8901\"]],UNIT[\"degree\",0.01745329251994328,AUTHORITY[\"EPSG\",\"9122\"]],AUTHORITY[\"EPSG\",\"4326\"]],PROJECTION[\"Lambert_Conformal_Conic_2SP\"],PARAMETER[\"standard_parallel_1\",-68.5],PARAMETER[\"standard_parallel_2\",-74.5],PARAMETER[\"latitude_of_origin\",-50],PARAMETER[\"central_meridian\",70],PARAMETER[\"false_easting\",6000000],PARAMETER[\"false_northing\",6000000],UNIT[\"metre\",1,AUTHORITY[\"EPSG\",\"9001\"]],AUTHORITY[\"EPSG\",\"3033\"]]";
            ICoordinateSystem targetCs    = csFactory.CreateFromWkt(targetCsWkt);

            Assert.That(targetCs, Is.Not.Null);
            CoordinateTransformationFactory ctFactory           = new CoordinateTransformationFactory();
            ICoordinateTransformation       coordTransformation = ctFactory.CreateFromCoordinateSystems(sourceCs, targetCs);

            IGeometryFactory gf      = GeometryFactory.Default;
            const string     geomWkt = "MULTIPOINT (152.83949210500001 -42.14413555,152.83910355899999 -42.129844618)";
            WKTReader        reader  = new WKTReader(gf);
            IGeometry        geom    = reader.Read(geomWkt);

            Assert.That(geom, Is.Not.Null);
            Assert.That(geom.IsValid, Is.True);
            Assert.That(geom, Is.InstanceOf <IMultiPoint>());

            IMultiPoint mp = (IMultiPoint)geom;

            foreach (IPoint pt in mp.Geometries)
            {
                IGeometry tp = GeometryTransform.TransformGeometry(gf, pt, coordTransformation.MathTransform);
                Assert.That(tp, Is.Not.Null);
                Assert.That(tp.IsValid, Is.True);
            }

            IGeometry transformed = GeometryTransform.TransformGeometry(gf, mp, coordTransformation.MathTransform);

            Assert.That(transformed, Is.Not.Null);
            Assert.That(transformed.IsValid, Is.True);
        }
        public virtual void IsDirty()
        {
            Assert.IsFalse(_session.IsDirty());

            var simple = _session.CreateCriteria <Simple>()
                         .SetMaxResults(1)
                         .UniqueResult <Simple>();

            Assert.NotNull(simple);

            // New instance of the same geometry
            var wkt      = simple.Geometry.AsText();
            var geometry = new WKTReader().Read(wkt);

            geometry.SRID = simple.Geometry.SRID;

            simple.Geometry = geometry;

            Assert.IsFalse(_session.IsDirty());

            simple.Geometry.SRID = 12345;

            Assert.IsTrue(_session.IsDirty());
        }