public override object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            if (value is AltitudeMode)
            {
                AltitudeMode option = (AltitudeMode)value;
                switch (option)
                {
                case AltitudeMode.Absolute:
                    return("Absolute");

                case AltitudeMode.ClampToGround:
                    return("Clamp to ground");

                case AltitudeMode.RelativeToGround:
                    return("Relative to ground");

                default:
                    return(option.ToString());
                }
            }
            else
            {
                return(Binding.DoNothing);
            }
        }
Esempio n. 2
0
 private void AppendLinearRing(IEnumerable <ScreenPointF> screenPoints, float xOffset, float yOffset, float height, StringBuilder contentStringBuilder)
 {
     contentStringBuilder.AppendLine(@"<LineString>");
     contentStringBuilder.AppendLine(@"<extrude>1</extrude>");
     contentStringBuilder.AppendLine(@"<altitudeMode>");
     contentStringBuilder.AppendLine(Mode.ToString().ToLower());
     contentStringBuilder.AppendLine(@"</altitudeMode>");
     AppendCoordinates(screenPoints, xOffset, yOffset, height, contentStringBuilder);
     contentStringBuilder.AppendLine(@"</LineString>");
 }
Esempio n. 3
0
        internal Camera Parse()
        {
            Camera camera = new Camera();

            try
            {
                camera.Longitude    = Longitude;
                camera.Latitude     = Latitude;
                camera.Altitude     = Altitude;
                camera.Heading      = Heading;
                camera.Tilt         = Tilt;
                camera.AltitudeMode = (AltitudeMode)Enum.Parse(typeof(AltitudeMode), AltitudeMode.ToString());
            }
            catch (Exception ex)
            {
                Log.OutputBox(ex);
            }

            return(camera);
        }
Esempio n. 4
0
        public override XmlNode ToXml(XmlDocument worldDoc)
        {
            XmlNode lfNode = worldDoc.CreateElement("LineFeature");

            ConfigurationSaver.getRenderableObjectProperties(this, lfNode);


            XmlNode altitudeModeNode = worldDoc.CreateElement("AltitudeMode");

            altitudeModeNode.AppendChild(worldDoc.CreateTextNode(AltitudeMode.ToString()));
            lfNode.AppendChild(altitudeModeNode);

            XmlNode minDANode = worldDoc.CreateElement("MinimumDisplayAltitude");

            minDANode.AppendChild(worldDoc.CreateTextNode(MinimumDisplayAltitude.ToString(CultureInfo.InvariantCulture)));
            lfNode.AppendChild(minDANode);

            XmlNode maxDANode = worldDoc.CreateElement("MaximumDisplayAltitude");

            maxDANode.AppendChild(worldDoc.CreateTextNode(MaximumDisplayAltitude.ToString(CultureInfo.InvariantCulture)));
            lfNode.AppendChild(maxDANode);

            XmlNode dASNode = worldDoc.CreateElement("DistanceAboveSurface");

            dASNode.AppendChild(worldDoc.CreateTextNode(DistanceAboveSurface.ToString(CultureInfo.InvariantCulture)));
            lfNode.AppendChild(dASNode);

            XmlNode extrudeHeightNode = worldDoc.CreateElement("ExtrudeHeight");

            extrudeHeightNode.AppendChild(worldDoc.CreateTextNode(ExtrudeHeight.ToString(CultureInfo.InvariantCulture)));
            lfNode.AppendChild(extrudeHeightNode);

            XmlNode extrudeNode = worldDoc.CreateElement("Extrude");

            extrudeNode.AppendChild(worldDoc.CreateTextNode(Extrude.ToString(CultureInfo.InvariantCulture)));
            lfNode.AppendChild(extrudeNode);

            XmlNode extrudeUpwardsNode = worldDoc.CreateElement("ExtrudeUpwards");

            extrudeUpwardsNode.AppendChild(worldDoc.CreateTextNode(ExtrudeUpwards.ToString(CultureInfo.InvariantCulture)));
            lfNode.AppendChild(extrudeUpwardsNode);

            XmlNode extrudeToGroundNode = worldDoc.CreateElement("ExtrudeToGround");

            extrudeToGroundNode.AppendChild(worldDoc.CreateTextNode(ExtrudeToGround.ToString(CultureInfo.InvariantCulture)));
            lfNode.AppendChild(extrudeToGroundNode);

            XmlNode imageUriNode = worldDoc.CreateElement("ImageUri");

            imageUriNode.AppendChild(worldDoc.CreateTextNode(ImageUri));
            lfNode.AppendChild(imageUriNode);

            XmlNode outlineNode = worldDoc.CreateElement("Outline");

            outlineNode.AppendChild(worldDoc.CreateTextNode(Outline.ToString(CultureInfo.InvariantCulture)));
            lfNode.AppendChild(outlineNode);

            // TODO: are these right?
            // FeatureColor in xml = LineColor, OutlineColor in xml = PolygonColor ?
            XmlNode featureColorNode = worldDoc.CreateElement("FeatureColor");

            ConfigurationSaver.createColorNode(featureColorNode, LineColor);
            lfNode.AppendChild(featureColorNode);

            XmlNode outlineColornode = worldDoc.CreateElement("OutlineColor");

            ConfigurationSaver.createColorNode(outlineColornode, PolygonColor);
            lfNode.AppendChild(outlineColornode);


            string  posList        = ConfigurationSaver.createPointList(Points);
            XmlNode lineStringNode = worldDoc.CreateElement("LineString");
            XmlNode posListNode    = worldDoc.CreateElement("posList");

            posListNode.AppendChild(worldDoc.CreateTextNode(posList));
            lineStringNode.AppendChild(posListNode);
            lfNode.AppendChild(lineStringNode);

            return(lfNode);
        }
