示例#1
0
        public TextWidget(string Text, T left, T bottom, T CapitalHeight)
            : base(M.Zero <T>(), M.Zero <T>(), M.Zero <T>(), M.Zero <T>())
        {
            m_text_color = (new RGBA_Doubles(0.0, 0.0, 0.0));
            m_BorderSize = CapitalHeight.Multiply(.2);
            m_Thickness  = CapitalHeight.Divide(8);
            m_CapsHeight = CapitalHeight;
            m_text       = new GsvText <T>();
            m_text.Text  = Text;
            m_text_poly  = new ConvStroke <T>(m_text);
            m_idx        = (0);
            T MinX, MinY, MaxX, MaxY;

            GetTextBounds(out MinX, out MinY, out MaxX, out MaxY);
            T FullWidth  = MaxX.Subtract(MinX).Add(m_BorderSize.Multiply(2));
            T FullHeight = m_CapsHeight.Add(m_text.AscenderHeight).Add(m_text.DescenderHeight).Add(m_BorderSize.Multiply(2));

            Bounds = new RectDouble <T>(left, bottom, left.Add(FullWidth), bottom.Add(FullHeight));
        }
示例#2
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);
            }
        }
示例#3
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()));
        }
示例#4
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();
        }
示例#5
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);
        }
示例#6
0
 public override int GetHashCode()
 {
     return(MinX.GetHashCode() ^ MinY.GetHashCode() ^ MaxX.GetHashCode() ^ MaxY.GetHashCode());
 }
        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);
        }
        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);
        }
示例#9
0
 public override string ToString()
 {
     return($"{MinX.ToString(CultureInfo.InvariantCulture)} - {MaxX.ToString(CultureInfo.InvariantCulture)}, {MinY.ToString(CultureInfo.InvariantCulture)} - {MaxY.ToString(CultureInfo.InvariantCulture)}");
 }
示例#10
0
 public override string ToString()
 {
     return("(" + MinX.ToString() + ',' + MaxX.ToString() + ',' + MinY.ToString() + ',' + MaxY.ToString() + ')');
 }
示例#11
0
 protected bool Equals(SpatialBounds other)
 {
     return(MinX.Equals(other.MinX) && MaxX.Equals(other.MaxX) && MinY.Equals(other.MinY) && MaxY.Equals(other.MaxY));
 }
        /// <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);
        }
        /// <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);
        }
示例#14
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)));
        }
示例#15
0
 public override int GetHashCode()
 {
     return(MinX.GetHashCode() >> 3 ^ MaxX.GetHashCode() << 3 ^ MinY.GetHashCode() >> 2 ^ MaxY.GetHashCode() << 2);
 }