private void SetSymbol(IReadOnlyDictionary<string, string> rDict)
 {
     int symbol_no = this.GetIntPr(rDict, "symbol_no", 1), 
         symbol_size = this.GetIntPr(rDict, "symbol_size", 15), 
         symbol_color = this.GetIntPr(rDict, "symbol_color", 0);
     MiApi.mitab_c_set_symbol(this.Handle, symbol_no, symbol_size, symbol_color);
 }
Exemple #2
0
        /// <summary>Конструктор</summary>
        /// <param name="layer">Слой</param>
        /// <param name="nid">Ключ</param>
        /// <param name="type">Тип</param>
        /// <param name="nParts">Список частей</param>
        /// <param name="nFieldValues">Список значений полей</param>
        /// <param name="nStyle">Стили</param>
        internal Feature(MiLayer layer, int nid, FeatureType type, List <List <Vertex> > nParts,
                         IReadOnlyList <string> nFieldValues, IReadOnlyDictionary <string, string> nStyle)
        {
            Id     = nid;
            Handle = MiApi.mitab_c_create_feature(layer.Handle, (int)type);
            Layer  = layer;
            Type   = type;
            Parts  = new Parts(this, nParts);
            if (nStyle != null)
            {
                SetStyle(nStyle);
            }
            if (nFieldValues != null)
            {
                for (var i = 0; i < nFieldValues.Count; i++)
                {
                    MiApi.mitab_c_set_field(Handle, i, nFieldValues[i]);
                }
            }
            var res = MiApi.mitab_c_write_feature(layer.Handle, Handle);

            if (res.ToInt32() == 1)
            {
                MiApi.mitab_c_destroy_feature(Handle);
            }
            else
            {
                throw new Exception("Ошибка создания Feature"); //
            }
        }
 private void SetPen(IReadOnlyDictionary<string, string> rDict)
 {
     int pen_pattern = this.GetIntPr(rDict, "pen_pattern", 1),
         pen_width = this.GetIntPr(rDict, "pen_width", 1),
         pen_color = this.GetIntPr(rDict, "pen_color", 0);
     MiApi.mitab_c_set_pen(this.Handle, pen_width, pen_pattern, pen_color);
 }
 private void GetPen(Dictionary<string, string> rDict)
 {
     if (rDict == null) throw new ArgumentNullException(nameof(rDict));
     rDict.Add("pen_pattern", MiApi.mitab_c_get_pen_pattern(this.Handle).ToString());
     rDict.Add("pen_width", MiApi.mitab_c_get_pen_width(this.Handle).ToString());
     rDict.Add("pen_color", MiApi.mitab_c_get_pen_color(this.Handle).ToString());
 }
 private void GetSymbol(Dictionary<string, string> rDict)
 {
     if (rDict == null) throw new ArgumentNullException(nameof(rDict));
     rDict.Add("symbol_no", MiApi.mitab_c_get_symbol_no(this.Handle).ToString());
     rDict.Add("symbol_size", MiApi.mitab_c_get_symbol_size(this.Handle).ToString());
     rDict.Add("symbol_color", MiApi.mitab_c_get_symbol_color(this.Handle).ToString());
 }
 /// <summary>Конструктор</summary>
 /// <param name="layer">Слой</param>
 protected internal Fields(MiLayer layer) : base(MiApi.mitab_c_get_field_count(layer.Handle))
 {
     for (int i = 0; i < Count; i++)
     {
         fields.Add(CreateField(layer, i));
     }
 }
Exemple #7
0
 private void GetBrush(Dictionary <string, string> rDict)
 {
     rDict.Add("brush_fgcolor", MiApi.mitab_c_get_brush_fgcolor(Handle).ToString());
     rDict.Add("brush_bgcolor", MiApi.mitab_c_get_brush_bgcolor(Handle).ToString());
     rDict.Add("brush_pattern", MiApi.mitab_c_get_brush_pattern(Handle).ToString());
     rDict.Add("brush_transparent", MiApi.mitab_c_get_brush_transparent(Handle).ToString());
 }
 /// <inheritdoc />
 public void Dispose(bool disposing)
 {
     if (disposing && !disposed)
     {
         MiApi.mitab_c_destroy_feature(this.Handle);
         disposed = true;
     }
 }
 private void SetBrush(IReadOnlyDictionary<string, string> rDict)
 {
     int brush_fgcolor = this.GetIntPr(rDict, "brush_fgcolor", 0),
         brush_bgcolor = this.GetIntPr(rDict, "brush_bgcolor", 0),
         brush_pattern = this.GetIntPr(rDict, "brush_pattern", 1),
         brush_transparent = this.GetIntPr(rDict, "brush_transparent", 0);
     MiApi.mitab_c_set_brush(this.Handle, brush_fgcolor, brush_bgcolor, brush_pattern, brush_transparent);
 }
