public static LanguageStringType[] GetLanguageStringTypes(string name) { LanguageStringType[] languageStringTypes = new LanguageStringType[] { new LanguageStringType() { Value = name } }; return(languageStringTypes); }
private static LanguageStringType[] CreateNode(IList <string> values = null) { LanguageStringType node = new LanguageStringType(); node.lang = "no"; List <LanguageStringType> listLst = new List <LanguageStringType>(); if (values != null) { foreach (string value in values) { node.Value = value; listLst.Add(node); } } return(listLst.ToArray()); }
public virtual Capabilities CreateCapabilities(string href) { #region ServiceIdentification LanguageStringType[] titles = new LanguageStringType[] { new LanguageStringType() { Value = "Web Map Tile Service" } }; LanguageStringType[] abstracts = new LanguageStringType[] { new LanguageStringType() { Value = "Service that contrains the map access interface to some TileMatrixSets" } }; LanguageStringType[] keyword1 = new LanguageStringType[] { new LanguageStringType() { Value = "tile" } }; KeywordsType keywordsType1 = new KeywordsType() { Keyword = keyword1 }; LanguageStringType[] keyword2 = new LanguageStringType[] { new LanguageStringType() { Value = "map" } }; KeywordsType keywordsType2 = new KeywordsType() { Keyword = keyword2 }; KeywordsType[] keywords = new KeywordsType[] { keywordsType1, keywordsType2 }; CodeType serviceType = new CodeType() { Value = "OGC WMTS" }; string[] serviceTypeVersion = new string[] { "1.0.0" }; string fees = "none"; string[] accessConstraints = new string[] { "none" }; ServiceIdentification serviceIdentification = new ServiceIdentification() { Title = titles, Abstract = abstracts, Keywords = keywords, ServiceType = serviceType, ServiceTypeVersion = serviceTypeVersion, Fees = fees, AccessConstraints = accessConstraints }; #endregion #region ServiceProvider string poroviderName = "SharpMapServer"; OnlineResourceType providerSiteType = new OnlineResourceType() { href = href }; string[] voices = new string[] { "0000-00000000" }; string[] facsimiles = new string[] { "0001-00000001" }; TelephoneType phone = new TelephoneType() { Voice = voices, Facsimile = facsimiles }; string[] deliveryPoints = new string[] { "jinjiang" }; string city = "chengdu"; string administrativeArea = "sichuan"; string country = "china"; string[] electronicMailAddress = new string[] { "*****@*****.**" }; string postalCode = "123456"; AddressType address = new AddressType() { DeliveryPoint = deliveryPoints, City = city, AdministrativeArea = administrativeArea, Country = country, ElectronicMailAddress = electronicMailAddress, PostalCode = postalCode }; ContactType contactInfo = new ContactType() { Phone = phone, Address = address }; string individualName = "lc"; string positionName = "Senior Software Engineer"; ResponsiblePartySubsetType serviceContact = new ResponsiblePartySubsetType() { IndividualName = individualName, PositionName = positionName, ContactInfo = contactInfo }; ServiceProvider serviceProvider = new ServiceProvider() { ProviderName = poroviderName, ProviderSite = providerSiteType, ServiceContact = serviceContact }; #endregion #region OperationsMetadata Operation getCapabilitiesOperation = GetOperation(href, "GetCapabilities"); Operation getTileOperation = GetOperation(href, "GetTile"); Operation getFeatureinfoOperation = GetOperation(href, "GetFeatureinfo"); Operation[] operations = new Operation[] { getCapabilitiesOperation, getTileOperation, getFeatureinfoOperation }; OperationsMetadata operationsMetadata = new OperationsMetadata() { Operation = operations }; #endregion Capabilities capabilities = new Capabilities() { ServiceIdentification = serviceIdentification, ServiceProvider = serviceProvider, OperationsMetadata = operationsMetadata }; return(capabilities); }
static void TestWmts() { XmlAttributeOverrides attrOverrides = new XmlAttributeOverrides(); XmlAttributes ddsAttrs = new XmlAttributes(); XmlElementAttribute layerAttr = new XmlElementAttribute { ElementName = "Layer", Type = typeof(LayerType) }; ddsAttrs.XmlElements.Add(layerAttr); attrOverrides.Add(typeof(ContentsBaseType), "DatasetDescriptionSummary", ddsAttrs); #region ServiceIdentification LanguageStringType[] titles = new LanguageStringType[] { new LanguageStringType() { Value = "Web Map Tile Service" } }; LanguageStringType[] abstracts = new LanguageStringType[] { new LanguageStringType() { Value = "Service that contrains the map access interface to some TileMatrixSets" } }; LanguageStringType[] keyword1 = new LanguageStringType[] { new LanguageStringType() { Value = "tile" } }; KeywordsType keywordsType1 = new KeywordsType() { Keyword = keyword1 }; LanguageStringType[] keyword2 = new LanguageStringType[] { new LanguageStringType() { Value = "map" } }; KeywordsType keywordsType2 = new KeywordsType() { Keyword = keyword2 }; KeywordsType[] keywords = new KeywordsType[] { keywordsType1, keywordsType2 }; CodeType serviceType = new CodeType() { Value = "OGC WMTS" }; string[] serviceTypeVersion = new string[] { "1.0.0" }; string fees = "none"; string[] accessConstraints = new string[] { "none" }; ServiceIdentification serviceIdentification = new ServiceIdentification() { Title = titles, Abstract = abstracts, Keywords = keywords, ServiceType = serviceType, ServiceTypeVersion = serviceTypeVersion, Fees = fees, AccessConstraints = accessConstraints }; #endregion string href = "http://123"; #region ServiceProvider string poroviderName = "SharpMapServer"; OnlineResourceType providerSiteType = new OnlineResourceType() { href = href }; string[] voices = new string[] { "0000-00000000" }; string[] facsimiles = new string[] { "0001-00000001" }; TelephoneType phone = new TelephoneType() { Voice = voices, Facsimile = facsimiles }; string[] deliveryPoints = new string[] { "jinjiang" }; string city = "chengdu"; string administrativeArea = "sichuan"; string country = "china"; string[] electronicMailAddress = new string[] { "*****@*****.**" }; string postalCode = "123456"; AddressType address = new AddressType() { DeliveryPoint = deliveryPoints, City = city, AdministrativeArea = administrativeArea, Country = country, ElectronicMailAddress = electronicMailAddress, PostalCode = postalCode }; ContactType contactInfo = new ContactType() { Phone = phone, Address = address }; string individualName = "lc"; string positionName = "Senior Software Engineer"; ResponsiblePartySubsetType serviceContact = new ResponsiblePartySubsetType() { IndividualName = individualName, PositionName = positionName, ContactInfo = contactInfo }; ServiceProvider serviceProvider = new ServiceProvider() { ProviderName = poroviderName, ProviderSite = providerSiteType, ServiceContact = serviceContact }; #endregion #region OperationsMetadata Operation getCapabilitiesOperation = CapabilitiesHelper.GetOperation(href, "GetCapabilities"); Operation getTileOperation = CapabilitiesHelper.GetOperation(href, "GetTile"); Operation getFeatureinfoOperation = CapabilitiesHelper.GetOperation(href, "GetFeatureinfo"); Operation[] operations = new Operation[] { getCapabilitiesOperation, getTileOperation, getFeatureinfoOperation }; OperationsMetadata operationsMetadata = new OperationsMetadata() { Operation = operations }; #endregion Capabilities capabilities = new Capabilities() { ServiceIdentification = serviceIdentification, ServiceProvider = serviceProvider, OperationsMetadata = operationsMetadata }; IWmtsService wmts1Service = OgcServiceHelper.GetOgcService("WMTS", "1.0.0") as IWmtsService; wmts1Service.AddContent(capabilities, @"E:\LC\数据\双流\2014年遥感影像.img"); List <object> objs = new List <object>(); capabilities.Themes = new Themes[] { new Themes() { Theme = new Theme[] { new Theme() { Identifier = new CodeType() { Value = "123" } } } } }; objs.Add(capabilities); StringBuilder sb = new StringBuilder(); using (TextWriter tw = new StringWriter(sb)) { foreach (var item in objs) { if (item == null) { continue; } var serializer = new XmlSerializer(item.GetType(), attrOverrides); serializer.Serialize(tw, item); var val = sb.ToString(); File.WriteAllText("123.xml", val); sb.Clear(); } } }
public static LayerType GetLayerType(IDataSet dataSet) { LayerType layerType = null; if (dataSet == null) { return(layerType); } LanguageStringType[] titles = new LanguageStringType[] { new LanguageStringType() { Value = dataSet.Name } }; LanguageStringType[] abstracts = new LanguageStringType[] { new LanguageStringType() { Value = dataSet.Name } }; var extent = dataSet.Extent; BoundingBoxType[] boundingBoxs = null; WGS84BoundingBoxType[] WGS84BoundingBoxes = null; ProjectionInfo wgs84PrjInfo = KnownCoordinateSystems.Geographic.World.WGS1984; if (dataSet.Projection.Equals(wgs84PrjInfo))//wgs84 { WGS84BoundingBoxes = new WGS84BoundingBoxType[] { new WGS84BoundingBoxType() { LowerCorner = $"{extent.MinX} {extent.MinY}", UpperCorner = $"{extent.MaxX} {extent.MaxY}" } }; } else { boundingBoxs = new BoundingBoxType[] { new BoundingBoxType() { LowerCorner = $"{extent.MinX} {extent.MinY}", UpperCorner = $"{extent.MaxX} {extent.MaxY}" } }; using (IDataSet tmpDs = DataManager.DefaultDataManager.OpenFile(dataSet.Filename)) { tmpDs.Reproject(wgs84PrjInfo); WGS84BoundingBoxes = new WGS84BoundingBoxType[] { new WGS84BoundingBoxType() { LowerCorner = $"{tmpDs.Extent.MinX} {tmpDs.Extent.MinY}", UpperCorner = $"{tmpDs.Extent.MaxX} {tmpDs.Extent.MaxY}" } }; } } CodeType identifier = new CodeType() { Value = dataSet.Name }; Style style = new Style() { isDefault = true, Identifier = new CodeType() { Value = "default" } }; Style[] styles = new Style[] { style }; string[] formats = new string[] { "image/png", "image/jpg" }; TileMatrixSetLink[] tileMatrixSetLinks = new TileMatrixSetLink[] { new TileMatrixSetLink() { TileMatrixSet = dataSet.Projection.Name } }; layerType = new LayerType() { Title = titles, Abstract = abstracts, BoundingBox = boundingBoxs, WGS84BoundingBox = WGS84BoundingBoxes, Identifier = identifier, Style = styles, Format = formats, TileMatrixSetLink = tileMatrixSetLinks }; return(layerType); }
public static ServiceIdentification GetServiceIdentification(string[] titles, string[] abstracts, string[] keyWords, string service, string[] serviceTypeVersions, string fees, string[] accessConstraints, string[] profiles) { LanguageStringType[] titleTypes = null; if (titles != null) { titleTypes = new LanguageStringType[titles.Length]; for (int i = 0; i < titles.Length; i++) { titleTypes[i] = new LanguageStringType() { Value = titles[i] }; } } LanguageStringType[] abstractTypes = null; if (abstracts != null) { abstractTypes = new LanguageStringType[abstracts.Length]; for (int i = 0; i < abstracts.Length; i++) { titleTypes[i] = new LanguageStringType() { Value = abstracts[i] }; } } KeywordsType[] keywordsTypes = null; if (keyWords != null) { keywordsTypes = new KeywordsType[keyWords.Length]; for (int i = 0; i < keyWords.Length; i++) { LanguageStringType[] keyword = new LanguageStringType[] { new LanguageStringType() { Value = keyWords[i] } }; keywordsTypes[i] = new KeywordsType() { Keyword = keyword }; } } CodeType serviceType = null; if (!string.IsNullOrWhiteSpace(service)) { serviceType = new CodeType() { Value = service }; } ServiceIdentification serviceIdentification = new ServiceIdentification() { Title = titleTypes, Abstract = abstractTypes, Keywords = keywordsTypes, ServiceType = serviceType, ServiceTypeVersion = serviceTypeVersions, Fees = fees, AccessConstraints = accessConstraints, Profile = profiles }; return(serviceIdentification); }