示例#1
0
        public void Render(Feature feature)
        {
            //todo get the index
            //object value = feature[feature.Values.Length - 1];
            //if (value is DBNull) return;
            //int index = Convert.ToInt32(value);
            var count = _expressions.Count;
            int index;

            if (_exprEval != null || _caseValue != null)
            {
                index = -1;
                var value = _exprEval != null ? _exprEval.Evaluate() : _caseValue;
                for (int i = 0; i < _expressions.Count; i++)
                    if (Equals(value, _expressions[i] != null ? ((IDynamicExpression)_expressions[i]).Evaluate() : _whenValues[i]))
                    {
                        index = i;
                        break;
                    }
            }
            else
                index = _expressions.FindIndex(e => e != null && ((IGenericExpression<bool>)e).Evaluate());

            ContainerNodeRenderer branchRenderer;
            if (index >= 0)
                branchRenderer = _caseNode.Nodes[index].Renderer as ContainerNodeRenderer;
            else if (_caseNode.Nodes.Count > _expressions.Count)
                branchRenderer = _caseNode.Nodes[count].Renderer as ContainerNodeRenderer;
            else
                return;

            branchRenderer.Render(feature);

            RenderCount++;
        }
示例#2
0
        public override void Render(Feature feature)
        {
            //_resolver.Feature = feature;
            var image = string.IsNullOrEmpty(_marker.File) ? null : GetImage(_marker.File.ToLower());

            foreach (var point in Renderer.GetPoint(feature.Geometry))
                DrawPoint(point, image);
        }
示例#3
0
        public override void Render(Feature feature)
        {
            if (!Visible)
                return;

            Renderer.Render(_renderers, feature);

            RenderCount++;
        }
示例#4
0
        public override void Render(Feature feature)
        {
            int tStart = Environment.TickCount;

            Renderer.Graphics.SmoothingMode = SmoothingMode;

            RenderChildren();

            RenderCount++;
            RenderTime = new TimeSpan((Environment.TickCount - tStart) * 10000);
        }
        public IEnumerable<Feature> GetFeatures(Feature feature)
        {
            var newFeature = _outputFeatureType.NewFeature(feature.Fid, feature.Values);
            var id = feature.Values.Length;
            var x = id + 1;
            var y = x + 1;
            var geometry = feature.Geometry;

            foreach (var lineString in Renderer.GetLineString(geometry))
            {
                int start, end, inc = 1;
                var vertices = lineString.CoordinateSequence;
                switch (_verticesEnumerator.Mode)
                {
                    case VerticesEnumeratorMode.All:
                        start = 0;
                        end = vertices.Count - 1;
                        break;
                    case VerticesEnumeratorMode.Range:
                        start = _verticesEnumerator.Start;
                        end = _verticesEnumerator.End;
                        inc = _verticesEnumerator.Increment;
                        break;
                    case VerticesEnumeratorMode.First:
                        start = end = 0;
                        break;
                    case VerticesEnumeratorMode.Last:
                        start = end = vertices.Count - 1;
                        break;
                    case VerticesEnumeratorMode.Outer:
                        start = 0;
                        inc = end = vertices.Count - 1;
                        break;
                    case VerticesEnumeratorMode.Inner:
                        start = 1;
                        end = vertices.Count - 2;
                        break;
                    default:
                        throw new InvalidEnumArgumentException();
                }

                for (int i = start; i <= end; i += inc)
                {
                    var vertex = vertices.GetCoordinate(i);
                    newFeature[id] = i;
                    newFeature[x] = vertex.X;
                    newFeature[y] = vertex.Y;
                    newFeature.Geometry = new NetTopologySuite.Geometries.Point(vertex) { SRID = geometry.SRID, M = 0 };

                    yield return newFeature;
                }
            }
        }
示例#6
0
        public override void Render(Feature feature)
        {
            try
            {
                foreach (var newFeature in GetFeatures(feature))
                {
                    Renderer.FeatureVarResolver.Feature = newFeature;

                    base.Render(newFeature);
                }
            }
            finally
            {
                Renderer.FeatureVarResolver.Feature = feature;
            }
        }
        public override void Render(Feature feature)
        {
            var newFeature = new Feature(feature.FeatureType, feature.Fid, feature.Values);
            newFeature.Geometry = CalibrateGeometry(feature.Geometry);

            //_resolver.Feature = newFeature;
            Renderer.FeatureVarResolver.Feature = newFeature;
            try
            {
                //RenderPath(node, newFeature, path);
                base.Render(newFeature);
            }
            finally
            {
                Renderer.FeatureVarResolver.Feature = feature;
            }
        }
