public static IGeometry Buffer(IGeometry geom, double distance)
 {
     ApplicationException originalEx = null;
     try
     {
         IGeometry result = geom.Buffer(distance);
         return result;
     }
     catch (ApplicationException ex)
     {
         originalEx = ex;
     }
     /*
      * If we are here, the original op encountered a precision problem
      * (or some other problem).  Retry the operation with
      * enhanced precision to see if it succeeds
      */
     try
     {
         CommonBitsOp cbo = new CommonBitsOp(true);
         IGeometry resultEP = cbo.Buffer(geom, distance);
         // check that result is a valid point after the reshift to orginal precision
         if (!resultEP.IsValid)
             throw originalEx;
         return resultEP;
     }
     catch (ApplicationException)
     {
         throw originalEx;
     }
 }
Exemple #2
0
 public IGeometry Edit(IGeometry geometry, IGeometryFactory factory)
 {
     if (geometry is IPolygonal)
     {
         return(geometry.Buffer(0));
     }
     return(geometry);
 }
Exemple #3
0
        private IGeometry BufferUnion(IGeometry g0, IGeometry g1)
        {
            IGeometryFactory factory  = g0.Factory;
            IGeometry        gColl    = factory.CreateGeometryCollection(new IGeometry[] { g0, g1 });
            IGeometry        unionAll = gColl.Buffer(0.0);

            return(unionAll);
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="geom"></param>
        public static void UnionUsingBufferOp(IGeometry[] geom)
        {
            var       fact     = geom[0].Factory;
            IGeometry geomColl = fact.CreateGeometryCollection(geom);
            var       union    = geomColl.Buffer(0.0);

            Console.WriteLine(union);
        }
Exemple #5
0
        public static IGeometry BufferValidatedGeom(IGeometry g, double distance)
        {
            var buf       = g.Buffer(distance);
            var validator = new BufferResultValidator(g, distance, buf);
            var isValid   = validator.IsValid();

            return(validator.ErrorIndicator);
        }
 /// <summary>
 /// Creates a valid area point from one that possibly has
 /// bad topology (i.e. self-intersections).
 /// Since buffer can handle invalid topology, but always returns
 /// valid point, constructing a 0-width buffer "corrects" the
 /// topology.
 /// Note this only works for area geometries, since buffer always returns
 /// areas.  This also may return empty geometries, if the input
 /// has no actual area.
 /// </summary>
 /// <param name="rawAreaGeom">An area point possibly containing self-intersections.</param>
 /// <returns>A valid area point.</returns>
 private IGeometry CreateValidArea(IGeometry rawAreaGeom)
 {
     if (_ensureValidTopology)
     {
         return(rawAreaGeom.Buffer(0.0));
     }
     return(rawAreaGeom);
 }
        private IGeometry BufferUnion(Geometry g0, Geometry g1)
        {
            var       factory  = g0.Factory;
            IGeometry gColl    = factory.CreateGeometryCollection(new Geometry[] { g0, g1 });
            var       unionAll = gColl.Buffer(0.0);

            return(unionAll);
        }
        public IList <MassnahmenvorschlagTeilsystemeGIS> GetAllKoordinierteMassnahmenAt(double x, double y, double tolerance)
        {
            IGeometry clickedPoint = GISService.CreateGeometryFactory().CreatePoint(new Coordinate((double)x, (double)y, 0));
            var       buffer       = clickedPoint.Buffer(tolerance);

            IList <MassnahmenvorschlagTeilsystemeGIS> koordinierteMassnahmenliste = GetBySpatialFilter(buffer).Where(mts => mts.Status != EMSG.Common.Enums.StatusTyp.Abgeschlossen).ToList();

            return(koordinierteMassnahmenliste);
        }
 private static IGeometry Clean(IGeometry geom)
 {
     // TODO: only buffer if it is a polygonal IGeometry
     if (!(geom is IPolygonal))
     {
         return(geom);
     }
     return(geom.Buffer(0));
 }
Exemple #10
0
        public static IGeometry BufferValidated(IGeometry g, double distance)
        {
            var buf    = g.Buffer(distance);
            var errMsg = BufferResultValidator.IsValidMessage(g, distance, buf);

            if (errMsg != null)
            {
                throw new InvalidOperationException(errMsg);
            }
            return(buf);
        }
        public string GetNearestAchsenSegment(double x, double y, double tolerance)
        {
            IGeometry clickedPoint = EMSG.Business.Services.GIS.GISService.CreateGeometryFactory().CreatePoint(new Coordinate((double)x, (double)y, 0));
            var       buffer       = clickedPoint.Buffer(tolerance);

            IList <AchsenSegment> achsegmentList        = GetCurrentEntityListBySpatialFilter(buffer);
            AchsenSegment         selectedAchsensegment = gisService.GetNearestGeometry(clickedPoint, achsegmentList);

            TextWriter       tw    = new StringWriter();
            IAttributesTable table = new AttributesTable();

            //GEOJSON PROPERTIES: STRASSENABSCHNITTE

            List <FeatureWithID> features = new List <FeatureWithID>();

            if (selectedAchsensegment == null)
            {
                return(GeoJSONStrings.GeoJSONFailure("No Achsen found"));
            }
            foreach (AchsenReferenz achsenreferenz in selectedAchsensegment.AchsenReferenzen.Where(ar => ar.Erfassungsperiod == historizationService.GetCurrentErfassungsperiod()))
            {
                if (achsenreferenz.ReferenzGruppe.StrassenabschnittGIS != null)
                {
                    FeatureWithID    feat = new FeatureWithID();
                    IAttributesTable att  = new AttributesTable();

                    feat.Id         = achsenreferenz.ReferenzGruppe.StrassenabschnittGIS.Id.ToString();
                    feat.Geometry   = achsenreferenz.ReferenzGruppe.StrassenabschnittGIS.Shape;
                    feat.Attributes = att;

                    if (!features.Contains(feat))
                    {
                        features.Add(feat);
                    }
                }
            }

            table.AddAttribute("Strassenabschnitte", features);

            table.AddAttribute("AchsenId", selectedAchsensegment.Achse.Id);
            table.AddAttribute("AchsenName", selectedAchsensegment.Achse.Name);
            table.AddAttribute("IsInverted", selectedAchsensegment.IsInverted);

            FeatureWithID feature = new FeatureWithID();

            feature.Id         = selectedAchsensegment.Id.ToString();
            feature.Geometry   = selectedAchsensegment.Shape;
            feature.Attributes = table;
            TextWriter sw = new StringWriter();

            GeoJSONWriter.WriteFeatureWithID(feature, sw);

            return(sw.ToString());
        }
        private IGeometry GetBuffer(IGeometry geom, double dist)
        {
            var buf = geom.Buffer(dist);

            //System.out.println(buf);
            Console.WriteLine(_sw.Elapsed);
            if (!buf.IsValid)
            {
                throw new Exception("buffer not valid!");
            }
            return(buf);
        }
Exemple #13
0
        public ZustandsabschnittGISModel GetZustandsabschnittAt(double x, double y, double tolerance)
        {
            IGeometry clickedPoint = GISService.CreateGeometryFactory().CreatePoint(new Coordinate(x, y, 0));
            var       buffer       = clickedPoint.Buffer(tolerance);

            //ZustandsabschnittGIS zustandsabschnitt = gisService.GetNearestGeometry(buffer, GetEntityListBySpatialFilter(buffer).Where(e=> e.ErfassungsPeriod==CurrentErfassungsPeriod).ToList());
            ZustandsabschnittGIS zustandsabschnitt = gisService.GetNearestGeometry(clickedPoint, GetCurrentZustandsAbschnitteBySpatialFilter(buffer, CurrentErfassungsPeriod));
            var zustandsabschnittmodel             = new ZustandsabschnittGISModel();//base.GetById(zustandsabschnitt.Id);

            zustandsabschnittmodel.FeatureGeoJSONString = geoJSONParseService.GenerateGeoJsonStringFromEntity(zustandsabschnitt);
            return(zustandsabschnittmodel);
        }
        public MassnahmenvorschlagTeilsystemeGISModel GetKoordinierteMassnahmeAt(double x, double y, double tolerance)
        {
            IGeometry clickedPoint = GISService.CreateGeometryFactory().CreatePoint(new Coordinate((double)x, (double)y, 0));
            var       buffer       = clickedPoint.Buffer(tolerance);

            IList <MassnahmenvorschlagTeilsystemeGIS> koordinierteMassnahmenliste = GetBySpatialFilter(buffer).Where(mts => mts.Status != EMSG.Common.Enums.StatusTyp.Abgeschlossen).ToList();

            MassnahmenvorschlagTeilsystemeGIS koordinierteMassnahme = gisService.GetNearestGeometry(buffer, koordinierteMassnahmenliste);

            return(new MassnahmenvorschlagTeilsystemeGISModel {
                FeatureGeoJSONString = geoJSONParseService.GenerateGeoJsonStringFromEntity(koordinierteMassnahme)
            });
        }
Exemple #15
0
        public RealisierteMassnahmeGISModel GetRealisierteMassnahmeAt(double x, double y, double tolerance)
        {
            IGeometry clickedPoint = GISService.CreateGeometryFactory().CreatePoint(new Coordinate(x, y, 0));
            var       buffer       = clickedPoint.Buffer(tolerance);

            IList <RealisierteMassnahmeGIS> realisierteMassnahmenliste = GetCurrentBySpatialFilter(buffer).ToList();

            RealisierteMassnahmeGIS realisierteMassnahme = gisService.GetNearestGeometry(buffer, realisierteMassnahmenliste);

            return(new RealisierteMassnahmeGISModel {
                FeatureGeoJSONString = geoJSONParseService.GenerateGeoJsonStringFromEntity(realisierteMassnahme)
            });
        }
Exemple #16
0
        /// <summary>
        /// Calculates conlicts.
        /// </summary>
        /// <param name="matrikel">The Geometry of the matrikel</param>
        /// <param name="features">The Geometry of the features</param>
        /// <param name="bufferWidth">The Geometry of the features</param>
        /// <returns>True if conflicts where found</returns>
        /// <exception cref="XsltException">If <paramref name="matrikel"/> or <paramref name="features"/> are badly formatted.</exception>
        public static bool Conflicts(XPathNodeIterator cadastral, XPathNodeIterator features, string bufferWidth)
        {
            if (!double.TryParse(bufferWidth, out var bufferWidthParsed))
            {
                throw new ArgumentException("BufferWidth is null or not a double.");
            }

            IGeometry cadastralGeometry         = CadastralIterToElement(cadastral);
            IGeometry cadastralGeometryBuffered = (!cadastralGeometry.Buffer(bufferWidthParsed).IsEmpty ? cadastralGeometry.Buffer(bufferWidthParsed) : cadastralGeometry) as Geometry;
            //using original geometry if buffered is empty
            IGeometry intersection = GetIntersectingGeometry(cadastralGeometryBuffered, features);

            return(intersection != null && !intersection.IsEmpty);
        }
Exemple #17
0
        public StrassenabschnittGISModel GetCurrentStrassenabschnittAt(double x, double y, double tolerance)
        {
            IGeometry clickedPoint = GISService.CreateGeometryFactory().CreatePoint(new Coordinate((double)x, (double)y, 0));
            var       buffer       = clickedPoint.Buffer(tolerance);

            //only strassenabschnitte from current erfassungsperiode
            ErfassungsPeriod             currentErfassungsperiod = historizationService.GetCurrentErfassungsperiod();
            IList <StrassenabschnittGIS> strabsliste             = GetCurrentBySpatialFilter(buffer);

            StrassenabschnittGIS strabs = gisService.GetNearestGeometry(clickedPoint, strabsliste);

            return(new StrassenabschnittGISModel {
                FeatureGeoJSONString = geoJSONParseService.GenerateGeoJsonStringFromEntity(strabs)
            });
        }
        void RunBuffer(IGeometry g, double dist)
        {
            IGeometry buf = g.Buffer(dist);
            BufferResultValidator validator = new BufferResultValidator(g, dist, buf);

            if (!validator.IsValid())
            {
                String msg = validator.ErrorMessage;

                Console.WriteLine(msg);
                Console.WriteLine(WKTWriter.ToPoint(validator.ErrorLocation));
                Console.WriteLine(g);
            }
            Assert.IsTrue(validator.IsValid());
        }
        static void RunBuffer(IGeometry g, double dist)
        {
            var buf       = g.Buffer(dist);
            var validator = new BufferResultValidator(g, dist, buf);

            if (!validator.IsValid())
            {
                String msg = validator.ErrorMessage;

                Console.WriteLine(msg);
                Console.WriteLine(WKTWriter.ToPoint(validator.ErrorLocation));
                Console.WriteLine(g);
            }
            Assert.IsTrue(validator.IsValid());
        }
Exemple #20
0
        private IList <IGeometry> CreateDiscs(int num, double radius)
        {
            var geoms = new List <IGeometry>();

            for (int i = 0; i < num; i++)
            {
                for (int j = 0; j < num; j++)
                {
                    Coordinate pt     = new Coordinate(i, j);
                    IGeometry  ptGeom = _geomFact.CreatePoint(pt);
                    IGeometry  disc   = ptGeom.Buffer(radius);
                    geoms.Add(disc);
                }
            }
            return(geoms);
        }
Exemple #21
0
        public static List <IGeometry> GetNearGeometries(IGeometry me, Quadtree <IGeometry> others, double buffer)
        {
            var bufferedGeom     = me.Buffer(0);
            var preparedGeometry = PreparedGeometryFactory.Prepare(bufferedGeom);
            var geometries       = new List <IGeometry>();

            foreach (var geom in others.Query(bufferedGeom.EnvelopeInternal))
            {
                var poly = geom as IPolygon;
                if (poly != null && preparedGeometry.Overlaps(poly.ExteriorRing))
                {
                    geometries.Add(poly);
                }
            }
            return(geometries);
        }
Exemple #22
0
        public void BufferZero()
        {
            const string wkt =
                @"LINESTRING (0.131499700898395 -106.048825207893, 0.214925873208014
-101.719050959423, 0.214925750753543 -97.6113163891882,
0.214925621679813 -93.2815420840726, 0.131499285788604
-83.2897551168332, 0.131499245289997 -81.0693579923862,
0.214925135170241 -76.9616232870209, 0.381776611037356
-68.4130942180089, 0.632053838837485 -64.1943395560651,
0.798904549239423 -55.8678500279518, 0.965755424490026
-51.6490952821928, 1.04918049754522 -47.5413603763288, 1.216031054491
-43.4336254307751, 1.21603034291624 -39.2148706216502,
1.46630613455377 -35.3291753291882, 1.46630527652542 -31.11042046793,
1.46630444107613 -27.0026854424598, 1.63315428396527
-22.8949503541264, 1.46630272501622 -18.5651755775079,
1.46630191214483 -14.5684603384853, 1.46630107669307
-10.4607252068867, 1.38287509348789 -6.35299006384426,
1.21602410725127 -2.24525490925484, 1.04917334027541 1.64044053479631,
0.965747720953842 5.85919563202954, 0.798897253949768
9.96693087540342, 0.632046967345163 14.1856860226623,
0.632046607221801 18.2934213404512
, 0.38177179615792 22.5121765415973, 0.548621118425862
26.5088920492596, 0.214921921523676 30.8386671810771,
0.214921795756638 35.0574224826751, 0.131497046191467 39.498217565559,
-0.0353521669617239 43.6059530460827, -0.4524747423803
47.9357283251215, -0.619323417988547 52.1544837536291,
-1.11986960213068 56.2622193766346, -1.28671779462348
59.9258754694222, -1.45356574932243 63.9225912326279,
-1.70383783249951 67.808287160798, -1.87068534577926 71.9160228671952,
-2.28780528663775 75.9127387944009, -2.37122831392773
79.4653751147445, -2.53807525425783 83.3510711417379,
-2.78834607948959 87.2367672248572, -2.95519284268212
90.5673638758933, -9.1285807394459 82.6849571608342)";

            IGeometryFactory factory = GeometryFactory.Default;
            WKTReader        reader  = new WKTReader(factory);
            IGeometry        geom    = reader.Read(wkt);

            Assert.IsNotNull(geom);
            Assert.IsTrue(geom.IsValid);
            IGeometry result = geom.Buffer(0);

            Assert.IsNotNull(result);
            Assert.IsTrue(result.IsValid);
            Assert.IsTrue(GeometryCollection.Empty.Equals(result));
        }
