Esempio n. 1
0
        public PolygonShape(
            int recordNumber,
            StringDictionary metadata,
            CartographicExtent extent,
            int[] parts,
            Rectangular[] positions,
            ShapeType shapeType = ShapeType.Polygon)
            : base(recordNumber, metadata, shapeType)
        {
            _extent = new CartographicExtent(
                extent.WestLongitude * Constants.RadiansPerDegree,
                extent.SouthLatitude * Constants.RadiansPerDegree,
                extent.EastLongitude * Constants.RadiansPerDegree,
                extent.NorthLatitude * Constants.RadiansPerDegree);

            for (int i = 0; i < positions.Length; i++)
            {
                positions[i] = new Rectangular(positions[i].X * Constants.RadiansPerDegree, positions[i].Y * Constants.RadiansPerDegree);
            }

            _parts = new List <ShapePart>(parts.Length);
            for (int i = 0; i < parts.Length; ++i)
            {
                int count = ((i == parts.Length - 1) ?
                             positions.Length : parts[i + 1]) - parts[i];

                _parts.Add(new ShapePart(positions, parts[i], count));
            }
        }
Esempio n. 2
0
        public void TestPolygonZValues()
        {
            Rectangular[] positions = new[]
            {
                new Rectangular(0.0, 5.0),
                new Rectangular(5.0, 10.0),
                new Rectangular(10.0, 5.0),
                new Rectangular(5.0, 0.0),
                new Rectangular(0.0, 5.0),
                new Rectangular(2.0, 5.0),
                new Rectangular(5.0, 2.0),
                new Rectangular(8.0, 5.0),
                new Rectangular(5.0, 8.0),
                new Rectangular(2.0, 5.0)
            };

            double[] zValues = new[]
            {
                1.0, 2.0, 3.0, 4.0, 1.0,
                5.0, 6.0, 7.0, 8.0, 5.0
            };

            CartographicExtent extent = new CartographicExtent(0.0, 0.0, 10.0, 10.0);

            int[]    parts    = new[] { 0, 5 };
            double[] measures = new[] { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 };

            PolygonZShape polygonZShape = new PolygonZShape(0, m_metadata, extent, parts, positions, 1.0, 8.0, zValues, 0.0, 0.0, measures);
            Polygon       polygon       = new Polygon(polygonZShape, m_document, Color.Blue);

            polygon.Write();
            string result = m_stringWriter.ToString();

            Assert.IsTrue(Regex.IsMatch(result, m_polygonPattern));
        }
        public void TestEqualsEpsilonExact()
        {
            CartographicExtent first  = new CartographicExtent(0.1, 0.1, 0.1, 0.1);
            CartographicExtent second = new CartographicExtent(0.1, 0.1, 0.1, 0.1);

            Assert.IsTrue(second.EqualsEpsilon(first, 0));
        }
Esempio n. 4
0
        public void TestMultipatchConversionWithMultipleRings()
        {
            Rectangular[] positions = new[]
            {
                new Rectangular(0.0, 5.0),
                new Rectangular(5.0, 10.0),
                new Rectangular(10.0, 5.0),
                new Rectangular(5.0, 0.0),
                new Rectangular(0.0, 5.0),
                new Rectangular(2.0, 5.0),
                new Rectangular(5.0, 2.0),
                new Rectangular(8.0, 5.0),
                new Rectangular(5.0, 8.0),
                new Rectangular(2.0, 5.0)
            };

            CartographicExtent extent = new CartographicExtent(0.0, 0.0, 10.0, 10.0);

            int[] parts = new[] { 0, 5 };
            MultiPatchPartType[] partTypes = new[] { MultiPatchPartType.Ring, MultiPatchPartType.Ring };

            double[] zValues  = new[] { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 };
            double[] measures = new[] { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 };

            MultiPatchShape multipatch = new MultiPatchShape(0, m_metadata, extent, parts, partTypes, positions, 0.0, 0.0, zValues, 0.0, 0.0, measures);
            MultiPatch      patch      = new MultiPatch(multipatch, m_document, Color.Blue);

            patch.Write();
            string result         = m_stringWriter.ToString();
            Regex  polygonPattern = new Regex(m_polygonPattern);

            Assert.AreEqual(2, polygonPattern.Matches(result).Count);
        }
Esempio n. 5
0
        public void TestMultipatchConversionWithInnerAndOuterRings()
        {
            Rectangular[] positions = new[]
            {
                new Rectangular(0.0, 5.0),
                new Rectangular(5.0, 10.0),
                new Rectangular(10.0, 5.0),
                new Rectangular(5.0, 0.0),
                new Rectangular(0.0, 5.0),
                new Rectangular(2.0, 5.0),
                new Rectangular(5.0, 2.0),
                new Rectangular(8.0, 5.0),
                new Rectangular(5.0, 8.0),
                new Rectangular(2.0, 5.0)
            };

            CartographicExtent extent = new CartographicExtent(0.0, 0.0, 10.0, 10.0);

            int[] parts = new[] { 0, 5 };
            MultiPatchPartType[] partTypes = new[] { MultiPatchPartType.OuterRing, MultiPatchPartType.InnerRing };

            double[] zValues  = new[] { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 };
            double[] measures = new[] { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 };

            MultiPatchShape multipatch = new MultiPatchShape(0, m_metadata, extent, parts, partTypes, positions, 0.0, 0.0, zValues, 0.0, 0.0, measures);
            MultiPatch      patch      = new MultiPatch(multipatch, m_document, Color.Blue);

            patch.Write();
            string result = m_stringWriter.ToString();

            Assert.IsTrue(Regex.IsMatch(result, m_polygonPattern));
        }
Esempio n. 6
0
        public PolygonZShape(
            int recordNumber,
            StringDictionary metadata,
            CartographicExtent extent,
            int[] parts,
            Rectangular[] positions,
            double minimumZ,
            double maximumZ,
            double[] zValues,
            double minimumMeasure,
            double maximumMeasure,
            double[] measures,
            ShapeType shapeType = ShapeType.PolygonZ
            )
            : base(recordNumber, metadata, extent, parts, positions, minimumMeasure, maximumMeasure, measures, shapeType)
        {
            _minimumZ = minimumZ;
            _maximumZ = maximumZ;

            for (int i = 0; i < parts.Length; ++i)
            {
                int count = ((i == parts.Length - 1) ?
                    positions.Length : parts[i + 1]) - parts[i];

                _parts[i] = new ShapePart(positions, zValues, measures, parts[i], count);
            }
        }
