Пример #1
0
 /// <summary>
 /// Simplifies the line with the given tolerance.
 /// Writes the result in file.
 /// </summary>
 /// <param name="line">Line to simplify</param>
 /// <param name="tolerance">Tolerance to use by simplify function</param>
 /// <param name="supposedResult">The supposed result</param>
 /// <param name="index"></param>
 public void Simplify(ILineString line, double tolerance, ILineString supposedResult, int index)
 {
     try
     {
         Console.WriteLine("Job {0} started", index);
         IGeometry geometry = TopologyPreservingSimplifier.Simplify((ILineString)line.Clone(), tolerance);
         Assert.IsTrue(geometry.Equals(supposedResult));
         Console.WriteLine("Job {0} terminated", index);
     }
     finally
     {
         Interlocked.Increment(ref _finishedJob);
     }
 }
Пример #2
0
 /// <summary>
 /// Simplifies the line with the given tolerance.
 /// Writes the result in file.
 /// </summary>
 /// <param name="line">Line to simplify</param>
 /// <param name="tolerance">Tolerance to use by simplify function</param>
 /// <param name="supposedResult">The supposed result</param>
 /// <param name="index"></param>
 public void Simplify(ILineString line, double tolerance, ILineString supposedResult, int index)
 {
     try
     {
         Console.WriteLine("Job {0} started", index);
         IGeometry geometry = TopologyPreservingSimplifier.Simplify((ILineString)line.Clone(), tolerance);
         Assert.IsTrue(geometry.Equals(supposedResult));
         Console.WriteLine("Job {0} terminated", index);
     }
     finally
     {
         Interlocked.Increment(ref _finishedJob);
     }
 }
        /// <summary>
        ///
        /// </summary>
        public override void Start()
        {
            IPoint      pointInLine  = Factory.CreatePoint(new Coordinate(20, 10));
            IPoint      pointOutLine = Factory.CreatePoint(new Coordinate(20, 31));
            ILineString aLine        = Factory.CreateLineString(new Coordinate[] { new Coordinate(23, 32.2), new Coordinate(922, 11) });
            ILineString anotherLine  = Factory.CreateLineString(new Coordinate[] { new Coordinate(0, 1), new Coordinate(30, 30) });

            try
            {
                Write(line.Area);
                Write(line.Boundary);
                Write(line.BoundaryDimension);
                Write(line.Centroid);
                Write(line.Coordinate);
                Write(line.Coordinates);
                Write(line.CoordinateSequence);
                Write(line.Dimension);
                Write(line.EndPoint);
                Write(line.Envelope);
                Write(line.EnvelopeInternal);
                Write(line.InteriorPoint);
                Write(line.IsClosed);
                Write(line.IsEmpty);
                Write(line.IsRing);
                Write(line.IsSimple);
                Write(line.IsValid);
                Write(line.Length);
                Write(line.NumPoints);
                Write(line.StartPoint);
                if (line.UserData != null)
                {
                    Write(line.UserData);
                }
                else
                {
                    Write("UserData null");
                }

                Write(line.Buffer(10));
                Write(line.Buffer(10, BufferStyle.CapButt));
                Write(line.Buffer(10, BufferStyle.CapSquare));
                Write(line.Buffer(10, 20));
                Write(line.Buffer(10, 20, BufferStyle.CapButt));
                Write(line.Buffer(10, 20, BufferStyle.CapSquare));
                Write(line.Contains(pointInLine));
                Write(line.Contains(pointOutLine));
                Write(line.Crosses(pointInLine));
                Write(line.Crosses(pointOutLine));
                Write(line.Difference(pointInLine));
                Write(line.Difference(pointOutLine));
                Write(line.Disjoint(pointInLine));
                Write(line.Disjoint(pointOutLine));
                Write(line.Distance(pointInLine));
                Write(line.Distance(pointOutLine));
                Write(line.Equals(line.Clone() as LineString));
                Write(line.EqualsExact(line.Clone() as LineString));
                Write(line.ConvexHull());
                Write(line.Intersection(pointInLine));
                Write(line.Intersection(pointOutLine));
                Write(line.Intersection(aLine));
                Write(line.Intersects(pointInLine));
                Write(line.Intersects(pointOutLine));
                Write(line.Intersects(aLine));
                Write(line.IsWithinDistance(pointOutLine, 2));
                Write(line.IsWithinDistance(pointOutLine, 222));
                Write(line.Overlaps(pointInLine));
                Write(line.Overlaps(pointOutLine));
                Write(line.Overlaps(aLine));
                Write(line.Overlaps(anotherLine));
                Write(line.Relate(pointInLine));
                Write(line.Relate(pointOutLine));
                Write(line.Relate(aLine));
                Write(line.Relate(anotherLine));
                Write(line.SymmetricDifference(pointInLine));
                Write(line.SymmetricDifference(pointOutLine));
                Write(line.SymmetricDifference(aLine));
                Write(line.SymmetricDifference(anotherLine));
                Write(line.ToString());
                Write(line.AsText());
                Write(line.Touches(pointInLine));
                Write(line.Touches(pointOutLine));
                Write(line.Touches(aLine));
                Write(line.Touches(anotherLine));
                Write(line.Union(pointInLine));
                Write(line.Union(pointOutLine));
                Write(line.Union(aLine));
                Write(line.Union(anotherLine));
                Write(line.Within(pointInLine));
                Write(line.Within(pointOutLine));
                Write(line.Within(aLine));
                Write(line.Within(anotherLine));

                string    linestring         = "LINESTRING (1.2 3.4, 5.6 7.8, 9.1 10.12)";
                string    anotherlinestringg = "LINESTRING (12345 3654321, 685 7777.945677, 782 111.1)";
                IGeometry geom1 = Reader.Read(linestring);
                Write(geom1.AsText());
                IGeometry geom2 = Reader.Read(anotherlinestringg);
                Write(geom2.AsText());

                byte[]    bytes = line.AsBinary();
                IGeometry test1 = new WKBReader().Read(bytes);
                Write(test1.ToString());

                bytes = new GDBWriter().Write(line);
                test1 = new GDBReader().Read(bytes);
                Write(test1.ToString());
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Пример #4
0
        private void AppendCoordinate(ILineString lineString, ICoordinate worldPosition)
        {
            var newLineString = (ILineString)lineString.Clone();

            double worldDistance = MapHelper.ImageToWorld(Map, (int)ActualMinDistance);

            ICoordinate coordinate;
            if (TemporalEnd)
                coordinate = lineString.Coordinates[lineString.Coordinates.Length - 2];
            else
                coordinate = lineString.Coordinates[lineString.Coordinates.Length - 1];
            if (worldPosition.Distance(coordinate) > worldDistance)
            {
                // if distance is larger than marge add new coordinate at exact location. During drawing line
                // you do not want to snap. For example a line should be able to pass very near a node.

                // HACK: not nice to solve here. If autocurve do not add snapped point when dragging. If not auto
                // curve use the actualSnapping value (=Snap)
                ICoordinate SnapLocation = worldPosition;
                if (!AutoCurve)
                    SnapLocation = Snap(worldPosition).Location;
                if (TemporalEnd)
                    newLineString = (ILineString)GeometryHelper.SetCoordinate(lineString, lineString.Coordinates.Length - 1, SnapLocation);
                else
                    newLineString = AppendCurvePoint(lineString, SnapLocation);
                TemporalEnd = false;
            }
            else
            {
                
                ICoordinate snapLocation = Snap(worldPosition).Location;
                if (TemporalEnd)
                    newLineString = (ILineString)GeometryHelper.SetCoordinate(lineString, lineString.Coordinates.Length - 1, snapLocation);
                else
                    newLineString = AppendCurvePoint(lineString, snapLocation);
                TemporalEnd = true;
            }
            newLineGeometry.Clear();
            newLineGeometry.Add(newLineString);
        }