Ejemplo n.º 1
0
        public override void createStyle(Shapefile sf)
        {
            LinePattern pattern = new LinePattern();

            pattern.AddLine(utils.ColorByName(tkMapColor.Black), 6.0f, tkDashStyle.dsSolid);
            pattern.AddLine(utils.ColorByName(tkMapColor.White), 5.0f, tkDashStyle.dsDot);


            ShapeDrawingOptions options = sf.DefaultDrawingOptions;


            // standard fill
            options.FillTransparency = 50;
            options.LineWidth        = 3;
            options.LineVisible      = true;
            options.LineColor        = utils.ColorByName(tkMapColor.Blue);
            options.LineStipple      = tkDashStyle.dsSolid;

            /*
             * addExpression(sf, "Casa madera y/o adobe", "[Name] = \"Casa madera y/o adobe\"", "rgb(37, 49, 232)");
             * addExpression(sf, "Casa ladrillo", "[Name] = \"Casa ladrillo\"", "rgb(13, 22, 168)");
             * addExpression(sf, "Escuela", "[Name] = \"Escuela estándar (muros de concreto)\"", "rgb(19, 25, 117)");
             * addExpression(sf, "Iglesia", "[Name] = \"Iglesia\"", "rgb(80, 88, 178)");
             * addExpression(sf, "Colegio", "[Name] = \"Colegio estatal\"", "rgb(50, 92, 163)");
             * addExpression(sf, "Tanque", "[Name] = \"Tanque de agua\"", "rgb(33, 91, 188)");
             * addExpression(sf, "Molino", "[Name] = \"Molino\"", "rgb(25, 66, 135)");
             * addExpression(sf, "Taller", "[Name] = \"Taller de bicicleta\"", "rgb(57, 66, 168)");
             * addExpression(sf, "Adminis", "[Name] = \"Edificio de administración\"", "rgb(65, 51, 155)");
             * addExpression(sf, "Mercado", "[Name] = \"Mercado\"", "rgb(26, 34, 127)");
             * addExpression(sf, "Hospital", "[Name] = \"Hospital\"", "rgb(57, 62, 119)");
             * addExpression(sf, "Escuela principal", "[Name] = \"Escuela principal\"", "rgb(40, 96, 186)");
             * addExpression(sf, "Puesto", "[Name] = \"Puesto de salud\"", "rgb(96, 36, 153)");
             *
             * addExpression(sf, "Infraestructura", "[Name] = \"Infraestructura de comunicación\"", "rgb(74, 39, 107)");
             * addExpression(sf, "Tubería", "[Name] = \"Tubería de agua al aire libre\"", "rgb(60, 22, 96)");
             * addExpression(sf, "Aeropuerto", "[Name] = \"Terminal / Aeropuerto\"", "rgb(63, 11, 112)");
             *
             * addExpression(sf, "Carretera", "[Name] = \"Carretera principal (pavimentada)\"", "rgb(103, 152, 198)");
             * addExpression(sf, "Camino", "[Name] = \"Camino comunitario (para vehiculos, no pavimentado)\"", "rgb(51, 97, 140)");
             * addExpression(sf, "Puente", "[Name] = \"Puente comunitario (para vehiculos, no pavimentado)\"", "rgb(10, 48, 84)");
             * addExpression(sf, "electrica", "[Name] = \"Línea electrica (incluyendo postes)\"", "rgb(40, 134, 224)");
             * addExpression(sf, "Transformador", "[Name] = \"Transformador\"", "rgb(31, 110, 186)");
             * addExpression(sf, "Reservorio", "[Name] = \"Reservorio (incluyendo bombas)\"", "rgb(31, 152, 168)");
             * addExpression(sf, "Canal", "[Name] = \"Canal de riego\"", "rgb(26, 194, 216)");
             * addExpression(sf, "Huerto", "[Name] = \"Huerto\"", "rgb(17, 139, 155)");
             * addExpression(sf, "Campos", "[Name] = \"Campos de maíz, frijol, sorghum\"", "rgb(14, 167, 178)");
             * addExpression(sf, "Frutales", "[Name] = \"Frutales\"", "rgb(36, 133, 140)");
             * addExpression(sf, "Camaroneras", "[Name] = \"Camaroneras\"", "rgb(57, 62, 119)");
             *
             * addExpression(sf, "Pastos", "[Name] = \"Pastos, Pastizales\"", "rgb(25, 66, 135)");
             */
            addExpression(sf, "NotStandard", "[IsStandard] = 0", "rgb(255, 0, 0)");

            sf.Categories.ApplyExpressions();
        }
