Example #1
0
        /// <summary>
        /// Constructs a new projected CRS.
        /// </summary>
        /// <param name="name">The name of the CRS.</param>
        /// <param name="baseCrs">The CRS this CRS is based on.</param>
        /// <param name="projection">The projection operation.</param>
        /// <param name="linearUnit">The linear unit of the projection.</param>
        /// <param name="axes">The axes of the projected CRS.</param>
        /// <param name="authority">The authority.</param>
        public OgcCrsProjected(
            string name,
            ICrsGeodetic baseCrs,
            ICoordinateOperationInfo projection,
            IUnit linearUnit,
            IEnumerable <IAxis> axes,
            IAuthorityTag authority = null
            )
            : base(name, authority)
        {
            if (null == baseCrs)
            {
                throw new ArgumentNullException("baseCrs");
            }
            if (null == projection)
            {
                throw new ArgumentNullException("projection");
            }
            if (null == linearUnit)
            {
                throw new ArgumentNullException("linearUnit");
            }
            if (null == axes)
            {
                throw new ArgumentNullException("axes");
            }
            Contract.Requires(name != null);

            BaseCrs    = baseCrs;
            Projection = projection;
            Unit       = linearUnit;
            Axes       = Array.AsReadOnly(null == axes ? new IAxis[0] : axes.ToArray());
        }
 public CoordinateOperationCrsPathInfo(ICrs node)
 {
     if(node == null) throw new ArgumentNullException("node");
     Contract.EndContractBlock();
     CrsNodesArray = new[] { node };
     OperationEdgesArray = new ICoordinateOperationInfo[0];
 }
Example #3
0
        private static bool IsNotRestricted(ICoordinateOperationInfo op)
        {
            var epsgInverseOp = op as EpsgCoordinateOperationInverse;
            var epsgOp        = epsgInverseOp != null
                ? epsgInverseOp.Core
                : op as EpsgCoordinateOperationInfoBase;

            if (epsgOp == null)
            {
                return(true);
            }

            var catOp = epsgOp as EpsgConcatenatedCoordinateOperationInfo;

            if (catOp != null)
            {
                return(catOp.Steps.All(s => !_restrictedOperationMethodCodes.Contains(s.Method.Code)));
            }

            var epsgOpInfo = epsgOp as EpsgCoordinateOperationInfo;

            if (epsgOpInfo != null)
            {
                return(!_restrictedOperationMethodCodes.Contains(epsgOpInfo.Method.Code));
            }

            return(true);
        }
 public OgcPassThroughCoordinateOperationInfo(ICoordinateOperationInfo core, int firstAffectedOrdinate)
 {
     if (null == core) throw new ArgumentNullException("core");
     Contract.EndContractBlock();
     Core = core;
     FirstAffectedOrdinate = firstAffectedOrdinate;
 }
Example #5
0
        public ICoordinateOperationInfo ReadPassThroughFromParams()
        {
            int index = 0;
            ICoordinateOperationInfo coordinateOperationInfo = null;

            foreach (var parameter in ReadParams())
            {
                if (parameter is int)
                {
                    index = (int)parameter;
                }
                else if (parameter is double)
                {
                    index = Convert.ToInt32(parameter);
                }
                else if (null == coordinateOperationInfo && parameter is ICoordinateOperationInfo)
                {
                    coordinateOperationInfo = (ICoordinateOperationInfo)parameter;
                }
            }

            if (coordinateOperationInfo == null)
            {
                if (Options.ThrowOnError)
                {
                    throw new WktParseExceptioncs("Passthrough Transform", "No coordinate operation.");
                }
                return(null);
            }

            return(new OgcPassThroughCoordinateOperationInfo(
                       coordinateOperationInfo,
                       index
                       ));
        }
        private bool IsOpAllowed(ICoordinateOperationInfo op) {
            Contract.Requires(op != null);
            if (OpFilters == null || OpFilters.Count == 0)
                return true;

            return OpFilters.All(f => f(op));
        }
 private CoordinateOperationCrsPathInfo(ICrs[] nodes, ICoordinateOperationInfo[] edges)
 {
     Contract.Requires(nodes != null);
     Contract.Requires(edges != null);
     CrsNodesArray = nodes;
     OperationEdgesArray = edges;
     if ((OperationEdgesArray.Length + 1) != CrsNodesArray.Length)
         throw new ArgumentException("There must be exactly one more node than edge.");
 }
