• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# IGeometryFactory类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: CreateFeatureFeatureLayer

 internal static GeometryLayer CreateFeatureFeatureLayer(IGeometryFactory geoFactory,
                                                         Boolean includeGeometryCollections)
 {
     GeometryLayer layer = new GeometryLayer("TestFeatures",
                                             CreateFeatureDatasource(geoFactory, includeGeometryCollections));
     return layer;
 }
开发者ID:pobingwanghai,项目名称:SharpMapV2,代码行数:7,代码来源:DataSourceHelper.cs


示例2: TestWktWkb

        private static bool TestWktWkb(int number, IGeometryFactory factory, string wkt, string wkb)
        {
            WKTReader r = new WKTReader(factory);
            IGeometry wktGeom = r.Read(wkt);
            WKBReader s = new WKBReader(factory);
            IGeometry wkbGeom = s.Read(WKBReader.HexToBytes(wkb));

            try
            {
                Assert.AreEqual(wkb, WKBWriter.ToHex(wktGeom.AsBinary()), "wkb's don't match");
                Assert.IsTrue(DiscreteHausdorffDistance.Distance(wktGeom, wkbGeom) < 1e-9, number + ": DiscreteHausdorffDistance.Distance(wktGeom, wkbGeom) < 1e-9");
                if (!wktGeom.EqualsExact(wkbGeom))
                {
                    Assert.AreEqual(wkt, wktGeom.AsText(), number + ": wkt.Equals(wktGeom.AsText())");
                    var wktGeom2 = s.Read(wktGeom.AsBinary());
                    Assert.AreEqual(wkt, wktGeom2.AsText(), number + ": wkt.Equals(wktGeom2.AsText())");
                    var diff = wkbGeom.Difference(wktGeom);
                    Assert.IsTrue(false, number + ": wktGeom.EqualsExact(wkbGeom)\n" + diff.AsText());
                }
                return false;
            }
            catch (AssertionException ex)
            {
                Console.WriteLine(ex.Message);
                return true;
            }
        }
开发者ID:Walt-D-Cat,项目名称:NetTopologySuite,代码行数:27,代码来源:Issue28Fixture.cs


示例3: Write

		/// <summary>
		/// Writes a Geometry to the given binary wirter.
		/// </summary>
		/// <param name="geometry">The geometry to write.</param>
		/// <param name="file">The file stream to write to.</param>
		/// <param name="geometryFactory">The geometry factory to use.</param>
		public override void Write(IGeometry geometry, System.IO.BinaryWriter file, IGeometryFactory geometryFactory)
		{
            if(!(geometry is IMultiPoint))
                throw new ArgumentException("Geometry Type error: MultiPoint expected, but the type retrieved is " + geometry.GetType().Name);

            // Slow and maybe not useful...
			// if (!geometry.IsValid)
			// 	Trace.WriteLine("Invalid multipoint being written.");

            IMultiPoint mpoint = geometry as IMultiPoint;
            
            file.Write(int.Parse(Enum.Format(typeof(ShapeGeometryTypes), this.ShapeType, "d")));

            IEnvelope box = geometry.EnvelopeInternal;
			IEnvelope bounds = ShapeHandler.GetEnvelopeExternal(geometryFactory.PrecisionModel, box);
			file.Write(bounds.MinX);
			file.Write(bounds.MinY);
			file.Write(bounds.MaxX);
			file.Write(bounds.MaxY);

            int numPoints = mpoint.NumPoints;
			file.Write(numPoints);						

			// write the points 
			for (int i = 0; i < numPoints; i++)
			{
                IPoint point = (IPoint) mpoint.Geometries[i];
                file.Write(point.X);
                file.Write(point.Y);	
			}            
		}
开发者ID:lishxi,项目名称:_SharpMap,代码行数:37,代码来源:MultiPointHandler.cs


示例4: Read

 ///<summary>
 /// Converts a <see cref="GraphicsPath"/> to a Geometry, flattening it first.
 ///</summary>
 /// <param name="shp">The <see cref="GraphicsPath"/></param>
 /// <param name="flatness">The flatness parameter to use</param>
 /// <param name="geomFact">The GeometryFactory to use</param>
 /// <returns>A Geometry representing the shape</returns>
 public static IGeometry Read(GraphicsPath shp, double flatness, IGeometryFactory geomFact)
 {
     var path = (GraphicsPath)shp.Clone();
     path.Flatten(InvertY, (float)flatness);
     var pathIt = new GraphicsPathIterator(path);
     return Read(pathIt, geomFact);
 }
