// Constructors

        public TypeMapping(TypeInfo type, MapTransform keyTransform, MapTransform transform, int[] keyIndexes)
        {
            Type         = type;
            KeyTransform = keyTransform;
            Transform    = transform;
            KeyIndexes   = keyIndexes;
        }
        /// <summary>
        /// 坐标转换
        /// </summary>
        /// <param name="coordinateType">坐标转换方式:1 百度地图转天地图,2天地图转百度地图</param>
        /// <param name="inMapX">经度</param>
        /// <param name="inMapY">纬度</param>
        /// <param name="MapX">经度</param>
        /// <param name="MapY">纬度</param>
        /// <returns></returns>
        private int GetMapXAndMapY(int coordinateType, string inMapX, string inMapY, out string MapX, out string MapY)
        {
            MapX = inMapX;
            MapY = inMapY;
            try
            {
                double mapx = double.Parse(MapX); double mapy = double.Parse(MapY);
                if (mapx > 0 && mapy > 0)
                {
                    if (coordinateType == 1)
                    {
                        //百度地图转天地图
                        double[] gcjarr = MapTransform.BD09ToGCJ02(mapx, mapy);
                        double[] wgsarr = MapTransform.GCJ02ToWGS84(gcjarr[0], gcjarr[1]);
                        MapX = Math.Round(wgsarr[0], 6).ToString();
                        MapY = Math.Round(wgsarr[1], 6).ToString();
                    }
                    else if (coordinateType == 2)
                    {
                        //天地图转百度地图
                        double[] GCJ02 = MapTransform.WGS84ToGCJ02(mapx, mapy);
                        double[] BD09  = MapTransform.GCJ02ToBD09(GCJ02[0], GCJ02[1]);
                        MapX = Math.Round(BD09[0], 6).ToString();
                        MapY = Math.Round(BD09[1], 6).ToString();
                    }
                }
                return(1);
            }
            catch (Exception ex)
            {
            }

            return(1);
        }
        /// <inheritdoc/>
        protected override void Initialize()
        {
            base.Initialize();
            var comparisonRules = new ComparisonRules[Order.Count];

            for (int i = 0; i < Order.Count; i++)
            {
                var orderItem    = Order[i];
                var culture      = CultureInfo.InvariantCulture;
                var column       = Header.Columns[orderItem.Key];
                var mappedColumn = column as MappedColumn;
                if (mappedColumn != null && mappedColumn.ColumnInfoRef != null)
                {
                    culture = mappedColumn.ColumnInfoRef.CultureInfo;
                }
                comparisonRules[i] = new ComparisonRule(orderItem.Value, culture);
            }

            var fieldTypes = new Type[Order.Count];
            var map        = new int[Order.Count];

            for (var i = 0; i < Order.Count; i++)
            {
                var p = Order[i];
                fieldTypes[i] = Header.Columns[p.Key].Type;
                map[i]        = p.Key;
            }
            var orderKeyDescriptor = TupleDescriptor.Create(fieldTypes);

            OrderKeyExtractorTransform = new MapTransform(true, orderKeyDescriptor, map);
        }