Esempio n. 7
0
        public void TestMultipatchConversionWithTriangleStrip()
        {
            Rectangular[] positions = new[]
            {
                new Rectangular(0.0, 0.0),
                new Rectangular(0.0, 1.0),
                new Rectangular(1.0, 0.0),
                new Rectangular(1.0, 1.0),
                new Rectangular(2.0, 0.0),
                new Rectangular(2.0, 1.0),
                new Rectangular(3.0, 0.0)
            };

            CartographicExtent extent = new CartographicExtent(0.0, 0.0, 3.0, 1.0);

            int[] parts = new[] { 0 };
            MultiPatchPartType[] partTypes = new[] { MultiPatchPartType.TriangleStrip };

            double[] zValues  = new[] { 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0 };
            double[] measures = new[] { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 };

            MultiPatchShape multipatch = new MultiPatchShape(0, m_metadata, extent, parts, partTypes, positions, 0.0, 0.0, zValues, 0.0, 0.0, measures);
            MultiPatch      patch      = new MultiPatch(multipatch, m_document, Color.Blue);

            patch.Write();
            string result          = m_stringWriter.ToString();
            Regex  trianglePattern = new Regex(m_trianglePattern);

            Assert.AreEqual(5, trianglePattern.Matches(result).Count);
        }
Esempio n. 8
0
        public PolylineZShape(
            int recordNumber,
            StringDictionary metadata,
            CartographicExtent extent,
            int[] parts,
            Rectangular[] positions,
            double minimumZ,
            double maximumZ,
            double[] zValues,
            double minimumMeasure,
            double maximumMeasure,
            double[] measures,
            ShapeType shapeType = ShapeType.PolylineZ
            )
            : base(recordNumber, metadata, extent, parts, positions, minimumMeasure, maximumMeasure, measures, shapeType)
        {
            _minimumZ = minimumZ;
            _maximumZ = maximumZ;

            for (int i = 0; i < parts.Length; ++i)
            {
                int count = ((i == parts.Length - 1) ?
                             positions.Length : parts[i + 1]) - parts[i];

                _parts[i] = new ShapePart(positions, zValues, measures, parts[i], count);
            }
        }
        public void TestExtentClass()
        {
            CartographicExtent box = new CartographicExtent(-2, -1, 1, 2);

            Assert.AreEqual(-2, box.WestLongitude);
            Assert.AreEqual(-1, box.SouthLatitude);
            Assert.AreEqual(1, box.EastLongitude);
            Assert.AreEqual(2, box.NorthLatitude);
            Assert.IsTrue(box.IsInsideExtent(0.5, 0.5));
            Assert.IsFalse(box.IsInsideExtent(0.5, 3));
            Assert.IsFalse(box.IsInsideExtent(0.3, -3));
            Assert.IsFalse(box.IsInsideExtent(-3, 0.5));
            Assert.IsFalse(box.IsInsideExtent(3, 0.5));

            CartographicExtent anotherBox = new CartographicExtent(0, 0, 1, 1);
            CartographicExtent firstCombo = box.Union(anotherBox);

            Assert.AreEqual(-2, firstCombo.WestLongitude);
            Assert.AreEqual(-1, firstCombo.SouthLatitude);
            Assert.AreEqual(1, firstCombo.EastLongitude);
            Assert.AreEqual(2, firstCombo.NorthLatitude);

            CartographicExtent yetAnotherBox = new CartographicExtent(-2, -2, 1, 1);
            CartographicExtent secondCombo   = box.Union(yetAnotherBox);

            Assert.AreEqual(-2, secondCombo.WestLongitude);
            Assert.AreEqual(-2, secondCombo.SouthLatitude);
            Assert.AreEqual(1, secondCombo.EastLongitude);
            Assert.AreEqual(2, secondCombo.NorthLatitude);
        }
Esempio n. 10
0
        /// <summary>
        /// Writes time-tagged <see cref="CartographicExtent"/> values as an array in [Time, WestLongitude, SouthLatitude, EastLongitude, NorthLatitude] order.
        /// Times are epoch seconds since an epoch that is determined from the first date to be written.
        /// The epoch property is written as well.
        /// </summary>
        /// <param name="output">The stream to which to write the array.</param>
        /// <param name="propertyName">The name of the property to write.</param>
        /// <param name="dates">The dates at which the value is specified.</param>
        /// <param name="values">The corresponding value for each date.</param>
        /// <param name="startIndex">The index of the first element to use in the <paramref name="values"/> collection.</param>
        /// <param name="length">The number of elements to use from the <paramref name="values"/> collection.</param>
        public static void WriteCartographicExtent(CesiumOutputStream output, string propertyName, IList <JulianDate> dates, IList <CartographicExtent> values, int startIndex, int length)
        {
            if (dates.Count != values.Count)
            {
                throw new ArgumentException(CesiumLocalization.MismatchedNumberOfDatesAndValues, "values");
            }

            JulianDate epoch = GetAndWriteEpoch(output, dates, startIndex, length);

            output.WritePropertyName(propertyName);
            output.WriteStartSequence();
            int last = startIndex + length;

            for (int i = startIndex; i < last; ++i)
            {
                output.WriteValue(epoch.SecondsDifference(dates[i]));
                CartographicExtent value = values[i];
                output.WriteValue(value.WestLongitude);
                output.WriteValue(value.SouthLatitude);
                output.WriteValue(value.EastLongitude);
                output.WriteValue(value.NorthLatitude);
                output.WriteLineBreak();
            }

            output.WriteEndSequence();
        }
Esempio n. 11
0
 /// <summary>
 /// Writes a <see cref="CartographicExtent"/> value as an array in WestLongitude, SouthLatitude, EastLongitude, NorthLatitude order.
 /// </summary>
 /// <param name="output">The stream to which to write the value.</param>
 /// <param name="value">The value to write.</param>
 public static void WriteCartographicExtent(CesiumOutputStream output, CartographicExtent value)
 {
     output.WriteStartSequence();
     output.WriteValue(value.WestLongitude);
     output.WriteValue(value.SouthLatitude);
     output.WriteValue(value.EastLongitude);
     output.WriteValue(value.NorthLatitude);
     output.WriteEndSequence();
 }
Esempio n. 12
0
 public void SetUp()
 {
     m_metadata = new StringDictionary();
     m_positions = new Rectangular[] {
         new Rectangular(0.0, 0.0),
         new Rectangular(1.0, 1.0)
     };
     m_extent = new CartographicExtent(0.0, 0.0, 1.0, 1.0);
     m_parts = new int[] { 0 };
 }
Esempio n. 13
0
 public void SetUp()
 {
     m_metadata  = new StringDictionary();
     m_positions = new Rectangular[] {
         new Rectangular(0.0, 0.0),
         new Rectangular(1.0, 1.0)
     };
     m_extent = new CartographicExtent(0.0, 0.0, 1.0, 1.0);
     m_parts  = new int[] { 0 };
 }