开发者ID:russcam,项目名称:Nhibernate.Spatial,代码行数:14,代码来源:GraphicsPathReader.cs


示例5: Write

 /// <summary>
 /// Writes to the given stream the equilivent shape file record given a Geometry object.
 /// </summary>
 /// <param name="geometry">The geometry object to write.</param>
 /// <param name="file">The stream to write to.</param>
 /// <param name="geometryFactory">The geometry factory to use.</param>
 public override void Write(IGeometry geometry, System.IO.BinaryWriter file, IGeometryFactory geometryFactory)
 {
     file.Write(int.Parse(Enum.Format(typeof(ShapeGeometryTypes), this.ShapeType, "d")));
     ICoordinate external = geometry.Coordinates[0];
     file.Write(external.X);
     file.Write(external.Y);
 }
开发者ID:izambakci,项目名称:tf-net,代码行数:13,代码来源:PointHandler.cs


示例6: GraphBuilder2

        public GraphBuilder2() : this (false) { } // TODO: maybe the default value must be true...

        /// <summary>
        /// Adds each line to the graph structure.
        /// </summary>
        /// <param name="lines"></param>
        /// <returns>
        /// <c>true</c> if all <paramref name="lines">lines</paramref> 
        /// are added, <c>false</c> otherwise.
        /// </returns>
        /// <exception cref="TopologyException">
        /// If geometries don't have the same <see cref="IGeometryFactory">factory</see>.
        /// </exception>
        public bool Add(params ILineString[] lines)
        {
            bool result = true;
            foreach (ILineString line in lines)
            {
                IGeometryFactory newfactory = line.Factory;
                if (factory == null)
                    factory = newfactory;
                else if (!newfactory.PrecisionModel.Equals(factory.PrecisionModel))
                    throw new TopologyException("all geometries must have the same precision model");

                bool lineFound = strings.Contains(line);
                result &= !lineFound;
                if (!lineFound)
                    strings.Add(line);
                else continue; // Skip vertex check because line is already present

                foreach (ICoordinate coord in line.Coordinates)
                {
                    if (!graph.ContainsVertex(coord))
                         graph.AddVertex(coord);
                    
                }
            }
            return result;
        }        
开发者ID:diegowald,项目名称:intellitrack,代码行数:39,代码来源:GraphBuilder2.cs


示例7: ShapefileBlockReader

 public ShapefileBlockReader(string path, ShapefileIndexReader index, IGeometryFactory geometryFactory = null, GeometryTransform transform = null, int blockSize = 25)
     : base(path, geometryFactory, transform)
 {
     _block = new int[blockSize, 2];
     _blockPos = blockSize;
     _index = index;
 }
开发者ID:interworks,项目名称:FastShapefile,代码行数:7,代码来源:ShapefileBlockReader.cs


示例8: 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();
            type = (ShapeGeometryType) Enum.Parse(typeof (ShapeGeometryType), shapeTypeNum.ToString());
            if (type == ShapeGeometryType.NullShape)
            {
                ICoordinate emptyCoordinate = null;
                return geometryFactory.CreatePoint(emptyCoordinate);
            }

            if (!(type == ShapeGeometryType.Point  || type == ShapeGeometryType.PointM ||
                  type == ShapeGeometryType.PointZ || type == ShapeGeometryType.PointZM))
                throw new ShapefileException("Attempting to load a point as point.");		    

            double x = file.ReadDouble();
            double y = file.ReadDouble();		    
            ICoordinate external = new Coordinate(x,y);			
            geometryFactory.PrecisionModel.MakePrecise(external);
            IPoint point = geometryFactory.CreatePoint(external);
            if (HasZValue() || HasMValue())
            {
                IDictionary<ShapeGeometryType, double> data = new Dictionary<ShapeGeometryType, double>(2);
                if (HasZValue())
                    GetZValue(file, data);
                if (HasMValue())
                    GetMValue(file, data);
                // point.UserData = data;
            }
            return point;
        }
开发者ID:diegowald,项目名称:intellitrack,代码行数:36,代码来源:PointHandler.cs


示例9: DataConverter

        public DataConverter(IGeometryFactory factory)
        {
            if (factory == null)
                throw new ArgumentNullException("factory");

            _factory = factory;
        }
开发者ID:Walt-D-Cat,项目名称:NetTopologySuite,代码行数:7,代码来源:DataConverter.cs


