public static string GetConfigFileContent(ArcGISTileSchema scheme) { StringBuilder builder = new StringBuilder(); builder.Append("<?xml version=\"1.0\" encoding=\"utf-8\"?>"); builder.Append("<CacheInfo xsi:type=\"typens:CacheInfo\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" xmlns:typens=\"http://www.esri.com/schemas/ArcGIS/10.1\">"); builder.Append("<TileCacheInfo xsi:type=\"typens:TileCacheInfo\">"); builder.Append(ArcGISPrjTool.GetSpatialReferenceXML(scheme.WKID)); builder.Append(string.Format("<TileOrigin xsi:type=\"typens:PointN\"><X>{0}</X><Y>{1}</Y></TileOrigin>", scheme.TileOrigin.Lng, scheme.TileOrigin.Lat)); builder.Append(string.Format("<TileCols>{0}</TileCols>", scheme.TileCols)); builder.Append(string.Format("<TileRows>{0}</TileRows>", scheme.TileRows)); builder.Append(string.Format("<DPI>{0}</DPI>", scheme.DPI)); builder.Append("<LODInfos xsi:type=\"typens:ArrayOfLODInfo\">"); foreach (LODInfo info in scheme.LODs) { builder.Append(string.Concat(new object[] { "<LODInfo xsi:type=\"typens:LODInfo\"><LevelID>", info.LevelID, "</LevelID><Scale>", info.Scale, "</Scale><Resolution>", info.Resolution, "</Resolution></LODInfo>" })); } builder.Append("</LODInfos>"); builder.Append("</TileCacheInfo>"); builder.Append("<TileImageInfo xsi:type=\"typens:TileImageInfo\">"); builder.Append(string.Format("<CacheTileFormat>{0}</CacheTileFormat><CompressionQuality>0</CompressionQuality><Antialiasing>false</Antialiasing>", scheme.CacheTileFormat.ToString().ToUpper())); builder.Append("</TileImageInfo>"); builder.Append(string.Format("<CacheStorageInfo xsi:type=\"typens:CacheStorageInfo\"><StorageFormat>{0}</StorageFormat><PacketSize>{1}</PacketSize></CacheStorageInfo></CacheInfo>", scheme.StorageFormat, scheme.PacketSize)); return(builder.ToString()); }
// Methods public TilePackageWriter(string path, ArcGISTileSchema scheme) { this.tillingScheme = scheme; if (File.Exists(path)) { throw new Exception(string.Format("文件({0})已存在!", path)); } this.Init(path); }
private ArcGISTileSchema GetArcGISTileSchema(EsriStorageFormat storageFormat) { List <int> zoomLevelList = this.GetExportLevels(); ArcGISTileSchema arcGisTileSchema = new ArcGISTileSchema { CacheTileFormat = ImageFormat.PNG, CompressionQuality = 0, DPI = (int)this.DPI, FullExtent = BoundingBox.FromRectLngLat(this.GetProjectedView()), InitialExtent = BoundingBox.FromRectLngLat(this.GetProjectedView()), LODs = new LODInfo[zoomLevelList.Count] }; int num = 0; foreach (int levelId in zoomLevelList) { LODInfo info = new LODInfo { LevelID = levelId, Resolution = this.mapProvider.Projection.GetLevelResolution(levelId), Scale = this.mapProvider.Projection.GetLevelScale(levelId) }; arcGisTileSchema.LODs[num++] = info; } if (storageFormat == EsriStorageFormat.esriMapCacheStorageModeExploded) { arcGisTileSchema.PacketSize = 0; } else if (storageFormat == EsriStorageFormat.esriMapCacheStorageModeCompact) { arcGisTileSchema.PacketSize = 128; } arcGisTileSchema.StorageFormat = storageFormat; arcGisTileSchema.TileOrigin = this.mapProvider.Projection.GetProjectedPoint(this.mapProvider.Projection.TileOrigin); arcGisTileSchema.TileCols = (int)this.mapProvider.Projection.TileSize.Width; arcGisTileSchema.TileRows = (int)this.mapProvider.Projection.TileSize.Height; arcGisTileSchema.WKID = this.mapProvider.Projection.EpsgCode; //arcGisTileSchema.WKID = 4326; //arcGisTileSchema.WKID = 3857; arcGisTileSchema.TPKName = new Guid().ToString(); return(arcGisTileSchema); }
public static string GetCDIFileContent(ArcGISTileSchema scheme, GMapProvider mapProvider = null) { StringBuilder builder = new StringBuilder(); builder.Append("<?xml version=\"1.0\" encoding=\"utf-8\" ?>"); builder.Append("<EnvelopeN xsi:type='typens:EnvelopeN' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:xs='http://www.w3.org/2001/XMLSchema' xmlns:typens='http://www.esri.com/schemas/ArcGIS/10.0'>"); builder.Append("<XMin>" + scheme.FullExtent.LowerCorner.X + "</XMin>"); if ((mapProvider != null) && (((mapProvider is BaiduMapProvider) || (mapProvider is BaiduSatelliteMapProvider)) || (mapProvider is BaiduHybridMapProvider))) { builder.Append("<YMin>" + (scheme.FullExtent.LowerCorner.Y - 30000.0) + "</YMin>"); } else { builder.Append("<YMin>" + scheme.FullExtent.LowerCorner.Y + "</YMin>"); } builder.Append("<XMax>" + scheme.FullExtent.UpperCorner.X + "</XMax>"); builder.Append("<YMax>" + scheme.FullExtent.UpperCorner.Y + "</YMax>"); builder.Append("</EnvelopeN>"); return(builder.ToString()); }
public bool CreateArcGISMetaFile() { try { string cdiFile = this.rootPath + "/Layer/conf.cdi"; string xmlFile = this.rootPath + "/Layer/conf.xml"; if (!Directory.Exists(cdiFile.Substring(0, cdiFile.LastIndexOf('/'))) && !Directory.Exists(cdiFile.Substring(0, cdiFile.LastIndexOf('/')))) { Directory.CreateDirectory(cdiFile.Substring(0, cdiFile.LastIndexOf('/'))); } ArcGISTileSchema schema = GetArcGISTileSchema(EsriStorageFormat.esriMapCacheStorageModeExploded); this.GenerateArcGISCDIFile(cdiFile, schema); this.GenerateArcGISConfFile(xmlFile, schema); return(true); } catch (Exception exception) { string msg = "创建ArcGIS切片元数据文件失败!"; log.Error(msg + exception); return(false); } }
private void GenerateArcGISCDIFile(string dstFile, ArcGISTileSchema schema) { string cdiFileContent = TilePackageWriter.GetCDIFileContent(schema, this.mapProvider); this.WriteXMLFile(dstFile, cdiFileContent); }
private void GenerateArcGISConfFile(string dstFile, ArcGISTileSchema schema) { string xmlFileContent = TilePackageWriter.GetConfigFileContent(schema); this.WriteXMLFile(dstFile, xmlFileContent); }