Esempio n. 14
0
 public void SetUp()
 {
     m_recordNumber = 1;
     m_metadata     = new StringDictionary();
     m_extent       = new CartographicExtent(0.0, 0.0, 1.0, 1.0);
     m_positions    = new Cartographic[] {
         new Cartographic(0.0, 0.0, 0.0),
         new Cartographic(1.0, 1.0, 1.0),
     };
 }
Esempio n. 15
0
 public void SetUp()
 {
     m_recordNumber = 1;
     m_metadata = new StringDictionary();
     m_extent = new CartographicExtent(0.0, 0.0, 1.0, 1.0);
     m_positions = new Cartographic[] {
         new Cartographic(0.0, 0.0, 0.0),
         new Cartographic(1.0, 1.0, 1.0),
     };
 }
Esempio n. 16
0
 public PolygonShape(
     int recordNumber,
     StringDictionary metadata,
     CartographicExtent extent,
     ShapePart[] parts,
     ShapeType shapeType = ShapeType.Polygon)
     : base(recordNumber, metadata, shapeType)
 {
     _extent = extent;
     _parts  = new List <ShapePart>(parts);
 }
        public void TestEqualsEpsilon()
        {
            CartographicExtent first  = new CartographicExtent(1e-1, 1e-2, 1e-3, 1e-4);
            CartographicExtent second = new CartographicExtent(1.1e-1, 1.1e-2, 1.1e-3, 1.1e-4);

            Assert.IsTrue(second.EqualsEpsilon(first, 1e-1));
            Assert.IsTrue(second.EqualsEpsilon(first, 1e-2));
            Assert.IsFalse(second.EqualsEpsilon(first, 1e-3));
            Assert.IsFalse(second.EqualsEpsilon(first, 1e-4));
            Assert.IsFalse(second.EqualsEpsilon(first, 1e-5));
        }
Esempio n. 18
0
 public MultiPointMShape(
     int recordNumber,
     StringDictionary metadata,
     CartographicExtent extent,
     Cartographic[] positions,
     double minimumMeasure,
     double maximumMeasure,
     double[] measures,
     ShapeType shapeType = ShapeType.MultiPointM)
     : base(recordNumber, metadata, extent, positions, shapeType)
 {
     _minimumMeasure = minimumMeasure;
     _maximumMeasure = maximumMeasure;
     _measures = (double[])measures.Clone();
 }
Esempio n. 19
0
 public MultiPointMShape(
     int recordNumber,
     StringDictionary metadata,
     CartographicExtent extent,
     Cartographic[] positions,
     double minimumMeasure,
     double maximumMeasure,
     double[] measures,
     ShapeType shapeType = ShapeType.MultiPointM)
     : base(recordNumber, metadata, extent, positions, shapeType)
 {
     _minimumMeasure = minimumMeasure;
     _maximumMeasure = maximumMeasure;
     _measures       = (double[])measures.Clone();
 }
Esempio n. 20
0
 public MultiPointZShape(
     int recordNumber,
     StringDictionary metadata,
     CartographicExtent extent,
     Cartographic[] positions,
     double minimumZ,
     double maximumZ,
     double minimumMeasure,
     double maximumMeasure,
     double[] measures,
     ShapeType shapeType = ShapeType.MultiPointZ)
     : base(recordNumber, metadata, extent, positions, minimumMeasure, maximumMeasure, measures, shapeType)
 {
     _minimumZ = minimumZ;
     _maximumZ = maximumZ;
 }
Esempio n. 21
0
 public MultiPointZShape(
     int recordNumber,
     StringDictionary metadata,
     CartographicExtent extent,
     Cartographic[] positions,
     double minimumZ,
     double maximumZ,
     double minimumMeasure,
     double maximumMeasure,
     double[] measures,
     ShapeType shapeType = ShapeType.MultiPointZ)
     : base(recordNumber, metadata, extent, positions, minimumMeasure, maximumMeasure, measures, shapeType)
 {
     _minimumZ = minimumZ;
     _maximumZ = maximumZ;
 }
        public void TestMultiPoint()
        {
            Cartographic[] points = new Cartographic[] {
                new Cartographic(0.0, 0.0, 0.0),
                new Cartographic(1.0, 1.0, 1.0),
                new Cartographic(2.0, 2.0, 2.0)
            };
            CartographicExtent extent     = new CartographicExtent(0.0, 0.0, 2.0, 2.0);
            MultiPointShape    multipoint = new MultiPointShape(0, m_metadata, extent, points);
            MultiPoint         mp         = new MultiPoint(multipoint, m_document, Color.Blue);

            mp.Write();
            string result       = m_stringWriter.ToString();
            Regex  pointPattern = new Regex(m_pointPattern);

            Assert.AreEqual(3, pointPattern.Matches(result).Count);
        }
        public void JoinsPolygonWithMultipleHoles()
        {
            Rectangular[] positions = new Rectangular[] {
                new Rectangular(-122.0, 37.0),
                new Rectangular(-121.9, 37.0),
                new Rectangular(-121.9, 37.1),
                new Rectangular(-122.0, 37.1),
                new Rectangular(-122.0, 37.0),

                new Rectangular(-121.99, 37.01),
                new Rectangular(-121.99, 37.04),
                new Rectangular(-121.96, 37.04),
                new Rectangular(-121.96, 37.01),
                new Rectangular(-121.99, 37.01),

                new Rectangular(-121.94, 37.06),
                new Rectangular(-121.94, 37.09),
                new Rectangular(-121.91, 37.09),
                new Rectangular(-121.91, 37.06),
                new Rectangular(-121.94, 37.06),

                new Rectangular(-121.99, 37.06),
                new Rectangular(-121.99, 37.09),
                new Rectangular(-121.96, 37.09),
                new Rectangular(-121.96, 37.06),
                new Rectangular(-121.99, 37.06),

                new Rectangular(-121.94, 37.01),
                new Rectangular(-121.94, 37.04),
                new Rectangular(-121.91, 37.04),
                new Rectangular(-121.91, 37.01),
                new Rectangular(-121.94, 37.01)
            };
            CartographicExtent extent = new CartographicExtent(0.0, 0.0, 10.0, 10.0);

            int[] parts = new int[] { 0, 5, 10, 15, 20 };

            Polygon polygon = new Polygon(new PolygonShape(0, m_metadata, extent, parts, positions), m_document, Color.Blue);

            polygon.Write();
            string result         = m_stringWriter.ToString();
            Regex  polygonPattern = new Regex(m_polygonPattern);

            Assert.AreEqual(1, polygonPattern.Matches(result).Count);
        }