示例10: ShapefileReader

        /// <summary>
        /// Initializes a new instance of the Shapefile class with the given parameters.
        /// </summary>
        /// <param name="filename">The filename of the shape file to read (with .shp).</param>
        /// <param name="geometryFactory">The GeometryFactory to use when creating Geometry objects.</param>
        public ShapefileReader(string filename, IGeometryFactory geometryFactory)
        {
            Guard.IsNotNull(filename, "filename");
            Guard.IsNotNull(geometryFactory, "geometryFactory");

            _filename = filename;
            _geometryFactory = geometryFactory;

            using (IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForApplication())
            {
                // read header information. note, we open the file, read the header information and then
                // close the file. This means the file is not opened again until GetEnumerator() is requested.
                // For each call to GetEnumerator() a new BinaryReader is created.
                using (
                    var stream = new IsolatedStorageFileStream(filename, FileMode.Open, FileAccess.Read, FileShare.Read,
                                                               isf))
                {
                    using (var shpBinaryReader = new BigEndianBinaryReader(stream))
                    {
                        _mainHeader = new ShapefileHeader(shpBinaryReader);
                        shpBinaryReader.Close();
                    }
                }
            }
        }
开发者ID:Walt-D-Cat,项目名称:NetTopologySuite,代码行数:30,代码来源:ShapefileReader.SL.cs


示例11: Execute

        private void Execute(IGeometryFactory factory)
        {
            const string wkt1 = @"POLYGON ((34.8998882099012 30.3837960942026, 34.9010566737651 30.3644568453302, 34.952062587058 30.3841960548712, 34.9237694926759 30.3379967024143, 34.8688043479468 30.2722872698552, 34.8675239767921 30.2729668362851, 34.8644624659558 30.2746560404891, 34.8614352803289 30.2763912924804, 34.8584433396252 30.2781720660657, 34.8554875530179 30.2799978212197, 34.8525688188649 30.2818680042466, 34.8496880244379 30.2837820479458, 34.8468460456542 30.2857393717817, 34.8440437468117 30.2877393820578, 34.8412819803279 30.2897814720941, 34.8385615864812 30.291865022409, 34.8358833931563 30.2939894009049, 34.8332482155932 30.2961539630577, 34.8306568561393 30.2983580521099, 34.8281101040059 30.3006009992674, 34.8256087350277 30.3028821239005, 34.8231535114263 30.3052007337477, 34.8207451815784 30.3075561251236, 34.8183844797864 30.3099475831299, 34.8160721260548 30.3123743818706, 34.813808825869 30.3148357846692, 34.8115952699799 30.3173310442906, 34.8094321341915 30.3198594031656, 34.8073200791532 30.3224200936183, 34.8052597501567 30.3250123380972, 34.8038593775008 30.3268416420348, 34.8413134524996 30.34133631112, 34.8380456129141 30.3420679436136, 34.8345469119455 30.3429079098264, 34.8310655827664 30.3438006160548, 34.827824169131 30.3446853380141, 34.827602680711 30.3447457917824, 34.8241592556176 30.3457431505854, 34.8207363515157 30.3467923902175, 34.8173350063135 30.3478931927008, 34.8139562514873 30.34904522442, 34.8106011117732 30.3502481362226, 34.80727060486 30.3515015635225, 34.8039657410851 30.3528051264095, 34.8006875231308 30.3541584297621, 34.7974369457248 30.355561063366, 34.8114061852091 30.3793421607384, 34.8098261518056 30.3806388748041, 34.8072325551456 30.3828429255909, 34.8046836035397 30.3850858339783, 34.8021800734927 30.387366919357, 34.7997227278858 30.3896854894863, 34.797312315744 30.3920408407015, 34.7949495720071 30.3944322581256, 34.7926352173053 30.3968590158832, 34.7903699577383 30.3993203773193, 34.7881544846595 30.4018155952199, 34.8175519633847 30.421036532238, 34.8473374156124 30.4405111377535, 34.8473374156124 30.4405111377536, 34.8945946797018 30.4714093282142, 34.89504284421 30.4639917561117, 34.9249010902965 30.4502666241023, 34.9120339400511 30.4239712613602, 34.8990624811609 30.3974627330299, 34.8990624811609 30.3974627330298, 34.8998882099012 30.3837960942026), (34.8998882099012 30.3837960942026, 34.8896581575596 30.3782440174851, 34.8896581575596 30.3782440174851, 34.8998882099012 30.3837960942026))";
            const string wkt2 = @"POLYGON ((34.89504284421 30.4639917561117, 34.8974881525283 30.4235194508906, 34.8362388038152 30.4216169690234, 34.8683403196915 30.4762662772922, 34.89504284421 30.4639917561117))";

            WKTReader reader = new WKTReader(factory);

            IGeometry g1 = reader.Read(wkt1);
            Assert.IsFalse(g1.IsValid);
            IGeometry v1 = g1.Buffer(0);
            Assert.IsTrue(v1.IsValid);

            IGeometry g2 = reader.Read(wkt2);
            //Assert.IsFalse(g2.IsValid);
            IGeometry v2 = g2.Buffer(0);
            Assert.IsTrue(v2.IsValid);

            IGeometry union1 = g1.Union(g2);
            Assert.IsNotNull(union1);
            Assert.IsTrue(union1.IsValid);

            IGeometry union2 = v1.Union(v2);
            Assert.IsNotNull(union2);
            Assert.IsTrue(union2.IsValid);
        }
