/// <summary>
        /// TBD ?!?
        /// </summary>
        public override string FormulaRepresentation()
        {
            string strTemplate = "BBox={0},{1} {2},{3}";
            string str         = string.Format(strTemplate, MinX.ToString(CultureInfo.InvariantCulture), MinY.ToString(CultureInfo.InvariantCulture), MaxX.ToString(CultureInfo.InvariantCulture), MaxY.ToString(CultureInfo.InvariantCulture));

            return(str);
        }
Esempio n. 2
0
 /// <summary>
 /// Normalize lat and lon values to their boundary values
 /// O(1)
 /// </summary>
 public void Normalize()
 {
     MinX = MinX.NormalizeLongitude();
     MaxX = MaxX.NormalizeLongitude();
     MinY = MinY.NormalizeLatitude();
     MaxY = MaxY.NormalizeLatitude();
 }
Esempio n. 3
0
 public void WriteXml(XmlWriter writer)
 {
     writer.WriteAttributeString("MinX", MinX.ToInvariantString());
     writer.WriteAttributeString("MinY", MinY.ToInvariantString());
     writer.WriteAttributeString("MaxX", MaxX.ToInvariantString());
     writer.WriteAttributeString("MaxY", MaxY.ToInvariantString());
 }
        /// <summary>
        /// TBD ?!?
        /// </summary>
        public override string WfsXmlRepresentation()
        {
            string strTemplate = "<gml:Envelope xmlns:gml=\"http://www.opengis.net/gml\" srsName=\"{0}\"><gml:lowerCorner>{1} {2}</gml:lowerCorner><gml:upperCorner>{3} {4}</gml:upperCorner></gml:Envelope>";
            string str         = string.Format(strTemplate, SrsName, MinX.ToString(CultureInfo.InvariantCulture), MinY.ToString(CultureInfo.InvariantCulture), MaxX.ToString(CultureInfo.InvariantCulture), MaxY.ToString(CultureInfo.InvariantCulture));

            return(str);
        }
Esempio n. 5
0
        public override string ToString()
        {
            NumberFormatInfo format = CultureInfo.InvariantCulture.NumberFormat;

            return(string.Format("{0},{1},{2},{3}", MinX.ToString(format), MinY.ToString(format), MaxX.ToString(format),
                                 MaxY.ToString(format)));
        }
Esempio n. 6
0
        public override int GetHashCode()
        {
            unchecked
            {
                int hashCode = (int)Type;
                hashCode = (hashCode * 397) ^ (int)Strategy;

                if (Type == SpatialFieldType.Geography)
                {
                    hashCode = (hashCode * 397) ^ Units.GetHashCode();
                }

                if (Strategy != SpatialSearchStrategy.BoundingBox)
                {
                    hashCode = (hashCode * 397) ^ MaxTreeLevel;

                    if (Type == SpatialFieldType.Cartesian)
                    {
                        hashCode = (hashCode * 397) ^ MinX.GetHashCode();
                        hashCode = (hashCode * 397) ^ MaxX.GetHashCode();
                        hashCode = (hashCode * 397) ^ MinY.GetHashCode();
                        hashCode = (hashCode * 397) ^ MaxY.GetHashCode();
                    }
                }

                return(hashCode);
            }
        }
Esempio n. 7
0
        /// <summary>Indicates whether the current object is equal to another object of the same type.</summary>
        /// <returns><c>true</c> if the current object is equal to the <paramref name="other" /> parameter; otherwise, <c>false</c>.</returns>
        /// <param name="other">An object to compare with this object.</param>
        public bool Equals(StatisticsCalculationResult other)
        {
            //check for null
            if (other is null)
            {
                return(false);
            }

            //check for same reference
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            //check for same values
            return(MinX.Equals(other.MinX) &&
                   MinY.Equals(other.MinY) &&
                   MaxX.Equals(other.MaxX) &&
                   MaxY.Equals(other.MaxY) &&
                   UsedAreaWidth.Equals(other.UsedAreaWidth) &&
                   UsedAreaHeight.Equals(other.UsedAreaHeight) &&
                   UsedTiles.Equals(other.UsedTiles) &&
                   MinTiles.Equals(other.MinTiles) &&
                   Efficiency.Equals(other.Efficiency));
        }