Ejemplo n.º 2
0
        // <summary>
        // Creates and displayes custom line patterns
        // </summary>
        public void LinePattern(AxMap axMap1, string iconPath)
        {
            axMap1.Projection = tkMapProjection.PROJECTION_NONE;

            var sf = this.CreateLines();

            axMap1.AddLayer(sf, true);

            var utils = new Utils();

            // railroad pattern
            LinePattern pattern = new LinePattern();

            pattern.AddLine(utils.ColorByName(tkMapColor.Black), 6.0f, tkDashStyle.dsSolid);
            pattern.AddLine(utils.ColorByName(tkMapColor.White), 5.0f, tkDashStyle.dsDot);

            ShapefileCategory ct = sf.Categories.Add("Railroad");

            ct.DrawingOptions.LinePattern    = pattern;
            ct.DrawingOptions.UseLinePattern = true;
            sf.set_ShapeCategory(0, 0);

            // river pattern
            pattern = new LinePattern();
            pattern.AddLine(utils.ColorByName(tkMapColor.DarkBlue), 6.0f, tkDashStyle.dsSolid);
            pattern.AddLine(utils.ColorByName(tkMapColor.LightBlue), 4.0f, tkDashStyle.dsSolid);

            ct = sf.Categories.Add("River");
            ct.DrawingOptions.LinePattern    = pattern;
            ct.DrawingOptions.UseLinePattern = true;
            sf.set_ShapeCategory(1, 1);

            // road with direction
            pattern = new LinePattern();
            pattern.AddLine(utils.ColorByName(tkMapColor.Gray), 8.0f, tkDashStyle.dsSolid);
            pattern.AddLine(utils.ColorByName(tkMapColor.Yellow), 7.0f, tkDashStyle.dsSolid);
            LineSegment segm = pattern.AddMarker(tkDefaultPointSymbol.dpsArrowRight);

            segm.Color          = utils.ColorByName(tkMapColor.Orange);
            segm.MarkerSize     = 10;
            segm.MarkerInterval = 32;

            ct = sf.Categories.Add("Direction");
            ct.DrawingOptions.LinePattern    = pattern;
            ct.DrawingOptions.UseLinePattern = true;
            sf.set_ShapeCategory(2, 2);
        }
Ejemplo n.º 3
0
        public override void createStyle(Shapefile sf)
        {
            LinePattern pattern = new LinePattern();

            pattern.AddLine(utils.ColorByName(tkMapColor.Black), 6.0f, tkDashStyle.dsSolid);
            pattern.AddLine(utils.ColorByName(tkMapColor.White), 5.0f, tkDashStyle.dsDot);

            ShapeDrawingOptions options = sf.DefaultDrawingOptions;

            // standard fill

            options.FillColor      = utils.ColorByName(tkMapColor.Gray);
            options.LineWidth      = 2;
            options.LinePattern    = pattern;
            options.UseLinePattern = true;
            options.LineVisible    = true;
            options.LineColor      = utils.ColorByName(tkMapColor.LightYellow);
        }
