Ejemplo n.º 1
0
 /// <summary>
 /// Generates visualization categories for OGR layer.
 /// </summary>
 /// <param name="Fieldname">%Field name to use as a base for classification.</param>
 /// <param name="ClassificationType">Type of classification.</param>
 /// <param name="numClasses">Number of classes (is not used with unique values classification type).</param>
 /// <param name="colorStart">Starting color for the color scheme.</param>
 /// <param name="colorEnd">End color for the color scheme.</param>
 /// <param name="schemeType">Type of color scheme.</param>
 /// <returns>True on success.</returns>
 /// <remarks> The whole set of features will be used during classification, not only those currently loaded into memory.
 /// Therefore the method has definite advantage over calling OgrLayer.GetBuffer.Categories.Generate
 /// directly for large layers.\n\n
 ///
 /// Categories will be added to underlying shapefile (OgrLayer.GetBuffer). This method
 /// will trigger the population of this shapefile if it's not yet in memory. \n
 ///
 /// The following code opens "buildings" layer, generates categories based on "population"
 /// field and then saves them as a "new_style" to the datasource.\n
 ///
 /// \code
 /// var layer = new OgrLayer();
 /// if (!layer.OpenFromDatabase(CONNECTION_STRING, "buildings"))
 /// {
 ///     Debug.WriteLine("Failed to open the layer: " + layer.GdalLastErrorMsg);
 /// }
 /// else
 /// {
 ///     layer.LabelExpression = "[Name]";
 ///     layer.LabelPosition = tkLabelPositioning.lpCenter;
 ///     layer.GlobalCallback = this;
 ///
 ///     if (!layer.GenerateCategories("population", tkClassificationType.ctEqualIntervals,
 ///         10, tkMapColor.Blue, tkMapColor.Yellow, tkColorSchemeType.ctSchemeGraduated))
 ///     {
 ///         Debug.WriteLine("Failed to generated categories: " + layer.get_ErrorMsg(layer.LastErrorCode));
 ///     }
 ///     else
 ///     {
 ///         var sf = layer.GetBuffer();
 ///         Debug.WriteLine("Number of generated categories: " + sf.Categories.Count);
 ///
 ///         // save it as a new style
 ///         if (!layer.SaveStyle("new_style"))
 ///         {
 ///             Debug.WriteLine("Failed to save style: " + layer.GdalLastErrorMsg);
 ///         }
 ///         else
 ///         {
 ///             Debug.WriteLine("The new style has been saved.");
 ///         }
 ///     }
 ///     layer.Close();
 /// }
 /// \endcode
 /// </remarks>
 public bool GenerateCategories(string Fieldname, tkClassificationType ClassificationType, int numClasses,
                                tkMapColor colorStart, tkMapColor colorEnd, tkColorSchemeType schemeType)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 2
0
 public LineSet(tkMapColor color, float Width, tkDashStyle style)
 {
     this.color = color;
     this.Width = Width;
     this.style = style;
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Color the shapes
        /// </summary>
        /// <param name="sf">
        /// The shapefile
        /// </param>
        /// <param name="fieldIndex">
        /// The index to color from
        /// </param>
        /// <param name="mapColorFrom">
        /// The color from.
        /// </param>
        /// <param name="mapColorTo">
        /// The color to.
        /// </param>
        /// <param name="forceUnique">
        /// Force unique.
        /// </param>
        internal static void ColorShapes(
            ref Shapefile sf,
            int fieldIndex,
            tkMapColor mapColorFrom,
            tkMapColor mapColorTo,
            bool forceUnique)
        {
            // Create visualization categories
            var utils = new Utils();

            if (sf.ShapefileType == ShpfileType.SHP_POLYGON || sf.ShapefileType == ShpfileType.SHP_POLYGONZ ||
                sf.ShapefileType == ShpfileType.SHP_POLYGONM)
            {
                sf.DefaultDrawingOptions.FillType  = tkFillType.ftStandard;
                sf.DefaultDrawingOptions.FillColor = utils.ColorByName(tkMapColor.Tomato);
            }

            if (sf.ShapefileType == ShpfileType.SHP_POLYLINE || sf.ShapefileType == ShpfileType.SHP_POLYLINEZ ||
                sf.ShapefileType == ShpfileType.SHP_POLYLINEM)
            {
                sf.DefaultDrawingOptions.LineWidth = 3;
            }

            if (sf.NumShapes == 1)
            {
                // No need to create categories:
                return;
            }

            if (sf.CellValue[fieldIndex, 0].ToString() == sf.CellValue[fieldIndex, 1].ToString())
            {
                // The same values in the field, so skip:
                return;
            }

            // String fields support only unique values classification for categories:
            if (sf.Table.Field[fieldIndex].Type == FieldType.STRING_FIELD)
            {
                forceUnique = true;
            }

            if (forceUnique)
            {
                sf.Categories.Generate(fieldIndex, tkClassificationType.ctUniqueValues, 0);
            }
            else
            {
                if (sf.NumShapes > 10)
                {
                    sf.Categories.Generate(fieldIndex, tkClassificationType.ctNaturalBreaks, 9);
                }
                else
                {
                    sf.Categories.Generate(fieldIndex, tkClassificationType.ctUniqueValues, 0);
                }
            }

            sf.Categories.ApplyExpressions();

            // apply color scheme
            var scheme = new ColorScheme();

            scheme.SetColors2(mapColorFrom, mapColorTo);
            sf.Categories.ApplyColorScheme(tkColorSchemeType.ctSchemeGraduated, scheme);
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Returns the numeric representation for the specified color.
 /// </summary>
 /// <remarks>The return value can be used for all properties which require color specification as unsigned integer.</remarks>
 /// <param name="Name">The name of the color.</param>
 /// <returns>The numeric code of the color.</returns>
 /// \new48 Added in version 4.8
 public uint ColorByName(tkMapColor Name)
 {
     throw new NotImplementedException();
 }