Example #8
0
 public CoordinateOperationInfoInverse(ICoordinateOperationInfo core)
 {
     if (null == core)
     {
         throw new ArgumentNullException("core");
     }
     Contract.EndContractBlock();
     Core = core;
 }
Example #9
0
        private static bool IsNotDeprecated(ICoordinateOperationInfo op)
        {
            var epsgInverseOp = op as EpsgCoordinateOperationInverse;
            var epsgOp        = epsgInverseOp != null
                ? epsgInverseOp.Core
                : op as EpsgCoordinateOperationInfoBase;

            return(epsgOp == null || !epsgOp.Deprecated);
        }
Example #10
0
 public EpsgCrsPathSearchNode(EpsgCrs crs, ICoordinateOperationInfo edgeFromParent, EpsgCrsPathSearchNode parent)
 {
     Contract.Requires(crs != null);
     Contract.Requires(edgeFromParent != null);
     Contract.Requires(parent != null);
     Crs            = crs;
     EdgeFromParent = edgeFromParent;
     Parent         = parent;
 }
 public PathNode Append(EpsgCrs crs, ICoordinateOperationInfo edgeFromParent) {
     Contract.Requires(edgeFromParent != null);
     Contract.Ensures(Contract.Result<PathNode>() != null);
     var newNode = new PathNode(crs) {
         Parent = this,
         EdgeFromParent = edgeFromParent
     };
     return newNode;
 }
 public CoordinateOperationCrsPathInfo(ICrs node)
 {
     if (node == null)
     {
         throw new ArgumentNullException("node");
     }
     Contract.EndContractBlock();
     CrsNodesArray       = new[] { node };
     OperationEdgesArray = new ICoordinateOperationInfo[0];
 }
 public static IEnumerable<ICoordinateOperationInfo> LinearizeOperations(ICoordinateOperationInfo operation)
 {
     Contract.Ensures(Contract.ForAll(Contract.Result<IEnumerable<ICoordinateOperationInfo>>(), x => x != null));
     if (null == operation)
         return Enumerable.Empty<ICoordinateOperationInfo>();
     var concatOperations = operation as IConcatenatedCoordinateOperationInfo;
     if (null == concatOperations)
         return new[] { operation };
     return concatOperations.Steps.SelectMany(LinearizeOperations);
 }
 public OgcPassThroughCoordinateOperationInfo(ICoordinateOperationInfo core, int firstAffectedOrdinate)
 {
     if (null == core)
     {
         throw new ArgumentNullException("core");
     }
     Contract.EndContractBlock();
     Core = core;
     FirstAffectedOrdinate = firstAffectedOrdinate;
 }
Example #15
0
 /// <summary>
 /// Constructs a new fitted CRS.
 /// </summary>
 /// <param name="name">The name.</param>
 /// <param name="toBaseOperation">The operation which converts to <paramref name="baseCrs"/>.</param>
 /// <param name="baseCrs">The base CRS.</param>
 /// <param name="authority">The authority code of the CRS.</param>
 public OgcCrsFitted(
     string name,
     ICoordinateOperationInfo toBaseOperation,
     ICrs baseCrs,
     IAuthorityTag authority = null
     )
     : base(name, authority)
 {
     if (null == toBaseOperation) throw new ArgumentNullException("toBaseOperation");
     if (null == baseCrs) throw new ArgumentNullException("baseCrs");
     Contract.Requires(name != null);
     ToBaseOperation = toBaseOperation;
     BaseCrs = baseCrs;
 }
