コード例 #1
0
        public void EpsgEnumTests()
        {
            var r       = SridRegister.GetById(Epsg.Netherlands);
            var factory = r.Factory;

            //SharpProj.
            Assert.AreEqual((int)Epsg.Netherlands, r.SRID);
            Assert.AreEqual((int)Epsg.Netherlands, factory.SRID);

            Assert.AreEqual((int)Epsg.BelgiumLambert, SridRegister.GetById(Epsg.BelgiumLambert).SRID);

            Assert.AreEqual(2, r.CRS.CoordinateSystem.Axis.Count);
            Point p = factory.CreatePoint(new Coordinate(155000, 463000));

            Point pp = p.Reproject(SridRegister.GetById(Epsg.BelgiumLambert));

            Assert.IsNotNull(pp);

            Assert.IsNotNull(p.Reproject <Geometry>(SridRegister.GetById(Epsg.BelgiumLambert)));

            Assert.AreEqual((int)Epsg.BelgiumLambert, pp.SRID);
            Assert.AreEqual(new Point(719706, 816781), new Point(pp.Coordinate.RoundAll(0)));

            using (CoordinateTransform t = CoordinateTransform.Create(SridRegister.GetByValue(p.SRID), SridRegister.GetById(Epsg.BelgiumLambert), new CoordinateTransformOptions {
                NoBallparkConversions = true
            }))
            {
                if (t is CoordinateTransformList mc)
                {
                    Assert.AreEqual(3, mc.Count);
                    Assert.AreEqual(5, mc[0].Parameters.Count);
                    Assert.AreEqual(7, mc[1].Parameters.Count);
                    Assert.AreEqual(6, mc[2].Parameters.Count);
                }
                else
                {
                    Assert.Fail();
                }

                var rr = t.Apply(new PPoint(155000, 463000));
            }
        }
コード例 #2
0
 /// <summary>
 /// Wraps <see cref="CoordinateTransform.Apply(PPoint)"/> for NTS
 /// </summary>
 /// <param name="op"></param>
 /// <param name="c"></param>
 /// <returns></returns>
 public static Coordinate Apply(this CoordinateTransform op, Coordinate c)
 {
     return(op.Apply(c.ToPPoint()).ToCoordinate());
 }
コード例 #3
0
        /// <summary>
        /// Generic low-level reprojection. Used by the other methods
        /// </summary>
        /// <typeparam name="TGeometry"></typeparam>
        /// <param name="geometry"></param>
        /// <param name="operation"></param>
        /// <param name="factory"></param>
        /// <returns></returns>
        public static TGeometry Reproject <TGeometry>(this TGeometry geometry, CoordinateTransform operation, GeometryFactory factory)
            where TGeometry : Geometry
        {
            if (geometry is null)
            {
                throw new ArgumentNullException(nameof(geometry));
            }
            else if (operation is null)
            {
                throw new ArgumentNullException(nameof(operation));
            }
            else if (factory is null)
            {
                throw new ArgumentNullException(nameof(factory));
            }

            return(SridRegister.ReProject(geometry, factory,
                                          sq => factory.CoordinateSequenceFactory.Create(sq.ToPPoints().Select(x => operation.Apply(x)).ToCoordinates().ToArray())));
        }