示例#8
0
        public override void Render(Feature scrapFeature)
        {
            if(!(Visible && _layer.IsVisibleAt(Renderer.Zoom)))
                return;

            var tStart = Environment.TickCount;

            Renderer.Graphics.SmoothingMode = SmoothingMode;

            try
            {
                var cnt = 0;

                foreach (var feature in _layer.GetFeatures(_featureType, _layer, Renderer.Window))
                {
                    Renderer.Context.Variables[Renderer.FEATURE_VAR] = feature;
                    if (cnt >= _layer.MaxRender)
                        return;

                    Renderer.FeatureVarResolver.Feature = feature;
                    Renderer.Render(Renderers, feature);
                    
                    cnt++;
                }

                FeatureCount = cnt;
                Renderer.PerformLayerRendered(new LayerEventArgs(_layer));
            }
            catch (Exception ex)
            {
                var args = new LayerFailedEventArgs(_layer, ex);
                Renderer.PerformLayerFailed(args);
            }
            finally
            {
                Renderer.FeatureVarResolver.Feature = null; //restore old feature
            }
            
            RenderCount++;
            RenderTime = new TimeSpan((Environment.TickCount - tStart) * 10000);
        }
示例#9
0
        public override void Render(Feature feature)
        {
            //_resolver.Feature = feature;

            var color = GetRenderColor(_opacityEvaluator, _opacity, _colorEvaluator, _color);

            if (feature != null)
            {
                _path.Reset();
                foreach (var lineString in Renderer.GetLineString(feature.Geometry))
                    AddToPath(lineString, _path);

                using (var brush = new SolidBrush(color))
                    Renderer.Graphics.FillPath(brush, _path);
            }

            //using (var path = new GraphicsPath())
            //{
            //    switch (geometry.GeometryType)
            //    {
            //        case GeometryType2.Polygon:
            //            FillPolygon(brush, path, (Polygon)geometry);
            //            break;
            //        case  GeometryType2.MultiPolygon:
            //            foreach (var polygon in ((MultiPolygon)geometry).Polygons)
            //            {
            //                FillPolygon(brush, path, polygon);
            //                path.Reset();
            //            }
            //            break;
            //        case GeometryType2.GeometryCollection:
            //            throw new NotImplementedException();
            //        default:
            //            throw new Exception("Unsuported geometry type for solid fill: " + geometry.GeometryType);
            //    }
            //}
        }
 public override void Render(Feature feature)
 {
     foreach (var newFeature in GetFeatures(feature))
         Renderer.Render(_verticesEnumerator, newFeature);
     
     RenderCount++;
 }
示例#11
0
		public Feature NewFeature(long fid)
		{
			var feature = new Feature(this, fid, new object[FieldCount]);
			return feature;
		}
示例#12
0
 public void Render(Feature feature)
 {
     _renderer.Context.Variables[_variable.Name] = _value;
     RenderCount++;
 }
示例#13
0
 public abstract void Render(Feature feature);
示例#14
0
        IEnumerable<Feature> GetFeatures(Feature feature, double start, double end, double Increment, double offset)
        {
            var newFeature = _outputFeatureType.NewFeature(feature.Fid, feature.Values);
            var geometry = feature.Geometry;

            for (var m = start; m <= end; m += Increment)
            {
                var loc = LengthLocationMap.GetLocation(geometry, m);
                var seg = loc.GetSegment(geometry);
                var coord = _offsetEvaluator != null ? seg.PointAlongOffset(loc.SegmentFraction, offset) : seg.PointAlong(loc.SegmentFraction);
                coord = coord.WithMeasure(m);

                if (_xIndex > 0) newFeature[_xIndex] = coord.X;
                if (_yIndex > 0) newFeature[_yIndex] = coord.Y;
                if (_zIndex > 0) newFeature[_zIndex] = coord.Z;
                if (_mIndex > 0) newFeature[_mIndex] = coord.M;
                if (_angleIndex >= 0) newFeature[_angleIndex] = seg.Angle / Math.PI * 180;

                newFeature.Geometry = new NetTopologySuite.Geometries.Point(coord) { SRID = geometry.SRID };
                yield return newFeature;

            }
        }
示例#15
0
        private IEnumerable<Feature> GetFeatures(Feature feature)
        {
            var geometry = feature.Geometry;

            var start = Evaluate(_startEvaluator, _start);
            double end = Evaluate(_endEvaluator, _end);
            var increment = Evaluate(_incEvaluator, _increment);
            var offset = Evaluate(_offsetEvaluator, _offset);

            switch (geometry.OgcGeometryType)
            {
                case OgcGeometryType.LineString:
                //case OgcGeometryType.LineStringZ:
                case OgcGeometryType.MultiLineString:
                //case OgcGeometryType.MultiLineStringZ:
                    if (start < 0) start += geometry.Length;
                    if(end < 0) end += geometry.Length;
                    return GetFeatures(feature, start, end, increment, offset);
                //case OgcGeometryType.LineStringM:
                //case OgcGeometryType.LineStringZM:
                //case OgcGeometryType.MultiLineStringM:
                //case OgcGeometryType.MultiLineStringZM:
                //    return GetFeaturesM(feature, start, end, increment, offset);
                default:
                    throw new InvalidEnumArgumentException();
            }
        }