Beispiel #4
0
    private void InitOrigin()
    {
        if (!initialized)
        {
            playerModel      = Instantiate(_jidoManager.PlayerModelPrefab);
            playerModel.name = name;
            HitTestPlayerFeet(playerModel.transform.position, playerModel.GetComponentInChildren <PlayerCallouts>());
            GetComponent <PlayerController>().SetGameStarted(playerModel);
            MapTransform transform = FindObjectOfType <MapSession> ().MultiplayerSync(getTapLocalFrame, tapLocalFrame, getTapRemoteFrame, tapRemoteFrame, null);
            rotationRemoteToLocal = transform.RotationRemoteToLocal;
            offsetLocalToRemote   = transform.OffsetLocalToRemote;
            initialized           = true;
        }
        else
        {
            MapTransform transform = FindObjectOfType <MapSession> ().MultiplayerSync(getTapLocalFrame, tapLocalFrame, getTapRemoteFrame, tapRemoteFrame, rotationRemoteToLocal);
            if (transform.UpdateError > (errorThresh * 1.2f))
            {
                return;
            }

            updateTarget = true;
            updateOffset = transform.OffsetLocalToRemote;
        }
    }
        private static EntitySetTypeState BuildEntitySetTypeState(object key, EntitySetBase entitySet)
        {
            var field            = ((Pair <object, FieldInfo>)key).Second;
            var association      = field.Associations.Last();
            var query            = association.UnderlyingIndex.GetQuery().Seek(() => keyParameter.Value);
            var seek             = entitySet.Session.Compile(query);
            var ownerDescriptor  = association.OwnerType.Key.TupleDescriptor;
            var targetDescriptor = association.TargetType.Key.TupleDescriptor;

            var itemColumnOffsets = association.AuxiliaryType == null
        ? association.UnderlyingIndex.ValueColumns
                                    .Where(ci => ci.IsPrimaryKey)
                                    .Select(ci => ci.Field.MappingInfo.Offset)
                                    .ToList()
        : Enumerable.Range(0, targetDescriptor.Count).ToList();

            var keyDescriptor = TupleDescriptor.Create(ownerDescriptor
                                                       .Concat(itemColumnOffsets.Select(i => targetDescriptor[i]))
                                                       .ToList());
            var map = Enumerable.Range(0, ownerDescriptor.Count)
                      .Select(i => new Pair <int, int>(0, i))
                      .Concat(itemColumnOffsets.Select(i => new Pair <int, int>(1, i)))
                      .ToArray();
            var seekTransform             = new MapTransform(true, keyDescriptor, map);
            Func <Tuple, Entity> itemCtor = null;

            if (association.AuxiliaryType != null)
            {
                itemCtor = DelegateHelper.CreateDelegate <Func <Tuple, Entity> >(null,
                                                                                 association.AuxiliaryType.UnderlyingType, DelegateHelper.AspectedFactoryMethodName,
                                                                                 ArrayUtils <Type> .EmptyArray);
            }
            return(new EntitySetTypeState(seek, seekTransform, itemCtor, entitySet.GetItemCountQueryDelegate(field)));
        }
        private async void Locations_ValueChanged(object sender, EventArgs e)
        {
            var locations   = this.Locations;
            var valueLevels = this.ValueLevels;

            if (locations == null || valueLevels == null)
            {
                return;
            }

            this.PolylineParts = await Task.Run(() => this.Segment(locations, valueLevels));

            var mapView          = this.GetParent <MapView>();
            var polylineParts    = this.PolylineParts;
            var tolerance        = this.Tolerance;
            var isEnabled        = this.IsEnabled;
            var doubleToBrushMap = this.DoubleToBrushMap;
            var disabledStroke   = this.DisabledStroke;
            var converter        = new MapTransform(mapView);

            this.SimplifiedPolylineParts = new ObservableCollection <LocationCollectionViewModel>();

            foreach (var part in polylineParts)
            {
                this.SimplifiedPolylineParts.Add(await Task.Run(() => this.Reduce(part, converter, tolerance, doubleToBrushMap, isEnabled, disabledStroke)));
            }
        }
