当前位置: 首页>>代码示例>>C#>>正文


C# IGeometryFactory.CreateLinearRing方法代码示例

本文整理汇总了C#中IGeometryFactory.CreateLinearRing方法的典型用法代码示例。如果您正苦于以下问题:C# IGeometryFactory.CreateLinearRing方法的具体用法?C# IGeometryFactory.CreateLinearRing怎么用?C# IGeometryFactory.CreateLinearRing使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IGeometryFactory的用法示例。


在下文中一共展示了IGeometryFactory.CreateLinearRing方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CreateCircle

 public static IPolygon CreateCircle(
                       IGeometryFactory fact,
                       double basex,
                       double basey,
                       double size,
                       int nPts)
 {
     Coordinate[] pts = CreateCircle(basex, basey, size, nPts);
     var ring = fact.CreateLinearRing(pts);
     var poly = fact.CreatePolygon(ring, null);
     return poly;
 }
开发者ID:Walt-D-Cat,项目名称:NetTopologySuite,代码行数:12,代码来源:GeometryTestFactory.cs

示例2: GetTriangles

 /// <summary>
 /// Gets the geometry for the triangles in a triangulated subdivision as a <see cref="IGeometryCollection"/>
 /// of triangular <see cref="IPolygon"/>s.
 /// </summary>
 /// <param name="geomFact">the GeometryFactory to use</param>
 /// <returns>a GeometryCollection of triangular Polygons</returns>
 public IGeometryCollection GetTriangles(IGeometryFactory geomFact)
 {
     var triPtsList = GetTriangleCoordinates(false);
     IPolygon[] tris = new Polygon[triPtsList.Count];
     int i = 0;
     foreach (var triPt in triPtsList)
     {
         tris[i++] = geomFact
                     .CreatePolygon(geomFact.CreateLinearRing(triPt), null);
     }
     return geomFact.CreateGeometryCollection(tris);
 }
开发者ID:Walt-D-Cat,项目名称:NetTopologySuite,代码行数:18,代码来源:QuadEdgeSubdivision.cs

示例3: Edit

            /// <summary>
            ///
            /// </summary>
            /// <param name="geometry"></param>
            /// <param name="factory"></param>
            /// <returns></returns>
            public virtual IGeometry Edit(IGeometry geometry, IGeometryFactory factory)
            {
                if (geometry is LinearRing)
                    return factory.CreateLinearRing(Edit(geometry.Coordinates, geometry));

                if (geometry is LineString)
                    return factory.CreateLineString(Edit(geometry.Coordinates, geometry));

                if (geometry is Point)
                {
                    IList<Coordinate> newCoordinates = Edit(geometry.Coordinates, geometry);
                    return factory.CreatePoint((newCoordinates.Count > 0) ? newCoordinates[0] : null);
                }

                return geometry;
            }
开发者ID:DIVEROVIEDO,项目名称:DotSpatial,代码行数:22,代码来源:GeometryEditor.cs

示例4: CreateBox

 public static IPolygon CreateBox(
     IGeometryFactory fact,
                       double minx, double miny,
                       int nSide,
                       double segLen)
 {
     Coordinate[] pts = CreateBox(minx, minx, nSide, segLen);
     var ring = fact.CreateLinearRing(pts);
     var poly = fact.CreatePolygon(ring, null);
     return poly;
 }
开发者ID:Walt-D-Cat,项目名称:NetTopologySuite,代码行数:11,代码来源:GeometryTestFactory.cs

示例5: CreateSineStar

 public static IPolygon CreateSineStar(
                       IGeometryFactory fact,
                       double basex,
                       double basey,
                       double size,
                       double armLen,
                       int nArms,
                       int nPts)
 {
     Coordinate[] pts = CreateSineStar(basex, basey, size, armLen, nArms, nPts);
     var ring = fact.CreateLinearRing(pts);
     var poly = fact.CreatePolygon(ring, null);
     return poly;
 }
开发者ID:Walt-D-Cat,项目名称:NetTopologySuite,代码行数:14,代码来源:GeometryTestFactory.cs

示例6: TransformLinearRing

 /// <summary>
 /// Transforms a <see cref="GeoAPI.Geometries.ILinearRing"/>.
 /// </summary>
 /// <param name="r">LinearRing to transform</param>
 /// <param name="from">Source Projection</param>
 /// <param name="to">Target Projection</param>
 /// <param name="toFactory">The factory to create geometries for <paramref name="to"/></param>
 /// <returns>Transformed LinearRing</returns>
 public static ILinearRing TransformLinearRing(ILinearRing r, ProjectionInfo from, ProjectionInfo to, IGeometryFactory toFactory)
 {
     try
     {
         var toSeq = TransformSequence(r.CoordinateSequence, from, to, toFactory.CoordinateSequenceFactory);
         return toFactory.CreateLinearRing(toSeq);
     }
     catch
     {
         return null;
     }
 }