Exemple #23
0
        public void make_valid_an_invalid_polygon()
        {
            const string wkt =
                "POLYGON ((14.270341 46.592393, 14.270168 46.592435, 14.269934 46.592458, 14.269978 46.593262, 14.2699883 46.5936283, 14.270001 46.5940778, 14.270014 46.594274, 14.270686 46.594253, 14.270693 46.593642, 14.271359 46.5936565, 14.271692 46.5936637, 14.272025 46.593671, 14.272195 46.594132, 14.272172 46.594195, 14.27209 46.594247, 14.271931 46.594269, 14.270686 46.594253, 14.270014 46.594274, 14.270019 46.594647, 14.270022 46.594839, 14.270025 46.595065, 14.269982 46.595242, 14.269848 46.595395, 14.270026 46.595429, 14.27019 46.595438, 14.270489 46.595431, 14.27098 46.59544, 14.271701 46.595454, 14.272504 46.595469, 14.272457 46.596781, 14.272752 46.59679, 14.273182 46.596802, 14.273244 46.596827, 14.273257 46.59688, 14.272969 46.598265, 14.272862 46.59882, 14.272678 46.599756, 14.274351 46.59994, 14.2751039 46.6001132, 14.2761378 46.5999951, 14.2771781 46.5999539, 14.2777771 46.5997631, 14.2773246 46.5981367, 14.2803556 46.598055, 14.2805422 46.5962748, 14.2797491 46.5950344, 14.2773383 46.5953999, 14.2768883 46.5940448, 14.2768778 46.5940764, 14.2768439 46.5941055, 14.2768337 46.5941175, 14.2767933 46.5941275, 14.276776 46.5941291, 14.2767338 46.5941326, 14.2766636 46.5941396, 14.2765618 46.5941536, 14.2757429 46.5942872, 14.2758657 46.5948156, 14.275941 46.595094, 14.2759673 46.5951778, 14.27606 46.595474, 14.2760834 46.595548, 14.2761099 46.5957387, 14.2761688 46.5959261, 14.2761983 46.5960198, 14.2762278 46.5961136, 14.2763228 46.5964155, 14.276476 46.5969376, 14.2766652 46.5969119, 14.2772167 46.5968929, 14.2777106 46.5968772, 14.2781873 46.596883, 14.2784029 46.5968768, 14.2784204 46.5969934, 14.2784262 46.5971391, 14.2784379 46.5973198, 14.2784495 46.597792, 14.2776009 46.5978119, 14.2767668 46.5978056, 14.277034 46.598467, 14.277006 46.598589, 14.276987 46.598671, 14.277071 46.598974, 14.277177 46.599357, 14.277166 46.599456, 14.277117 46.599514, 14.277015 46.599552, 14.27634 46.599662, 14.2760042 46.5997169, 14.275662 46.599773, 14.2756026 46.5995442, 14.2755891 46.599492, 14.2754907 46.5991126, 14.275412 46.598809, 14.2752905 46.5984064, 14.275211 46.598143, 14.27516 46.597986, 14.2767668 46.5978056, 14.2767276 46.5975411, 14.2766713 46.5973164, 14.2766302 46.5972164, 14.2765891 46.5971314, 14.276476 46.5969376, 14.2763228 46.5964155, 14.2762278 46.5961136, 14.2761983 46.5960198, 14.2761688 46.5959261, 14.2761099 46.5957387, 14.2760834 46.595548, 14.27606 46.595474, 14.2759673 46.5951778, 14.275941 46.595094, 14.2758657 46.5948156, 14.2757429 46.5942872, 14.275628 46.593775, 14.2752901 46.5918595, 14.274801 46.5918166, 14.2745653 46.591794, 14.2741145 46.5917857, 14.273769 46.5917797, 14.2737496 46.5918088, 14.2737285 46.5918274, 14.2737026 46.5918398, 14.2736637 46.5918495, 14.2736339 46.5918502, 14.2736033 46.5918476, 14.2735699 46.5918408, 14.2735275 46.5918264, 14.2734989 46.5918118, 14.2734807 46.5917959, 14.2734682 46.5917778, 14.2726925 46.5918505, 14.2723 46.591896, 14.271899 46.591974, 14.2716247 46.5920462, 14.270867 46.592246, 14.270341 46.592393))";

            WKTReader reader = new WKTReader();
            IGeometry geom   = reader.Read(wkt);

            Assert.That(geom, Is.Not.Null);
            Assert.That(geom, Is.InstanceOf <IPolygon>());
            Assert.That(geom.IsValid, Is.False);

            IGeometry valid = geom.Buffer(0);

            Assert.That(valid.IsValid, Is.True);
            Console.WriteLine(valid);
        }