Beispiel #7
0
        /// <summary>
        /// Returns a cloned copy of this map-object.
        /// Layers are not cloned. The same instances are referenced from the cloned copy as from the original.
        /// The property <see cref="DisposeLayersOnDispose"/> is however false on this object (which prevents layers beeing disposed and then not usable from the original map)
        /// </summary>
        /// <returns>Instance of <see cref="Map"/></returns>
        public Map Clone()
        {
            Map clone = null;

            lock (MapTransform)
            {
                clone = new Map()
                {
                    BackColor          = BackColor,
                    Disclaimer         = Disclaimer,
                    DisclaimerLocation = DisclaimerLocation,
                    MaximumZoom        = MaximumZoom,
                    MinimumZoom        = MinimumZoom,
                    PixelAspectRatio   = PixelAspectRatio,
                    Zoom = Zoom,
                    DisposeLayersOnDispose = false
                };

                if (DisclaimerFont != null)
                {
                    clone.DisclaimerFont = (Font)DisclaimerFont.Clone();
                }
                if (MapTransform != null)
                {
                    clone.MapTransform = MapTransform.Clone();
                }
                if (Size != null)
                {
                    clone.Size = new Size(Size.Width, Size.Height);
                }
                if (Center != null)
                {
                    clone.Center = Center.Clone();
                }
            }
            if (clone != null)
            {
                if (BackgroundLayer != null)
                {
                    clone.BackgroundLayer.AddCollection(BackgroundLayer.Clone());
                }

                for (int i = 0; i < Decorations.Count; i++)
                {
                    clone.Decorations.Add(Decorations[i]);
                }

                if (Layers != null)
                {
                    clone.Layers.AddCollection(Layers.Clone());
                }

                if (VariableLayers != null)
                {
                    clone.VariableLayers.AddCollection(VariableLayers.Clone());
                }
            }
            return(clone);
        }
 public EntitySetTypeState(ExecutableProvider seekProvider, MapTransform seekTransform,
                           Func <Tuple, Entity> itemCtor, Func <QueryEndpoint, long> itemCountQuery)
 {
     SeekProvider   = seekProvider;
     SeekTransform  = seekTransform;
     ItemCtor       = itemCtor;
     ItemCountQuery = itemCountQuery;
 }
        public TypeMapping GetTypeMapping(int entityIndex, TypeInfo approximateType, int typeId, Pair <int>[] columns)
        {
            TypeMapping result;
            var         cache = entityMappings[entityIndex];

            if (cache.SingleItem != null)
            {
                if (typeId != ResolveTypeToNodeSpecificTypeIdentifier(cache.SingleItem.Type))
                {
                    throw new ArgumentOutOfRangeException("typeId");
                }
                return(cache.SingleItem);
            }
            if (cache.Items.TryGetValue(typeId, out result))
            {
                return(result);
            }

            var type       = TypeIdRegistry[typeId];
            var keyInfo    = type.Key;
            var descriptor = type.TupleDescriptor;

            var typeColumnMap = columns.ToArray();

            if (approximateType.IsInterface)
            {
                // fixup target index
                for (int i = 0; i < columns.Length; i++)
                {
                    var pair = typeColumnMap[i];
                    var approxTargetIndex = pair.First;
                    var interfaceField    = approximateType.Columns[approxTargetIndex].Field;
                    var field             = type.FieldMap[interfaceField];
                    var targetIndex       = field.MappingInfo.Offset;
                    typeColumnMap[i] = new Pair <int>(targetIndex, pair.Second);
                }
            }

            int[] allIndexes = MaterializationHelper.CreateSingleSourceMap(descriptor.Count, typeColumnMap);
            int[] keyIndexes = allIndexes.Take(keyInfo.TupleDescriptor.Count).ToArray();

            var transform    = new MapTransform(true, descriptor, allIndexes);
            var keyTransform = new MapTransform(true, keyInfo.TupleDescriptor, keyIndexes);

            result = new TypeMapping(type, keyTransform, transform, keyIndexes);

            if (type.Hierarchy.Root.IsLeaf && approximateType == type)
            {
                cache.SingleItem = result;
            }
            else
            {
                cache.Items.Add(typeId, result);
            }
            entityMappings[entityIndex] = cache;

            return(result);
        }
        /// <inheritdoc/>
        protected override RecordSetHeader BuildHeader()
        {
            var newHeader = Source.Header.Add(new SystemColumn(ResultColumnName, 0, typeof(bool)));
            var types     = FilteredColumns.Select(m => newHeader.Columns[m].Type);

            FilteredColumnsExtractionTransform = new MapTransform(true, TupleDescriptor.Create(types), FilteredColumns);
            ResultTransform = new CombineTransform(true, Source.Header.TupleDescriptor, TupleDescriptor.Create(new [] { typeof(bool) }));
            return(newHeader);
        }
        public void MainTest()
        {
            Xtensive.Tuples.Tuple source    = Tuple.Create(1);
            MapTransform          transform = new MapTransform(true, TupleDescriptor.Create <byte, int, string>(), new[] { -1, 0 });

            Xtensive.Tuples.Tuple result = transform.Apply(TupleTransformType.TransformedTuple, source);
            Assert.AreEqual(TupleFieldState.Default, result.GetFieldState(0));
            Assert.AreEqual(TupleFieldState.Available, result.GetFieldState(1));
            Assert.AreEqual(TupleFieldState.Default, result.GetFieldState(2));
        }
        /// <inheritdoc/>
        protected override void Initialize()
        {
            base.Initialize();
            var columnIndexes = new int[Header.Length];

            for (int i = 0; i < columnIndexes.Length; i++)
            {
                columnIndexes[i] = (i < Source.Header.Length) ? i : MapTransform.NoMapping;
            }
            ResizeTransform = new MapTransform(false, Header.TupleDescriptor, columnIndexes);
        }