Example #16
0
        public static IEnumerable <ICoordinateOperationInfo> LinearizeOperations(ICoordinateOperationInfo operation)
        {
            Contract.Ensures(Contract.ForAll(Contract.Result <IEnumerable <ICoordinateOperationInfo> >(), x => x != null));
            if (null == operation)
            {
                return(Enumerable.Empty <ICoordinateOperationInfo>());
            }
            var concatOperations = operation as IConcatenatedCoordinateOperationInfo;

            if (null == concatOperations)
            {
                return new[] { operation }
            }
            ;
            return(concatOperations.Steps.SelectMany(LinearizeOperations));
        }
Example #17
0
        private ICrsFitted ReadFittedCsFromParams()
        {
            var name = String.Empty;
            ICoordinateOperationInfo toBaseOperation = null;
            ICrs baseCrs = null;

            foreach (var parameter in ReadParams())
            {
                if (parameter is string)
                {
                    name = (string)parameter;
                }
                else if (parameter is ICoordinateOperationInfo)
                {
                    toBaseOperation = (ICoordinateOperationInfo)parameter;
                }
                else if (parameter is ICrs)
                {
                    baseCrs = (ICrs)parameter;
                }
            }

            if (baseCrs == null)
            {
                if (Options.ThrowOnError)
                {
                    throw new WktParseExceptioncs("Fitted CS", "No base CRS.");
                }
                return(null);
            }
            if (toBaseOperation == null)
            {
                if (Options.ThrowOnError)
                {
                    throw new WktParseExceptioncs("Fitted CS", "No to-base operation.");
                }
                return(null);
            }

            return(new OgcCrsFitted(
                       name,
                       toBaseOperation,
                       baseCrs
                       ));
        }
Example #18
0
 /// <summary>
 /// Constructs a new fitted CRS.
 /// </summary>
 /// <param name="name">The name.</param>
 /// <param name="toBaseOperation">The operation which converts to <paramref name="baseCrs"/>.</param>
 /// <param name="baseCrs">The base CRS.</param>
 /// <param name="authority">The authority code of the CRS.</param>
 public OgcCrsFitted(
     string name,
     ICoordinateOperationInfo toBaseOperation,
     ICrs baseCrs,
     IAuthorityTag authority = null
     )
     : base(name, authority)
 {
     if (null == toBaseOperation)
     {
         throw new ArgumentNullException("toBaseOperation");
     }
     if (null == baseCrs)
     {
         throw new ArgumentNullException("baseCrs");
     }
     Contract.Requires(name != null);
     ToBaseOperation = toBaseOperation;
     BaseCrs         = baseCrs;
 }
        public CoordinateOperationCrsPathInfo Append(ICrs node, ICoordinateOperationInfo edge)
        {
            if (node == null)
            {
                throw new ArgumentNullException("node");
            }
            if (edge == null)
            {
                throw new ArgumentNullException("edge");
            }
            Contract.Ensures(Contract.Result <CoordinateOperationCrsPathInfo>() != null);
            var nodes = new ICrs[CrsNodesArray.Length + 1];

            CrsNodesArray.CopyTo(nodes, 0);
            nodes[nodes.Length - 1] = node;
            var edges = new ICoordinateOperationInfo[OperationEdgesArray.Length + 1];

            OperationEdgesArray.CopyTo(edges, 0);
            edges[edges.Length - 1] = edge;
            return(new CoordinateOperationCrsPathInfo(nodes, edges));
        }