Exemple #10
0
 /// <summary>Конструктор</summary>
 /// <param name="layer">Слой</param>
 /// <param name="featureId">Ключ</param>
 internal Feature(MiLayer layer, int featureId)
 {
     Id     = featureId;
     Layer  = layer;
     Handle = MiApi.mitab_c_read_feature(layer.Handle, featureId);
     Type   = MiApi.mitab_c_get_type(Handle);
     Parts  = CreateParts(this);
 }
 /// <summary>Конструктор</summary>
 /// <param name="layer">Слой</param>
 /// <param name="featureId">Ключ</param>
 protected internal Feature(MiLayer layer, int featureId)
 {
     this.Id = featureId;
     this.Layer = layer;
     this.Handle = MiApi.mitab_c_read_feature(layer.Handle, featureId);
     this.Type = MiApi.mitab_c_get_type(Handle);
     this.Parts = CreateParts(this);
 }
Exemple #12
0
 /// <summary>Конструктор</summary>
 /// <param name="layer">Слой</param>
 /// <param name="i">Индекс</param>
 protected internal Field(MiLayer layer, int i)
 {
     this.Layer     = layer;
     this.Index     = i;
     this.Name      = MiApi.mitab_c_get_field_name(layer.Handle, i);
     this.Type      = MiApi.mitab_c_get_field_type(layer.Handle, i);
     this.Precision = (short)MiApi.mitab_c_get_field_precision(layer.Handle, i);
     this.Width     = MiApi.mitab_c_get_field_width(layer.Handle, i);
 }
Exemple #13
0
 /// <summary>Освобождаем ресурсы</summary>
 /// <param name="disposing"></param>
 public void Dispose(bool disposing)
 {
     if (!disposing || _disposed)
     {
         return;
     }
     MiApi.mitab_c_destroy_feature(Handle);
     _disposed = true;
 }
        /// <summary>Создать mif-файл</summary>
        /// <param name="tabFileName">Имя файла</param>
        /// <param name="lay">Слой данных</param>
        /// <returns></returns>
        public static MiLayer CreateMIF(string tabFileName, DataLayer lay)
        {
            var bounds = lay.GetMBR();
            var res    = new MiLayer(MiApi.mitab_c_create(tabFileName, "mif", "NonEarth Units \"m\"",
                                                          bounds.maxy, bounds.miny, bounds.minx, bounds.maxx), tabFileName);

            res.AddLayer(lay);
            res.Close();
            return(res);
        }
 /// <summary>Конструктор</summary>
 /// <param name="fileName">Имя файла</param>
 protected internal MiLayer(string fileName)
 {
     this._handle = MiApi.mitab_c_open(fileName);
     if (this.Handle == IntPtr.Zero)
     {
         throw new FileNotFoundException("File " + fileName + " not found", fileName);
     }
     this._fields   = CreateFields();
     this._features = CreateFeatures();
     this._fileName = fileName;
 }
Exemple #16
0
 private void GetTextDisplay(Dictionary <string, string> rDict)
 {
     rDict.Add("text_angle", MiApi.mitab_c_get_text_angle(Handle).ToString(CultureInfo.InvariantCulture));
     rDict.Add("text_height", MiApi.mitab_c_get_text_height(Handle).ToString(CultureInfo.InvariantCulture));
     rDict.Add("text_width", MiApi.mitab_c_get_text_width(Handle).ToString(CultureInfo.InvariantCulture));
     rDict.Add("text_fgcolor", MiApi.mitab_c_get_text_fgcolor(Handle).ToString());
     rDict.Add("text_bgcolor", MiApi.mitab_c_get_text_bgcolor(Handle).ToString());
     rDict.Add("text_justification", MiApi.mitab_c_get_text_justification(Handle).ToString());
     rDict.Add("text_spacing", MiApi.mitab_c_get_text_spacing(Handle).ToString());
     rDict.Add("text_linetype", MiApi.mitab_c_get_text_linetype(Handle).ToString());
 }
 private void GetTextDisplay(Dictionary<string, string> rDict)
 {
     rDict.Add("text_angle", MiApi.mitab_c_get_text_angle(this.Handle).ToString());
     rDict.Add("text_height", MiApi.mitab_c_get_text_height(this.Handle).ToString());
     rDict.Add("text_width", MiApi.mitab_c_get_text_width(this.Handle).ToString());
     rDict.Add("text_fgcolor", MiApi.mitab_c_get_text_fgcolor(this.Handle).ToString());
     rDict.Add("text_bgcolor", MiApi.mitab_c_get_text_bgcolor(this.Handle).ToString());
     rDict.Add("text_justification", MiApi.mitab_c_get_text_justification(this.Handle).ToString());
     rDict.Add("text_spacing", MiApi.mitab_c_get_text_spacing(this.Handle).ToString());
     rDict.Add("text_linetype", MiApi.mitab_c_get_text_linetype(this.Handle).ToString());
 }