Ejemplo n.º 4
0
        // <summary>
        // Loads the layers, registers event handlers
        // </summary>
        public void Tracking(AxMap axMap1, string dataPath)
        {
            axMap1.Projection             = tkMapProjection.PROJECTION_NONE;
            axMap1.GrabProjectionFromData = true;

            axMap1.DisableWaitCursor = true;

            string filename1 = dataPath + "buildings.shp";
            string filename2 = dataPath + "roads.shp";
            string filename3 = dataPath + "path.shp";

            if (!File.Exists(filename1) || !File.Exists(filename2) || !File.Exists(filename3))
            {
                MessageBox.Show("Couldn't find the files (buildings.shp, roads.shp, path.shp): " + dataPath);
            }
            else
            {
                Shapefile sf = new Shapefile();
                sf.Open(filename1, null);
                axMap1.AddLayer(sf, true);

                sf = new Shapefile();
                sf.Open(filename2, null);
                sf.Labels.Generate("[Name]", tkLabelPositioning.lpLongestSegement, false);

                Utils       utils   = new Utils();
                LinePattern pattern = new LinePattern();
                pattern.AddLine(utils.ColorByName(tkMapColor.Brown), 10.0f, tkDashStyle.dsSolid);
                pattern.AddLine(utils.ColorByName(tkMapColor.Yellow), 9.0f, tkDashStyle.dsSolid);
                sf.DefaultDrawingOptions.LinePattern    = pattern;
                sf.DefaultDrawingOptions.UseLinePattern = true;
                axMap1.AddLayer(sf, true);

                sf = new Shapefile();
                sf.Open(filename3, null);
                m_path              = sf.Shape[0];
                axMap1.MapUnits     = tkUnitsOfMeasure.umMeters;
                axMap1.CurrentScale = 5000.0;

                m_timer.Interval = 250;
                m_timer.Tick    += TimerTick;
                m_timer.Start();
            }
        }
        public override void createStyle(Shapefile sf)
        {
            LinePattern pattern = new LinePattern();

            pattern.AddLine(utils.ColorByName(tkMapColor.Black), 6.0f, tkDashStyle.dsSolid);
            pattern.AddLine(utils.ColorByName(tkMapColor.White), 5.0f, tkDashStyle.dsDot);


            ShapeDrawingOptions options = sf.DefaultDrawingOptions;

            sf.Labels.Generate("[Index]", tkLabelPositioning.lpInteriorPoint, false);
            sf.Labels.FontOutlineColor   = utils.ColorByName(tkMapColor.Black);
            sf.Labels.FontOutlineVisible = true;
            sf.Labels.FontSize           = 12;
            sf.Labels.FontColor          = utils.ColorByName(tkMapColor.White);
            sf.Labels.FrameVisible       = false;
            // standard fill
            options.FillTransparency = 70;
            options.LineWidth        = 2;
            options.LineVisible      = true;
            options.LineColor        = utils.ColorByName(tkMapColor.Black);
            options.LineStipple      = tkDashStyle.dsSolid;


            ShapefileCategory ct = sf.Categories.Add("Danger");

            ct.Expression = "[Index] >= 7";
            ct.DrawingOptions.FillColor = utils.ColorByName(tkMapColor.Red);


            ct            = sf.Categories.Add("Medium");
            ct.Expression = "[Index] < 7";
            ct.DrawingOptions.FillColor = utils.ColorByName(tkMapColor.Yellow);


            ct            = sf.Categories.Add("Low");
            ct.Expression = "[Index] < 3";
            ct.DrawingOptions.FillColor = utils.ColorByName(tkMapColor.Green);

            sf.Categories.ApplyExpressions();
        }
