/// <summary>
        /// Converts the specified content.
        /// </summary>
        /// <param name="content">The content.</param>
        /// <returns>The converted reference.</returns>
        protected override ProjectedCoordinateReferenceSystem Convert(String[] content)
        {
            switch (content[3])
            {
            case "projected":
                AreaOfUse areaOfUse = this.areaOfUseCollection[Authority, Int32.Parse(content[2])];
                GeographicCoordinateReferenceSystem baseReferenceSystem = this.baseCoordinateReferenceSystemCollection[Authority, Int32.Parse(content[6])];
                CoordinateSystem coordinateSystem = this.coordinateSystemCollection[Authority, Int32.Parse(content[4])];

                // the projection should use the ellipsoid with the unit specified by the coordinate system
                CoordinateProjection projection = this.coordinateProjectionCollection[Authority, Int32.Parse(content[7]), baseReferenceSystem.Datum.Ellipsoid.ToUnit(coordinateSystem.GetAxis(0).Unit)];

                // TODO: remove condition, once all projections are implemented
                if (projection == null)
                {
                    return(null);
                }

                return(new ProjectedCoordinateReferenceSystem(IdentifiedObject.GetIdentifier(Authority, content[0]), content[1],
                                                              content[11], this.GetAliases(Int32.Parse(content[0])), content[10],
                                                              baseReferenceSystem, coordinateSystem, areaOfUse, projection));

            default:
                return(null);
            }
        }
コード例 #2
0
        /// <summary>
        /// Computes the projected coordinate reference system.
        /// </summary>
        /// <returns>The projected coordinate reference system.</returns>
        /// <exception cref="System.IO.InvalidDataException">Projected coordinate reference system code is invalid.</exception>
        private ProjectedCoordinateReferenceSystem ComputeProjectedCoordinateReferenceSystem()
        {
            Int32 code = Convert.ToInt32(_currentGeoKeys[GeoKey.ProjectedCoordinateReferenceSystemType]);

            // EPSG Projected Coordinate Reference System codes
            if (code < 32767)
            {
                ProjectedCoordinateReferenceSystem referenceSystem = ProjectedCoordinateReferenceSystems.FromIdentifier("EPSG::" + code).FirstOrDefault();

                if (referenceSystem == null)
                {
                    return(new ProjectedCoordinateReferenceSystem("EPSG::" + code, "undefined", Geographic2DCoordinateReferenceSystems.WGS84, CoordinateSystems.CartesianENM, AreasOfUse.World, null));
                }

                return(referenceSystem);
            }
            // user-defined Projected Coordinate Reference System
            if (code == Int16.MaxValue)
            {
                GeographicCoordinateReferenceSystem baseReferenceSystem = ComputeGeodeticCoordinateReferenceSystem();
                CoordinateProjection projection = ComputeProjection(baseReferenceSystem.Datum.Ellipsoid);

                return(new ProjectedCoordinateReferenceSystem(ProjectedCoordinateReferenceSystem.UserDefinedIdentifier, ProjectedCoordinateReferenceSystem.UserDefinedName,
                                                              baseReferenceSystem, CoordinateSystems.CartesianENM, baseReferenceSystem.AreaOfUse, projection));
            }

            throw new InvalidDataException("Projected coordinate reference system code is invalid.");
        }
        /// <summary>
        /// Returns a collection with items matching a specified projection.
        /// </summary>
        /// <param name="projection">The coordinate projection.</param>
        /// <returns>A collection containing the items that match the specified projection.</returns>
        /// <exception cref="System.ArgumentNullException">The projection is null.</exception>
        public IEnumerable <ProjectedCoordinateReferenceSystem> WithProjection(CoordinateProjection projection)
        {
            if (projection == null)
            {
                throw new ArgumentNullException(nameof(projection));
            }

            return(this.GetReferences().Where(referenceSystem => referenceSystem.Projection.Equals(projection)));
        }
コード例 #4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ProjectionReverseStrategy" /> class.
        /// </summary>
        /// <param name="source">The source reference system.</param>
        /// <exception cref="System.ArgumentNullException">The source coordinate reference system is null.</exception>
        public ReverseProjectionStrategy(ProjectedCoordinateReferenceSystem source)
        {
            if (source == null)
            {
                throw new ArgumentNullException("source", "The source reference system is null.");
            }

            _source     = source;
            _projection = source.Projection;
        }
コード例 #5
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ForwardProjectionStrategy" /> class.
        /// </summary>
        /// <param name="target">The target reference system.</param>
        /// <exception cref="System.ArgumentNullException">target;The target coordinate reference system is null.</exception>
        public ForwardProjectionStrategy(ProjectedCoordinateReferenceSystem target)
        {
            if (target == null)
            {
                throw new ArgumentNullException("target", "The target reference system is null.");
            }

            _target     = target;
            _projection = target.Projection;
        }