Beispiel #13
0
        /// <summary>
        /// Converts a point from world coordinates to image coordinates based on the current
        /// zoom, center and mapsize.
        /// </summary>
        /// <param name="p">Point in world coordinates</param>
        /// <param name="careAboutMapTransform">Indicates whether MapTransform should be taken into account</param>
        /// <returns>Point in image coordinates</returns>
        public PointF WorldToImage(Point p, bool careAboutMapTransform)
        {
            PointF pTmp = Transform.WorldtoMap(p, this);

            if (careAboutMapTransform && !MapTransform.IsIdentity)
            {
                PointF[] pts = new PointF[] { pTmp };
                MapTransform.TransformPoints(pts);
                pTmp = pts[0];
            }
            return(pTmp);
        }
        protected override Provider VisitRaw(RawProvider provider)
        {
            var mapping = mappings[provider];

            if (mapping.SequenceEqual(Enumerable.Range(0, provider.Header.Length)))
            {
                return(provider);
            }
            var mappingTransform = new MapTransform(true, provider.Header.TupleDescriptor, mapping.ToArray());
            var newExpression    = RemapRawProviderSource(provider.Source, mappingTransform);

            return(new RawProvider(provider.Header.Select(mapping), newExpression));
        }
Beispiel #15
0
        /// <inheritdoc/>
        protected override void Initialize()
        {
            base.Initialize();
            var types         = new List <Type>();
            int i             = 0;
            var columnIndexes = new int[GroupColumnIndexes.Length];

            foreach (var index in GroupColumnIndexes)
            {
                types.Add(Source.Header.Columns[index].Type);
                columnIndexes[i++] = index;
            }
            Transform = new MapTransform(false, TupleDescriptor.Create(types), columnIndexes);
        }
Beispiel #16
0
        private NamePrepTransform()
        {
            // load the resource bundle
            //ICUResourceBundle bundle = (ICUResourceBundle)ICUResourceBundle.GetBundleInstance("com/ibm/icu/dev/data/testdata", "idna_rules", typeof(NamePrepTransform).GetTypeInfo().Assembly, true);
            ICUResourceBundle bundle   = (ICUResourceBundle)ICUResourceBundle.GetBundleInstance("Dev/Data/TestData", "idna_rules", typeof(NamePrepTransform).GetTypeInfo().Assembly, true);
            String            mapRules = bundle.GetString("MapNoNormalization");

            mapRules += bundle.GetString("MapNFKC");
            // disable
            mapTransform      = new MapTransform("CaseMap", mapRules, 0 /*Transliterator.FORWARD*/);
            labelSeparatorSet = new UnicodeSet(bundle.GetString("LabelSeparatorSet"));
            prohibitedSet     = new UnicodeSet(bundle.GetString("ProhibitedSet"));
            unassignedSet     = new UnicodeSet(bundle.GetString("UnassignedSet"));
        }
        private static Expression <Func <ParameterContext, IEnumerable <Tuple> > > RemapRawProviderSource(
            Expression <Func <ParameterContext, IEnumerable <Tuple> > > source, MapTransform mappingTransform)
        {
            var selectMethodInfo = WellKnownTypes.Enumerable
                                   .GetMethods()
                                   .Single(methodInfo => methodInfo.Name == nameof(Enumerable.Select) &&
                                           methodInfo.GetParameters()[1].ParameterType.GetGenericTypeDefinition() == typeof(Func <,>))
                                   .MakeGenericMethod(WellKnownOrmTypes.Tuple, WellKnownOrmTypes.Tuple);

            Func <Tuple, Tuple> selector = tuple => mappingTransform.Apply(TupleTransformType.Auto, tuple);
            var newExpression            = Expression.Call(selectMethodInfo, source.Body, Expression.Constant(selector));

            return((Expression <Func <ParameterContext, IEnumerable <Tuple> > >)FastExpression.Lambda(newExpression, source.Parameters[0]));
        }