Esempio n. 24
0
        public MultiPatchShape(
            int recordNumber,
            StringDictionary metadata,
            CartographicExtent extent,
            int[] parts,
            MultiPatchPartType[] partTypes,
            Rectangular[] positions,
            double minimumZ,
            double maximumZ,
            double[] zValues,
            double minimumMeasure,
            double maximumMeasure,
            double[] measures,
            ShapeType shapeType = ShapeType.MultiPatch)
            : base(recordNumber, metadata, shapeType)
        {
            _extent = new CartographicExtent(
               extent.WestLongitude * Constants.RadiansPerDegree,
               extent.SouthLatitude * Constants.RadiansPerDegree,
               extent.EastLongitude * Constants.RadiansPerDegree,
               extent.NorthLatitude * Constants.RadiansPerDegree);

            _minimumZ = minimumZ;
            _maximumZ = maximumZ;
            _minimumMeasure = minimumMeasure;
            _maximumMeasure = maximumMeasure;
            _measures = (double[])measures.Clone();

            for (int i = 0; i < positions.Length; i++)
            {
                positions[i] = new Rectangular(positions[i].X * Constants.RadiansPerDegree, positions[i].Y * Constants.RadiansPerDegree);
            }

            _parts = new ShapePart[parts.Length];
            for (int i = 0; i < parts.Length; ++i)
            {
                int count = ((i == parts.Length - 1) ?
                    positions.Length : parts[i + 1]) - parts[i];

                _parts[i] = new ShapePart(positions, zValues, parts[i], count);
            }

            _partTypes = (MultiPatchPartType[])partTypes.Clone();
        }
Esempio n. 25
0
        public MultiPatchShape(
            int recordNumber,
            StringDictionary metadata,
            CartographicExtent extent,
            int[] parts,
            MultiPatchPartType[] partTypes,
            Rectangular[] positions,
            double minimumZ,
            double maximumZ,
            double[] zValues,
            double minimumMeasure,
            double maximumMeasure,
            double[] measures,
            ShapeType shapeType = ShapeType.MultiPatch)
            : base(recordNumber, metadata, shapeType)
        {
            _extent = new CartographicExtent(
                extent.WestLongitude * Constants.RadiansPerDegree,
                extent.SouthLatitude * Constants.RadiansPerDegree,
                extent.EastLongitude * Constants.RadiansPerDegree,
                extent.NorthLatitude * Constants.RadiansPerDegree);

            _minimumZ       = minimumZ;
            _maximumZ       = maximumZ;
            _minimumMeasure = minimumMeasure;
            _maximumMeasure = maximumMeasure;
            _measures       = (double[])measures.Clone();

            for (int i = 0; i < positions.Length; i++)
            {
                positions[i] = new Rectangular(positions[i].X * Constants.RadiansPerDegree, positions[i].Y * Constants.RadiansPerDegree);
            }

            _parts = new ShapePart[parts.Length];
            for (int i = 0; i < parts.Length; ++i)
            {
                int count = ((i == parts.Length - 1) ?
                             positions.Length : parts[i + 1]) - parts[i];

                _parts[i] = new ShapePart(positions, zValues, parts[i], count);
            }

            _partTypes = (MultiPatchPartType[])partTypes.Clone();
        }
        public void TestPolylineZValues()
        {
            Rectangular[] positions = new Rectangular[] {
                new Rectangular(0.0, 0.0),
                new Rectangular(1.0, 1.0),
                new Rectangular(2.0, 2.0),
                new Rectangular(3.0, 3.0),
            };

            double[] zValues = new double[] { 0.0, 1.0, 2.0, 3.0 };
            CartographicExtent extent = new CartographicExtent(0.0, 0.0, 3.0, 3.0);
            int[] parts = new int[] { 0 };
            double[] measures = new double[] { 0.0, 0.0, 0.0, 0.0 };

            PolylineZShape polylineZShape = new PolylineZShape(0, new StringDictionary(), extent, parts, positions, 1.0, 8.0, zValues, 0.0, 0.0, measures);
            Polyline polyline = new Polyline(polylineZShape, m_document, Color.Blue);
            polyline.Write();
            string result = m_stringWriter.ToString();
            Assert.IsTrue(System.Text.RegularExpressions.Regex.IsMatch(result, m_polylinePattern));
        }
        public void JoinsPolygonWithMultipleOuterRings()
        {
            Rectangular[] positions = new Rectangular[] {
                new Rectangular(0.0, 5.0),
                new Rectangular(5.0, 10.0),
                new Rectangular(10.0, 5.0),
                new Rectangular(5.0, 0.0),
                new Rectangular(0.0, 5.0),

                new Rectangular(2.0, 5.0),
                new Rectangular(5.0, 2.0),
                new Rectangular(8.0, 5.0),
                new Rectangular(5.0, 8.0),
                new Rectangular(2.0, 5.0),

                new Rectangular(20.0, 5.0),
                new Rectangular(25.0, 10.0),
                new Rectangular(30.0, 5.0),
                new Rectangular(25.0, 0.0),
                new Rectangular(20.0, 5.0),

                new Rectangular(22.0, 5.0),
                new Rectangular(25.0, 2.0),
                new Rectangular(28.0, 5.0),
                new Rectangular(25.0, 8.0),
                new Rectangular(22.0, 5.0)
            };
            CartographicExtent extent = new CartographicExtent(0.0, 0.0, 30.0, 10.0);

            int[] parts = new int[] { 0, 5, 10, 15 };

            Polygon polygon = new Polygon(new PolygonShape(0, m_metadata, extent, parts, positions), m_document, Color.Blue);

            polygon.Write();
            string result         = m_stringWriter.ToString();
            Regex  polygonPattern = new Regex(m_polygonPattern);

            Assert.AreEqual(2, polygonPattern.Matches(result).Count);
        }
        public void TestPolylineZValues()
        {
            Rectangular[] positions = new Rectangular[] {
                new Rectangular(0.0, 0.0),
                new Rectangular(1.0, 1.0),
                new Rectangular(2.0, 2.0),
                new Rectangular(3.0, 3.0),
            };

            double[]           zValues = new double[] { 0.0, 1.0, 2.0, 3.0 };
            CartographicExtent extent  = new CartographicExtent(0.0, 0.0, 3.0, 3.0);

            int[]    parts    = new int[] { 0 };
            double[] measures = new double[] { 0.0, 0.0, 0.0, 0.0 };

            PolylineZShape polylineZShape = new PolylineZShape(0, new StringDictionary(), extent, parts, positions, 1.0, 8.0, zValues, 0.0, 0.0, measures);
            Polyline       polyline       = new Polyline(polylineZShape, m_document, Color.Blue);

            polyline.Write();
            string result = m_stringWriter.ToString();

            Assert.IsTrue(System.Text.RegularExpressions.Regex.IsMatch(result, m_polylinePattern));
        }