Example #20
0
            public StepCompilationParameters(
                ICoordinateOperationInfo coordinateOperationInfo,
                IUnit inputUnit,
                ICrs relatedInputCrs,
                ICrs relatedOutputCrs
                )
            {
                if (null == coordinateOperationInfo)
                {
                    throw new ArgumentNullException("coordinateOperationInfo");
                }
                if (null == inputUnit)
                {
                    throw new ArgumentNullException("inputUnit");
                }
                Contract.EndContractBlock();

                CoordinateOperationInfo = coordinateOperationInfo;
                InputUnit        = inputUnit;
                RelatedInputCrs  = relatedInputCrs;
                RelatedOutputCrs = relatedOutputCrs;
            }
        public static CoordinateOperationCrsPathInfo Join(CoordinateOperationCrsPathInfo primary, CoordinateOperationCrsPathInfo other)
        {
            if (primary == null)
            {
                throw new ArgumentNullException("primary");
            }
            if (other == null)
            {
                throw new ArgumentNullException("other");
            }
            Contract.Ensures(Contract.Result <CoordinateOperationCrsPathInfo>() != null);
            // TODO: make sure that the last node of the first list and the first node of the last list are a match
            var nodes = new ICrs[primary.CrsNodesArray.Length + other.CrsNodesArray.Length - 1];

            primary.CrsNodesArray.CopyTo(nodes, 0);
            other.CrsNodesArray.CopyTo(nodes, primary.CrsNodesArray.Length - 1);
            var edges = new ICoordinateOperationInfo[primary.OperationEdgesArray.Length + other.OperationEdgesArray.Length];

            primary.OperationEdgesArray.CopyTo(edges, 0);
            other.OperationEdgesArray.CopyTo(edges, primary.OperationEdgesArray.Length);
            return(new CoordinateOperationCrsPathInfo(nodes, edges));
        }
        private bool IsOpAllowed(ICoordinateOperationInfo op)
        {
            Contract.Requires(op != null);
            if (OpFilters == null || OpFilters.Count == 0)
                return true;

            return OpFilters.All(f => f(op));
        }
Example #23
0
        private static bool IsNotRestricted(ICoordinateOperationInfo op)
        {
            var epsgInverseOp = op as EpsgCoordinateOperationInverse;
            var epsgOp = epsgInverseOp != null
                ? epsgInverseOp.Core
                : op as EpsgCoordinateOperationInfoBase;

            if (epsgOp == null)
                return true;

            var catOp = epsgOp as EpsgConcatenatedCoordinateOperationInfo;
            if (catOp != null) {
                return catOp.Steps.All(s => !_restrictedOperationMethodCodes.Contains(s.Method.Code));
            }

            var epsgOpInfo = epsgOp as EpsgCoordinateOperationInfo;
            if(epsgOpInfo != null)
                return !_restrictedOperationMethodCodes.Contains(epsgOpInfo.Method.Code);

            return true;
        }
Example #24
0
 private static bool IsNotDeprecated(ICoordinateOperationInfo op)
 {
     var epsgInverseOp = op as EpsgCoordinateOperationInverse;
     var epsgOp = epsgInverseOp != null
         ? epsgInverseOp.Core
         : op as EpsgCoordinateOperationInfoBase;
     return epsgOp == null || !epsgOp.Deprecated;
 }
Example #25
0
 public NamedParameterLookup(ICoordinateOperationInfo operationInfo)
     : this(operationInfo as IParameterizedCoordinateOperationInfo)
 {
 }
            public StepCompilationParameters(
                ICoordinateOperationInfo coordinateOperationInfo,
                IUnit inputUnit,
                ICrs relatedInputCrs,
                ICrs relatedOutputCrs
            )
            {
                if (null == coordinateOperationInfo) throw new ArgumentNullException("coordinateOperationInfo");
                if (null == inputUnit) throw new ArgumentNullException("inputUnit");
                Contract.EndContractBlock();

                CoordinateOperationInfo = coordinateOperationInfo;
                InputUnit = inputUnit;
                RelatedInputCrs = relatedInputCrs;
                RelatedOutputCrs = relatedOutputCrs;
            }
 public CoordinateOperationInfoInverse(ICoordinateOperationInfo core)
 {
     if (null == core) throw new ArgumentNullException("core");
     Contract.EndContractBlock();
     Core = core;
 }