Beispiel #18
0
        /// <inheritdoc/>
        protected override void Initialize()
        {
            base.Initialize();
            var fieldTypes    = new Type[GroupColumnIndexes.Length];
            var columnIndexes = new int[GroupColumnIndexes.Length];
            var i             = 0;

            foreach (var index in GroupColumnIndexes)
            {
                fieldTypes[i]    = Source.Header.Columns[index].Type;
                columnIndexes[i] = index;
                i++;
            }
            Transform = new MapTransform(false, TupleDescriptor.Create(fieldTypes), columnIndexes);
        }
Beispiel #19
0
        /// <inheritdoc/>
        protected override RecordSetHeader BuildHeader()
        {
            var newHeader  = Source.Header.Add(new SystemColumn(ResultColumnName, 0, BoolType));
            var fieldTypes = new Type[FilteredColumns.Count];

            for (var index = 0; index < fieldTypes.Length; index++)
            {
                fieldTypes[index] = newHeader.Columns[FilteredColumns[index]].Type;
            }
            var tupleDescriptor = TupleDescriptor.Create(fieldTypes);

            FilteredColumnsExtractionTransform = new MapTransform(true, tupleDescriptor, FilteredColumns);
            ResultTransform = new CombineTransform(true, Source.Header.TupleDescriptor, BoolTupleDescriptor);
            return(newHeader);
        }
Beispiel #20
0
        /// <summary>
        /// Cuts out <paramref name="segment"/> from <paramref name="tuple"/> <see cref="Tuple"/>.
        /// </summary>
        /// <param name="tuple">The <see cref="Tuple"/> to get segment from.</param>
        /// <param name="segment">The <see cref="Segment{T}"/> to cut off.</param>
        /// <returns></returns>
        public static Tuple GetSegment(this Tuple tuple, Segment <int> segment)
        {
            var map = new int[segment.Length];

            for (int i = 0; i < segment.Length; i++)
            {
                map[i] = segment.Offset + i;
            }

            var types      = new ArraySegment <Type>(tuple.Descriptor.FieldTypes, segment.Offset, segment.Length);
            var descriptor = TupleDescriptor.Create(types.AsEnumerable());
            var transform  = new MapTransform(false, descriptor, map);

            return(transform.Apply(TupleTransformType.TransformedTuple, tuple));
        }
Beispiel #21
0
        /// <summary>
        /// Converts a point from world coordinates to image coordinates based on the current
        /// zoom, center and mapsize.
        /// </summary>
        /// <param name="p">Point in world coordinates</param>
        /// <param name="careAboutMapTransform">Indicates whether MapTransform should be taken into account</param>
        /// <returns>Point in image coordinates</returns>
        public PointF WorldToImage(Coordinate p, bool careAboutMapTransform)
        {
            var pTmp = Transform.WorldtoMap(p, this);

            lock (MapTransform)
            {
                if (careAboutMapTransform && !MapTransform.IsIdentity)
                {
                    var pts = new[] { pTmp };
                    MapTransform.TransformPoints(pts);
                    pTmp = pts[0];
                }
            }
            return(pTmp);
        }
Beispiel #22
0
        private void BuildVersionExtractor()
        {
            // Building version tuple extractor
            var versionColumns = GetVersionColumns();

            if (versionColumns == null || versionColumns.Count == 0)
            {
                VersionExtractor = null;
                return;
            }
            var types = versionColumns.Select(c => c.ValueType).ToArray();
            var map   = versionColumns.Select(c => c.Field.MappingInfo.Offset).ToArray();
            var versionTupleDescriptor = TupleDescriptor.Create(types);

            VersionExtractor = new MapTransform(true, versionTupleDescriptor, map);
        }
Beispiel #23
0
    public override void Read(XmlNode os)
    {
        foreach (XmlNode current in LoadXML.GetChilds(os))
        {
            switch (current.Name)
            {
            case "Camp":
                this.Camp = (EBattleCamp)ReadInt(current);
                break;

            case "TransParam":
                this.TransParam = new MapTransform();
                this.TransParam.Read(current);
                break;
            }
        }
    }