Esempio n. 5
0
        /// <summary>
        /// This method will be called when a new figure is passed to sink
        /// </summary>
        /// <param name="x">X coordinate</param>
        /// <param name="y">Y coordinate</param>
        /// <param name="z">Z coordinate</param>
        /// <param name="m">M coordinate</param>
        public void BeginFigure(double x, double y, Nullable <double> z, Nullable <double> m)
        {
            m_Context.BeginFigure();

            #region Export of Altitude Mode flag

            if ((m_Context.Type == OpenGisGeographyType.Polygon && m_Context.IsFirstFigure) ||
                m_Context.Type == OpenGisGeographyType.Point ||
                m_Context.Type == OpenGisGeographyType.LineString)
            {
                // The following code exports the geography instance's altitude mode.
                // Altitude mode is stored as the m coordinate of every point,
                // but altitude mode is a geography instance property, so it must be the same for all vertices,
                // and we take it from the m coordinate of the first point.

                if (m.HasValue)
                {
                    int altitudeModeCode = (int)m.Value;
                    if (Enum.IsDefined(typeof(AltitudeMode), altitudeModeCode))
                    {
                        AltitudeMode altitudeMode = (AltitudeMode)altitudeModeCode;

                        switch (altitudeMode)
                        {
                        case AltitudeMode.absolute:
                        case AltitudeMode.relativeToGround:
                        case AltitudeMode.relativeToSeaFloor:
                        {
                            StartElement("altitudeMode");
                            WriteString(altitudeMode.ToString());
                            EndElement();
                            break;
                        }

                        case AltitudeMode.clampToGround:
                        case AltitudeMode.clampToSeaFloor:
                        {
                            _writer.WriteStartElement("altitudeMode", Constants.GxNamespace);
                            WriteString(altitudeMode.ToString());
                            _writer.WriteEndElement();
                            break;
                        }

                        default:
                        {
                            throw new KMLException("Altitude mode not supported: " + altitudeMode.ToString());
                        }
                        }
                    }
                }
            }

            #endregion

            #region Export of Tesselate Flag

            // If the altitude mode is "clamp to ground" or "clamp to sea floor" then a tesselate flag will be exported

            if (m_Context.Type == OpenGisGeographyType.LineString ||
                (m_Context.Type == OpenGisGeographyType.Polygon && m_Context.IsFirstFigure))
            {
                if (m.HasValue)
                {
                    int altitudeModeCode = (int)m.Value;
                    if (Enum.IsDefined(typeof(AltitudeMode), altitudeModeCode))
                    {
                        AltitudeMode altitudeMode = (AltitudeMode)altitudeModeCode;
                        if (altitudeMode == AltitudeMode.clampToGround ||
                            altitudeMode == AltitudeMode.clampToSeaFloor)
                        {
                            StartElement("tessellate");
                            WriteString("1");
                            EndElement();
                        }
                    }
                }
            }

            #endregion

            if (m_Context.Type == OpenGisGeographyType.Point ||
                m_Context.Type == OpenGisGeographyType.LineString)
            {
                StartElement("coordinates");
            }
            else if (m_Context.Type == OpenGisGeographyType.Polygon)
            {
                StartElement(m_Context.IsFirstFigure ? "outerBoundaryIs" : "innerBoundaryIs");
                StartElement("LinearRing");
                StartElement("coordinates");
            }

            _writer.WriteValue(Utilities.ShiftInRange(y, 180));
            _writer.WriteValue(",");
            _writer.WriteValue(Utilities.ShiftInRange(x, 90));
            if (z != null && z.HasValue)
            {
                _writer.WriteValue(",");
                _writer.WriteValue(z.Value);
            }
        }