コード例 #1
0
        async static public Task <ServiceMap> CreateAsync(Map original, IMapServer mapServer, IEnumerable <IMapApplicationModule> modules)
        {
            var serviceMap = new ServiceMap();

            serviceMap._mapServer = mapServer;
            serviceMap._modules   = modules;
            serviceMap._layers    = original._layers;
            serviceMap._datasets  = original._datasets;

            serviceMap.m_imageMerger = new ImageMerger2();

            serviceMap.m_name = original.Name;
            serviceMap._toc   = original._toc;
            serviceMap.Title  = original.Title;
            //serviceMap._ceckLayerVisibilityBeforeDrawing = true;
            serviceMap._mapUnits        = original.MapUnits;
            serviceMap._displayUnits    = original.DisplayUnits;
            serviceMap._backgroundColor = original.BackgroundColor;
            serviceMap.refScale         = original.refScale;

            serviceMap.SpatialReference             = original.Display.SpatialReference;
            serviceMap.LayerDefaultSpatialReference = original.LayerDefaultSpatialReference != null?original.LayerDefaultSpatialReference.Clone() as ISpatialReference : null;

            serviceMap._drawScaleBar = false;

            // Metadata
            await serviceMap.SetMetadataProviders(await original.GetMetadataProviders());

            serviceMap._debug = false;

            serviceMap._layerDescriptions   = original.LayerDescriptions;
            serviceMap._layerCopyrightTexts = original.LayerCopyrightTexts;

            serviceMap.SetResourceContainer(original.ResourceContainer);

            return(serviceMap);
        }
コード例 #2
0
        private static void ApplyMetadata(Map map)
        {
            try
            {
                if (map == null)
                {
                    return;
                }
                FileInfo fi = new FileInfo(ServicesPath + @"\" + map.Name + ".meta");

                IServiceMap sMap = new ServiceMap(map, Instance);
                XmlStream   xmlStream;
                // 1. Bestehende Metadaten auf sds anwenden
                if (fi.Exists)
                {
                    xmlStream = new XmlStream("");
                    xmlStream.ReadStream(fi.FullName);
                    sMap.ReadMetadata(xmlStream);
                }
                // 2. Metadaten neu schreiben...
                xmlStream = new XmlStream("Metadata");
                sMap.WriteMetadata(xmlStream);

                if (map is Metadata)
                {
                    ((Metadata)map).Providers = sMap.Providers;
                }

                // Overriding: no good idea -> problem, if multiple instances do this -> killing the metadata file!!!
                //xmlStream.WriteStream(fi.FullName);
            }
            catch (Exception ex)
            {
                Logger.Log(loggingMethod.error, "LoadConfig: " + ex.Message);
            }
        }
コード例 #3
0
        async private Task <IServiceMap> FindServiceMap(string name, string alias, IServiceRequestContext context)
        {
            Map map = await FindMap(name, context);

            if (map != null)
            {
                IEnumerable <IMapApplicationModule> modules = null;
                if (_mapServiceDeploymentMananger.MapDocument is IMapDocumentModules)
                {
                    modules = ((IMapDocumentModules)_mapServiceDeploymentMananger.MapDocument).GetMapModules(map);
                }
                return(await ServiceMap.CreateAsync(map, this, modules));
            }

            if (name.Contains(",") /* && _serverLicType == ServerLicType.gdi*/)
            {
                Map newMap = null;

                string[] names = name.Split(',');

                #region Alias Service auflösen...
                StringBuilder sb = new StringBuilder();
                foreach (string n in names)
                {
                    IMapService ms = GetMapService(n.ServiceName(), n.FolderName());
                    if (ms == null)
                    {
                        return(null);
                    }

                    if (sb.Length > 0)
                    {
                        sb.Append(",");
                    }

                    if (ms is MapServiceAlias)
                    {
                        sb.Append(((MapServiceAlias)ms).ServiceName);
                    }
                    else
                    {
                        sb.Append(ms.Name);
                    }
                }
                names = sb.ToString().Split(',');
                #endregion
                Array.Reverse(names);

                //if (names.Length > _maxGDIServices)
                //{
                //    return null;
                //}

                foreach (string n in names)
                {
                    Map m1 = await FindMap(n, context);

                    if (m1.Name == n)
                    {
                        if (newMap == null)
                        {
                            newMap = new Map(m1, true);
                        }
                        else
                        {
                            newMap.Append(m1, true);

                            // SpatialReference von am weitesten unten liegenden Karte übernehmen
                            // ist geschackssache...
                            if (m1.Display != null && m1.Display.SpatialReference != null)
                            {
                                newMap.Display.SpatialReference =
                                    m1.Display.SpatialReference.Clone() as ISpatialReference;
                            }
                        }
                    }
                }
                if (newMap != null)
                {
                    // alle webServiceThemes im TOC vereinigen...
                    if (newMap.TOC != null)
                    {
                        foreach (ITOCElement tocElement in newMap.TOC.Elements)
                        {
                            if (tocElement == null ||
                                tocElement.Layers == null)
                            {
                                continue;
                            }

                            foreach (ILayer layer in tocElement.Layers)
                            {
                                if (layer is IWebServiceLayer)
                                {
                                    newMap.TOC.RenameElement(tocElement, newMap.Name + "_WebThemes");
                                    break;
                                }
                            }
                        }
                    }
                    newMap.Name = alias;
                    if (!_mapServiceDeploymentMananger.MapDocument.AddMap(newMap))
                    {
                        return(null);
                    }

                    bool found = false;
                    foreach (IMapService ms in _mapServiceMananger.MapServices)
                    {
                        if (ms != null &&
                            ms.Name == alias && ms.Type == MapServiceType.GDI)
                        {
                            found = true;
                            break;
                        }
                    }

                    if (!found)
                    {
                        _mapServiceMananger.MapServices.Add(new MapService(_mapServiceMananger, name, String.Empty, MapServiceType.GDI));
                    }

                    return(await ServiceMap.CreateAsync(newMap, this, null));
                }
            }

            return(null);
        }