Beispiel #24
0
        /// <summary>
        /// Returns a cloned copy of this map-object.
        /// Layers are not cloned. The same instances are referenced from the cloned copy as from the original.
        /// The property <see cref="DisposeLayersOnDispose"/> is however false on this object (which prevents layers beeing disposed and then not usable from the original map)
        /// </summary>
        /// <returns>Instance of <see cref="Map"/></returns>
        public Map Clone()
        {
            Map clone = null;

            lock (MapTransform)
            {
                clone = new Map()
                {
                    BackColor          = BackColor,
                    Center             = Center,
                    Disclaimer         = Disclaimer,
                    DisclaimerFont     = DisclaimerFont,
                    DisclaimerLocation = DisclaimerLocation,
                    MapTransform       = MapTransform.Clone(),
                    MaximumZoom        = MaximumZoom,
                    MinimumZoom        = MinimumZoom,
                    PixelAspectRatio   = PixelAspectRatio,
                    Size = Size,
                    Zoom = Zoom,
                    DisposeLayersOnDispose = false
                };
            }
            if (clone != null)
            {
                foreach (var lay in BackgroundLayer)
                {
                    clone.BackgroundLayer.Add(lay);
                }
                foreach (var dec in Decorations)
                {
                    clone.Decorations.Add(dec);
                }
                foreach (var lay in Layers)
                {
                    clone.Layers.Add(lay);
                }
                foreach (var lay in VariableLayers)
                {
                    clone.VariableLayers.Add(lay);
                }
            }
            return(clone);
        }
Beispiel #25
0
        /// <summary>
        /// Returns a cloned copy of this map-object.
        /// Layers are not cloned. The same instances are referenced from the cloned copy as from the original.
        /// The property <see cref="DisposeLayersOnDispose"/> is however false on this object (which prevents layers beeing disposed and then not usable from the original map)
        /// </summary>
        /// <returns>Instance of <see cref="Map"/></returns>
        public Map Clone()
        {
            Map clone = null;

            lock (MapTransform)
            {
                clone = new Map()
                {
                    BackColor = BackColor,
#pragma warning disable 612,618
                    Disclaimer         = Disclaimer,
                    DisclaimerLocation = DisclaimerLocation,
#pragma warning restore 612,618
                    MaximumZoom            = MaximumZoom,
                    MinimumZoom            = MinimumZoom,
                    PixelAspectRatio       = PixelAspectRatio,
                    Zoom                   = Zoom,
                    DisposeLayersOnDispose = false,
                    SRID                   = SRID
                };

#pragma warning disable 612,618
                if (DisclaimerFont != null)
                {
                    clone.DisclaimerFont = (Font)DisclaimerFont.Clone();
                }
#pragma warning restore 612,618
                if (MapTransform != null)
                {
                    clone.MapTransform = MapTransform.Clone();
                }
                if (!Size.IsEmpty)
                {
                    clone.Size = new Size(Size.Width, Size.Height);
                }
                if (Center != null)
                {
                    clone.Center = (Coordinate)Center.Clone();
                }
            }

            if (BackgroundLayer != null)
            {
                clone.BackgroundLayer.AddCollection(BackgroundLayer.Clone());
            }

            for (int i = 0; i < Decorations.Count; i++)
            {
                clone.Decorations.Add(Decorations[i]);
            }

            if (Layers != null)
            {
                clone.Layers.AddCollection(Layers.Clone());
            }

            if (VariableLayers != null)
            {
                clone.VariableLayers.AddCollection(VariableLayers.Clone());
            }

            return(clone);
        }
