コード例 #1
0
        /// <summary>
        /// Converts the geometry from Geography Markup Language (GML) representation.
        /// </summary>
        /// <param name="source">The source XML element.</param>
        /// <param name="geometryFactory">The geometry factory.</param>
        /// <param name="referenceSystemFactory">The reference system factory.</param>
        /// <returns>The converted geometry.</returns>
        /// <remarks>
        /// The <see cref="XElement" /> does not contain the namespace attribute for <code>gml</code>
        /// (<code>xmlns:gml="http://www.opengis.net/gml/"</code>), which should be added to a parent node before usage.
        /// </remarks>
        /// <exception cref="System.ArgumentNullException">
        /// The source is null.
        /// or
        /// The geometry factory is null.
        /// or
        /// The reference system factory is null.
        /// </exception>
        /// <exception cref="System.ArgumentException">The specified source is invalid.</exception>
        public static IGeometry ToGeometry(this XElement source, IGeometryFactory geometryFactory, IReferenceSystemFactory referenceSystemFactory)
        {
            if (source == null)
            {
                throw new ArgumentNullException(nameof(source));
            }
            if (geometryFactory == null)
            {
                throw new ArgumentNullException(nameof(geometryFactory));
            }
            if (referenceSystemFactory == null)
            {
                throw new ArgumentNullException(nameof(referenceSystemFactory));
            }

            IReferenceSystem referenceSystem = GetReferenceSystem(source.Attribute("srsName"), referenceSystemFactory);

            return(ToGeometry(source, geometryFactory.WithReferenceSystem(referenceSystem)));
        }