Ejemplo n.º 1
0
		public static void main(string[] args)
		{
			// create a factory using default values (e.g. floating precision)
			GeometryFactory fact = new GeometryFactory();
			
			IPoint p1 = fact.CreatePoint(new Coordinate(0, 0));
			Console.WriteLine(p1);
			
			IPoint p2 = fact.CreatePoint(new Coordinate(1, 1));
			Console.WriteLine(p1);
			
			IMultiPoint mpt = fact.CreateMultiPoint(new ICoordinate[]{ new Coordinate(0, 0), new Coordinate(1, 1), });
			Console.WriteLine(mpt);
		}
Ejemplo n.º 2
0
        public static IGeometry InsertCurvePoint(IGeometry geometry, ICoordinate coordinate, int index)
        {
            var vertices = new List<ICoordinate>(geometry.Coordinates);
            vertices.Insert(index, coordinate);
            var geometryFactory = new GeometryFactory();

            if (geometry is ILineString)
            {
                return geometryFactory.CreateLineString(vertices.ToArray());
            }
            if (geometry is IPolygon)
            {
                return geometryFactory.CreatePolygon(geometryFactory.CreateLinearRing(vertices.ToArray()), null);
            }
            return geometry.Union(geometryFactory.CreatePoint(coordinate));
        }
Ejemplo n.º 3
0
        public static IGeometry RemoveCurvePoint(IGeometry geometry, int index, bool keepLineStringEndPoints=false)
        {
            var vertices = new List<ICoordinate>(geometry.Coordinates);
            vertices.RemoveAt(index);
            var geometryFactory = new GeometryFactory();
            var lastIndex = geometry.Coordinates.Length - 1;
            if (geometry is ILineString)
            {
                if (vertices.Count < 2)
                {
                    return null;
                }
                if (keepLineStringEndPoints && (index == 0 || index == lastIndex))
                {
                    return null;
                }
                return geometryFactory.CreateLineString(vertices.ToArray());
            }
            if (geometry is IPolygon)
            {
                // If first or last index is removed -> remove corresponding duplicate at the other end and close the ring.
                if (index == lastIndex)
                {
                    vertices[0] = vertices[lastIndex];
                }
                if (index == 0)
                {
                    vertices[lastIndex - 1] = vertices[0];
                }

                if (vertices.Count < 4)
                {
                    return null;
                }
                return geometryFactory.CreatePolygon(geometryFactory.CreateLinearRing(vertices.ToArray()), null);
            }
            if (index < geometry.Coordinates.Length)
            {
                var coordinate = geometry.Coordinates[index];
                var point = geometryFactory.CreatePoint(coordinate);
                return geometry.Difference(point);
            }
            return geometry;
        }
Ejemplo n.º 4
0
 internal static GisSharpBlog.NetTopologySuite.Geometries.Point ToNTSPoint(Point point,
                                                                           GeometryFactory factory)
 {
     return
         factory.CreatePoint(ToNTSCoordinate(point, factory)) as GisSharpBlog.NetTopologySuite.Geometries.Point;
 }