Beispiel #26
0
        /// <summary>
        /// Renders the map using the provided <see cref="Graphics"/> object.
        /// </summary>
        /// <param name="g">the <see cref="Graphics"/> object to use</param>
        /// <param name="layerCollectionType">the <see cref="LayerCollectionType"/> to use</param>
        /// <param name="drawMapDecorations">Set whether to draw map decorations on the map (if such are set)</param>
        /// <param name="drawTransparent">Set wether to draw with transparent background or with BackColor as background</param>
        /// <exception cref="ArgumentNullException">if <see cref="Graphics"/> object is null.</exception>
        /// <exception cref="InvalidOperationException">if there are no layers to render.</exception>
        public void RenderMap(Graphics g, LayerCollectionType layerCollectionType, bool drawMapDecorations, bool drawTransparent)
        {
            if (g == null)
            {
                throw new ArgumentNullException("g", "Cannot render map with null graphics object!");
            }

            VariableLayerCollection.Pause = true;

            LayerCollection lc = null;

            switch (layerCollectionType)
            {
            case LayerCollectionType.Static:
                lc = Layers;
                break;

            case LayerCollectionType.Variable:
                lc = VariableLayers;
                break;

            case LayerCollectionType.Background:
                lc = BackgroundLayer;
                break;
            }

            if (lc == null || lc.Count == 0)
            {
                throw new InvalidOperationException("No layers to render");
            }

            Matrix transform = g.Transform;

            lock (MapTransform)
            {
                g.Transform = MapTransform.Clone();
            }
            if (!drawTransparent)
            {
                g.Clear(BackColor);
            }

            g.PageUnit = GraphicsUnit.Pixel;


            ILayer[] layerList = new ILayer[lc.Count];
            lc.CopyTo(layerList, 0);

            foreach (ILayer layer in layerList)
            {
                if (layer.Enabled && layer.MaxVisible >= Zoom && layer.MinVisible < Zoom)
                {
                    layer.Render(g, this);
                }
            }

            if (drawTransparent)
            {
                g.Transform = transform;
            }
            if (layerCollectionType == LayerCollectionType.Static)
            {
#pragma warning disable 612,618
                RenderDisclaimer(g);
#pragma warning restore 612,618
                if (drawMapDecorations)
                {
                    foreach (var mapDecoration in Decorations)
                    {
                        mapDecoration.Render(g, this);
                    }
                }
            }



            VariableLayerCollection.Pause = false;
        }
Beispiel #27
0
        /// <summary>
        /// Renders the map using the provided <see cref="Graphics"/> object.
        /// </summary>
        /// <param name="g">the <see cref="Graphics"/> object to use</param>
        /// <exception cref="ArgumentNullException">if <see cref="Graphics"/> object is null.</exception>
        /// <exception cref="InvalidOperationException">if there are no layers to render.</exception>
        public void RenderMap(Graphics g)
        {
            OnMapRendering(g);

            if (g == null)
            {
                throw new ArgumentNullException("g", "Cannot render map with null graphics object!");
            }

            //Pauses the timer for VariableLayer
            VariableLayerCollection.Pause = true;

            if ((Layers == null || Layers.Count == 0) && (BackgroundLayer == null || BackgroundLayer.Count == 0) && (_variableLayers == null || _variableLayers.Count == 0))
            {
                throw new InvalidOperationException("No layers to render");
            }

            lock (MapTransform)
            {
                g.Transform = MapTransform.Clone();
            }
            g.Clear(BackColor);
            g.PageUnit = GraphicsUnit.Pixel;


            //int srid = (Layers.Count > 0 ? Layers[0].SRID : -1); //Get the SRID of the first layer
            ILayer[] layerList;
            if (_backgroundLayers != null && _backgroundLayers.Count > 0)
            {
                layerList = new ILayer[_backgroundLayers.Count];
                _backgroundLayers.CopyTo(layerList, 0);
                foreach (ILayer layer in layerList)
                {
                    OnLayerRendering(layer, LayerCollectionType.Background);
                    if (layer.Enabled && layer.MaxVisible >= Zoom && layer.MinVisible < Zoom)
                    {
                        layer.Render(g, this);
                    }
                    OnLayerRendered(layer, LayerCollectionType.Background);
                }
            }

            if (_layers != null && _layers.Count > 0)
            {
                layerList = new ILayer[_layers.Count];
                _layers.CopyTo(layerList, 0);

                //int srid = (Layers.Count > 0 ? Layers[0].SRID : -1); //Get the SRID of the first layer
                foreach (ILayer layer in layerList)
                {
                    OnLayerRendering(layer, LayerCollectionType.Static);
                    if (layer.Enabled && layer.MaxVisible >= Zoom && layer.MinVisible < Zoom)
                    {
                        layer.Render(g, this);
                    }
                    OnLayerRendered(layer, LayerCollectionType.Static);
                }
            }

            if (_variableLayers != null && _variableLayers.Count > 0)
            {
                layerList = new ILayer[_variableLayers.Count];
                _variableLayers.CopyTo(layerList, 0);
                foreach (ILayer layer in layerList)
                {
                    if (layer.Enabled && layer.MaxVisible >= Zoom && layer.MinVisible < Zoom)
                    {
                        layer.Render(g, this);
                    }
                }
            }

#pragma warning disable 612,618
            RenderDisclaimer(g);
#pragma warning restore 612,618

            // Render all map decorations
            foreach (var mapDecoration in _decorations)
            {
                mapDecoration.Render(g, this);
            }
            //Resets the timer for VariableLayer
            VariableLayerCollection.Pause = false;

            OnMapRendered(g);
        }
 private LocationCollectionViewModel Reduce(LocationCollection locationCollection, MapTransform converter, double tolerance, IDoubleToBrushMap doubleToBrushMap, bool isEnabled, Brush disabledStroke)
 {
     return(new LocationCollectionViewModel
     {
         Locations = new LocationCollection(locationCollection.Reduce(converter, tolerance)),
         //Stroke = isEnabled ? doubleToBrushMap.Map(locationCollection[1].Value) : disabledStroke
     });
 }