Esempio n. 29
0
        public MultiPointShape(
            int recordNumber,
            StringDictionary metadata,
            CartographicExtent extent,
            Cartographic[] positions,
            ShapeType shapeType = ShapeType.MultiPoint)
            : base(recordNumber, metadata, shapeType)
        {
            _extent = new CartographicExtent(
                extent.WestLongitude * Constants.RadiansPerDegree,
                extent.SouthLatitude * Constants.RadiansPerDegree,
                extent.EastLongitude * Constants.RadiansPerDegree,
                extent.NorthLatitude * Constants.RadiansPerDegree);

            _positions = new Cartographic[positions.Length];
            for (int i = 0; i < positions.Length; i++)
            {
                _positions[i] = new Cartographic(
                    positions[i].Longitude * Constants.RadiansPerDegree,
                    positions[i].Latitude * Constants.RadiansPerDegree,
                    positions[i].Height);
            }
        }
Esempio n. 30
0
        public MultiPointShape(
            int recordNumber,
            StringDictionary metadata,
            CartographicExtent extent,
            Cartographic[] positions,
            ShapeType shapeType = ShapeType.MultiPoint)
            : base(recordNumber, metadata, shapeType)
        {
            _extent = new CartographicExtent(
                extent.WestLongitude * Constants.RadiansPerDegree,
                extent.SouthLatitude * Constants.RadiansPerDegree,
                extent.EastLongitude * Constants.RadiansPerDegree,
                extent.NorthLatitude * Constants.RadiansPerDegree);

            _positions = new Cartographic[positions.Length];
            for (int i = 0; i < positions.Length; i++)
            {
                _positions[i] = new Cartographic(
                    positions[i].Longitude * Constants.RadiansPerDegree,
                    positions[i].Latitude * Constants.RadiansPerDegree,
                    positions[i].Height);
            }
        }
        public void TestMultipatchConversionWithMultipleRings()
        {
            Rectangular[] positions = new[]
                                          {
                                              new Rectangular(0.0, 5.0),
                                              new Rectangular(5.0, 10.0),
                                              new Rectangular(10.0, 5.0),
                                              new Rectangular(5.0, 0.0),
                                              new Rectangular(0.0, 5.0),
                                              new Rectangular(2.0, 5.0),
                                              new Rectangular(5.0, 2.0),
                                              new Rectangular(8.0, 5.0),
                                              new Rectangular(5.0, 8.0),
                                              new Rectangular(2.0, 5.0)
                                          };

            CartographicExtent extent = new CartographicExtent(0.0, 0.0, 10.0, 10.0);
            int[] parts = new[] { 0, 5 };
            MultiPatchPartType[] partTypes = new[] { MultiPatchPartType.Ring, MultiPatchPartType.Ring };

            double[] zValues = new[] { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 };
            double[] measures = new[] { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 };

            MultiPatchShape multipatch = new MultiPatchShape(0, m_metadata, extent, parts, partTypes, positions, 0.0, 0.0, zValues, 0.0, 0.0, measures);
            MultiPatch patch = new MultiPatch(multipatch, m_document, Color.Blue);
            patch.Write();
            string result = m_stringWriter.ToString();
            Regex polygonPattern = new Regex(m_polygonPattern);
            Assert.AreEqual(2, polygonPattern.Matches(result).Count);
        }
        public void TestToString()
        {
            var extent = new CartographicExtent(-2, -1, 1, 2);

            Assert.AreEqual("-2, -1, 1, 2", extent.ToString());
        }
        public void TestMultipatchConversionWithInnerAndOuterRings()
        {
            Rectangular[] positions = new[]
                                          {
                                              new Rectangular(0.0, 5.0),
                                              new Rectangular(5.0, 10.0),
                                              new Rectangular(10.0, 5.0),
                                              new Rectangular(5.0, 0.0),
                                              new Rectangular(0.0, 5.0),
                                              new Rectangular(2.0, 5.0),
                                              new Rectangular(5.0, 2.0),
                                              new Rectangular(8.0, 5.0),
                                              new Rectangular(5.0, 8.0),
                                              new Rectangular(2.0, 5.0)
                                          };

            CartographicExtent extent = new CartographicExtent(0.0, 0.0, 10.0, 10.0);
            int[] parts = new[] { 0, 5 };
            MultiPatchPartType[] partTypes = new[] { MultiPatchPartType.OuterRing, MultiPatchPartType.InnerRing };

            double[] zValues = new[] { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 };
            double[] measures = new[] { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 };

            MultiPatchShape multipatch = new MultiPatchShape(0, m_metadata, extent, parts, partTypes, positions, 0.0, 0.0, zValues, 0.0, 0.0, measures);
            MultiPatch patch = new MultiPatch(multipatch, m_document, Color.Blue);
            patch.Write();
            string result = m_stringWriter.ToString();
            Assert.IsTrue(Regex.IsMatch(result, m_polygonPattern));
        }
 /// <summary>
 /// Writes a <see cref="CartographicExtent"/> value as an array in WestLongitude, SouthLatitude, EastLongitude, NorthLatitude order.
 /// </summary>
 /// <param name="output">The stream to which to write the value.</param>
 /// <param name="value">The value to write.</param>
 public static void WriteCartographicExtent(CesiumOutputStream output, CartographicExtent value)
 {
     output.WriteStartSequence();
     output.WriteValue(value.WestLongitude);
     output.WriteValue(value.SouthLatitude);
     output.WriteValue(value.EastLongitude);
     output.WriteValue(value.NorthLatitude);
     output.WriteEndSequence();
 }
        public void JoinsPolygonWithMultipleOuterRings()
        {
            Rectangular[] positions = new[]
                                          {
                                              new Rectangular(0.0, 5.0),
                                              new Rectangular(5.0, 10.0),
                                              new Rectangular(10.0, 5.0),
                                              new Rectangular(5.0, 0.0),
                                              new Rectangular(0.0, 5.0),
                                              new Rectangular(2.0, 5.0),
                                              new Rectangular(5.0, 2.0),
                                              new Rectangular(8.0, 5.0),
                                              new Rectangular(5.0, 8.0),
                                              new Rectangular(2.0, 5.0),
                                              new Rectangular(20.0, 5.0),
                                              new Rectangular(25.0, 10.0),
                                              new Rectangular(30.0, 5.0),
                                              new Rectangular(25.0, 0.0),
                                              new Rectangular(20.0, 5.0),
                                              new Rectangular(22.0, 5.0),
                                              new Rectangular(25.0, 2.0),
                                              new Rectangular(28.0, 5.0),
                                              new Rectangular(25.0, 8.0),
                                              new Rectangular(22.0, 5.0)
                                          };
            CartographicExtent extent = new CartographicExtent(0.0, 0.0, 30.0, 10.0);
            int[] parts = new[] { 0, 5, 10, 15 };

            Polygon polygon = new Polygon(new PolygonShape(0, m_metadata, extent, parts, positions), m_document, Color.Blue);
            polygon.Write();
            string result = m_stringWriter.ToString();
            Regex polygonPattern = new Regex(m_polygonPattern);
            Assert.AreEqual(2, polygonPattern.Matches(result).Count);
        }
        public void JoinsPolygonWithMultipleHoles()
        {
            Rectangular[] positions = new[]
                                          {
                                              new Rectangular(-122.0, 37.0),
                                              new Rectangular(-121.9, 37.0),
                                              new Rectangular(-121.9, 37.1),
                                              new Rectangular(-122.0, 37.1),
                                              new Rectangular(-122.0, 37.0),
                                              new Rectangular(-121.99, 37.01),
                                              new Rectangular(-121.99, 37.04),
                                              new Rectangular(-121.96, 37.04),
                                              new Rectangular(-121.96, 37.01),
                                              new Rectangular(-121.99, 37.01),
                                              new Rectangular(-121.94, 37.06),
                                              new Rectangular(-121.94, 37.09),
                                              new Rectangular(-121.91, 37.09),
                                              new Rectangular(-121.91, 37.06),
                                              new Rectangular(-121.94, 37.06),
                                              new Rectangular(-121.99, 37.06),
                                              new Rectangular(-121.99, 37.09),
                                              new Rectangular(-121.96, 37.09),
                                              new Rectangular(-121.96, 37.06),
                                              new Rectangular(-121.99, 37.06),
                                              new Rectangular(-121.94, 37.01),
                                              new Rectangular(-121.94, 37.04),
                                              new Rectangular(-121.91, 37.04),
                                              new Rectangular(-121.91, 37.01),
                                              new Rectangular(-121.94, 37.01)
                                          };
            CartographicExtent extent = new CartographicExtent(0.0, 0.0, 10.0, 10.0);
            int[] parts = new[] { 0, 5, 10, 15, 20 };

            Polygon polygon = new Polygon(new PolygonShape(0, m_metadata, extent, parts, positions), m_document, Color.Blue);
            polygon.Write();
            string result = m_stringWriter.ToString();
            Regex polygonPattern = new Regex(m_polygonPattern);
            Assert.AreEqual(1, polygonPattern.Matches(result).Count);
        }
        public void TestPolygonZValues()
        {
            Rectangular[] positions = new[]
                                          {
                                              new Rectangular(0.0, 5.0),
                                              new Rectangular(5.0, 10.0),
                                              new Rectangular(10.0, 5.0),
                                              new Rectangular(5.0, 0.0),
                                              new Rectangular(0.0, 5.0),
                                              new Rectangular(2.0, 5.0),
                                              new Rectangular(5.0, 2.0),
                                              new Rectangular(8.0, 5.0),
                                              new Rectangular(5.0, 8.0),
                                              new Rectangular(2.0, 5.0)
                                          };

            double[] zValues = new[]
                                   {
                                       1.0, 2.0, 3.0, 4.0, 1.0,
                                       5.0, 6.0, 7.0, 8.0, 5.0
                                   };

            CartographicExtent extent = new CartographicExtent(0.0, 0.0, 10.0, 10.0);
            int[] parts = new[] { 0, 5 };
            double[] measures = new[] { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 };

            PolygonZShape polygonZShape = new PolygonZShape(0, m_metadata, extent, parts, positions, 1.0, 8.0, zValues, 0.0, 0.0, measures);
            Polygon polygon = new Polygon(polygonZShape, m_document, Color.Blue);
            polygon.Write();
            string result = m_stringWriter.ToString();
            Assert.IsTrue(Regex.IsMatch(result, m_polygonPattern));
        }