Exemple #24
0
        /// <summary>
        ///
        /// </summary>
        private void PerformTest(IGeometryFactory factory)
        {
            IGeometry path = new WKTReader(factory).Read(GeomText);

            Assert.IsNotNull(path);
            Debug.WriteLine(String.Format("Original Points: {0}", path.NumPoints));

            IGeometry simplified = DouglasPeuckerSimplifier.Simplify(path, 2);

            Assert.IsNotNull(simplified);
            Debug.WriteLine(String.Format("Simplified Points: {0}", simplified.NumPoints));

            IGeometry buffered = simplified.Buffer(1.143);

            Assert.IsNotNull(buffered);
            Debug.WriteLine(buffered);
        }
Exemple #25
0
        private static bool IsApproximateCoincident(IGeometry g1, IGeometry g2, double tolerance)
        {
            IGeometry symdiff;

            if (g1.Dimension < Dimension.Surface && g2.Dimension < Dimension.Surface)
            {
                g1      = g1.Buffer(tolerance);
                g2      = g2.Buffer(tolerance);
                symdiff = g1.SymmetricDifference(g2).Buffer(tolerance);
            }
            else
            {
                symdiff = g1.SymmetricDifference(g2);
            }
            double relError = symdiff.Area / (g1.Area + g2.Area);

            return(relError < tolerance);
        }