Ejemplo n.º 6
0
        /// <summary>
        /// 加入样式
        /// </summary>
        private void btnAddStyle_Click(object sender, EventArgs e)
        {
            MapWinGIS.LinePattern pattern = new LinePattern();
            this.ApplyPattern();

            if (_options.UseLinePattern && _options.LinePattern != null)
            {
                string s = _options.LinePattern.Serialize();
                pattern.Deserialize(s);
            }
            else
            {
                pattern.AddLine(_options.LineColor, _options.LineWidth, _options.LineStipple);
            }
            linePatternControl1.AddPattern(pattern);
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Adds current options as a style to the list
        /// </summary>
        private void btnAddStyle_Click(object sender, EventArgs e)
        {
            MapWinGIS.LinePattern pattern = new LinePattern();
            this.ApplyPattern();

            if (_options.UseLinePattern && _options.LinePattern != null)
            {
                string s = _options.LinePattern.Serialize();
                pattern.Deserialize(s);
            }
            else
            {
                // there is no actual patter, a single line only;
                // pattern object should be created on the fly
                pattern.AddLine(_options.LineColor, _options.LineWidth, _options.LineStipple);
            }
            linePatternControl1.AddPattern(pattern);
        }
Ejemplo n.º 8
0
        /// <summary>
        /// 根据坐标在地图上划线
        /// </summary>
        /// <param name="Xstart"></param>
        /// <param name="Ystart"></param>
        /// <param name="Xend"></param>
        /// <param name="Yend"></param>
        public int WriteLine(ClassLine line, LineSet lineSet)
        {
            Shape shp = new Shape();

            shp.Create(ShpfileType.SHP_POLYLINE);

            Point pnt = new Point();

            pnt.x = line.startX;
            pnt.y = line.startY;
            int index = shp.numPoints;

            shp.InsertPoint(pnt, ref index);

            pnt   = new Point();
            pnt.x = line.endX;
            pnt.y = line.endY;
            index = shp.numPoints;
            shp.InsertPoint(pnt, ref index);

            index = sf.NumShapes;
            sf.EditInsertShape(shp, ref index);


            //var utils = new Utils();
            //LinePattern pattern = new LinePattern();
            //pattern.AddLine(utils.ColorByName(lineSet.color), lineSet.Width, lineSet.style);
            //ShapefileCategory ct = sf.Categories.Add("Railroad");
            //ct.DrawingOptions.LinePattern = pattern;
            //ct.DrawingOptions.UseLinePattern = true;
            //sf.set_ShapeCategory(0, 0);

            var         utils   = new Utils();
            LinePattern pattern = new LinePattern();

            pattern.AddLine(utils.ColorByName(lineSet.color), lineSet.Width, lineSet.style);
            sf.DefaultDrawingOptions.LinePattern    = pattern;
            sf.DefaultDrawingOptions.UseLinePattern = true;
            layerHandle = map.AddLayer(sf, true);



            return(layerHandle);
        }
        public override void createStyle(Shapefile sf)
        {
            LinePattern pattern = new LinePattern();

            pattern.AddLine(utils.ColorByName(tkMapColor.Black), 6.0f, tkDashStyle.dsSolid);

            ShapeDrawingOptions options = sf.DefaultDrawingOptions;


            // standard fill
            options.FillTransparency = 60;
            options.LineWidth        = 2;
            options.LineVisible      = true;
            options.LineColor        = utils.ColorByName(tkMapColor.Black);
            options.LineStipple      = tkDashStyle.dsSolid;

            addExpression(sf, "With Resilience", "[savedvalues] > 1", "rgb(194, 66, 244)");
            addExpression(sf, "With Resilience", "[savedvalues] = 1", "rgb(65, 160, 244)");

            sf.Categories.ApplyExpressions();
        }
Ejemplo n.º 10
0
 public void AddLine(Color color, float width, DashStyle style)
 {
     _pattern.AddLine(ColorHelper.ColorToUInt(color), width, (tkDashStyle)style);
 }
        // <summary>
        // Calculates the length of intersection of rivers and land parcels
        // </summary>
        public void IntersectionLength(AxMap axMap1, ToolStripStatusLabel label, string dataPath)
        {
            axMap1.Projection             = tkMapProjection.PROJECTION_NONE;
            axMap1.GrabProjectionFromData = true;

            string filename1 = dataPath + "landuse.shp";
            string filename2 = dataPath + "waterways.shp";

            if (!File.Exists(filename1) || !File.Exists(filename2))
            {
                MessageBox.Show("The necessary files (waterways.shp, building.shp) are missing: " + dataPath);
            }
            else
            {
                Shapefile sfParcels = new Shapefile();
                sfParcels.Open(filename1, null);
                sfParcels.StartEditingShapes(true, null);

                Field field = new Field {
                    Name = "Length", Type = FieldType.DOUBLE_FIELD, Precision = 10
                };
                int fieldIndex = sfParcels.NumShapes;
                sfParcels.EditInsertField(field, ref fieldIndex, null);

                Shapefile sfRivers = new Shapefile();
                sfRivers.Open(filename2, null);
                sfRivers.StartEditingShapes(true, null);
                Utils utils = new Utils();
                sfRivers.DefaultDrawingOptions.LineWidth = 2;
                sfRivers.DefaultDrawingOptions.LineColor = utils.ColorByName(tkMapColor.Blue);

                Shapefile           sfNew   = sfRivers.Clone();
                ShapeDrawingOptions options = sfNew.DefaultDrawingOptions;

                LinePattern pattern = new LinePattern();
                pattern.AddLine(utils.ColorByName(tkMapColor.Blue), 8, tkDashStyle.dsSolid);
                pattern.AddLine(utils.ColorByName(tkMapColor.LightBlue), 4, tkDashStyle.dsSolid);
                options.LinePattern    = pattern;
                options.UseLinePattern = true;

                for (int i = 0; i < sfParcels.NumShapes; i++)
                {
                    Shape  shp1   = sfParcels.Shape[i];
                    double length = 0.0;    // the length of intersection

                    for (int j = 0; j < sfRivers.NumShapes; j++)
                    {
                        Shape shp2 = sfRivers.Shape[j];
                        if (shp1.Intersects(shp2))
                        {
                            Shape result = shp1.Clip(shp2, tkClipOperation.clIntersection);
                            if (result != null)
                            {
                                int index = sfNew.EditAddShape(result);
                                length += result.Length;
                            }
                        }
                    }
                    sfParcels.EditCellValue(fieldIndex, i, length);
                    label.Text = string.Format("Parcel: {0}/{1}", i + 1, sfParcels.NumShapes);
                    Application.DoEvents();
                }

                // generating charts
                var chartField = new ChartField();
                chartField.Name  = "Length";
                chartField.Color = utils.ColorByName(tkMapColor.LightBlue);
                chartField.Index = fieldIndex;
                sfParcels.Charts.AddField(chartField);
                sfParcels.Charts.Generate(tkLabelPositioning.lpInteriorPoint);
                sfParcels.Charts.ChartType     = tkChartType.chtBarChart;
                sfParcels.Charts.BarHeight     = 100;
                sfParcels.Charts.ValuesVisible = true;
                sfParcels.Charts.Visible       = true;

                axMap1.AddLayer(sfParcels, true);
                axMap1.AddLayer(sfRivers, true);
                axMap1.AddLayer(sfNew, true);
                axMap1.ZoomToMaxExtents();
            }
        }