Exemplo n.º 1
0
        private void DrawFeature(IFeature feature)
        {
            if (LayerData.GeoType == VectorLayer.GEOTYPE_POINT)
            {
                var pos = feature.GeoData[0];
                AddSpot(new Point(pos.X, pos.Y), feature);
                AddLable(new Point(pos.X, pos.Y), LayerLableStyle.GetLable(feature));
            }
            else if (LayerData.GeoType == VectorLayer.GEOTYPE_LINEAR)
            {
                var poly = new PointString(feature.GeoData);
                if (IsRoad())
                {
                    AddRoadStroke(poly.Points.Select(p => new Point(p.X, p.Y)).ToArray(), feature);
                }
                if (!IsRoad())
                {
                    AddPolyline(poly.Points.Select(p => new Point(p.X, p.Y)).ToArray(), feature);
                }
                else
                {
                    AddRoadFill(poly.Points.Select(p => new Point(p.X, p.Y)).ToArray(), feature);
                }

                string        text = LayerLableStyle.GetLable(feature);
                double        linearRepeatInterval = LayerLableStyle.LinearRepeatInterval;
                double        length    = poly.Length();
                List <double> positions = new List <double>(); // mod 20130528 与SVG同步
                if (length > 0 && length < 2 * linearRepeatInterval)
                {
                    positions.Add(length / 2);
                }
                else
                {
                    int index = 1;
                    while (index * linearRepeatInterval < length)
                    {
                        positions.Add(index * linearRepeatInterval);
                        index++;
                    }
                }
                foreach (double position in positions)
                {
                    var    tempPt   = poly.GetPointAtDist(position);
                    double rotation = poly.Dir(position).Heading();
                    double angle    = 180 / Math.PI * rotation;
                    AddLable(new Point(tempPt.X, tempPt.Y), text, angle);
                }
            }
            else if (LayerData.GeoType == VectorLayer.GEOTYPE_REGION)
            {
                var poly = new PointString(feature.GeoData);
                if (poly.Points.Count >= 3)
                {
                    var center = poly.Centroid(); // mod 20130507
                    AddPolygon(poly.Points.Select(p => new Point(p.X, p.Y)).ToArray(), feature);
                    AddLable(new Point(center.X, center.Y), LayerLableStyle.GetLable(feature));
                }
            }
        }
Exemplo n.º 2
0
        private void DrawFeature(IFeature feature)
        {
            if (LayerData.GeoType == "1")
            {
                Geometry.Point2D pos = new Geometry.Point2D(feature.GeoData);
                AddSpot(new Point(pos.x, pos.y), feature);
                AddLable(new Point(pos.x, pos.y), LayerLableStyle.GetLable(feature));
            }
            else if (LayerData.GeoType == "2")
            {
                Geometry.Polyline poly = new Geometry.Polyline(feature.GeoData);
                if (IsRoad())
                {
                    AddRoadStroke(poly.Points.Select(p => new Point(p.x, p.y)).ToArray(), feature);
                }
                if (!IsRoad())
                {
                    AddPolyline(poly.Points.Select(p => new Point(p.x, p.y)).ToArray(), feature);
                }
                else
                {
                    AddRoadFill(poly.Points.Select(p => new Point(p.x, p.y)).ToArray(), feature);
                }

                string        text = LayerLableStyle.GetLable(feature);
                double        linearRepeatInterval = LayerLableStyle.LinearRepeatInterval;
                double        length    = poly.Length;
                List <double> positions = new List <double>(); // mod 20130528 与SVG同步
                if (length > 0 && length < 2 * linearRepeatInterval)
                {
                    positions.Add(length / 2);
                }
                else
                {
                    int index = 1;
                    while (index * linearRepeatInterval < length)
                    {
                        positions.Add(index * linearRepeatInterval);
                        index++;
                    }
                }
                foreach (double position in positions)
                {
                    Geometry.Point2D tempPt   = poly.GetPointAtDist(position);
                    double           tanVal   = poly.GetFirstDerivative(position);
                    double           rotation = Math.Atan(tanVal);
                    double           angle    = 180 / Math.PI * rotation;
                    AddLable(new Point(tempPt.x, tempPt.y), text, angle);
                }
            }
            else if (LayerData.GeoType == "4")
            {
                Geometry.Polygon poly   = new Geometry.Polygon(feature.GeoData);
                Geometry.Point2D center = poly.Centroid; // mod 20130507
                AddPolygon(poly.Points.Select(p => new Point(p.x, p.y)).ToArray(), feature);
                AddLable(new Point(center.x, center.y), LayerLableStyle.GetLable(feature));
            }
        }