Esempio n. 8
0
 public bool Equals(Extent other)
 {
     return(other != null &&
            MaxX.Equals(other.MaxX) &&
            MaxY.Equals(other.MaxY) &&
            MinX.Equals(other.MinX) &&
            MinY.Equals(other.MinY));
 }
Esempio n. 9
0
        public void TxtIntoChart()
        {
            try
            {
                ChartForm chartForm = new ChartForm();
                var       myChart   = chartForm.chart1;
                //double minX = 10000;
                //double minY = 10000;
                foreach (var oneRowData in rowDatas)
                {
                    int getSeries = int.Parse(oneRowData.plan_value);
                    if (getSeries < 0 || getSeries > 20)
                    {
                        Console.WriteLine();
                    }
                    double getX = double.Parse(oneRowData.plan_x);
                    double getY = double.Parse(oneRowData.plan_y);
                    if (getX < MinX)
                    {
                        MinX = getX;
                    }
                    if (getY < MinY)
                    {
                        MinY = getX;
                    }
                    myChart.Series[getSeries].Points.AddXY(getX, getY);
                }
                SignofXY signofX = SignofXY.P;
                if (MinX < 0)
                {
                    signofX = SignofXY.N;
                    MinX    = -MinX;
                }
                SignofXY signofY = SignofXY.P;
                if (MinY < 0)
                {
                    signofY = SignofXY.N;
                    MinY    = -MinY;
                }

                myChart.ChartAreas[0].RecalculateAxesScale();

                string destFileSaveName = Path.GetFileNameWithoutExtension(SrcFileFullPath);
                destFileSaveName += "_" + signofX.ToString() + MinX.ToString("00000") + signofY.ToString() + MinY.ToString("00000");// + ".png";

                SaveNameWithShift = destFileSaveName;

                chartForm.ResetImageAndPb();

                chartForm.Show();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.StackTrace);
            }
        }
Esempio n. 10
0
        public override int GetHashCode()
        {
            int hashCode = -1882349014;

            hashCode = hashCode * -1521134295 + MinX.GetHashCode();
            hashCode = hashCode * -1521134295 + MinY.GetHashCode();
            hashCode = hashCode * -1521134295 + MaxX.GetHashCode();
            hashCode = hashCode * -1521134295 + MaxY.GetHashCode();
            return(hashCode);
        }
Esempio n. 11
0
 public override int GetHashCode()
 {
     unchecked
     {
         int hashCode = MinX.GetHashCode();
         hashCode = (hashCode * 397) ^ MaxX.GetHashCode();
         hashCode = (hashCode * 397) ^ MinY.GetHashCode();
         hashCode = (hashCode * 397) ^ MaxY.GetHashCode();
         return(hashCode);
     }
 }
Esempio n. 12
0
 /// <summary>
 /// A hash code produced out of hash codes of <see cref="MinX"/>, <see cref="MinY"/>, <see cref="SizeX"/>, <see cref="SizeY"/>.
 /// </summary>
 /// <returns>A hash code produced out of hash codes of <see cref="MinX"/>, <see cref="MinY"/>, <see cref="SizeX"/>, <see cref="SizeY"/>.</returns>
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = MinX.GetHashCode();
         hashCode = (hashCode * 397) ^ MinY.GetHashCode();
         hashCode = (hashCode * 397) ^ SizeX.GetHashCode();
         hashCode = (hashCode * 397) ^ SizeY.GetHashCode();
         return(hashCode);
     }
 }
