Example #1
0
        /// <summary>
        /// Transform an array of LLH coordinates to an array of NEE points with variable from and to coordinate type inputs.
        /// </summary>
        /// <returns>Returns an array of NEE points in radians.</returns>
        public NEE[] TransformLLHToNEE(string csib, LLH[] coordinates, CoordinateTypes fromType, CoordinateTypes toType)
        {
            var neeCoordinates = new NEE[coordinates.Length];

            using var transformer = GeodeticXTransformer(csib);

            for (var i = 0; i < coordinates.Length; i++)
            {
                var llh = coordinates[i];

                transformer.Transform(
                    (geoCoordinateTypes)fromType,
                    llh.Latitude,
                    llh.Longitude,
                    llh.Height,
                    (geoCoordinateTypes)toType,
                    out var toY, out var toX, out var toZ);

                neeCoordinates[i] = new NEE
                {
                    North     = toY,
                    East      = toX,
                    Elevation = toZ
                };
            }

            return(neeCoordinates);
        }
Example #2
0
        /// <summary>
        /// Transform an array of NEE points to an array of LLH coordinates with variable from and to coordinate type inputs.
        /// </summary>
        /// <returns>Returns an array of LLH coordinates in radians.</returns>
        public LLH[] TransformNEEToLLH(string csib, NEE[] coordinates, CoordinateTypes fromType, CoordinateTypes toType)
        {
            var llhCoordinates = new LLH[coordinates.Length];

            using var transformer = GeodeticXTransformer(csib);

            for (var i = 0; i < coordinates.Length; i++)
            {
                var nee = coordinates[i];

                transformer.Transform(
                    (geoCoordinateTypes)fromType,
                    nee.North,
                    nee.East,
                    nee.Elevation,
                    (geoCoordinateTypes)toType,
                    out var toY, out var toX, out var toZ);

                // The toX and toY parameters mirror the order of the input parameters fromX and fromY; they are not grid coordinate positions.
                llhCoordinates[i] = new LLH
                {
                    Latitude  = toY,
                    Longitude = toX,
                    Height    = toZ
                };
            }

            return(llhCoordinates);
        }
        public void LoadConfiguration()
        {
            try
            {
                var filename = GetConfigFilename();

                if (string.IsNullOrWhiteSpace(filename) || !File.Exists(filename))
                {
                    return;
                }

                XmlSerializer x    = new XmlSerializer(GetType());
                TextReader    tr   = new StreamReader(filename);
                var           temp = x.Deserialize(tr) as VisibilityConfig;

                if (temp == null)
                {
                    return;
                }

                DisplayCoordinateType = temp.DisplayCoordinateType;
            }
            catch (Exception ex)
            {
                // do nothing
            }
        }
Example #4
0
        /// <summary>
        /// Transform an LLH to NEE with variable from and to coordinate type inputs.
        /// </summary>
        /// <returns>A NEE point of the LLH provided coordinates in radians.</returns>
        public NEE TransformLLHToNEE(string csib, LLH coordinates, CoordinateTypes fromType, CoordinateTypes toType)
        {
            using var transformer = GeodeticXTransformer(csib);

            transformer.Transform(
                (geoCoordinateTypes)fromType,
                coordinates.Latitude,
                coordinates.Longitude,
                coordinates.Height,
                (geoCoordinateTypes)toType,
                out var toY, out var toX, out var toZ);

            return(new NEE
            {
                North = toY,
                East = toX,
                Elevation = toZ
            });
        }
Example #5
0
        /// <summary>
        /// Transform an NEE to LLH with variable from and to coordinate type inputs.
        /// </summary>
        /// <returns>Returns LLH object in radians.</returns>
        public LLH TransformNEEToLLH(string csib, NEE nee, CoordinateTypes fromType, CoordinateTypes toType)
        {
            using var transformer = GeodeticXTransformer(csib);

            transformer.Transform(
                (geoCoordinateTypes)fromType,
                nee.North,
                nee.East,
                nee.Elevation,
                (geoCoordinateTypes)toType,
                out var toY, out var toX, out var toZ);

            // The toX and toY parameters mirror the order of the input parameters fromX and fromY; they are not grid coordinate positions.
            return(new LLH
            {
                Latitude = toY,
                Longitude = toX,
                Height = toZ
            });
        }
        public void LoadConfiguration()
        {
            try
            {
                var filename = GetConfigFilename();

                if (string.IsNullOrWhiteSpace(filename) || !File.Exists(filename))
                    return;

                XmlSerializer x = new XmlSerializer(GetType());
                TextReader tr = new StreamReader(filename);
                var temp = x.Deserialize(tr) as DistanceAndDirectionConfig;

                if (temp == null)
                    return;

                DisplayCoordinateType = temp.DisplayCoordinateType;
            }
            catch(Exception ex)
            {
                // do nothing
            }
        }
Example #7
0
        public void LoadConfiguration()
        {
            TextReader tr = null;

            try
            {
                var filename = GetConfigFilename();

                if (string.IsNullOrWhiteSpace(filename) || !File.Exists(filename))
                {
                    return;
                }

                XmlSerializer x = new XmlSerializer(GetType());
                tr = new StreamReader(filename);
                var temp = x.Deserialize(tr) as DistanceAndDirectionConfig;

                if (temp == null)
                {
                    return;
                }

                DisplayCoordinateType = temp.DisplayCoordinateType;
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.Message);
            }
            finally
            {
                if (tr != null)
                {
                    tr.Close();
                }
            }
        }
Example #8
0
        /// <summary>
        /// Without changing the feature type or anything else, simply update the local coordinates
        /// to include the new coordinates.  All the new coordinates will be considered one part.
        /// Since point and multi-point shapes don't have parts, they will just be appended to the
        /// original part.
        /// </summary>
        public void AddPart(IEnumerable<Coordinate> coordinates, CoordinateTypes coordType)
        {
            bool hasM = (coordType == CoordinateTypes.M || coordType == CoordinateTypes.Z);
            bool hasZ = (coordType == CoordinateTypes.Z);
            List<double> vertices = new List<double>();
            List<double> z = new List<double>();
            List<double> m = new List<double>();
            int numPoints = 0;
            int oldNumPoints = (_vertices != null) ? _vertices.Length/2: 0;
            foreach (Coordinate coordinate in coordinates)
            {
                if(_shapeRange.Extent == null)_shapeRange.Extent = new Extent();
                _shapeRange.Extent.ExpandToInclude(coordinate.X, coordinate.Y);
                vertices.Add(coordinate.X);
                vertices.Add(coordinate.Y);
                if(hasM)m.Add(coordinate.M);
                if(hasZ)z.Add(coordinate.Z);
                numPoints++;
            }
            // Using public accessor also updates individual part references
            Vertices = (_vertices != null) ? _vertices.Concat(vertices).ToArray() : vertices.ToArray();
            if(hasZ) _z = (_z != null) ? _z.Concat(z).ToArray() : z.ToArray();
            if(hasM) _m = (_m != null) ? _m.Concat(m).ToArray() : m.ToArray();

            if(_shapeRange.FeatureType == FeatureTypes.MultiPoint || _shapeRange.FeatureType == FeatureTypes.Point)
            {
                // Only one part exists
                _shapeRange.Parts[0].NumVertices += numPoints;
            }
            else
            {
                PartRange part = new PartRange(_vertices, _shapeRange.StartIndex, oldNumPoints, _shapeRange.FeatureType );
                part.NumVertices = numPoints;
                _shapeRange.Parts.Add(part);

            }    
        }