Exemplo n.º 3
0
        public virtual void SetData(VectorLayer layer)
        {
            LayerData       = layer;
            LayerStyle      = GetLayerStyle(layer);
            LayerLableStyle = GetLabelStyle(layer);
            Features.Clear();
            Overlays.Clear();
            Children.Clear();
            LabelLayer = new MapLayer();

            if (layer.GeoType == "1")
            {
                foreach (Feature feature in layer.Features)
                {
                    Geometry.Point2D pos = new Geometry.Point2D(feature.GeoData);
                    AddSpot(new Point(pos.x, pos.y), feature);
                    AddLable(new Point(pos.x, pos.y), LayerLableStyle.GetLable(feature));
                }
            }
            else if (layer.GeoType == "2")
            {
                if (IsRoad())
                {
                    foreach (Feature feature in layer.Features)
                    {
                        Geometry.Polyline polyline = new Geometry.Polyline(feature.GeoData);
                        AddRoadStroke(polyline.Points.Select(p => new Point(p.x, p.y)).ToArray(), feature);
                    }
                }
                foreach (Feature feature in layer.Features)
                {
                    Geometry.Polyline poly = new Geometry.Polyline(feature.GeoData);
                    if (!IsRoad())
                    {
                        AddPolyline(poly.Points.Select(p => new Point(p.x, p.y)).ToArray(), feature);
                    }
                    else
                    {
                        AddRoadFill(poly.Points.Select(p => new Point(p.x, p.y)).ToArray(), feature);
                    }
                }
                foreach (Feature feature in layer.Features) // mod 20130516 最后统一加标签
                {
                    Geometry.Polyline poly = new Geometry.Polyline(feature.GeoData);
                    string            text = LayerLableStyle.GetLable(feature);
                    double            linearRepeatInterval = LayerLableStyle.LinearRepeatInterval;
                    double            length = poly.Length;
                    //double scale = 4;  // 这个时候出现主窗口的Scale是不合适的。
                    List <double> positions = new List <double>(); // mod 20130528 与SVG同步
                    if (length > 0 && length < 2 * linearRepeatInterval)
                    {
                        positions.Add(length / 2);
                    }
                    else
                    {
                        int index = 1;
                        while (index * linearRepeatInterval < length)
                        {
                            positions.Add(index * linearRepeatInterval);
                            index++;
                        }
                    }
                    foreach (double position in positions)
                    {
                        Geometry.Point2D tempPt   = poly.GetPointAtDist(position);
                        double           tanVal   = poly.GetFirstDerivative(position);
                        double           rotation = Math.Atan(tanVal);
                        double           angle    = 180 / Math.PI * rotation;
                        AddLable(new Point(tempPt.x, tempPt.y), text, angle);
                    }
                }
            }
            else if (layer.GeoType == "4")
            {
                foreach (Feature feature in layer.Features)
                {
                    Geometry.Polygon poly   = new Geometry.Polygon(feature.GeoData);
                    Geometry.Point2D center = poly.Centroid;
                    AddPolygon(poly.Points.Select(p => new Point(p.x, p.y)).ToArray(), feature);
                    AddLable(new Point(center.x, center.y), LayerLableStyle.GetLable(feature));
                }
            }
        }
Exemplo n.º 4
0
        public virtual void SetData(VectorLayer layer)
        {
            LayerData       = layer;
            LayerStyle      = GetLayerStyle(layer);
            LayerLableStyle = GetLabelStyle(layer);
            Features.Clear();
            Overlays.Clear();
            Children.Clear();
            LabelLayer = new MapLayer();

            if (layer.GeoType == VectorLayer.GEOTYPE_POINT)
            {
                foreach (Feature feature in layer.Features)
                {
                    var pos = feature.GeoData[0];
                    AddSpot(new Point(pos.X, pos.Y), feature);
                    AddLable(new Point(pos.X, pos.Y), LayerLableStyle.GetLable(feature));
                }
            }
            else if (layer.GeoType == VectorLayer.GEOTYPE_LINEAR)
            {
                if (IsRoad())
                {
                    foreach (Feature feature in layer.Features)
                    {
                        var polyline = new PointString(feature.GeoData);
                        AddRoadStroke(polyline.Points.Select(p => new Point(p.X, p.Y)).ToArray(), feature);
                    }
                }
                foreach (Feature feature in layer.Features)
                {
                    var poly = new PointString(feature.GeoData);
                    if (!IsRoad())
                    {
                        AddPolyline(poly.Points.Select(p => new Point(p.X, p.Y)).ToArray(), feature);
                    }
                    else
                    {
                        AddRoadFill(poly.Points.Select(p => new Point(p.X, p.Y)).ToArray(), feature);
                    }
                }
                foreach (Feature feature in layer.Features) // mod 20130516 最后统一加标签
                {
                    var    poly = new PointString(feature.GeoData);
                    string text = LayerLableStyle.GetLable(feature);
                    double linearRepeatInterval = LayerLableStyle.LinearRepeatInterval;
                    double length = poly.Length();
                    //double scale = 4;  // 这个时候出现主窗口的Scale是不合适的。
                    List <double> positions = new List <double>(); // mod 20130528 与SVG同步
                    if (length > 0 && length < 2 * linearRepeatInterval)
                    {
                        positions.Add(length / 2);
                    }
                    else
                    {
                        int index = 1;
                        while (index * linearRepeatInterval < length)
                        {
                            positions.Add(index * linearRepeatInterval);
                            index++;
                        }
                    }
                    foreach (double position in positions)
                    {
                        var    tempPt   = poly.GetPointAtDist(position);
                        double rotation = poly.Dir(position).Heading();
                        double angle    = 180 / Math.PI * rotation;
                        AddLable(new Point(tempPt.X, tempPt.Y), text, angle);
                    }
                }
            }
            else if (layer.GeoType == VectorLayer.GEOTYPE_REGION)
            {
                foreach (Feature feature in layer.Features)
                {
                    var poly   = new PointString(feature.GeoData);
                    var center = poly.Centroid();
                    AddPolygon(poly.Points.Select(p => new Point(p.X, p.Y)).ToArray(), feature);
                    AddLable(new Point(center.X, center.Y), LayerLableStyle.GetLable(feature));
                }
            }
        }