Exemple #26
0
        protected virtual bool TestBuffer()
        {
            Geometry geoResult = (Geometry)m_objResult;
            double   dArg      = Double.Parse((string)m_objArgument2, GetNumberFormatInfo());

            if (m_bIsDefaultTarget && m_objGeometryA != null)
            {
                Geometry buffer = (Geometry)m_objGeometryA.Buffer(dArg);
                if (buffer != null)
                {
                    if (buffer.IsEmpty && geoResult.IsEmpty)
                    {
                        return(true);
                    }

                    if (geoResult.GetType().Name == "GeometryCollection")
                    {
                        return(CompareGeometries(geoResult, buffer));
                    }

                    return(buffer.Equals(geoResult));
                }
            }
            else if (m_objGeometryB != null)
            {
                Geometry buffer = (Geometry)m_objGeometryB.Buffer(dArg);
                if (buffer != null)
                {
                    if (buffer.IsEmpty && geoResult.IsEmpty)
                    {
                        return(true);
                    }

                    if (geoResult.GetType().Name == "GeometryCollection")
                    {
                        return(CompareGeometries(geoResult, buffer));
                    }

                    return(buffer.Equals(geoResult));
                }
            }

            return(false);
        }
        void RunTest(String wkt, double dist)
        {
            IGeometry             g         = rdr.Read(wkt);
            IGeometry             buf       = g.Buffer(dist);
            BufferResultValidator validator = new BufferResultValidator(g, dist, buf);

            if (!validator.IsValid())
            {
                String msg = validator.ErrorMessage;

                Console.WriteLine(msg);
                var errorLocation = validator.ErrorLocation;
                if (errorLocation != null)
                {
                    Console.WriteLine(WKTWriter.ToPoint(errorLocation));
                }
                Assert.Fail("The buffer result was not valid");
            }
            Assert.IsTrue(validator.IsValid());
        }
