예제 #1
0
        public void Execute(CancellationToken token, Predicate <MotorInfoMap <double> > posInfoHandler)
        {
            this.token = token;
            var first = this.jobs.First().GetDataCollection().First();

            this.layerConfig = this.jobs[0] as ILayerConfig;
            this.UpdateControlInfo();

            try
            {
                this.MoveZToCutHeight();
                this.BlowingOn();
                this.LaserOn();

                foreach (var m in this.jobs.SkipWhile(x => pierceDisabled && x.GetType() == typeof(PierceJob)))
                {
                    this.layerConfig = m as ILayerConfig;
                    m.Execute(token, posInfoHandler, this.IsFirst);
                    this.IsFirst = false;
                }
            }
            catch (Exception ex)
            {
                LogUtil.Instance.Error(ex.Message);
            }
            finally
            {
                this.LaserOff();
                this.BlowingOff();
                this.MoveZToLiftHeight();
            }

            token.ThrowIfCancellationRequested();
        }
예제 #2
0
        public WmsTileSourceFactory(ILayerConfig layerConfig)
        {
            this.layerConfig = layerConfig;
            Uri uri     = new Uri(layerConfig.Url);
            var request = (HttpWebRequest)WebRequest.Create(uri);

            //referer and username password for access
            request.Referer = "http://astra.admin.ch";
            if (String.IsNullOrEmpty(layerConfig.Username) && String.IsNullOrEmpty(layerConfig.Password))
            {
                request.Credentials = new NetworkCredential(layerConfig.Username, layerConfig.Password);
            }
            WebResponse resp = request.GetResponse();



            var ser = new XmlSerializer(typeof(WMS_Capabilities));

            using (var reader = new StreamReader(resp.GetResponseStream()))
            {
                capabilities = (WMS_Capabilities)ser.Deserialize(reader);
            }
            this.Format = !String.IsNullOrEmpty(layerConfig.Format) && capabilities.Capability.Request.GetMap.Format.Contains(layerConfig.Format)
                ? layerConfig.Format
                : capabilities.Capability.Request.GetMap.Format.First();
        }
예제 #3
0
 public LayerBuilder(ILayerConfig config)
 {
     firstLayer = new int[config.N][];
     for (int i = 0; i < config.N; i++)
     {
         firstLayer[i] = Console.ReadLine().Split(" ", StringSplitOptions.RemoveEmptyEntries).Select(x => int.Parse(x)).ToArray();
     }
 }
예제 #4
0
        public WmtsTileSourceFactory(ILayerConfig layer)
        {
            this.layer = layer;
            Uri uri     = new Uri(layer.Url);
            var request = (HttpWebRequest)WebRequest.Create(uri);

            //referer and username password for access
            request.Referer = "http://astra.admin.ch";
            if (String.IsNullOrEmpty(layer.Username) && String.IsNullOrEmpty(layer.Password))
            {
                request.Credentials = new NetworkCredential(layer.Username, layer.Password);
            }
            WebResponse resp = request.GetResponse();



            var ser = new XmlSerializer(typeof(Capabilities));

            using (var reader = new StreamReader(resp.GetResponseStream()))
            {
                this.capabilities = (Capabilities)ser.Deserialize(reader);
            }

            var capLayer = this.capabilities.Contents.Layers.Single(l => l.Identifier.Value == layer.WMSLayer);

            //we only want one MatrixSet either the first or the user defined
            if (String.IsNullOrEmpty(layer.MatrixSet))
            {
                capLayer.TileMatrixSetLink = new TileMatrixSetLink[] { capLayer.TileMatrixSetLink.First() };
            }
            else
            {
                capLayer.TileMatrixSetLink = new TileMatrixSetLink[] { capLayer.TileMatrixSetLink.Single(tm => tm.TileMatrixSet == layer.MatrixSet) };
            }

            //ditto with style: either the the first, default, or the user defined
            if (String.IsNullOrEmpty(layer.Style))
            {
                Style style = capLayer.Style.SingleOrDefault(s => s.isDefault);
                if (style == null)
                {
                    style = capLayer.Style.First();
                }
                capLayer.Style = new Style[] { style };
            }
            else
            {
                capLayer.Style = new Style[] { capLayer.Style.SingleOrDefault(s => s.Identifier.Value == layer.Style) };
            }

            //ditto with format: either first or user defined
            Format = String.IsNullOrEmpty(layer.Format) ? capLayer.Format.First() : layer.Format;
            URLTemplateType[] urls = capLayer.ResourceURL.Where(u => u.format == Format).ToArray();
            capLayer.Format      = new string[] { Format };
            capLayer.ResourceURL = urls;
        }
예제 #5
0
        /// <summary>
        /// Set the layer zIndex from the map config.
        /// </summary>
        /// <param name="layer"></param>
        private void SetLayerZIndex(ILayerConfig layer)
        {
            LayerOptions foundLayer = this.layerSwitcherOptions.baselayers.ToList().Find(l => l.id == layer.id);

            if (foundLayer == null)
            {
                foundLayer = this.FindLayerInGroup(layer, this.layerSwitcherOptions.groups);
                if (foundLayer != null)
                {
                    layer.zIndex = foundLayer.drawOrder;
                }
            }
            else
            {
                layer.zIndex = foundLayer.drawOrder;
            }
        }