开发者ID:Walt-D-Cat,项目名称:NetTopologySuite,代码行数:25,代码来源:Issue58Tests.cs


示例12: ShapefileDataReader

        public ShapefileDataReader(IStreamProviderRegistry streamProviderRegistry, IGeometryFactory geometryFactory)
        {
            if (streamProviderRegistry==null)
                throw new ArgumentNullException("streamProviderRegistry");
            if (geometryFactory == null)
                throw new ArgumentNullException("geometryFactory");
            _open = true;

            _dbfReader = new DbaseFileReader(streamProviderRegistry);
            _shpReader = new ShapefileReader(streamProviderRegistry, geometryFactory);

            _dbfHeader = _dbfReader.GetHeader();
            _recordCount = _dbfHeader.NumRecords;

            // copy dbase fields to our own array. Insert into the first position, the shape column
            _dbaseFields = new DbaseFieldDescriptor[_dbfHeader.Fields.Length + 1];
            _dbaseFields[0] = DbaseFieldDescriptor.ShapeField();
            for (int i = 0; i < _dbfHeader.Fields.Length; i++)
                _dbaseFields[i + 1] = _dbfHeader.Fields[i];

            _shpHeader = _shpReader.Header;
            _dbfEnumerator = _dbfReader.GetEnumerator();
            _shpEnumerator = _shpReader.GetEnumerator();
            _moreRecords = true;
        }
开发者ID:Walt-D-Cat,项目名称:NetTopologySuite,代码行数:25,代码来源:ShapefileDataReader.cs


示例13: ShapefileDataReader

        /// <summary>
        /// Initializes a new instance of the ShapefileDataReader class.
        /// </summary>
        /// <param name="filename">The shapefile to read (minus the .shp extension)</param>
        ///<param name="geometryFactory">The GeometryFactory to use.</param>
        public ShapefileDataReader(string filename, IGeometryFactory geometryFactory)
        {
            if (filename == null)
                throw new ArgumentNullException("filename");
            if (geometryFactory == null)
                throw new ArgumentNullException("geometryFactory");
            _geometryFactory = geometryFactory;
            _open = true;

            if (filename.ToLower().EndsWith(".shp"))
                filename = filename.ToLower().Replace(".shp",String.Empty);

             _dbfReader = new DbaseFileReader(filename + ".dbf");
             _shpReader = new ShapefileReader(filename + ".shp", geometryFactory);

            _dbfHeader =  _dbfReader.GetHeader();
            _recordCount = _dbfHeader.NumRecords;

            // copy dbase fields to our own array. Insert into the first position, the shape column
            _dbaseFields = new DbaseFieldDescriptor[_dbfHeader.Fields.Length + 1];
            _dbaseFields[0] = DbaseFieldDescriptor.ShapeField();
            for(int i=0; i < _dbfHeader.Fields.Length; i++)
                _dbaseFields[i+1] = _dbfHeader.Fields[i];

            _shpHeader = _shpReader.Header;
            _dbfEnumerator = _dbfReader.GetEnumerator();
            _shpEnumerator = _shpReader.GetEnumerator();
            _moreRecords = true;
        }
开发者ID:izambakci,项目名称:tf-net,代码行数:34,代码来源:ShapefileDataReader.cs