Beispiel #29
0
        private void BuildTuplePrototype()
        {
            // Building nullable map
            var nullabilityMap = new BitArray(TupleDescriptor.Count);
            int i = 0;

            foreach (var column in Columns)
            {
                nullabilityMap[i++] = column.IsNullable;
            }

            // fixing reference fields that are marked as not nullable
            foreach (var field in Fields.Where(f => f.IsEntity && !f.IsPrimaryKey && f.IsNullable == false))
            {
                var segment = field.MappingInfo;
                for (int j = segment.Offset; j < segment.EndOffset; j++)
                {
                    nullabilityMap[j] = true;
                }
            }

            // Building TuplePrototype
            var tuple = Tuple.Create(TupleDescriptor);

            tuple.Initialize(nullabilityMap);

            // Initializing defaults
            i = 0;
            foreach (var column in Columns)
            {
                if (column.DefaultValue != null)
                {
                    try {
                        tuple.SetValue(i, column.DefaultValue);
                    }
                    catch (Exception e) {
                        OrmLog.Error(e, Strings.LogExErrorSettingDefaultValueXForColumnYInTypeZ,
                                     column.DefaultValue, column.Name, Name);
                    }
                }
                i++;
            }

            // Aditional initialization for entities
            if (IsEntity)
            {
                // Setting type discriminator column
                if (Hierarchy.TypeDiscriminatorMap != null)
                {
                    tuple.SetValue(Hierarchy.TypeDiscriminatorMap.Field.MappingInfo.Offset, typeDiscriminatorValue);
                }

                // Building primary key injector
                var fieldCount    = TupleDescriptor.Count;
                var keyFieldCount = Key.TupleDescriptor.Count;
                var keyFieldMap   = new Pair <int, int> [fieldCount];
                for (i = 0; i < fieldCount; i++)
                {
                    keyFieldMap[i] = new Pair <int, int>((i < keyFieldCount) ? 0 : 1, i);
                }
                primaryKeyInjector = new MapTransform(false, TupleDescriptor, keyFieldMap);
            }
            TuplePrototype = IsEntity ? tuple.ToFastReadOnly() : tuple;
        }
        private static Expression <Func <IEnumerable <Tuple> > > RemapRawProviderSource(Expression <Func <IEnumerable <Tuple> > > source, MapTransform mappingTransform)
        {
            var selectMethodInfo = typeof(Enumerable)
                                   .GetMethods()
                                   .Single(methodInfo => methodInfo.Name == "Select" &&
                                           methodInfo.GetParameters()[1].ParameterType.GetGenericTypeDefinition() == typeof(Func <,>))
                                   .MakeGenericMethod(typeof(Tuple), typeof(Tuple));

            Func <Tuple, Tuple> selector = tuple => mappingTransform.Apply(TupleTransformType.Auto, tuple);
            var newExpression            = Expression.Call(selectMethodInfo, source.Body, Expression.Constant(selector));

            return((Expression <Func <IEnumerable <Tuple> > >)Expression.Lambda(newExpression));
        }