コード例 #6
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ProjectedCoordinateReferenceSystem" /> class.
        /// </summary>
        /// <param name="identifier">The identifier.</param>
        /// <param name="name">The name.</param>
        /// <param name="remarks">The remarks.</param>
        /// <param name="aliases">The aliases.</param>
        /// <param name="scope">The scope.</param>
        /// <param name="baseReferenceSystem">The base reference system.</param>
        /// <param name="coordinateSystem">The coordinate system.</param>
        /// <param name="areaOfUse">The area of use.</param>
        /// <param name="projection">The projection.</param>
        /// <exception cref="System.ArgumentNullException">
        /// The identifier is null.
        /// or
        /// The base reference system is null.
        /// or
        /// The coordinate system is null.
        /// or
        /// The projection is null.
        /// </exception>
        public ProjectedCoordinateReferenceSystem(String identifier, String name, String remarks, String[] aliases, String scope, GeographicCoordinateReferenceSystem baseReferenceSystem, CoordinateSystem coordinateSystem, AreaOfUse areaOfUse, CoordinateProjection projection)
            : base(identifier, name, remarks, aliases, scope, coordinateSystem, baseReferenceSystem != null ? baseReferenceSystem.Datum : null, areaOfUse)
        {
            if (baseReferenceSystem == null)
            {
                throw new ArgumentNullException("baseReferenceSystem", "The base reference system is null.");
            }

            _baseReferenceSystem = baseReferenceSystem;
            _projection          = projection;
        }
コード例 #7
0
        /// <summary>
        /// Computes the coordinate projection for the geo-key directory.
        /// </summary>
        /// <param name="geoKeyDirectory">The geo-key directory.</param>
        /// <param name="projection">The coordinate projection.</param>
        private void ComputeCoordinateProjection(GeoKeyDirectory geoKeyDirectory, CoordinateProjection projection)
        {
            if (projection.Code >= 10000 && projection.Code <= 19999)
            {
                geoKeyDirectory.Add(GeoKey.Projection, (Int16)projection.Code);
                return;
            }

            // user-defined projection
            geoKeyDirectory.Add(GeoKey.Projection, Int16.MaxValue);
            geoKeyDirectory.Add(GeoKey.ProjectionCoordinateTransformation, (Int16)projection.Method.Code);

            // TODO: process parameters
        }
コード例 #8
0
        public void CoordinateProjectionFactoryFromMethodNameTest()
        {
            CoordinateProjection expected = CoordinateProjectionFactory.BritishNationalGrid(Ellipsoids.WGS1984);

            Dictionary <CoordinateOperationParameter, Object> parameters = new Dictionary <CoordinateOperationParameter, Object>();

            parameters.Add(CoordinateOperationParameters.LatitudeOfNaturalOrigin, Angle.FromDegree(49));
            parameters.Add(CoordinateOperationParameters.LongitudeOfNaturalOrigin, Angle.FromDegree(-2));
            parameters.Add(CoordinateOperationParameters.FalseEasting, Length.Convert(Length.FromMetre(400000), Ellipsoids.WGS1984.SemiMajorAxis.Unit));
            parameters.Add(CoordinateOperationParameters.FalseNorthing, Length.Convert(Length.FromMetre(-100000), Ellipsoids.WGS1984.SemiMajorAxis.Unit));
            parameters.Add(CoordinateOperationParameters.ScaleFactorAtNaturalOrigin, 0.9996012717);

            CoordinateProjection actual = CoordinateProjectionFactory.FromMethodName(expected.Method.Name, parameters, Ellipsoids.WGS1984, AreasOfUse.GreatBritainMan).FirstOrDefault();

            Assert.AreEqual(expected.Method, actual.Method);
        }
コード例 #9
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ProjectedCoordinateReferenceSystem" /> class.
 /// </summary>
 /// <param name="identifier">The identifier.</param>
 /// <param name="name">The name.</param>
 /// <param name="baseReferenceSystem">The base reference system.</param>
 /// <param name="coordinateSystem">The coordinate system.</param>
 /// <param name="areaOfUse">The area of use.</param>
 /// <param name="projection">The projection.</param>
 /// <exception cref="System.ArgumentNullException">
 /// The identifier is null.
 /// or
 /// The base reference system is null.
 /// or
 /// The coordinate system is null.
 /// </exception>
 public ProjectedCoordinateReferenceSystem(String identifier, String name, GeographicCoordinateReferenceSystem baseReferenceSystem, CoordinateSystem coordinateSystem, AreaOfUse areaOfUse, CoordinateProjection projection)
     : this(identifier, name, null, null, null, baseReferenceSystem, coordinateSystem, areaOfUse, projection)
 {
 }
コード例 #10
0
        /// <summary>
        /// Returns a collection with items matching a specified projection.
        /// </summary>
        /// <param name="collection">The projected coordinate reference system collection.</param>
        /// <param name="projection">The coordinate projection.</param>
        /// <returns>A collection containing the items that match the specified projection.</returns>
        /// <exception cref="System.ArgumentNullException">
        /// The collection is null.
        /// or
        /// The projection is null.
        /// </exception>
        public static IEnumerable <ProjectedCoordinateReferenceSystem> WithProjection(this IEnumerable <ProjectedCoordinateReferenceSystem> collection, CoordinateProjection projection)
        {
            if (collection == null)
            {
                throw new ArgumentNullException(nameof(collection));
            }

            return(collection.Where(item => item.Projection.Equals(projection)));
        }