示例14: PerformTest

        private static void PerformTest(IGeometryFactory factory)
        {
            if (factory == null)
                throw new ArgumentNullException("factory");

            WKTReader reader = new WKTReader(factory);
            IGeometry g1 = reader.Read(t1);
            Assert.IsNotNull(g1);
            Assert.IsTrue(g1.IsValid);
            Assert.IsInstanceOf(typeof(IPolygon), g1);
            Assert.IsInstanceOf(typeof(Polygon), g1);

            IGeometry g2 = reader.Read(t2);
            Assert.IsNotNull(g2);
            Assert.IsTrue(g2.IsValid);
            Assert.IsInstanceOf(typeof(IMultiPolygon), g2);
            Assert.IsInstanceOf(typeof(MultiPolygon), g2);

            Stopwatch watch = new Stopwatch();
            watch.Start();
            IGeometry r = g1.Intersection(g2);
            watch.Stop();
            Assert.IsNotNull(r);
            Assert.IsInstanceOf(typeof(IMultiPolygon), r);
            Assert.IsInstanceOf(typeof(MultiPolygon), r);
            Assert.IsTrue(r.IsValid);
            Console.WriteLine("GeometryFactory.Default => Elapsed: {0}", watch.Elapsed);
        }
开发者ID:Walt-D-Cat,项目名称:NetTopologySuite,代码行数:28,代码来源:SlowIntersectionTest.cs


示例15: ShapefileDataReader

        public ShapefileDataReader(string path, IGeometryFactory geometryFactory = null, GeometryTransform transform = null)
            : base(path, geometryFactory, transform)
        {
            _dbf = DbfFile.Open(Path.ChangeExtension(path, ".dbf"));

            _currentRecord = new DbfRecord(_dbf.Header);
        }
开发者ID:interworks,项目名称:FastShapefile,代码行数:7,代码来源:ShapefileDataReader.cs


示例16: ToNTSGeometry

        /// <summary>
        /// Converts any <see cref="GisSharpBlog.NetTopologySuite.Geometries.Geometry"/> to the correspondant 
        /// <see cref="SharpMap.Geometries.Geometry"/>.
        /// </summary>
        public static NTSGeometry ToNTSGeometry(Geometries.Geometry geometry, IGeometryFactory factory)
        {
            if (geometry == null)
                throw new NullReferenceException("geometry");

            if (TypeOf(geometry, typeof(Geometries.Point)))
                return ToNTSPoint(geometry as Geometries.Point, factory);

            if (TypeOf(geometry, typeof (Geometries.LineString)))
                return ToNTSLineString(geometry as Geometries.LineString, factory);

            if (TypeOf(geometry, typeof (Geometries.Polygon)))
                return ToNTSPolygon(geometry as Geometries.Polygon, factory);

            if (TypeOf(geometry, typeof (Geometries.MultiPoint)))
                return ToNTSMultiPoint(geometry as Geometries.MultiPoint, factory);

            if (TypeOf(geometry, typeof (Geometries.MultiLineString)))
                return ToNTSMultiLineString(geometry as Geometries.MultiLineString, factory);

            if (TypeOf(geometry, typeof (Geometries.MultiPolygon)))
                return ToNTSMultiPolygon(geometry as Geometries.MultiPolygon, factory);

            if (TypeOf(geometry, typeof (Geometries.GeometryCollection)))
                return ToNTSGeometryCollection(geometry as Geometries.GeometryCollection, factory);

            var message = String.Format("Type {0} not supported", geometry.GetType().FullName);
            throw new NotSupportedException(message);
        }
开发者ID:lishxi,项目名称:_SharpMap,代码行数:33,代码来源:NtsGeometryConverter.cs


示例17: Point

 /// <summary>
 /// Constructs a <c>Point</c> with the given coordinate.
 /// </summary>
 /// <param name="coordinates">
 /// Contains the single coordinate on which to base this <c>Point</c>,
 /// or <c>null</c> to create the empty point.
 /// </param>
 /// <param name="factory"></param>
 public Point(ICoordinateSequence coordinates, IGeometryFactory factory) : base(factory)
 {               
     if (coordinates == null) 
         coordinates = factory.CoordinateSequenceFactory.Create(new Coordinate[] { });
     NetTopologySuite.Utilities.Assert.IsTrue(coordinates.Count <= 1);
     this._coordinates = coordinates;
 }        
开发者ID:ste10k41,项目名称:nettopologysuite,代码行数:15,代码来源:Point.cs