Exemple #28
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);
        }
            /// <summary>
            /// Creates a valid area geometry from one that possibly has bad topology (i.e.
            /// self-intersections).
            /// </summary>
            /// <param name="area">An area geometry possibly containing self-intersections</param>
            /// <returns>
            /// A valid area geometry
            /// </returns>
            private IGeometry CreateValidArea(IGeometry area)
            {
                if (area.IsValid)
                {
                    return(area);
                }
                // TODO: this is slow and has potential errors (due to buffer robustness failure)
                // TODO: replace with a proper polygon cleaner

                /**
                 * Creates a valid area geometry from one that possibly has bad topology (i.e.
                 * self-intersections). Since buffer can handle invalid topology, but always
                 * returns valid geometry, constructing a 0-width buffer "corrects" the
                 * topology. Note this only works for area geometries, since buffer always
                 * returns areas. This also may return empty geometries, if the input has no
                 * actual area.
                 */
                //return area;
                return(area.Buffer(0.0));
            }
Exemple #30
0
        //[ExpectedException(typeof(TopologyException))]
        public void FailedUnionTest()
        {
            WKTReader reader = new WKTReader(GeometryFactory.Fixed);

            Assert.IsNotNull(reader);

            IGeometry g1 = reader.Read(s1);

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

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

            Assert.IsNotNull(g2);

            IGeometry result = g1.Union(g2);

            Assert.IsNotNull(result);
            Debug.WriteLine(result);
        }
        public List <FilterLinkModel> GetLinkModelsToRemove(IGeometry scribble)
        {
            var filterLinkViewModel = DataContext as FilterLinkViewModel;
            var models = new List <FilterLinkModel>();

            if (scribble.Intersects(_linkViewGeometry.Buffer(3)))
            {
                models = filterLinkViewModel.FilterLinkModels.ToList();
            }
            else
            {
                foreach (var model in _visualizationViewModelGeometries.Keys)
                {
                    if (_visualizationViewModelGeometries[model].Buffer(3).Intersects(scribble))
                    {
                        models.Add(filterLinkViewModel.FilterLinkModels.First(lm => lm.FromOperationModel == model.OperationModel));
                    }
                }
            }
            return(models);
        }
        public InspektionsRouteGISModel GetInspektionsRouteGISAt(double x, double y, double tolerance)
        {
            IGeometry clickedPoint = GISService.CreateGeometryFactory().CreatePoint(new Coordinate((double)x, (double)y, 0));
            IGeometry buffer       = clickedPoint.Buffer(tolerance);

            IList <InspektionsRouteGIS> inspektionsRouteGISListe = GetCurrentEntityListBySpatialFilter(buffer);

            InspektionsRouteGIS inspektionsRoute = gisService.GetNearestGeometry(buffer, inspektionsRouteGISListe);

            if (inspektionsRoute != null)
            {
                return(new InspektionsRouteGISModel {
                    FeatureGeoJSONString = geoJSONParseService.GenerateGeoJsonStringFromEntity(inspektionsRoute)
                });
            }
            else
            {
                return(new InspektionsRouteGISModel {
                    FeatureGeoJSONString = "{ \"type\": \"FeatureCollection\", \"features\": []}"
                });
            }
        }
		private static bool IsApproximateCoincident(IGeometry g1, IGeometry g2, double tolerance)
		{
			IGeometry symdiff;
			if (g1.Dimension < Dimensions.Surface && g2.Dimension < Dimensions.Surface)
			{
				g1 = g1.Buffer(tolerance);
				g2 = g2.Buffer(tolerance);
				symdiff = g1.SymmetricDifference(g2).Buffer(tolerance);
			}
			else
			{
				symdiff = g1.SymmetricDifference(g2);
			}
			double relError = symdiff.Area / (g1.Area + g2.Area);
			return relError < tolerance;

		}
 public static IGeometry BufferValidated(IGeometry g, double distance)
 {
     var buf = g.Buffer(distance);
     var errMsg = BufferResultValidator.IsValidMessage(g, distance, buf);
     if (errMsg != null)
         throw new InvalidOperationException(errMsg);
     return buf;
 }
 public static IGeometry Buffer(IGeometry g, double distance) { return g.Buffer(distance); }
 private static IGeometry CleanPolygonal(IGeometry geom)
 {
     // TODO: use a better method of removing collapsed topology 
     return geom.Buffer(0);
 }
 /// <summary>
 /// Creates a valid area point from one that possibly has
 /// bad topology (i.e. self-intersections).
 /// Since buffer can handle invalid topology, but always returns
 /// valid point, constructing a 0-width buffer "corrects" the
 /// topology.
 /// Note this only works for area geometries, since buffer always returns
 /// areas.  This also may return empty geometries, if the input
 /// has no actual area.
 /// </summary>
 /// <param name="rawAreaGeom">An area point possibly containing self-intersections.</param>
 /// <returns>A valid area point.</returns>
 private IGeometry CreateValidArea(IGeometry rawAreaGeom)
 {
     if (_ensureValidTopology)
         return rawAreaGeom.Buffer(0.0);
     return rawAreaGeom;
 }
 /// <summary>
 /// Creates a valid area point from one that possibly has
 /// bad topology (i.e. self-intersections).
 /// Since buffer can handle invalid topology, but always returns
 /// valid point, constructing a 0-width buffer "corrects" the
 /// topology.
 /// Notice this only works for area geometries, since buffer always returns
 /// areas.  This also may return empty geometries, if the input
 /// has no actual area.
 /// </summary>
 /// <param name="roughAreaGeom">An area point possibly containing self-intersections.</param>
 /// <returns>A valid area point.</returns>
 private static IGeometry CreateValidArea(IGeometry roughAreaGeom)
 {
     return roughAreaGeom.Buffer(0.0);
 }
 /// <summary>
 /// Creates a valid area geometry from one that possibly has bad topology
 /// (i.e. self-intersections). Since buffer can handle invalid topology, but
 /// always returns valid geometry, constructing a 0-width buffer "corrects"
 /// the topology. Note this only works for area geometries, since buffer
 /// always returns areas. This also may return empty geometries, if the input
 /// has no actual area.
 /// </summary>
 /// <param name="rawAreaGeom">An area geometry possibly containing self-intersections.</param>
 /// <returns>A valid area geometry.</returns>
 private IGeometry CreateValidArea(IGeometry rawAreaGeom)
 {
     return _isEnsureValidTopology ? rawAreaGeom.Buffer(0.0) : rawAreaGeom;
 }
 public static IGeometry BufferValidatedGeom(IGeometry g, double distance)
 {
     var buf = g.Buffer(distance);
     var validator = new BufferResultValidator(g, distance, buf);
     var isValid = validator.IsValid();
     return validator.ErrorIndicator;
 }
 private IGeometry InvokeBuffer(IGeometry geom)
 {
     if (_argCount == 1)
     {
         return geom.Buffer(_distance);
     }
     if (_argCount == 2)
     {
         return geom.Buffer(_distance, _quadSegments);
     }
     Assert.ShouldNeverReachHere("Unknown or unhandled buffer method");
     return null;
 }
 private static IGeometry Clean(IGeometry geom)
 {
     // TODO: only buffer if it is a polygonal IGeometry
     if (!(geom is IPolygonal) ) return geom;
     return geom.Buffer(0);
 }