Esempio n. 13
0
        public void Interprete(string[] filetext)
        {
            UsedCulture = new CultureInfo("da-DK");
            string firstline = filetext[0].Trim();

            string[] metadata = firstline.Split('\t');
            YUnit = metadata[2];
            Count = filetext.Length - 1;
            X     = new DateTime[Count];
            Y     = new double[Count];

            string[] currentline;
            for (int i = 1; i < filetext.Length; i++)
            {
                currentline = filetext[i].Split('\t');
                string datetime = currentline[0].Trim().Replace('.', '/') + " " +
                                  currentline[1].Trim().Replace('.', ':');
                X[i - 1] = DateTime.Parse(datetime);
                Y[i - 1] = float.Parse(currentline[2].Trim());
                Note     = currentline[4];
            }

            Total = 0.0;
            foreach (double d in Y)
            {
                Total += d;
            }

            MinX = X[0];
            MaxX = X[Count - 1];

            MinY = Y[0];
            MaxY = Y[0];
            foreach (double f in Y)
            {
                if (f < MinY)
                {
                    MinY = f;
                }
                if (MaxY < f)
                {
                    MaxY = f;
                }
            }

            string newPathFormat;

            (XFormat, newPathFormat) = NumberFormatter.DefineDateTimeFormat(X);
            YFormat     = NumberFormatter.DefineFloatFormat(Y);
            XUnit       = "Dato/tid";
            Note        = metadata[4] + ": " + Note;
            NewFileName = NumberFormatter.DefineFilename(MinX, MaxX);
            NewFilepath = MinX.ToString(newPathFormat);
        }
Esempio n. 14
0
        public override int GetHashCode()
        {
            int hashCode = 0;

            unchecked {
                hashCode += 1000000007 * MinX.GetHashCode();
                hashCode += 1000000009 * MinY.GetHashCode();
                hashCode += 1000000021 * Width.GetHashCode();
                hashCode += 1000000033 * Height.GetHashCode();
            }
            return(hashCode);
        }
Esempio n. 15
0
        /// <summary>
        /// Hashcode method
        /// </summary>
        /// <returns></returns>
        public override int GetHashCode()
        {
            int hashCode = -1838259446;

            hashCode = hashCode * -1521134295 + MinX.GetHashCode();
            hashCode = hashCode * -1521134295 + MinY.GetHashCode();
            hashCode = hashCode * -1521134295 + MinZ.GetHashCode();
            hashCode = hashCode * -1521134295 + MaxX.GetHashCode();
            hashCode = hashCode * -1521134295 + MaxY.GetHashCode();
            hashCode = hashCode * -1521134295 + MaxZ.GetHashCode();
            return(hashCode);
        }