示例#16
0
        public override void Render(Feature feature)
        {
            if (_recursion > _window.MaxRecursion)
                return;
            RenderCount++;

            var geometry = feature.Geometry;
            //geometry = geometry.Envelope;

            if (geometry.OgcGeometryType != OgcGeometryType.Polygon &&
                geometry.OgcGeometryType != OgcGeometryType.MultiPolygon)
                return;

            if (feature.Fid != 6306)
                return;
            
            //evaluate fields
            var centerX = Evaluate(_centerXEvaluator, _centerX);
            var centerY = Evaluate(_centerYEvaluator, _centerY);
            var zoom = Evaluate(_zoomEvaluator, _zoom);
            var angle = Evaluate(_angleEvaluator, _angle);
            
            var centroid = geometry.Centroid.ToWinPoint();

            //temporary debug value
            //_zoom = (_zoom + 10) % 360;
            //centerX = centroid.X + 25;
            //centerY = centroid.Y;
            //zoom = 0.5;
            //angle = -_zoom;
            
            //clip path coordinates      
            var coordinates = ToWinPointArray(geometry.Coordinates);
            Renderer.Transform(coordinates);
            var coordinatesF = coordinates.ToPointFArray();
            var clipPath = new GraphicsPath();
            clipPath.AddPolygon(coordinatesF);

            //camera transform
            var camera = new WinMatrix();
            camera.Translate(-centroid.X, -centroid.Y);
            camera.Scale(1/zoom, 1/zoom);
            camera.Rotate(-angle);
            camera.Translate(centerX, centerY);

            //camera polygon
            coordinates = ToWinPointArray(geometry.Coordinates);
            camera.Transform(coordinates);

            var queryWindow = new Envelope();
            ExpendToInclude(queryWindow, coordinates);

            var oldMatrix = Renderer.Matrix;
            var invCamera = camera;
            invCamera.Invert();
            var newMatrix = invCamera * oldMatrix;

            var newTranslate = newMatrix;
            newTranslate.OffsetX = newTranslate.OffsetY = 0;
            newTranslate.Invert();
            newTranslate = newMatrix * newTranslate;

            Feature queryFeature = null;
            Feature windowTargetFeature = null;
            var newTransform = new System.Drawing.Drawing2D.Matrix((float)newMatrix.M11, (float)newMatrix.M12, (float)newMatrix.M21, (float)newMatrix.M22, 0f, 0f);
            var oldWindow = Renderer.Window;
            var savedState = Renderer.Graphics.Save();
            var oldModelView = Renderer.Translate;
            var oldZoom = Renderer.Zoom;
            //var oldAngle = Renderer.Angle;
            
            _recursion++;

            int i = 0;
            while (i < Renderers.Count)
            {
                var renderer = Renderers[i];
                var childNode = renderer.Node;
                if (childNode is WindowQuery)
                {
                    if (queryFeature == null)
                    {
                        queryFeature = new Feature(feature);
                        queryFeature.Geometry = Util.ToPolygon(queryWindow);
                    }

                    do
                        renderer.Render(queryFeature);
                    while (++i < Renderers.Count && (childNode = (renderer = Renderers[i]).Node) is WindowQuery);
                }
                else if (childNode is WindowTarget)
                {
                    if (windowTargetFeature == null)
                    {
                        windowTargetFeature = new Feature(feature);
                        windowTargetFeature.Geometry = new Polygon(new LinearRing(ToCoordinateArray(coordinates)));
                    }

                    do
                        renderer.Render(windowTargetFeature);
                    while (++i < Renderers.Count && (childNode = (renderer = Renderers[i]).Node) is WindowTarget);
                }
                else
                {
                    try
                    {
                        Renderer.Window = queryWindow;
                        if (_window.Clip)
                        {
                            var region = Renderer.Graphics.Clip;
                            if (region != null)
                            {
                                region.Intersect(clipPath);
                                Renderer.Graphics.Clip = region;
                            }
                            else
                                Renderer.Graphics.SetClip(clipPath);
                        }

                        Renderer.Matrix = newMatrix;
                        Renderer.Translate = newTranslate;
                        Renderer.Graphics.Transform = newTransform;
                        Renderer.Zoom *= zoom;
                        //Renderer.Angle += angle;

                        //Renderer.Graphics.Clear(Evaluate(_bgColorEvaluator, _bgColor));

                        do
                            renderer.Render(feature);
                        while (++i < Renderers.Count && !((childNode = (renderer = Renderers[i]).Node) is WindowQuery || childNode is WindowTarget));
                    }
                    finally
                    {
                        Renderer.Window = oldWindow;
                        Renderer.Graphics.Restore(savedState);
                        Renderer.Translate = oldModelView;
                        Renderer.Zoom = oldZoom;
                        //Renderer.Angle = oldAngle;
                        Renderer.Matrix = oldMatrix;
                        _recursion--;
                    }
                }
            }

            ////debug: render camera polygon
            //Renderer.Transform(coordinates);
            //coordinatesF = coordinates.ToPointFArray();
            //using (var brush = new SolidBrush(Color.FromArgb(50, Color.Red)))
            //    Renderer.Graphics.FillPolygon(brush, coordinatesF);

            ////debug: render camera envelope
            //var points = new[] { new WinPoint(queryWindow.MinX, queryWindow.MinY), new WinPoint(queryWindow.MaxX, queryWindow.MaxY) };
            //Renderer.Transform(points);
            //var size = points[1] - points[0];
            //using (var brush = new SolidBrush(Color.FromArgb(50, Color.Green)))
            //    Renderer.Graphics.FillRectangle(brush, (float)points[0].X, (float)points[0].Y, (float)size.X, (float)size.Y);
        }