开发者ID:PedroMaitan,项目名称:sharpmap,代码行数:20,代码来源:GeometryTransformDotSpatial.cs

示例7: GeneratePolygons

        private static void GeneratePolygons(IGeometryFactory factory, ICollection<IGeometry> geometry, Random rndGen)
        {
            int numPolygons = rndGen.Next(10, 100);
            for (var polyIndex = 0; polyIndex < numPolygons; polyIndex++)
            {
                var vertices = new GeoPoint[5];
                var upperLeft = new GeoPoint(rndGen.NextDouble()*1000, rndGen.NextDouble()*1000);
                var sideLength = rndGen.NextDouble()*50;

                // Make a square
                vertices[0] = new GeoPoint(upperLeft.X, upperLeft.Y);
                vertices[1] = new GeoPoint(upperLeft.X + sideLength, upperLeft.Y);
                vertices[2] = new GeoPoint(upperLeft.X + sideLength, upperLeft.Y - sideLength);
                vertices[3] = new GeoPoint(upperLeft.X, upperLeft.Y - sideLength);
                vertices[4] = upperLeft;

                geometry.Add(factory.CreatePolygon(factory.CreateLinearRing(vertices), null));
            }
        }
开发者ID:junglewithyou,项目名称:SharpMap,代码行数:19,代码来源:MainForm.cs

示例8: ReadPolygonText

        /// <summary>
        /// Creates a Polygon using the next token in the stream.
        /// </summary>
        /// <param name="tokenizer">Tokenizer over a stream of text in Well-known Text
        ///  format. The next tokens must form a &lt;Polygon Text&gt;.</param>
        /// <param name="factory">The factory to create the result geometry</param>
        /// <returns>Returns a Polygon specified by the next token
        ///  in the stream</returns>
        ///  <remarks>
        ///  ParseException is thrown if the coordinates used to create the Polygon
        ///  shell and holes do not form closed linestrings, or if an unexpected
        ///  token is encountered.
        ///  </remarks>
        private static IPolygon ReadPolygonText(WktStreamTokenizer tokenizer, IGeometryFactory factory)
        {
            string nextToken = GetNextEmptyOrOpener(tokenizer);
            if (nextToken == "EMPTY")
                return factory.CreatePolygon(null, null);

            var exteriorRing = factory.CreateLinearRing(GetCoordinates(tokenizer));
            nextToken = GetNextCloserOrComma(tokenizer);
            var interiorRings = new List<ILinearRing>();
            while (nextToken == ",")
            {
                //Add holes
                interiorRings.Add(factory.CreateLinearRing(GetCoordinates(tokenizer)));
                nextToken = GetNextCloserOrComma(tokenizer);
            }
            return factory.CreatePolygon(exteriorRing, interiorRings.ToArray());
        }
开发者ID:geobabbler,项目名称:SharpMap,代码行数:30,代码来源:GeometryFromWKT.cs

示例9: CreateWKBLinearRing

 private static ILinearRing CreateWKBLinearRing(BinaryReader reader, WkbByteOrder byteOrder, IGeometryFactory factory)
 {
     var points = new List<Coordinate>(ReadCoordinates(reader, byteOrder));
     if (!points[0].Equals2D(points[points.Count-1]))
         points.Add(new Coordinate(points[0]));
     return factory.CreateLinearRing(points.ToArray());
 }
开发者ID:PedroMaitan,项目名称:sharpmap,代码行数:7,代码来源:GeometryFromWKB.cs

示例10: ToNTSLinearRing

 internal static NTSLinearRing ToNTSLinearRing(Geometries.LinearRing geom,
     IGeometryFactory factory)
 {
     NTSCoordinate[] coordinates = new NTSCoordinate[geom.NumPoints];
     int index = 0;
     foreach (Geometries.Point point in geom.Vertices)
         coordinates[index++] = ToNTSCoordinate(point, factory);
     return factory.CreateLinearRing(coordinates) as NTSLinearRing;
 }
开发者ID:lishxi,项目名称:_SharpMap,代码行数:9,代码来源:NtsGeometryConverter.cs