Esempio n. 16
0
 public bool Search(string str)
 {
     if (ID.ToString().Contains(str) || MinX.ToString().Contains(str) || MinY.ToString().Contains(str) || MinZ.ToString().Contains(str) ||
         MaxX.ToString().Contains(str) || MaxY.ToString().Contains(str) || MaxZ.ToString().Contains(str))
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
Esempio n. 17
0
        private bool IsFormValid()
        {
            try
            {
                if (textMinX.Text == null || textMinX.Text.Trim() == "")
                {
                    return(false);
                }
                if (textMaxX.Text == null || textMaxX.Text.Trim() == "")
                {
                    return(false);
                }
                if (textMinY.Text == null || textMinY.Text.Trim() == "")
                {
                    return(false);
                }
                if (textMaxY.Text == null || textMaxY.Text.Trim() == "")
                {
                    return(false);
                }

                MinX = Convert.ToDouble(textMinX.Text, System.Globalization.CultureInfo.InvariantCulture);
                MaxX = Convert.ToDouble(textMaxX.Text, System.Globalization.CultureInfo.InvariantCulture);
                MinY = Convert.ToDouble(textMinY.Text, System.Globalization.CultureInfo.InvariantCulture);
                MaxY = Convert.ToDouble(textMaxY.Text, System.Globalization.CultureInfo.InvariantCulture);

                if ((MinX > MaxX) || (MinY > MaxY))
                {
                    throw new Exception("area not valid");
                }

                InterruptString = Convert.ToString("Zone " + MinX.ToString() + " " + MaxX.ToString() + " " + MinY.ToString() + " " + MaxY.ToString());
                System.Text.RegularExpressions.Match mz = ZoneEx.Match(InterruptString);
                if (mz.Success == false)
                {
                    InterruptString = null;
                    MessageBox.Show("area string not valid");
                    return(false);
                }
            }
            catch (Exception x)
            {
                InterruptString = null;
                MessageBox.Show(x.Message, "Error");
                return(false);
            }

            return(true);
        }
Esempio n. 18
0
 public override void WriteXml(XmlWriter writer)
 {
     writer.WriteAttributeString("CRS", CRS);
     writer.WriteAttributeString("minx", MinX.ToString(NumberFormatInfo.InvariantInfo));
     writer.WriteAttributeString("maxx", MaxX.ToString(NumberFormatInfo.InvariantInfo));
     writer.WriteAttributeString("miny", MinY.ToString(NumberFormatInfo.InvariantInfo));
     writer.WriteAttributeString("maxy", MaxY.ToString(NumberFormatInfo.InvariantInfo));
     if (ResX.HasValue)
     {
         writer.WriteAttributeString("resx", ResX.Value.ToString(NumberFormatInfo.InvariantInfo));
     }
     if (ResY.HasValue)
     {
         writer.WriteAttributeString("resy", ResY.Value.ToString(NumberFormatInfo.InvariantInfo));
     }
 }
Esempio n. 19
0
        protected override void WriteDataXML(XElement ele, ElderScrollsPlugin master)
        {
            XElement subEle;

            ele.TryPathTo("Divisor", true, out subEle);
            subEle.Value = Divisor.ToString();

            ele.TryPathTo("MaxDistance/X", true, out subEle);
            subEle.Value = MaxDistanceX.ToString("G15");

            ele.TryPathTo("MaxDistance/Y", true, out subEle);
            subEle.Value = MaxDistanceY.ToString("G15");

            ele.TryPathTo("Min/X", true, out subEle);
            subEle.Value = MinX.ToString("G15");

            ele.TryPathTo("Min/Y", true, out subEle);
            subEle.Value = MinY.ToString("G15");

            ele.TryPathTo("Min/Z", true, out subEle);
            subEle.Value = MinZ.ToString("G15");

            ele.TryPathTo("Max/X", true, out subEle);
            subEle.Value = MaxX.ToString("G15");

            ele.TryPathTo("Max/Y", true, out subEle);
            subEle.Value = MaxY.ToString("G15");

            ele.TryPathTo("Max/Z", true, out subEle);
            subEle.Value = MaxZ.ToString("G15");

            ele.TryPathTo("Cell", true, out subEle);
            foreach (List <short> list in Cell)
            {
                XElement cell = new XElement("Row");
                foreach (short num in list)
                {
                    cell.Add(new XElement("Triangle", num));
                }
                subEle.Add(cell);
            }
        }
Esempio n. 20
0
        public override XElement ToXElement(string nameSpace)
        {
            var attributes = new List <XAttribute>
            {
                new XAttribute("CRS", CRS),
                new XAttribute("minx", MinX.ToString(NumberFormatInfo.InvariantInfo)),
                new XAttribute("maxx", MaxX.ToString(NumberFormatInfo.InvariantInfo)),
                new XAttribute("miny", MinY.ToString(NumberFormatInfo.InvariantInfo)),
                new XAttribute("maxy", MaxY.ToString(NumberFormatInfo.InvariantInfo))
            };

            if (ResX.HasValue)
            {
                attributes.Add(new XAttribute("resx", ResX.Value.ToString(NumberFormatInfo.InvariantInfo)));
            }
            if (ResY.HasValue)
            {
                attributes.Add(new XAttribute("resy", ResY.Value.ToString(NumberFormatInfo.InvariantInfo)));
            }
            return(new XElement(XName.Get("BoundingBox", nameSpace), attributes.ToArray()));
        }
Esempio n. 21
0
        protected override void WriteDataXML(XElement ele, ElderScrollsPlugin master)
        {
            XElement subEle;

            ele.TryPathTo("UsableSize/X", true, out subEle);
            subEle.Value = UsableXSize.ToString();

            ele.TryPathTo("UsableSize/Y", true, out subEle);
            subEle.Value = UsableYSize.ToString();

            ele.TryPathTo("MinX", true, out subEle);
            subEle.Value = MinX.ToString();

            ele.TryPathTo("MinY", true, out subEle);
            subEle.Value = MinY.ToString();

            ele.TryPathTo("MaxX", true, out subEle);
            subEle.Value = MaxX.ToString();

            ele.TryPathTo("MaxY", true, out subEle);
            subEle.Value = MaxY.ToString();
        }
Esempio n. 22
0
        protected bool Equals(SpatialOptions other)
        {
            var result = Type == other.Type && Strategy == other.Strategy;

            if (Type == SpatialFieldType.Geography)
            {
                result = result && Units == other.Units;
            }

            if (Strategy != SpatialSearchStrategy.BoundingBox)
            {
                result = result && MaxTreeLevel == other.MaxTreeLevel;

                if (Type == SpatialFieldType.Cartesian)
                {
                    result = result &&
                             MinX.Equals(other.MinX) &&
                             MaxX.Equals(other.MaxX) &&
                             MinY.Equals(other.MinY) &&
                             MaxY.Equals(other.MaxY);
                }
            }
            return(result);
        }
Esempio n. 23
0
 /// <summary>
 /// Show some debugging text
 /// </summary>
 private void ShowDebugText()
 {
     DebugText.Value = "pxs=" + PixelScale.ToString("0.0000") + Text.NewLine +
                       "minX=" + MinX.ToString("0.00") + Text.NewLine +
                       "missiles=" + alienMissiles.Count();
 }
Esempio n. 24
0
 protected bool Equals(SpatialBounds other)
 {
     return(MinX.Equals(other.MinX) && MaxX.Equals(other.MaxX) && MinY.Equals(other.MinY) && MaxY.Equals(other.MaxY));
 }
Esempio n. 25
0
 public override int GetHashCode()
 {
     return(MinX.GetHashCode() >> 3 ^ MaxX.GetHashCode() << 3 ^ MinY.GetHashCode() >> 2 ^ MaxY.GetHashCode() << 2);
 }
Esempio n. 26
0
 public override int GetHashCode()
 {
     return(MinX.GetHashCode() ^ MinY.GetHashCode() ^ MaxX.GetHashCode() ^ MaxY.GetHashCode());
 }
Esempio n. 27
0
        public Chart CreateChart()
        {
            Chart chart = new Chart();

            chart.Size = new System.Drawing.Size(3508, 2480);

            var chartArea = new ChartArea();

            chartArea.AxisX.LabelStyle.Format       = XFormat;
            chartArea.AxisY.LabelStyle.Format       = YFormat;
            chartArea.AxisX.LabelStyle.Font         = new Font("Arial", 26);
            chartArea.AxisY.LabelStyle.Font         = new Font("Arial", 30);
            chartArea.AxisX.LabelStyle.Angle        = 90;
            chartArea.AxisX.TitleFont               = new Font("Arial", 30, FontStyle.Bold);
            chartArea.AxisY.Title                   = YUnit;
            chartArea.AxisY.TitleFont               = new Font("Arial", 30, FontStyle.Bold);
            chartArea.AxisX.LabelAutoFitMinFontSize = 20;
            chartArea.AxisX.LabelAutoFitStyle       = LabelAutoFitStyles.LabelsAngleStep90;
            chartArea.AxisY.LabelAutoFitMinFontSize = 10;
            chartArea.AxisX.LabelAutoFitMaxFontSize = 30;
            chartArea.AxisY.LabelAutoFitMaxFontSize = 30;
            chartArea.AxisX.MajorGrid.LineColor     = Color.DarkGray;
            chartArea.AxisY.MajorGrid.LineColor     = Color.DarkGray;
            TimeSpan ts = MaxX - MinX;

            if (ts.TotalHours < 30)
            {
                chartArea.AxisX.IntervalType = DateTimeIntervalType.Hours;
                chartArea.AxisX.Title        = "Time";
            }
            else if (ts.TotalDays < 40)
            {
                chartArea.AxisX.IntervalType = DateTimeIntervalType.Days;
                chartArea.AxisX.Title        = "Dato";
            }
            else if (ts.TotalDays < 370)
            {
                chartArea.AxisX.IntervalType = DateTimeIntervalType.Months;
                chartArea.AxisX.Title        = "Måned";
            }
            else
            {
                chartArea.AxisX.IntervalType = DateTimeIntervalType.Years;
            }
            chartArea.AxisX.Interval = 1;
            chart.ChartAreas.Add(chartArea);

            var series = new Series();

            series.Name                = Note;
            series.ChartType           = SeriesChartType.Column;
            series.XValueType          = ChartValueType.DateTime;
            series.YValueType          = ChartValueType.Double;
            series.Font                = new Font("Arial", 25);
            series.LabelFormat         = "N2";
            series.LabelAngle          = 90;
            series.IsValueShownAsLabel = true;
            Title title = new Title();

            title.Font = new Font("Arial", 40);
            title.Text = $"{MinX.ToLongDateString()}, {MinX.ToShortTimeString()} - " +
                         $"{MaxX.ToLongDateString()}, {MaxX.ToShortTimeString()}{Environment.NewLine}" +
                         $"{Note}{Environment.NewLine}" +
                         $"Total forbrug: {Total.ToString(YFormat)}";
            chart.Titles.Add(title);
            chart.Series.Add(series);


            // bind the datapoints
            chart.Series[Note].Points.DataBindXY(X, Y);

            if (25 < ts.TotalDays && ts.TotalDays < 35)
            {
                for (int i = 0; i < X.Length; i++)
                {
                    if (X[i].DayOfWeek == DayOfWeek.Saturday || (X[i].DayOfWeek == DayOfWeek.Sunday))
                    {
                        chart.Series[Note].Points[i].Color = Color.DarkSlateGray;
                    }
                }
            }

            // draw!
            chart.Invalidate();
            return(chart);
        }
Esempio n. 28
0
 public override string ToString()
 {
     return("(" + MinX.ToString() + ',' + MaxX.ToString() + ',' + MinY.ToString() + ',' + MaxY.ToString() + ')');
 }
Esempio n. 29
0
 public override string ToString()
 {
     return($"{MinX.ToString(CultureInfo.InvariantCulture)} - {MaxX.ToString(CultureInfo.InvariantCulture)}, {MinY.ToString(CultureInfo.InvariantCulture)} - {MaxY.ToString(CultureInfo.InvariantCulture)}");
 }
        public XmlDocument GetTileSets(Models.Layer layer)
        {
            var doc  = new XmlDocument();
            var root = doc.CreateElement(String.Empty, "TileMap", String.Empty);

            doc.AppendChild(root);

            var versionAttribute = doc.CreateAttribute("version");

            versionAttribute.Value = TileMapServiceVersion;
            root.Attributes.Append(versionAttribute);

            var tilemapservice          = $"{this.baseUrl}/tms/{TileMapServiceVersion}/";
            var tilemapserviceAttribute = doc.CreateAttribute("tilemapservice");

            tilemapserviceAttribute.Value = tilemapservice;
            root.Attributes.Append(tilemapserviceAttribute);

            var titleNode = doc.CreateElement("Title");

            titleNode.AppendChild(doc.CreateTextNode(layer.Title));
            root.AppendChild(titleNode);

            var srs = doc.CreateElement("SRS");

            srs.AppendChild(doc.CreateTextNode(EPSG3857));
            root.AppendChild(srs);

            // GoogleMapsCompatible tile grid
            const double MinX = -20037508.342789;
            const double MinY = -20037508.342789;
            const double MaxX = 20037508.342789;
            const double MaxY = 20037508.342789;

            var boundingBox = doc.CreateElement("BoundingBox");

            var minxAttribute = doc.CreateAttribute("minx");

            minxAttribute.Value = MinX.ToString("F6", CultureInfo.InvariantCulture);
            boundingBox.Attributes.Append(minxAttribute);

            var minyAttribute = doc.CreateAttribute("miny");

            minyAttribute.Value = MinY.ToString("F6", CultureInfo.InvariantCulture);
            boundingBox.Attributes.Append(minyAttribute);

            var maxxAttribute = doc.CreateAttribute("maxx");

            maxxAttribute.Value = MaxX.ToString("F6", CultureInfo.InvariantCulture);
            boundingBox.Attributes.Append(maxxAttribute);

            var maxyAttribute = doc.CreateAttribute("maxy");

            maxyAttribute.Value = MaxY.ToString("F6", CultureInfo.InvariantCulture);
            boundingBox.Attributes.Append(maxyAttribute);

            root.AppendChild(boundingBox);

            var origin = doc.CreateElement("Origin");

            var yAttribute = doc.CreateAttribute("y");

            yAttribute.Value = MinY.ToString("F6", CultureInfo.InvariantCulture);
            origin.Attributes.Append(yAttribute);

            var xAttribute = doc.CreateAttribute("x");

            xAttribute.Value = MinX.ToString("F6", CultureInfo.InvariantCulture);
            origin.Attributes.Append(xAttribute);

            root.AppendChild(origin);

            var tileFormat = doc.CreateElement("TileFormat");

            var extensionAttribute = doc.CreateAttribute("extension");

            extensionAttribute.Value = layer.Format; // TODO: jpg/jpeg ?
            tileFormat.Attributes.Append(extensionAttribute);

            var mimetypeAttribute = doc.CreateAttribute("mime-type");

            mimetypeAttribute.Value = layer.ContentType;
            tileFormat.Attributes.Append(mimetypeAttribute);

            var heightAttribute = doc.CreateAttribute("height");

            heightAttribute.Value = TileHeight.ToString(CultureInfo.InvariantCulture);
            tileFormat.Attributes.Append(heightAttribute);

            var widthAttribute = doc.CreateAttribute("width");

            widthAttribute.Value = TileWidth.ToString(CultureInfo.InvariantCulture);
            tileFormat.Attributes.Append(widthAttribute);

            root.AppendChild(tileFormat);

            var tileSets = doc.CreateElement("TileSets");

            root.AppendChild(tileSets);

            for (var level = layer.MinZoom; level <= layer.MaxZoom; level++)
            {
                var tileSet = doc.CreateElement("TileSet");

                var href          = $"{this.baseUrl}/tms/{TileMapServiceVersion}/{layer.Identifier}/{level}";
                var hrefAttribute = doc.CreateAttribute("href");
                hrefAttribute.Value = href;
                tileSet.Attributes.Append(hrefAttribute);

                var orderAttribute = doc.CreateAttribute("order");
                orderAttribute.Value = $"{level}";
                tileSet.Attributes.Append(orderAttribute);

                // TODO: ? units-per-pixel = 78271.516 / 2^n
                // TODO: ? an initial zoom level that consists of four 256x256 pixel tiles covering the whole earth
                var unitsperpixel          = (MaxX - MinX) / (((double)TileWidth) * Math.Pow(2, level));
                var unitsperpixelAttribute = doc.CreateAttribute("units-per-pixel");
                unitsperpixelAttribute.Value = unitsperpixel.ToString(CultureInfo.InvariantCulture);
                tileSet.Attributes.Append(unitsperpixelAttribute);

                tileSets.AppendChild(tileSet);
            }

            return(doc);
        }