Example #28
0
        public void Write(ICoordinateOperationInfo entity)
        {
            if (entity == null)
            {
                throw new ArgumentNullException("entity");
            }
            Contract.EndContractBlock();

            if (entity is IPassThroughCoordinateOperationInfo)
            {
                Write(entity as IPassThroughCoordinateOperationInfo);
            }
            else if (entity is IConcatenatedCoordinateOperationInfo)
            {
                Write(entity as IConcatenatedCoordinateOperationInfo);
            }
            else
            {
                if (entity.IsInverseOfDefinition && entity.HasInverse)
                {
                    Write(WktKeyword.InverseMt);
                    WriteOpenParenthesis();
                    Indent();
                    WriteIndentedNewLineIfPretty();
                    if (entity.HasInverse)
                    {
                        Write(entity.GetInverse());
                    }
                    else
                    {
                        if (Options.ThrowOnError)
                        {
                            throw new Exception("TODO:");
                        }
                        WriteQuoted(String.Empty);
                    }
                }
                else
                {
                    Write(WktKeyword.ParamMt);
                    WriteOpenParenthesis();
                    var parameterizedOperation = entity as IParameterizedCoordinateOperationInfo;
                    if (null != parameterizedOperation)
                    {
                        var method = parameterizedOperation.Method;
                        WriteQuoted(FixName(null == method ? entity.Name : method.Name));
                        Indent();
                        Contract.Assume(parameterizedOperation.Parameters != null);
                        foreach (var parameter in parameterizedOperation.Parameters)
                        {
                            StartNextLineParameter();
                            if (parameter != null)
                            {
                                Write(parameter);
                            }
                        }
                    }
                    else
                    {
                        WriteQuoted(FixName(entity.Name));
                    }
                }

                UnIndent();
                WriteCloseParenthesis();
            }
        }
 public NamedParameterLookup(ICoordinateOperationInfo operationInfo)
     : this(operationInfo as IParameterizedCoordinateOperationInfo)
 {
 }
 public static CoordinateOperationCrsPathInfo Join(CoordinateOperationCrsPathInfo primary, CoordinateOperationCrsPathInfo other)
 {
     if (primary == null) throw new ArgumentNullException("primary");
     if (other == null) throw new ArgumentNullException("other");
     Contract.Ensures(Contract.Result<CoordinateOperationCrsPathInfo>() != null);
     // TODO: make sure that the last node of the first list and the first node of the last list are a match
     var nodes = new ICrs[primary.CrsNodesArray.Length + other.CrsNodesArray.Length - 1];
     primary.CrsNodesArray.CopyTo(nodes, 0);
     other.CrsNodesArray.CopyTo(nodes, primary.CrsNodesArray.Length - 1);
     var edges = new ICoordinateOperationInfo[primary.OperationEdgesArray.Length + other.OperationEdgesArray.Length];
     primary.OperationEdgesArray.CopyTo(edges, 0);
     other.OperationEdgesArray.CopyTo(edges, primary.OperationEdgesArray.Length);
     return new CoordinateOperationCrsPathInfo(nodes, edges);
 }
 public CoordinateOperationCrsPathInfo Append(ICrs node, ICoordinateOperationInfo edge)
 {
     if(node == null) throw new ArgumentNullException("node");
     if(edge == null) throw new ArgumentNullException("edge");
     Contract.Ensures(Contract.Result<CoordinateOperationCrsPathInfo>() != null);
     var nodes = new ICrs[CrsNodesArray.Length + 1];
     CrsNodesArray.CopyTo(nodes, 0);
     nodes[nodes.Length - 1] = node;
     var edges = new ICoordinateOperationInfo[OperationEdgesArray.Length + 1];
     OperationEdgesArray.CopyTo(edges, 0);
     edges[edges.Length - 1] = edge;
     return new CoordinateOperationCrsPathInfo(nodes, edges);
 }
 public PathNode Append(EpsgCrs crs, ICoordinateOperationInfo edgeFromParent)
 {
     Contract.Requires(edgeFromParent != null);
     Contract.Ensures(Contract.Result<PathNode>() != null);
     var newNode = new PathNode(crs) {
         Parent = this,
         EdgeFromParent = edgeFromParent
     };
     return newNode;
 }