Esempio n. 1
0
 /// <summary>
 /// Creates a shapefile from a TIN object.
 /// </summary>
 /// <param name="Tin">The TIN object to be used to create a new shapefile.</param>
 /// <param name="Type">The type of the shapefile to be created.</param>
 /// <param name="cBack">The ICallback object which will receive progress and error messages while
 /// shapefile is being created from the TIN.</param>
 /// <returns>The new shapefile created from the TIN.</returns>
 public Shapefile TinToShapefile(Tin Tin, ShpfileType Type, ICallback cBack)
 {
     throw new NotImplementedException();
 }
        /// <summary>
        /// Applies the options
        /// </summary>
        bool ApplyOptions()
        {
            if (m_categoryEdited)
            {
                return(true);
            }

            if (richTextBox1.Text == "" && m_shapefile.Labels.Count > 0)
            {
                // clear
                if (MessageBox.Show("Expression is empty. Remove all the labels?",
                                    LegendControl.Legend.AppName, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    m_shapefile.Labels.Clear();
                    m_shapefile.Labels.Expression = "";
                }
                else
                {
                    return(false);
                }
            }
            else if ((!m_shapefile.Labels.Synchronized || m_shapefile.Labels.Count == 0) && richTextBox1.Text != "")
            {
                // generate
                AddLabelsForm form = new AddLabelsForm(m_shapefile, m_category.Alignment);
                if (form.ShowDialog(this) == DialogResult.OK)
                {
                    ShpfileType type = Globals.ShapefileType2D(m_shapefile.ShapefileType);
                    if (type == ShpfileType.SHP_POINT || type == ShpfileType.SHP_MULTIPOINT)
                    {
                        m_category.Alignment = form.m_alignment;
                    }

                    form.Dispose();
                }
                else
                {
                    form.Dispose();
                    return(false);
                }
            }
            else if (richTextBox1.Text == "" && m_shapefile.Labels.Count == 0)
            {
                //MessageBox.Show("No expression was entered.", Globals.AppName, MessageBoxButtons.OK, MessageBoxIcon.Information);
                //return false;
            }

            // applying options
            if (!m_categoryEdited)
            {
                // in case of labels we are editing a copy of the LabelsCategory class, so options should be applied
                m_shapefile.Labels.Options = m_category;

                if (m_shapefile.Labels.Expression != richTextBox1.Text)
                {
                    m_shapefile.Labels.Expression = MWLite.Symbology.Classes.LabelUtilities.FixExpression(richTextBox1.Text);
                }
            }

            return(true);
        }
Esempio n. 3
0
 /// <summary>
 /// Partially implemented. Creates a shapefile from any vector format supported by OGR library.
 /// </summary>
 /// <remarks>The method needs testing and elaboration to handle the peculiarities of various data formats.</remarks>
 /// <param name="Filename">The name of the vector data source.</param>
 /// <param name="ShpType">The type of the output shapefile.</param>
 /// <param name="cBack">The callback object to return information about progress and errors.</param>
 /// <returns>The reference to the resulting shapefile or NULL reference on failure.</returns>
 /// \new48 Added in version 4.8
 public Shapefile OGRLayerToShapefile(string Filename, ShpfileType ShpType, ICallback cBack)
 {
     throw new NotImplementedException();
 }
Esempio n. 4
0
 /// <summary>
 /// Creates a new shape of the specified type.
 /// </summary>
 /// <param name="ShpType">The type of the shape to be created.</param>
 /// <returns>A boolean value representing the success or failure of creating the new shape.</returns>
 public bool Create(ShpfileType ShpType)
 {
     throw new NotImplementedException();
 }
        /// <summary>
        /// Initializes controls of the form
        /// </summary>
        private void Initialize(LabelCategory lb)
        {
            m_category = lb;

            m_NoEvents = true;
            cboFontName.Items.Clear();
            foreach (FontFamily family in FontFamily.Families)
            {
                cboFontName.Items.Add(family.Name);
            }

            cboDecimalPlaces.Items.Add("Auto");
            for (int i = 1; i <= 6; i++)
            {
                cboDecimalPlaces.Items.Add(i.ToString());
            }
            cboDecimalPlaces.SelectedIndex = 0;

            icbLineType.ComboStyle  = ImageComboStyle.LineStyle;
            icbLineWidth.ComboStyle = ImageComboStyle.LineWidth;

            icbFrameType.Color1        = Color.Transparent;
            icbFrameType.ComboStyle    = ImageComboStyle.FrameType;
            icbFrameType.SelectedIndex = 0;

            if (!m_categoryEdited)
            {
                for (int i = 0; i < m_shapefile.NumFields; i++)
                {
                    string name = m_shapefile.Field[i].Name;
                    if (name.ToLower() != "mwshapeid")
                    {
                        listBox1.Items.Add(name);
                    }
                }
            }

            string[] scales = { "1",      "10",     "100",     "1000", "5000", "10000", "25000", "50000", "100000",
                                "250000", "500000", "1000000", "10000000" };
            cboMinScale.Items.Clear();
            cboMaxScale.Items.Clear();
            cboBasicScale.Items.Clear();
            foreach (string t in scales)
            {
                cboMinScale.Items.Add(t);
                cboMaxScale.Items.Add(t);
                cboBasicScale.Items.Add(t);
            }

            // displaying options in the GUI
            LabelStyle2Gui(m_category);

            btnTest_Click(null, null);

            txtLabelExpression.Text = m_shapefile.Labels.VisibilityExpression;

            // serialization
            if (m_categoryEdited)
            {
                m_initState = m_category.Serialize();
            }
            else
            {
                tkSavingMode mode = m_shapefile.Labels.SavingMode;
                m_shapefile.Labels.SavingMode = tkSavingMode.modeNone;
                m_initState = m_shapefile.Labels.Serialize();
                m_shapefile.Labels.SavingMode = mode;
            }

            cboLabelsVerticalPosition.Items.Clear();
            cboLabelsVerticalPosition.Items.Add("Above layer");
            cboLabelsVerticalPosition.Items.Add("Above all layers");

            var labels = m_shapefile.Labels;

            cboLabelsVerticalPosition.SelectedIndex = (int)labels.VerticalPosition;
            chkLabelsRemoveDuplicates.Checked       = labels.RemoveDuplicates;
            chkAviodCollisions.Checked = labels.AvoidCollisions;
            chkScaleLabels.Checked     = labels.ScaleLabels;
            cboBasicScale.Text         = labels.BasicScale.ToString();

            udLabelOffsetX.SetValue(labels.OffsetX);
            udLabelOffsetY.SetValue(labels.OffsetY);
            udLabelsBuffer.SetValue(labels.CollisionBuffer);

            // alignment
            optAlignBottomCenter.Checked = (labels.Alignment == tkLabelAlignment.laBottomCenter);
            optAlignBottomLeft.Checked   = (labels.Alignment == tkLabelAlignment.laBottomLeft);
            optAlignBottomRight.Checked  = (labels.Alignment == tkLabelAlignment.laBottomRight);
            optAlignCenter.Checked       = (labels.Alignment == tkLabelAlignment.laCenter);
            optAlignCenterLeft.Checked   = (labels.Alignment == tkLabelAlignment.laCenterLeft);
            optAlignCenterRight.Checked  = (labels.Alignment == tkLabelAlignment.laCenterRight);
            optAlignTopCenter.Checked    = (labels.Alignment == tkLabelAlignment.laTopCenter);
            optAlignTopLeft.Checked      = (labels.Alignment == tkLabelAlignment.laTopLeft);
            optAlignTopRight.Checked     = (labels.Alignment == tkLabelAlignment.laTopRight);

            ShpfileType shpType = Globals.ShapefileType2D(m_shapefile.ShapefileType);

            optAlignCenter.Enabled = (shpType != ShpfileType.SHP_POINT && shpType != ShpfileType.SHP_MULTIPOINT);

            btnApply.Enabled = (m_shapefile.Labels.Expression != "" && m_shapefile.Labels.Count == 0);
            string[] list = new string[] {
                "Default",
                "SingleBitPerPixelGridFit",
                "SingleBitPerPixel",
                "AntiAliasGridFit",
                "HintAntiAlias",
                "ClearType"
            };
            cboTextRenderingHint.DataSource = list;
            SetSelectedIndex(cboTextRenderingHint, (int)m_shapefile.Labels.TextRenderingHint);
            cboTextRenderingHint.SelectedIndexChanged += Gui2LabelStyle;

            m_NoEvents = false;

            // initial drawing
            this.DrawPreview(null, null);
        }
        /// <summary>
        /// Changes the enabled properties of controls
        /// </summary>
        private void RefreshControlsState(object sender, EventArgs e)
        {
            if (_noEvents)
            {
                return;
            }

            ShpfileType type = Globals.ShapefileType2D(_shapefile.ShapefileType);

            // appearance
            udDefaultSize.Enabled = (type == ShpfileType.SHP_POINT || type == ShpfileType.SHP_MULTIPOINT);
            clpPointFill.Enabled  = (type != ShpfileType.SHP_POLYLINE);
            clpSelection.Enabled  = (type != ShpfileType.SHP_POLYLINE);

            // provide the options if there are a single line pattern, otherwise extednded options are needed
            ShapeDrawingOptions options = _shapefile.DefaultDrawingOptions;

            if (options.UseLinePattern)
            {
                if (options.LinePattern.Count <= 1)
                {
                    panelLineOptions.Visible    = true;
                    clpDefaultOutline.Enabled   = true;
                    icbLineWidth.Enabled        = (options.LinePattern.get_Line(0).LineType == tkLineType.lltSimple);
                    lblMultilinePattern.Visible = false;
                }
                else
                {
                    lblMultilinePattern.Visible = true;
                    panelLineOptions.Visible    = false;
                }
            }
            else
            {
                clpDefaultOutline.Enabled   = true;
                icbLineWidth.Enabled        = true;
                panelLineOptions.Visible    = true;
                lblMultilinePattern.Visible = false;
            }

            // categories
            udMinSize.Enabled             = chkUseVariableSize.Checked;
            udMaxSize.Enabled             = chkUseVariableSize.Checked;
            udNumCategories.Enabled       = !chkUniqueValues.Checked;
            btnCategoryAppearance.Enabled = (dgvCategories.SelectedCells.Count > 0);
            btnCategoryRemove.Enabled     = (dgvCategories.SelectedCells.Count > 0);
            btnCategoryClear.Enabled      = (dgvCategories.Rows.Count > 0);

            // labels
            MapWinGIS.Labels labels = _shapefile.Labels;

            //btnLabelsAppearance.Enabled = (labels.Count > 0);
            btnLabelsClear.Enabled       = (labels.Count > 0);
            groupLabelAppearance.Enabled = (labels.Count > 0);
            groupLabelStyle.Enabled      = (labels.Count > 0);
            chkShowLabels.Enabled        = (labels.Count > 0);
            panelLabels.Enabled          = (labels.Count > 0);
            groupChartAppearance.Enabled = _shapefile.Charts.Count > 0;

            // charts
            bool enabled = (_shapefile.Charts.Count > 0); //&& (_shapefile.Charts.NumFields > 0);

            btnClearCharts.Enabled           = (_shapefile.Charts.Count > 0);
            icbChartColorScheme.Enabled      = enabled;
            groupCharts.Enabled              = enabled;
            optChartBars.Enabled             = enabled;
            optChartsPie.Enabled             = enabled;
            chkChartsVisible.Enabled         = enabled;
            btnChartsEditColorScheme.Enabled = enabled;
        }
Esempio n. 7
0
 /// <summary>
 /// Initializes editor for creation of unbound shape.
 /// </summary>
 /// <remarks>Unbound shape is the one which is not linked to particular shapefile. This
 /// method is used internally by a number of built-in tools,
 /// like cmSelectByPolygon or cmSplitByPolyline.</remarks>
 /// <param name="ShpType">Type of shape to be created.</param>
 /// <returns>True on success.</returns>
 public bool StartUnboundShape(ShpfileType ShpType)
 {
     throw new NotImplementedException();
 }
        /// <summary>
        /// Generates labels with specified positions
        /// </summary>
        private void btnOk_Click(object sender, EventArgs e)
        {
            // callback and wait cursor
            ICallback cBackOld = m_shapefile.GlobalCallback;
            Callback  cback    = new Callback();

            m_shapefile.GlobalCallback = cback;
            this.Enabled = false;
            this.Cursor  = Cursors.WaitCursor;

            MapWinGIS.Labels   lb          = m_shapefile.Labels;
            tkLabelPositioning positioning = get_LabelPositioning();

            lb.LineOrientation = (tkLineLabelOrientation)cboLineOrientation.SelectedIndex;

            try
            {
                // generation
                m_shapefile.GenerateLabels(-1, positioning, !chkLabelEveryPart.Checked);
                m_shapefile.Labels.SavingMode = tkSavingMode.modeXMLOverwrite;  // .lbl file should be updated

                ShpfileType type = Globals.ShapefileType2D(m_shapefile.ShapefileType);
                if (type == ShpfileType.SHP_POINT || type == ShpfileType.SHP_MULTIPOINT)
                {
                    if (optAlignBottomCenter.Checked)
                    {
                        m_alignment = tkLabelAlignment.laBottomCenter;
                    }
                    if (optAlignBottomLeft.Checked)
                    {
                        m_alignment = tkLabelAlignment.laBottomLeft;
                    }
                    if (optAlignBottomRight.Checked)
                    {
                        m_alignment = tkLabelAlignment.laBottomRight;
                    }
                    if (optAlignCenter.Checked)
                    {
                        m_alignment = tkLabelAlignment.laCenter;
                    }
                    if (optAlignCenterLeft.Checked)
                    {
                        m_alignment = tkLabelAlignment.laCenterLeft;
                    }
                    if (optAlignCenterRight.Checked)
                    {
                        m_alignment = tkLabelAlignment.laCenterRight;
                    }
                    if (optAlignTopCenter.Checked)
                    {
                        m_alignment = tkLabelAlignment.laTopCenter;
                    }
                    if (optAlignTopLeft.Checked)
                    {
                        m_alignment = tkLabelAlignment.laTopLeft;
                    }
                    if (optAlignTopRight.Checked)
                    {
                        m_alignment = tkLabelAlignment.laTopRight;
                    }
                }

                // updating references to categories
                if (lb.NumCategories > 0)
                {
                    for (int i = 0; i < lb.Count; i++)
                    {
                        MapWinGIS.Label label = lb.get_Label(i, 0);
                        label.Category = m_shapefile.get_ShapeCategory(i);
                    }
                }
            }
            finally
            {
                this.Enabled = true;
                this.Cursor  = Cursors.Default;
                cback.Clear();
                m_shapefile.GlobalCallback = cBackOld;
            }
        }
        internal tkLabelAlignment m_alignment; // = tkLabelAlignment.laCenter;

        /// <summary>
        /// Creates a new instance of the AddLabelsForm
        /// </summary>
        public AddLabelsForm(MapWinGIS.Shapefile sf, tkLabelAlignment alignment)
        {
            InitializeComponent();

            if (sf == null)
            {
                throw new Exception("AddLabelsForm: Unexpected null parameter");
            }

            m_alignment = alignment;
            m_shapefile = sf;
            cboLineOrientation.Enabled = false;
            panel1.Visible             = false;

            ShpfileType type = Globals.ShapefileType2D(m_shapefile.ShapefileType);

            if (type == ShpfileType.SHP_POLYGON)
            {
                optPosition1.Text    = "Center";
                optPosition2.Text    = "Centroid";
                optPosition3.Text    = "Interior point";
                optPosition4.Visible = false;

                optPosition1.Tag = tkLabelPositioning.lpCenter;
                optPosition2.Tag = tkLabelPositioning.lpCentroid;
                optPosition3.Tag = tkLabelPositioning.lpInteriorPoint;

                groupBox5.Height -= 30;
                groupBox4.Top    -= 30;
                this.Height      -= 30;

                optPosition2.Checked = true;        // TODO: choose according Labels.Positioning
            }
            else if (type == ShpfileType.SHP_POLYLINE)
            {
                optPosition1.Text = "First segment";
                optPosition2.Text = "Last segment";
                optPosition3.Text = "Middle segment";
                optPosition4.Text = "The longest segment";

                optPosition1.Tag = tkLabelPositioning.lpFirstSegment;
                optPosition2.Tag = tkLabelPositioning.lpLastSegment;
                optPosition3.Tag = tkLabelPositioning.lpMiddleSegment;
                optPosition4.Tag = tkLabelPositioning.lpLongestSegement;

                optPosition4.Checked       = true; // TODO: choose according Labels.Positioning
                cboLineOrientation.Enabled = true;
            }
            else
            {
                panel1.Visible       = true;
                optPosition1.Visible = false;
                optPosition2.Visible = false;
                optPosition3.Visible = false;
                optPosition4.Visible = false;
                this.Height         -= 100;
                groupBox4.Visible    = false;

                optAlignBottomCenter.Checked = (m_alignment == tkLabelAlignment.laBottomCenter);
                optAlignBottomLeft.Checked   = (m_alignment == tkLabelAlignment.laBottomLeft);
                optAlignBottomRight.Checked  = (m_alignment == tkLabelAlignment.laBottomRight);
                optAlignCenterLeft.Checked   = (m_alignment == tkLabelAlignment.laCenterLeft);
                optAlignCenterRight.Checked  = (m_alignment == tkLabelAlignment.laCenterRight || m_alignment == tkLabelAlignment.laCenter);
                optAlignTopCenter.Checked    = (m_alignment == tkLabelAlignment.laTopCenter);
                optAlignTopLeft.Checked      = (m_alignment == tkLabelAlignment.laTopLeft);
                optAlignTopRight.Checked     = (m_alignment == tkLabelAlignment.laTopRight);

                // Applicable for polyline and polygon shapefiles
                //throw new Exception("AddLabelsForm: invalid shapefile type");
            }

            // line orientation
            cboLineOrientation.Items.Clear();
            cboLineOrientation.Items.Add("Horizontal");
            cboLineOrientation.Items.Add("Parallel");
            cboLineOrientation.Items.Add("Perpendicular");
            cboLineOrientation.SelectedIndex = 1;
        }
Esempio n. 10
0
 public DrawingOptions(ShapeDrawingOptions options, ShpfileType type)
 {
     Options = options;
     Type    = type;
 }
Esempio n. 11
0
 /// <summary>
 /// Tries to open specified file as OGR layer.
 /// </summary>
 /// <remarks>When preferedShapeType is set to default ShpfileType.SHP_NULLSHAPE value or there is no layer
 /// with preferedShapeType, then the first layer in datasource will be returned.</remarks>
 /// <param name="Filename">Filename of the datasource to be opened.</param>
 /// <param name="preferedShapeType">Sets type of layer to be returned from datasource in case there are multiple layers available.</param>
 /// <param name="forUpdate">True in case layer should be open in read/write mode.</param>
 /// <returns>Instance of OgrLayer or null on failure.</returns>
 /// \new493 Added in version 4.9.3
 public OgrLayer OpenVectorLayer(string Filename, ShpfileType preferedShapeType = ShpfileType.SHP_NULLSHAPE, bool forUpdate = false)
 {
     throw new NotImplementedException();
 }
Esempio n. 12
0
 public static int VerticalIconOffset(this AxMap map, ShapeDrawingOptions opt, ShpfileType shpType)
 {
     if (shpType == ShpfileType.SHP_POINT && opt.Picture != null &&
         opt.PointType == tkPointSymbolType.ptSymbolPicture)
     {
         return((int)(((double)opt.Picture.Height * opt.PictureScaleY) / 2.0 + 0.5));
     }
     return(0);
 }
Esempio n. 13
0
        /// <summary>
        /// Displays symbology form of the appropriate type
        /// </summary>
        public static Form GetSymbologyForm(LegendControl.Legend legend, int layerHandle, ShpfileType type, ShapeDrawingOptions options, bool applyDisabled)
        {
            Form form    = null;
            var  shpType = Globals.ShapefileType2D(type);
            var  layer   = legend.Layers.ItemByHandle(layerHandle);

            if (shpType == ShpfileType.SHP_POINT || shpType == ShpfileType.SHP_MULTIPOINT)
            {
                form = new PointsForm(legend, layer, options, applyDisabled);
            }
            else if (shpType == ShpfileType.SHP_POLYLINE)
            {
                form = new LinesForm(legend, layer, options, applyDisabled);
            }
            else if (shpType == ShpfileType.SHP_POLYGON)
            {
                form = new PolygonsForm(legend, layer, options, applyDisabled);
            }
            return(form);
        }
Esempio n. 14
0
 /// <summary>
 /// Creates a new empty layer in the datasource.
 /// </summary>
 /// <remarks>
 /// SRID will be set to 0 if null or empty GeoProjection object is passed.
 /// See OgrDatasource.ImportShapefile for the details on creation options.\n
 ///
 /// Known issues: creation of layer in nonexistent schema in PostGIS databases completes successfully,
 /// yet the neither schema nor objects in it are visible afterwards.
 /// </param>
 /// </remarks>
 /// <param name="layerName">Name of the new layer.</param>
 /// <param name="ShpType">ShpType of the new layer. Will be converted to appropriate OGRwkbGeometryType.</param>
 /// <param name="Projection">%GeoProjection object which sets SRID of the new layer.</param>
 /// <param name="creationOptions">Format specific creation options separated with semicolon, e.g.
 /// "OVERWRITE=YES;MW_MULTI_PART=no". </param>
 /// <returns>True on success.</returns>
 public bool CreateLayer(string layerName, ShpfileType ShpType, GeoProjection Projection = null, string creationOptions = "")
 {
     throw new NotImplementedException();
 }
Esempio n. 15
0
 public ComplexGeometryType(GeometryType type, ZValueType zValue = Enums.ZValueType.None)
 {
     _shpType = GeometryHelper.GeometryType2ShpType(GeometryType, ZValueType);
 }
Esempio n. 16
0
 internal ComplexGeometryType(ShpfileType shpType)
 {
     _shpType = shpType;
 }