예제 #6
0
 /// <summary>
 /// Find layer in layerswitcher, recursively look through all groups.
 /// </summary>
 /// <param name="lookupLayer"></param>
 /// <param name="groups"></param>
 /// <returns>Found layer</returns>
 private LayerOptions FindLayerInGroup(ILayerConfig lookupLayer, List <GroupOptions> groups)
 {
     foreach (GroupOptions group in groups)
     {
         var found = this.FindLayerInGroup(lookupLayer, group.groups);
         if (found != null)
         {
             return(found);
         }
         foreach (LayerOptions layer in group.layers)
         {
             if (layer.id == lookupLayer.id)
             {
                 return(layer);
             }
         }
     }
     return(null);
 }
예제 #7
0
 /// <summary>
 /// Lookup layer
 /// </summary>
 /// <param name="layer"></param>
 /// <param name="layers"></param>
 /// <returns>Mathing layers</returns>
 private bool LayerLookup(ILayerConfig layer, string[] layers)
 {
     return(layers.Any(layerId => layerId == layer.id));
 }
예제 #8
0
        public TiledLayerInfo GetTiles(ILayerConfig layer, IGeometry bbox, string path, bool useCache, string format, double buffer = 0, int limit = 0, int maxThreads = 6, bool download = true)
        {
            Uri              uri    = new Uri(layer.Url);
            Extent           extent = new Extent(bbox.EnvelopeInternal.MinX - buffer, bbox.EnvelopeInternal.MinY - buffer, bbox.EnvelopeInternal.MaxX + buffer, bbox.EnvelopeInternal.MaxY + buffer);
            IList <TileInfo> infos  = new List <TileInfo>();
            List <ASTRA.EMSG.Common.EMSGBruTile.TileMatrix> matrixset = new List <ASTRA.EMSG.Common.EMSGBruTile.TileMatrix>();

            //sort by scale (low resolution first) and break if tiles go over limit (limit <= 0 means no limit)
            var orderedres = tileSource.Schema.Resolutions.OrderByDescending(r => r.Value.ScaleDenominator);
            int count      = 0;

            foreach (var res in orderedres)
            {
                var tileinfos = tileSource.Schema.GetTilesInView(extent, res.Key);
                count += tileinfos.Count();
                if (limit > 0 && count > limit)
                {
                    break;
                }
                infos = infos.Union(tileinfos).ToList();
                ASTRA.EMSG.Common.EMSGBruTile.TileMatrix matrix = new ASTRA.EMSG.Common.EMSGBruTile.TileMatrix();
                matrix.Identifier       = res.Value.Id;
                matrix.Left             = res.Value.Left;
                matrix.ScaleDenominator = res.Value.ScaleDenominator;
                matrix.TileHeight       = res.Value.TileHeight;
                matrix.TileWidth        = res.Value.TileWidth;
                matrix.Top = res.Value.Top;
                matrixset.Add(matrix);
            }

            string extension = GetDefaultExtension(format);

            //Create Directory Structure
            foreach (TileInfo info in infos)
            {
                string filepath = Path.Combine(path, string.Format(@"{0}\{1}\{2}\{3}\", uri.Host, layer.Name, info.Index.Level, info.Index.Row));
                if (!Directory.Exists(filepath))
                {
                    Directory.CreateDirectory(filepath);
                }
            }

            List <string>    filePaths = new List <string>();
            List <LoadError> errors    = new List <LoadError>();

            if (download)
            {
                int               listSize = (int)Math.Ceiling((decimal)(infos.Count() / maxThreads));
                var               chunks   = Chunk(infos, listSize);
                List <Thread>     threads  = new List <Thread>();
                List <LoadWorker> workers  = new List <LoadWorker>();
                foreach (IEnumerable <TileInfo> chunk in chunks)
                {
                    LoadWorker worker = new LoadWorker(chunk, tileSource, path, useCache, layer.Name, uri.Host, extension);
                    workers.Add(worker);
                    Thread thread = new Thread(worker.DoWork);
                    threads.Add(thread);
                    thread.Start();
                }
                foreach (Thread thread in threads)
                {
                    thread.Join();
                }
                foreach (LoadWorker worker in workers)
                {
                    filePaths.AddRange(worker.FilePaths);
                    errors.AddRange(worker.Errors);
                }
            }
            int errorCount = errors.Count();

            if (errorCount > 0)
            {
                throw new Exception(String.Format("{0} error{1} while downloading {2}", errorCount, errorCount > 1?"s":string.Empty, layer.Name));
            }

            TiledLayerInfo result = new TiledLayerInfo();

            result.Name              = layer.Name;
            result.IsDefaultVisible  = layer.IsDefaultVisible;
            result.Container         = layer.LayerContainer;
            result.Order             = layer.Order;
            result.AbsoluteFilePaths = filePaths.ToArray();
            result.RelativePath      = String.Format(@"{0}\{1}\", uri.Host, layer.Name);
            result.BasePath          = path;
            result.SourceUrl         = result.RelativePath + @"{TileMatrix}\{TileRow}\{TileCol}" + extension;
            result.MatrixSet         = matrixset;
            List <XMLKeyValuePair <string, string> > localization = new List <XMLKeyValuePair <string, string> >();

            foreach (var kvp in layer.LocalizationDict)
            {
                localization.Add(new XMLKeyValuePair <string, string>(kvp.Key, kvp.Value));
            }
            result.Localization = localization;
            return(result);
        }
예제 #9
0
 public NetworkBuilder AddLayer(ILayerConfig layerConfig)
 {
     return(AddLayer(layerConfig.CreateLayer(_executionContext, _currentLayer.Dimensionality)));
 }
예제 #10
0
 public BrickWork(ILayerConfig config)
 {
     this.config = config;
 }