示例11: Read

		/// <summary>
		/// Reads a stream and converts the shapefile record to an equilivent geometry object.
		/// </summary>
		/// <param name="file">The stream to read.</param>
		/// <param name="geometryFactory">The geometry factory to use when making the object.</param>
		/// <returns>The Geometry object that represents the shape file record.</returns>
		public override IGeometry Read(BigEndianBinaryReader file, IGeometryFactory geometryFactory)
		{
			int shapeTypeNum = file.ReadInt32();
            ShapeGeometryTypes shapeType = (ShapeGeometryTypes)Enum.Parse(typeof(ShapeGeometryTypes), shapeTypeNum.ToString());
            if ( ! ( shapeType == ShapeGeometryTypes.Polygon  || shapeType == ShapeGeometryTypes.PolygonM ||
                     shapeType == ShapeGeometryTypes.PolygonZ || shapeType == ShapeGeometryTypes.PolygonZM))	
				throw new ShapefileException("Attempting to load a non-polygon as polygon.");

			// Read and for now ignore bounds.
			double[] box = new double[4];
			for (int i = 0; i < 4; i++) 
				box[i] = file.ReadDouble();

		    int numParts = file.ReadInt32();
			int numPoints = file.ReadInt32();
			int[] partOffsets = new int[numParts];
			for (int i = 0; i < numParts; i++)
				partOffsets[i] = file.ReadInt32();

			ArrayList shells = new ArrayList();
			ArrayList holes = new ArrayList();

		    for (int part = 0; part < numParts; part++)
			{
				int start = partOffsets[part];
			    int finish;
			    if (part == numParts - 1)
					 finish = numPoints;
				else finish = partOffsets[part + 1];
				int length = finish - start;
                CoordinateList points = new CoordinateList();
				for (int i = 0; i < length; i++)
				{
					Coordinate external = new Coordinate(file.ReadDouble(), file.ReadDouble() );					
                    new PrecisionModel(geometryFactory.PrecisionModel).MakePrecise(external);
                    Coordinate internalCoord = external;
					points.Add(internalCoord);
				}

				ILinearRing ring = geometryFactory.CreateLinearRing(points.ToArray());
				
                // If shape have only a part, jump orientation check and add to shells
                if (numParts == 1)
                    shells.Add(ring);
                else
                {
                    // Orientation check
                    if (CGAlgorithms.IsCounterClockwise(points.ToArray()))
                        holes.Add(ring);
                    else shells.Add(ring);
                }
			}

			// Now we have a list of all shells and all holes
			ArrayList holesForShells = new ArrayList(shells.Count);
			for (int i = 0; i < shells.Count; i++)
				holesForShells.Add(new ArrayList());
			// Find holes
			for (int i = 0; i < holes.Count; i++)
			{
				LinearRing testRing = (LinearRing) holes[i];
				LinearRing minShell = null;
				IEnvelope minEnv = null;
				IEnvelope testEnv = testRing.EnvelopeInternal;
				Coordinate testPt = testRing.GetCoordinateN(0);
				LinearRing tryRing;
				for (int j = 0; j < shells.Count; j++)
				{
					tryRing = (LinearRing) shells[j];
					IEnvelope tryEnv = tryRing.EnvelopeInternal;
					if (minShell != null) 
						minEnv = minShell.EnvelopeInternal;
					bool isContained = false;
					CoordinateList coordList = new CoordinateList(tryRing.Coordinates);
					if (tryEnv.Contains(testEnv)
                        && (CGAlgorithms.IsPointInRing(testPt, coordList.ToArray()) 
                        || (PointInList(testPt, coordList)))) 				
						isContained = true;

                    // Check if this new containing ring is smaller than the current minimum ring
                    if (isContained)
                    {
                        if (minShell == null || minEnv.Contains(tryEnv))
                            minShell = tryRing;

                        // Suggested by Brian Macomber and added 3/28/2006:
                        // holes were being found but never added to the holesForShells array
                        // so when converted to geometry by the factory, the inner rings were never created.
                        ArrayList holesForThisShell = (ArrayList)holesForShells[j];
                        holesForThisShell.Add(holes[i]);
                    }
				}
			}

//.........这里部分代码省略.........
开发者ID:zhongshuiyuan,项目名称:mapwindowsix,代码行数:101,代码来源:PolygonHandler.cs

示例12: ReadLinearRingText

 /// <summary>
 /// Creates a <c>LinearRing</c> using the next token in the stream.
 /// </summary>
 /// <param name="tokens">
 ///   Tokenizer over a stream of text in Well-known Text
 ///   format. The next tokens must form a &lt;LineString Text.
 /// </param>
 /// <param name="factory"> </param>
 /// <returns>A <c>LinearRing</c> specified by the next
 /// token in the stream.</returns>
 private ILinearRing ReadLinearRingText(IEnumerator<Token> tokens, IGeometryFactory factory)
 {
     return factory.CreateLinearRing(GetCoordinates(tokens, false));
 }
开发者ID:ste10k41,项目名称:nettopologysuite,代码行数:14,代码来源:WKTReader.cs

示例13: Edit

            public IGeometry Edit(IGeometry geometry, IGeometryFactory factory)
            {
                var linearRing = geometry as ILinearRing;
                if (linearRing != null)
                {
                    return factory.CreateLinearRing(EditSequence(
                        (linearRing).CoordinateSequence, geometry));
                }

                var lineString = geometry as ILineString;
                if (lineString != null)
                {
                    return factory.CreateLineString(EditSequence(
                        (lineString).CoordinateSequence,
                        geometry));
                }

                var point = geometry as IPoint;
                if (point != null)
                {
                    return factory.CreatePoint(EditSequence(
                        (point).CoordinateSequence, geometry));
                }

                return geometry;
            }
开发者ID:sridhar19091986,项目名称:sharpmapx,代码行数:26,代码来源:GeometryEditor.cs

示例14: GetVoronoiCellPolygon

        /// <summary>
        /// Gets the Voronoi cell around a site specified
        /// by the origin of a QuadEdge.
        /// </summary>
        /// <remarks>
        /// The userData of the polygon is set to be the <see cref="Coordinate" />
        /// of the site.  This allows attaching external
        /// data associated with the site to this cell polygon.
        /// </remarks>
        /// <param name="qe">a quadedge originating at the cell site</param>
        /// <param name="geomFact">a factory for building the polygon</param>
        /// <returns>a polygon indicating the cell extent</returns>
        public IPolygon GetVoronoiCellPolygon(QuadEdge qe, IGeometryFactory geomFact)
        {
            var cellPts = new List<Coordinate>();
            QuadEdge startQE = qe;

            do
            {
                // Coordinate cc = circumcentre(qe);
                // use previously computed circumcentre
                Coordinate cc = qe.Rot.Orig.Coordinate;
                cellPts.Add(cc);

                // move to next triangle CW around vertex
                qe = qe.OPrev;
            } while (qe != startQE);

            var coordList = new CoordinateList();
            coordList.AddAll(cellPts, false);
            coordList.CloseRing();

            if (coordList.Count < 4)
            {
            #if !PCL
                Debug.WriteLine(coordList);
            #endif
                coordList.Add(coordList[coordList.Count - 1], true);
            }

            Coordinate[] pts = coordList.ToCoordinateArray();
            IPolygon cellPoly = geomFact.CreatePolygon(geomFact.CreateLinearRing(pts), null);

            Vertex v = startQE.Orig;
            cellPoly.UserData = v.Coordinate;
            return cellPoly;
        }
开发者ID:Walt-D-Cat,项目名称:NetTopologySuite,代码行数:47,代码来源:QuadEdgeSubdivision.cs

示例15: ReadPolygon

        private static GeoAPI.Geometries.IPolygon ReadPolygon(byte[] geom, ref int idx, bool isLittleEndian, IGeometryFactory factory)
        {
            double[] adfTuple = new double[2];
            int nRings;

            nRings = ReadUInt32(geom,ref idx, isLittleEndian);

            if (nRings < 1 || nRings > Int32.MaxValue / (2 * 8))
                throw new ApplicationException("Currupt SpatialLite geom");

            List<GeoAPI.Geometries.ILineString> lineStrings = new List<GeoAPI.Geometries.ILineString>();
            for (int i = 0; i < nRings; i++)
                lineStrings.Add(ReadLineString(geom,ref idx, isLittleEndian, factory));

            List<GeoAPI.Geometries.ILinearRing> holes = null;
            var shell = factory.CreateLinearRing(lineStrings[0].Coordinates);
            if (lineStrings.Count > 1)
            {
                holes = new List<GeoAPI.Geometries.ILinearRing>();
                for (int i = 1; i < lineStrings.Count; i++)
                {
                    holes.Add(new NetTopologySuite.Geometries.LinearRing(lineStrings[i].Coordinates));
                }
            }
            return factory.CreatePolygon(shell, holes == null ? null : holes.ToArray());
        }
开发者ID:PedroMaitan,项目名称:sharpmap,代码行数:26,代码来源:GeometryFromSpatiaLite.cs


注:本文中的IGeometryFactory.CreateLinearRing方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。