示例#17
0
        private void RenderText(Feature feature, IPoint geometry, float size, float angle, string content, Font f, Brush brush, SizeF stringSize, ContentAlignment alignment)
        {
            geometry.ToWinPoint(ref _tempPoint);
            var pointF = Renderer.Transform(_tempPoint).ToPointF();
            var basePoint = new PointF(pointF.X, pointF.Y);

            
            pointF.Y -= (float)GetVerticalAlignentOffset(alignment, stringSize.Height);
            pointF.X += (float)GetHorizontalAligmentOffset(alignment, stringSize.Width);



            //using (var pen = new Pen(text.Color, 1 / (float)_scale))
            //{
            //    _g.DrawLine(pen, basePoint.X, basePoint.Y, basePoint.X + stringSize.Width, basePoint.Y);
            //    _g.DrawEllipse(pen, basePoint.X - 2, basePoint.Y - 2, 4, 4);
            //}

            var m = new Matrix();
            m.RotateAt(-angle, basePoint);
            var scaleX = (float)Evaluate(_scaleXEvaluator, _scaleX);
            var scaleY = (float)Evaluate(_scaleXEvaluator, _scaleY);

            m.Multiply(new Matrix(scaleX, 0.0f, 0.0f, scaleY, basePoint.X - (scaleX * basePoint.X), basePoint.Y - (scaleY * basePoint.Y)));
            Renderer.Graphics.MultiplyTransform(m);

            if (_labelBoxRenderer != null && _labelBoxRenderer.Visible) 
            {
                var oldModelView = Renderer.Translate;
                Renderer.Translate = System.Windows.Media.Matrix.Identity;

                var polygon = new RectangleF(pointF, stringSize).ToRectanglePolygon();
                var newFeature = feature;
                newFeature.Geometry = polygon;
                _labelBoxRenderer.Render(feature);

                Renderer.Translate = oldModelView;
            }

            Renderer.Graphics.DrawString(content, f, brush, pointF, StringFormat.GenericTypographic);
        }
示例#18
0
文件: Feature.cs 项目: netgrim/MapKit
 public Feature(Feature feature)
     :this(feature.FeatureType, feature.Fid, feature.Values)
 {
 }
示例#19
0
        public override void Render(Feature feature)
        {
            if (feature == null) return;

            //Renderer.FeatureVarResolver.Feature = feature;

            var size = (float)Evaluate(_sizeEvaluator, _size);
            if (Renderer.Zoom * size < 1 || (_contentEvaluator == null && _content == null)) return; //culling
            var oldMatrix = Renderer.Graphics.Transform;

            var content = Convert.ToString(_contentEvaluator != null ? _contentEvaluator.Evaluate() : _content);
            if (string.IsNullOrWhiteSpace(content)) return;

            var angle = (float)Evaluate(_angleEvaluator, _angle);
            var alignment = Evaluate(_alignEvaluator, _alignment);

            if (_text.KeepUpward && Math.Abs((angle + Node.Map.Angle) % 360) > 90)
            {
                angle += 180;
                alignment = FlipXY(alignment);
            }

            using (var f = new Font(Evaluate(_fontEvaluator, "Browallia New"), size))
            using (var brush = new SolidBrush(GetRenderColor(_opacityEvaluator, _opacity, _colorEvaluator, _color)))
            {
                var stringSize = Renderer.Graphics.MeasureString(content, f, 0, StringFormat.GenericTypographic);
                foreach (var point in Renderer.GetPoint(feature.Geometry))
                    RenderText(feature, point, size, angle, content, f, brush, stringSize, alignment);
            }

            Renderer.Graphics.Transform = oldMatrix;
        }