Exemple #1
0
        /// <summary>
        /// Writes a Geometry as KML to a string, using
        /// a specified Z value.
        /// </summary>
        /// <param name="geometry">the geometry to write</param>
        /// <param name="z">the Z value to use</param>
        /// <returns>a string containing the KML geometry representation</returns>
        public static string WriteGeometry(IGeometry geometry, double z)
        {
            KMLWriter writer = new KMLWriter {
                Z = z
            };

            return(writer.Write(geometry));
        }
Exemple #2
0
        /// <summary>
        /// Writes a Geometry as KML to a string, using
        /// a specified Z value, precision, extrude flag,
        /// and altitude mode code.
        /// </summary>
        /// <param name="geometry">the geometry to write</param>
        /// <param name="z">the Z value to use</param>
        /// <param name="precision">the maximum number of decimal places to write</param>
        /// <param name="extrude">the extrude flag to write</param>
        /// <param name="altitudeMode">the altitude model code to write</param>
        /// <returns>a string containing the KML geometry representation</returns>
        public static string WriteGeometry(IGeometry geometry, double z, int precision,
                                           bool extrude, string altitudeMode)
        {
            KMLWriter writer = new KMLWriter
            {
                Z            = z,
                Precision    = precision,
                Extrude      = extrude,
                AltitudeMode = altitudeMode
            };

            return(writer.Write(geometry));
        }
 /// <summary>
 /// Writes a Geometry as KML to a string, using
 /// a specified Z value, precision, extrude flag,
 /// and altitude mode code.
 /// </summary>
 /// <param name="geometry">the geometry to write</param>
 /// <param name="z">the Z value to use</param>
 /// <param name="precision">the maximum number of decimal places to write</param>
 /// <param name="extrude">the extrude flag to write</param>
 /// <param name="altitudeMode">the altitude model code to write</param>
 /// <returns>a string containing the KML geometry representation</returns>
 public static string WriteGeometry(IGeometry geometry, double z, int precision,
     bool extrude, string altitudeMode)
 {
     KMLWriter writer = new KMLWriter
     {
         Z = z,
         Precision = precision,
         Extrude = extrude,
         AltitudeMode = altitudeMode
     };
     return writer.Write(geometry);
 }
 public void TestExtrudeAltitudePolygon()
 {
     KMLWriter writer = new KMLWriter { Extrude = true, AltitudeMode = KMLWriter.AltitudeModeAbsolute };
     CheckEqual(writer, "POLYGON ((1 1, 2 1, 2 2, 1 2, 1 1))",
         "<Polygon><extrude>1</extrude><altitudeMode>absolute</altitudeMode><outerBoundaryIs><LinearRing><coordinates>1,1 2,1 2,2 1,2 1,1</coordinates></LinearRing></outerBoundaryIs></Polygon>");
 }
 /// <summary>
 /// Writes a Geometry as KML to a string, using
 /// a specified Z value.
 /// </summary>
 /// <param name="geometry">the geometry to write</param>
 /// <param name="z">the Z value to use</param>
 /// <returns>a string containing the KML geometry representation</returns>
 public static string WriteGeometry(IGeometry geometry, double z)
 {
     KMLWriter writer = new KMLWriter { Z = z };
     return writer.Write(geometry);
 }
 public void TestExtrudeAltitudeLineString()
 {
     KMLWriter writer = new KMLWriter { Extrude = true, AltitudeMode = KMLWriter.AltitudeModeAbsolute };
     CheckEqual(writer, "LINESTRING (1 1, 2 2)",
         "<LineString><extrude>1</extrude><altitudeMode>absolute</altitudeMode><coordinates>1,1 2,2</coordinates></LineString>");
 }
 public void TestExtrudeTesselateLineString()
 {
     KMLWriter writer = new KMLWriter { Extrude = true, Tesselate = true };
     CheckEqual(writer, "LINESTRING (1 1, 2 2)",
         "<LineString><extrude>1</extrude><tesselate>1</tesselate><coordinates>1,1 2,2</coordinates></LineString>");
 }
 private void CheckEqual(KMLWriter writer, string wkt, string expected)
 {
     IGeometry geom = new WKTReader().Read(wkt);
     CheckEqual(writer, geom, expected);
 }
 private void CheckEqual(KMLWriter writer, IGeometry geom, string expected)
 {
     string actual = writer.Write(geom);
     string actualNorm = normalizeKML(actual);
     string expectedNorm = normalizeKML(expected);
     bool isEqual = String.Equals(actualNorm, expectedNorm, StringComparison.InvariantCultureIgnoreCase);
     Assert.IsTrue(isEqual, String.Format("\nGenerated KML:  {0}\n  Expected KML: {1}", actualNorm, expectedNorm));
 }
 private void CheckEqual(string wkt, string expectedKML)
 {
     KMLWriter writer = new KMLWriter();
     CheckEqual(writer, wkt, expectedKML);
 }
 public void negative_precision_means_floating_precision()
 {
     KMLWriter writer = new KMLWriter { Precision = -1 };
     CheckEqual(writer, "LINESTRING (1.0001 1.1234, 2.5555 2.99999)",
         " <LineString><coordinates>1.0001,1.1234 2.5555,2.99999</coordinates></LineString>");
 }
 public void precision_zero_means_only_integers_allowed()
 {
     KMLWriter writer = new KMLWriter { Precision = 0 };
     CheckEqual(writer, "LINESTRING (1.0001 1.1234, 2.5555 2.99999)",
         " <LineString><coordinates>1,1 3,3</coordinates></LineString>");
 }
 public void TestPrecision()
 {
     KMLWriter writer = new KMLWriter { Precision = 1 };
     CheckEqual(writer, "LINESTRING (1.0001 1.1234, 2.5555 2.99999)",
         " <LineString><coordinates>1,1.1 2.6,3</coordinates></LineString>");
 }
 public void TestExtrudeGeometryCollection()
 {
     KMLWriter writer = new KMLWriter { Extrude = true };
     CheckEqual(writer, "GEOMETRYCOLLECTION (LINESTRING (1 9, 1 2, 3 2), POLYGON ((3 9, 5 9, 5 7, 3 7, 3 9)), POINT (5 5))",
         "<MultiGeometry><LineString><extrude>1</extrude><coordinates>1,9 1,2 3,2</coordinates></LineString><Polygon><extrude>1</extrude><outerBoundaryIs><LinearRing><coordinates>3,9 5,9 5,7 3,7 3,9</coordinates></LinearRing></outerBoundaryIs></Polygon><Point><extrude>1</extrude><coordinates>5,5</coordinates></Point></MultiGeometry>");
 }