Exemple #18
0
        /// <summary>Установка значений стилей</summary>
        /// <param name="rDict"></param>
        public void SetStyle(IReadOnlyDictionary <string, string> rDict)
        {
            switch (Type)
            {
            case FeatureType.TABFC_Point:
            case FeatureType.TABFC_MultiPoint:
                SetSymbol(rDict);
                break;

            case FeatureType.TABFC_FontPoint:
                SetSymbol(rDict);
                MiApi.mitab_c_set_font(Handle, GetStringPr(rDict, "font", "Arial"));
                break;

            case FeatureType.TABFC_Text:
                MiApi.mitab_c_set_text(Handle, GetStringPr(rDict, "text", "text"));
                MiApi.mitab_c_set_font(Handle, GetStringPr(rDict, "font", "Arial"));
                SetTextDisplay(rDict);
                break;

            case FeatureType.TABFC_Polyline:
                SetPen(rDict);
                break;

            case FeatureType.TABFC_Ellipse:
                SetBrush(rDict);
                SetPen(rDict);
                break;

            case FeatureType.TABFC_Region:
                SetBrush(rDict);
                SetPen(rDict);
                break;

            case FeatureType.TABFC_Rectangle:
                SetBrush(rDict);
                SetPen(rDict);
                break;

            case FeatureType.TABFC_NoGeom:
                break;

            case FeatureType.TABFC_CustomPoint:
                break;

            case FeatureType.TABFC_Arc:
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
 private void SetTextDisplay(IReadOnlyDictionary<string, string> rDict)
 {
     double text_angle = this.GetDoublePr(rDict, "text_angle", 0),
         text_height = this.GetDoublePr(rDict, "text_height", 1),
         text_width = this.GetDoublePr(rDict, "text_width", 1);
     int text_fgcolor = this.GetIntPr(rDict, "text_fgcolor", 0),
         text_bgcolor = this.GetIntPr(rDict, "text_bgcolor", 0),
         text_justification = this.GetIntPr(rDict, "text_justification", 0),
         text_spacing = this.GetIntPr(rDict, "text_spacing", 0),
         text_linetype = this.GetIntPr(rDict, "text_linetype", 0);
     MiApi.mitab_c_set_text_display(this.Handle, text_angle, text_height, text_width,
         text_fgcolor, text_bgcolor, text_justification, text_spacing, text_linetype);
 }
Exemple #20
0
        /// <summary>Конструктор</summary>
        /// <param name="layer">Слой</param>
        /// <param name="fieldName">Имя поля</param>
        /// <param name="fieldType">Тип поля</param>
        /// <param name="width">Ширина</param>
        /// <param name="precision">Точность</param>
        /// <param name="indexed"></param>
        /// <param name="unique"></param>
        protected internal Field(MiLayer layer, string fieldName, FieldType fieldType, int width, int precision,
                                 int indexed, int unique)
        {
            IntPtr fieldId = MiApi.mitab_c_add_field(layer.Handle,
                                                     fieldName, (int)fieldType, width, precision, indexed, unique);;

            this.Layer     = layer;
            this.Index     = fieldId.ToInt32();
            this.Name      = fieldName;
            this.Type      = fieldType;
            this.Precision = (short)precision;
            this.Width     = width;
        }
Exemple #21
0
        /// <summary>Установка значений координат вершин</summary>
        /// <param name="nVertices">Список новых значений вершин</param>
        internal void SetPoints(List <Vertex> nVertices)
        {
            var count = nVertices.Count;
            var x     = new double[count];
            var y     = new double[count];

            for (var i = 0; i < count; i++)
            {
                var v = nVertices[i];
                x[i] = v.X;
                y[i] = v.Y;
            }
            MiApi.mitab_c_set_points(Feature.Handle, Index, count, x, y);
        }
Exemple #22
0
        /// <summary>Установка значений координат вершин</summary>
        /// <param name="nVertices">Список новых значений вершин</param>
        internal void SetPoints(List <Vertex> nVertices)
        {
            int count = nVertices.Count;

            double[] x = new double[count];
            double[] y = new double[count];
            Vertex   v;

            for (int i = 0; i < count; i++)
            {
                v    = nVertices[i];
                x[i] = v.X;
                y[i] = v.Y;
            }
            MiApi.mitab_c_set_points(this.Feature.Handle, this.Index, count, x, y);
        }
Exemple #23
0
        /// <summary>Создать tab-файл</summary>
        /// <param name="tabFileName">Имя файла</param>
        /// <param name="lay">Слой данных</param>
        /// <returns></returns>
        public static MiLayer CreateTab(string tabFileName, DataLayer lay)
        {
            var bounds = lay.GetMBR();

            if (bounds == null)
            {
                return(null);
            }
            var res = new MiLayer(MiApi.mitab_c_create(tabFileName, "tab", "NonEarth Units \"m\"",
                                                       bounds.maxy, bounds.miny, bounds.minx, bounds.maxx), tabFileName);

            //
            res.AddLayer(lay);
            res.Close();
            return(res);
        }
Exemple #24
0
        /// <summary>Получить стили</summary>
        /// <returns></returns>
        public Dictionary <string, string> GetStyle()
        {
            var rDict = new Dictionary <string, string>();

            switch (Type)
            {
            case FeatureType.TABFC_Point:
            case FeatureType.TABFC_MultiPoint:
                GetSymbol(rDict);
                break;

            case FeatureType.TABFC_FontPoint:
                GetSymbol(rDict);
                rDict.Add("font", MiApi.mitab_c_get_font(Handle));
                break;

            case FeatureType.TABFC_Text:
                rDict.Add("text", MiApi.mitab_c_get_text(Handle));
                rDict.Add("font", MiApi.mitab_c_get_font(Handle));
                GetTextDisplay(rDict);
                break;

            case FeatureType.TABFC_Polyline:
                GetPen(rDict);
                break;

            case FeatureType.TABFC_Ellipse:
                GetBrush(rDict);
                GetPen(rDict);
                break;

            case FeatureType.TABFC_Region:
                GetBrush(rDict);
                GetPen(rDict);
                break;

            case FeatureType.TABFC_Rectangle:
                GetBrush(rDict);
                GetPen(rDict);
                break;
            }
            return(rDict);
        }
 /// <summary>Получение первой сущности в коллекции</summary>
 /// <returns></returns>
 public Feature GetFirst()
 {
     return(this[MiApi.mitab_c_next_feature_id(Layer.Handle, -1)]);
 }
 /// <summary>онструктор</summary>
 /// <param name="layer"></param>
 protected internal Features(MiLayer layer) : base(MiApi.mitab_c_get_feature_count(layer.Handle))
 {
     this.Layer = layer;
 }
 /// <inheritdoc />
 public override bool MoveNext()
 {
     return((eIdx = MiApi.mitab_c_next_feature_id(_layer.Handle, eIdx)) != -1);
 }
 /// <summary>Конструктор</summary>
 /// <param name="feature"></param>
 protected internal Parts(Feature feature) : base(MiApi.mitab_c_get_parts(feature.Handle))
 {
     this._feature = feature;
 }
 /// <summary>Получение точки по индексу</summary>
 /// <param name="index">индекс точки</param>
 /// <returns></returns>
 public virtual Vertex this[int index] =>
 index < Count?CreateVertex(
     MiApi.mitab_c_get_vertex_x(Part.Feature.Handle, Part.Index, index),
     MiApi.mitab_c_get_vertex_y(Part.Feature.Handle, Part.Index, index)) : null;
 /// <summary>Конструктор</summary>
 /// <param name="part">родительский элемент</param>
 protected internal Vertices(Part part) : base(MiApi.mitab_c_get_vertex_count(part.Feature.Handle, part.Index))
 {
     this.Part = part;
 }