Esempio n. 38
0
        public ShapefileReader(string filename)
        {
            // ESRI Shapefile Technical Description:
            //    http://www.esri.com/library/whitepapers/pdfs/shapefile.pdf
            using (FileStream fs = new FileStream(filename, FileMode.Open, FileAccess.Read))
            {
                // File Header:
                //
                // Position  Field         Value        Type     Byte Order
                // --------  -----         -----        ----     ----------
                // Byte 0    File Code     9994         Integer  Big
                // Byte 4    Unused        0            Integer  Big
                // Byte 8    Unused        0            Integer  Big
                // Byte 12   Unused        0            Integer  Big
                // Byte 16   Unused        0            Integer  Big
                // Byte 20   Unused        0            Integer  Big
                // Byte 24   File Length   File Length  Integer  Big
                // Byte 28   Version       1000         Integer  Little
                // Byte 32   Shape Type    Shape Type   Integer  Little
                // Byte 36   Bounding Box  Xmin         Double   Little
                // Byte 44   Bounding Box  Ymin         Double   Little
                // Byte 52   Bounding Box  Xmax         Double   Little
                // Byte 60   Bounding Box  Ymax         Double   Little
                // Byte 68*  Bounding Box  Zmin         Double   Little
                // Byte 76*  Bounding Box  Zmax         Double   Little
                // Byte 84*  Bounding Box  Mmin         Double   Little
                // Byte 92*  Bounding Box  Mmax         Double   Little
                //
                // * Unused, with value 0.0, if not Measured or Z type

                byte[] fileHeader = Read(fs, _fileHeaderLength);
                if (fileHeader == null)
                {
                    throw new InvalidDataException("Could not read shapefile header.");
                }

                _byteOrder = BitConverter.IsLittleEndian ? ByteOrder.LittleEndian : ByteOrder.BigEndian;
                int fileCode = ToInteger(fileHeader, 0, ByteOrder.BigEndian);;

                if (fileCode != _fileCode)
                {
                    throw new InvalidDataException("Could not read shapefile file code.  Is this a valid shapefile?");
                }

                int fileLengthInBytes = ToInteger(fileHeader, 24, ByteOrder.BigEndian) * 2;

                int version = ToInteger(fileHeader, 28, ByteOrder.LittleEndian);
                if (version != _version)
                {
                    throw new InvalidDataException("Shapefile version " + version + " is not supported.  Only version " + _version + " is supported.");
                }

                // If a .prj file exists, check to see if the projection is supported.
                string prjFilepath = Path.ChangeExtension(filename, "prj");
                if (File.Exists(prjFilepath))
                {
                    string prj        = System.IO.File.ReadAllText(prjFilepath);
                    string projection = @"PROJECTION";
                    string unit       = @"Degree";
                    if (Regex.IsMatch(prj, projection))
                    {
                        throw new InvalidDataException("Shapefile projection not supported.");
                    }
                    else if (!(Regex.IsMatch(prj, unit)))
                    {
                        throw new InvalidDataException("Shapefile units not supported. Only degrees is supported.");
                    }
                }

                _shapeType = (ShapeType)ToInteger(fileHeader, 32, ByteOrder.LittleEndian);

                double xMin = ToDouble(fileHeader, 36, ByteOrder.LittleEndian);
                double yMin = ToDouble(fileHeader, 44, ByteOrder.LittleEndian);
                double xMax = ToDouble(fileHeader, 52, ByteOrder.LittleEndian);
                double yMax = ToDouble(fileHeader, 60, ByteOrder.LittleEndian);

                if (fileLengthInBytes == _fileHeaderLength)
                {
                    // If the shapefile is empty (that is, has no records),
                    // the values for xMin, yMin, xMax, and yMax are unspecified.
                    //
                    // I like zero better.

                    xMin = 0.0;
                    yMin = 0.0;
                    xMax = 0.0;
                    yMax = 0.0;
                }

                _extent = new CartographicExtent(xMin, yMin, xMax, yMax);

                // Read each header...

                // Record Header:
                //
                // Position  Field           Value           Type     Byte Order
                // --------  -----           -----           ----     ----------
                // Byte 0    Record Number   Record Number   Integer  Big
                // Byte 4    Content Length  Content Length  Integer  Big

                _shapes = new List <Shape>();
                byte[] recordHeader;

                string    dBaseFilepath = Path.ChangeExtension(filename, "dbf");
                DataTable metadataTable = ParseDBF.ReadDBF(dBaseFilepath);

                while ((recordHeader = Read(fs, _recordHeaderLength)) != null)
                {
                    int    recordNumber         = ToInteger(recordHeader, 0, ByteOrder.BigEndian);
                    int    contextLengthInBytes = ToInteger(recordHeader, 4, ByteOrder.BigEndian) * 2;
                    byte[] record = Read(fs, contextLengthInBytes);
                    int    mOffset, zOffset;

                    StringDictionary metadata = new StringDictionary();
                    foreach (DataColumn column in metadataTable.Columns)
                    {
                        metadata.Add(column.ColumnName, Convert.ToString(metadataTable.Rows[recordNumber - 1][column]).Trim());
                    }

                    ShapeType recordShapeType = (ShapeType)ToInteger(record, 0, ByteOrder.LittleEndian);
                    switch (recordShapeType)
                    {
                    case ShapeType.NullShape:
                        // Filter out null shapes.  Otherwise, every client
                        // would have to deal with them.
                        break;

                    case ShapeType.Point:
                        double       x        = ToDouble(record, 4, ByteOrder.LittleEndian);
                        double       y        = ToDouble(record, 12, ByteOrder.LittleEndian);
                        Cartographic position = new Cartographic(x, y, 0.0);
                        _shapes.Add(new PointShape(recordNumber, metadata, position));
                        break;

                    case ShapeType.PointM:
                        x        = ToDouble(record, 4, ByteOrder.LittleEndian);
                        y        = ToDouble(record, 12, ByteOrder.LittleEndian);
                        position = new Cartographic(x, y, 0.0);
                        double measure = ToDouble(record, 20, ByteOrder.LittleEndian);
                        _shapes.Add(new PointMShape(recordNumber, metadata, position, measure));
                        break;

                    case ShapeType.PointZ:
                        x = ToDouble(record, 4, ByteOrder.LittleEndian);
                        y = ToDouble(record, 12, ByteOrder.LittleEndian);
                        double z = ToDouble(record, 20, ByteOrder.LittleEndian);
                        position = new Cartographic(x, y, z);
                        measure  = ToDouble(record, 28, ByteOrder.LittleEndian);
                        _shapes.Add(new PointZShape(recordNumber, metadata, position, measure));
                        break;

                    case ShapeType.MultiPoint:
                    case ShapeType.MultiPointM:
                    case ShapeType.MultiPointZ:
                        CartographicExtent extent = new CartographicExtent(
                            ToDouble(record, 4, ByteOrder.LittleEndian),
                            ToDouble(record, 12, ByteOrder.LittleEndian),
                            ToDouble(record, 20, ByteOrder.LittleEndian),
                            ToDouble(record, 28, ByteOrder.LittleEndian));

                        int            numberOfPoints = ToInteger(record, 36, ByteOrder.LittleEndian);
                        Cartographic[] points         = new Cartographic[numberOfPoints];
                        for (int i = 0; i < numberOfPoints; ++i)
                        {
                            points[i] = new Cartographic(
                                ToDouble(record, 40 + (16 * i), ByteOrder.LittleEndian),
                                ToDouble(record, 40 + (16 * i) + 8, ByteOrder.LittleEndian),
                                0.0);
                        }

                        if (recordShapeType == ShapeType.MultiPoint)
                        {
                            _shapes.Add(new MultiPointShape(recordNumber, metadata, extent, points));
                        }
                        else
                        {
                            mOffset = 40 + (16 * numberOfPoints);
                            zOffset = 40 + (16 * numberOfPoints);
                            if (recordShapeType == ShapeType.MultiPointZ)
                            {
                                mOffset = zOffset + 16 + (8 * numberOfPoints);
                            }

                            double   mMin     = ToDouble(record, mOffset, ByteOrder.LittleEndian);
                            double   mMax     = ToDouble(record, mOffset + 8, ByteOrder.LittleEndian);
                            double[] measures = new double[numberOfPoints];
                            for (int i = 0; i < numberOfPoints; i++)
                            {
                                measures[i] = ToDouble(record, mOffset + 16 + (8 * i), ByteOrder.LittleEndian);
                            }

                            if (recordShapeType == ShapeType.MultiPointM)
                            {
                                _shapes.Add(new MultiPointMShape(recordNumber, metadata, extent, points, mMin, mMax, measures));
                            }
                            else
                            {
                                double   zMin    = ToDouble(record, zOffset, ByteOrder.LittleEndian);
                                double   zMax    = ToDouble(record, zOffset + 8, ByteOrder.LittleEndian);
                                double[] zValues = new double[numberOfPoints];
                                for (int i = 0; i < numberOfPoints; i++)
                                {
                                    x         = points[i].Longitude;
                                    y         = points[i].Latitude;
                                    z         = ToDouble(record, zOffset + 16 + (8 * i), ByteOrder.LittleEndian);
                                    points[i] = new Cartographic(x, y, z);
                                }
                                _shapes.Add(new MultiPointZShape(recordNumber, metadata, extent, points, zMin, zMax, mMin, mMax, measures));
                            }
                        }

                        break;

                    case ShapeType.Polyline:
                    case ShapeType.PolylineM:
                    case ShapeType.PolylineZ:
                    case ShapeType.Polygon:
                    case ShapeType.PolygonM:
                    case ShapeType.PolygonZ:
                    case ShapeType.MultiPatch:
                        extent = new CartographicExtent(
                            ToDouble(record, 4, ByteOrder.LittleEndian),
                            ToDouble(record, 12, ByteOrder.LittleEndian),
                            ToDouble(record, 20, ByteOrder.LittleEndian),
                            ToDouble(record, 28, ByteOrder.LittleEndian));
                        int numberOfParts = ToInteger(record, 36, ByteOrder.LittleEndian);
                        numberOfPoints = ToInteger(record, 40, ByteOrder.LittleEndian);

                        int[]         parts     = new int[numberOfParts];
                        Rectangular[] positions = new Rectangular[numberOfPoints];

                        // These two loops can be optimized if the machine is little endian.
                        for (int i = 0; i < numberOfParts; ++i)
                        {
                            parts[i] = ToInteger(record, 44 + (4 * i), ByteOrder.LittleEndian);
                        }

                        int pointOffset    = 44 + (4 * numberOfParts);
                        int partTypeOffset = 44 + (4 * numberOfParts);
                        if (recordShapeType == ShapeType.MultiPatch)
                        {
                            pointOffset = partTypeOffset + (4 * numberOfParts);
                        }

                        for (int i = 0; i < numberOfPoints; ++i)
                        {
                            positions[i] = new Rectangular(
                                ToDouble(record, pointOffset + (16 * i), ByteOrder.LittleEndian),
                                ToDouble(record, pointOffset + (16 * i) + 8, ByteOrder.LittleEndian));
                        }

                        if (recordShapeType == ShapeType.Polyline)
                        {
                            _shapes.Add(new PolylineShape(recordNumber, metadata, extent, parts, positions));
                        }
                        else if (recordShapeType == ShapeType.Polygon)
                        {
                            _shapes.Add(new PolygonShape(recordNumber, metadata, extent, parts, positions));
                        }
                        else
                        {
                            mOffset = pointOffset + (16 * numberOfPoints);
                            zOffset = pointOffset + (16 * numberOfPoints);
                            if (recordShapeType == ShapeType.PolylineZ || recordShapeType == ShapeType.PolygonZ || recordShapeType == ShapeType.MultiPatch)
                            {
                                mOffset = zOffset + 16 + (8 * numberOfPoints);
                            }

                            double   mMin     = ToDouble(record, mOffset, ByteOrder.LittleEndian);
                            double   mMax     = ToDouble(record, mOffset + 8, ByteOrder.LittleEndian);
                            double[] measures = new double[numberOfPoints];
                            for (int i = 0; i < numberOfPoints; i++)
                            {
                                measures[i] = ToDouble(record, mOffset + 16 + (8 * i), ByteOrder.LittleEndian);
                            }

                            if (recordShapeType == ShapeType.PolylineM)
                            {
                                _shapes.Add(new PolylineMShape(recordNumber, metadata, extent, parts, positions, mMin, mMax, measures));
                            }
                            else if (recordShapeType == ShapeType.PolygonM)
                            {
                                _shapes.Add(new PolygonMShape(recordNumber, metadata, extent, parts, positions, mMin, mMax, measures));
                            }
                            else
                            {
                                double   zMin    = ToDouble(record, zOffset, ByteOrder.LittleEndian);
                                double   zMax    = ToDouble(record, zOffset + 8, ByteOrder.LittleEndian);
                                double[] zValues = new double[numberOfPoints];
                                for (int i = 0; i < numberOfPoints; i++)
                                {
                                    zValues[i] = ToDouble(record, zOffset + 16 + (8 * i), ByteOrder.LittleEndian);
                                }

                                if (recordShapeType == ShapeType.PolylineZ)
                                {
                                    _shapes.Add(new PolylineZShape(recordNumber, metadata, extent, parts, positions, zMin, zMax, zValues, mMin, mMax, measures));
                                }
                                else if (recordShapeType == ShapeType.PolygonZ)
                                {
                                    _shapes.Add(new PolygonZShape(recordNumber, metadata, extent, parts, positions, zMin, zMax, zValues, mMin, mMax, measures));
                                }
                                else
                                {
                                    MultiPatchPartType[] partTypes = new MultiPatchPartType[numberOfParts];
                                    for (int i = 0; i < numberOfParts; i++)
                                    {
                                        partTypes[i] = (MultiPatchPartType)ToInteger(record, partTypeOffset + (4 * i), ByteOrder.LittleEndian);
                                    }
                                    _shapes.Add(new MultiPatchShape(recordNumber, metadata, extent, parts, partTypes, positions, zMin, zMax, zValues, mMin, mMax, measures));
                                }
                            }
                        }

                        break;

                    default:
                        throw new NotImplementedException("The shapefile type is not supported.  Only null, point, polyline, and polygon are supported.");
                    }
                }
            }
        }
        public void TestMultipatchConversionWithTriangleStrip()
        {
            Rectangular[] positions = new[]
                                          {
                                              new Rectangular(0.0, 0.0),
                                              new Rectangular(0.0, 1.0),
                                              new Rectangular(1.0, 0.0),
                                              new Rectangular(1.0, 1.0),
                                              new Rectangular(2.0, 0.0),
                                              new Rectangular(2.0, 1.0),
                                              new Rectangular(3.0, 0.0)
                                          };

            CartographicExtent extent = new CartographicExtent(0.0, 0.0, 3.0, 1.0);
            int[] parts = new[] { 0 };
            MultiPatchPartType[] partTypes = new[] { MultiPatchPartType.TriangleStrip };

            double[] zValues = new[] { 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0 };
            double[] measures = new[] { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 };

            MultiPatchShape multipatch = new MultiPatchShape(0, m_metadata, extent, parts, partTypes, positions, 0.0, 0.0, zValues, 0.0, 0.0, measures);
            MultiPatch patch = new MultiPatch(multipatch, m_document, Color.Blue);
            patch.Write();
            string result = m_stringWriter.ToString();
            Regex trianglePattern = new Regex(m_trianglePattern);
            Assert.AreEqual(5, trianglePattern.Matches(result).Count);
        }
 /// <summary>
 /// Positions the camera to view a given extent on the surface from a given azimuth and elevation angle.
 /// </summary>
 public static void ViewExtent(Insight3D insight3D, CentralBody centralBody, CartographicExtent extent,
                               double azimuthAngle, double elevationAngle)
 {
     ViewExtent(insight3D, centralBody, extent.WestLongitude, extent.SouthLatitude, extent.EastLongitude, extent.NorthLatitude, azimuthAngle, elevationAngle);
 }
 public void TestMultiPoint()
 {
     Cartographic[] points = new[]
                                 {
                                     new Cartographic(0.0, 0.0, 0.0),
                                     new Cartographic(1.0, 1.0, 1.0),
                                     new Cartographic(2.0, 2.0, 2.0)
                                 };
     CartographicExtent extent = new CartographicExtent(0.0, 0.0, 2.0, 2.0);
     MultiPointShape multipoint = new MultiPointShape(0, m_metadata, extent, points);
     MultiPoint mp = new MultiPoint(multipoint, m_document, Color.Blue);
     mp.Write();
     string result = m_stringWriter.ToString();
     Regex pointPattern = new Regex(m_pointPattern);
     Assert.AreEqual(3, pointPattern.Matches(result).Count);
 }