示例18: SpatialDbFeatureDataReader

        protected internal SpatialDbFeatureDataReader(IGeometryFactory geomFactory, IDataReader internalReader,
                                                      string geometryColumn, string oidColumn)
        {
            _geomFactory = geomFactory;
            _internalReader = internalReader;
            _geometryColumn = geometryColumn;
            _oidColumn = oidColumn;


            for (int i = 0; i < internalReader.FieldCount; i++)
            // note: GetOrdinal crashes if the column does not exist so loop through fields
            {
                string name = internalReader.GetName(i);
                if (String.Compare(name, geometryColumn, StringComparison.CurrentCultureIgnoreCase) == 0)
                    _geomColumnIndex = i;

                if (String.Compare(name, oidColumn, StringComparison.CurrentCultureIgnoreCase) == 0)
                    _oidColumnIndex = i;

                if (_geomColumnIndex > -1 && _oidColumnIndex > -1)
                    break;
            }
            if (_oidColumnIndex > -1)
                _oidType = _internalReader.GetFieldType(_oidColumnIndex);
        }
开发者ID:pobingwanghai,项目名称:SharpMapV2,代码行数:25,代码来源:SpatialDbFeatureDataReader.cs


示例19: ShapefileDataReader

        /// <summary>
        /// Initializes a new instance of the ShapefileDataReader class.
        /// </summary>
        /// <param name="filename">The shapefile to read (minus the .shp extension)</param>
        ///<param name="geometryFactory">The GeometryFactory to use.</param>
        public ShapefileDataReader(string filename, IGeometryFactory geometryFactory)
        {
            if (String.IsNullOrEmpty(filename))
                throw new ArgumentNullException("filename");
            if (geometryFactory == null)
                throw new ArgumentNullException("geometryFactory");
            _open = true;

            string dbfFile = Path.ChangeExtension(filename, "dbf");
            _dbfReader = new DbaseFileReader(dbfFile);
            string shpFile = Path.ChangeExtension(filename, "shp");
            _shpReader = new ShapefileReader(shpFile, geometryFactory);

            _dbfHeader = _dbfReader.GetHeader();
            _recordCount = _dbfHeader.NumRecords;

            // copy dbase fields to our own array. Insert into the first position, the shape column
            _dbaseFields = new DbaseFieldDescriptor[_dbfHeader.Fields.Length + 1];
            _dbaseFields[0] = DbaseFieldDescriptor.ShapeField();
            for (int i = 0; i < _dbfHeader.Fields.Length; i++)
                _dbaseFields[i + 1] = _dbfHeader.Fields[i];

            _shpHeader = _shpReader.Header;
            _dbfEnumerator = _dbfReader.GetEnumerator();
            _shpEnumerator = _shpReader.GetEnumerator();
            _moreRecords = true;
        }
开发者ID:ste10k41,项目名称:nettopologysuite,代码行数:32,代码来源:ShapefileDataReader.cs


示例20: 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="totalRecordLength">Total length of the record we are about to read</param>
        /// <param name="factory">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, int totalRecordLength, IGeometryFactory factory)
        {
            int totalRead = 0;
            ShapeGeometryType type = (ShapeGeometryType)ReadInt32(file, totalRecordLength, ref totalRead);
            //type = (ShapeGeometryType) EnumUtility.Parse(typeof (ShapeGeometryType), shapeTypeNum.ToString());
            if (type == ShapeGeometryType.NullShape)
                return factory.CreatePoint((Coordinate)null);

            if (type != ShapeType)
                throw new ShapefileException(string.Format("Encountered a '{0}' instead of a  '{1}'", type, ShapeType));

            CoordinateBuffer buffer = new CoordinateBuffer(1, NoDataBorderValue, true);
            IPrecisionModel precisionModel = factory.PrecisionModel;

            double x = precisionModel.MakePrecise(ReadDouble(file, totalRecordLength, ref totalRead));
            double y = precisionModel.MakePrecise(ReadDouble(file, totalRecordLength, ref totalRead));

            double? z = null, m = null;
            
            // Trond Benum: Let's read optional Z and M values                                
            if (HasZValue() && totalRead < totalRecordLength)
                z = ReadDouble(file, totalRecordLength, ref totalRead);

            if ((HasMValue() || HasZValue()) &&
                (totalRead < totalRecordLength))
                m = ReadDouble(file, totalRecordLength, ref totalRead);

            buffer.AddCoordinate(x, y, z, m);
            return factory.CreatePoint(buffer.ToSequence(factory.CoordinateSequenceFactory));
        }
开发者ID:Walt-D-Cat,项目名称:NetTopologySuite,代码行数:37,代码来源:PointHandler.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# IGetter类代码示例发布时间:2022-05-24
下一篇:
C# IGeometryCollection类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap