protected TileSource(TileSchema tileSchema, string id) : base(id) { this.tileSchema = tileSchema; this.tileDownloader = this.tileDownloader ?? new ImageTileDownloader(); this.tileDownloader.TileCache = new MemoryTileCache <byte[]>(); this.tileFormat = TileFormat.Png; }
public BaseTemplate() { this.TileFormat = new TileFormat(); this.DefaultFont = new FontFormat("Segoe UI", 8.0f); this.TitleFont = new FontFormat("Segoe UI Semibold", this.DefaultFont.EmSize + 5.0f); this.Palette = PaletteBuilder.GetDefaultPalette(); this.Title = this.DefaultChartTitle; this.SubTitle = this.DefaultChartSubTitle; }
public FileTileCache(string directory, TileFormat format, TimeSpan expirationTime) { this.directory = directory; this.format = format; this.expirationTime = expirationTime; if (!Directory.Exists(directory)) { Directory.CreateDirectory(directory); } }
internal SphericalMercatorTileSchema(IEnumerable <ZoomLevel> zoomLevels, TileFormat format) { TileFormat = format; Crs = "EPSG:3857"; IsYAxisReversed = true; foreach (var zoomLevel in zoomLevels) { ZoomLevels.Add(zoomLevel); } BoundingBox = new BoundingBox(-20037508.342789, -20037508.342789, 20037508.342789, 20037508.342789); }
private void GoToOamPreset(int layer) { int bpp = _layerBpp[_state.Ppu.BgMode, layer]; TileFormat format = TileFormat.Bpp4; int address = _state.Ppu.OamBaseAddress + (layer == 1 ? _state.Ppu.OamAddressOffset : 0); cboMemoryType.SetEnumValue(SnesMemoryType.VideoRam); cboFormat.SetEnumValue(format); int bytesPerRow = GetBytesPerTile() / 8 * _options.Width; int scrollRow = (address * 2 / bytesPerRow) & 0xFFF8; _selectedTile = scrollRow * bytesPerRow / GetBytesPerTile(); RefreshViewer(); ctrlImagePanel.ScrollTo(scrollRow * ctrlImagePanel.ImageScale); }
private void GoToBgLayer(int layer) { int bpp = _layerBpp[_state.Ppu.BgMode, layer]; TileFormat format = TileFormat.Bpp2; if (_state.Ppu.BgMode == 7) { format = _state.Ppu.DirectColorMode ? TileFormat.Mode7DirectColor : TileFormat.Mode7; } else if (bpp == 4) { format = TileFormat.Bpp4; } else if (bpp == 8) { format = _state.Ppu.DirectColorMode ? TileFormat.DirectColor : TileFormat.Bpp8; } cboMemoryType.SetEnumValue(SnesMemoryType.VideoRam); cboFormat.SetEnumValue(format); if (_state.Ppu.BgMode == 7) { nudAddress.Value = 0; _selectedTile = 0; RefreshViewer(); ctrlImagePanel.ScrollTo(0); } else { if (nudAddress.Maximum < _state.Ppu.Layers[layer].ChrAddress) { int gap = _state.Ppu.Layers[layer].ChrAddress - (int)nudAddress.Value; int bytesPerRow = GetBytesPerTile() / 8 * _options.Width; int scrollRow = (gap / bytesPerRow) & ~0x7; _selectedTile = scrollRow * bytesPerRow / GetBytesPerTile(); } else { _selectedTile = 0; } nudAddress.Value = _state.Ppu.Layers[layer].ChrAddress; RefreshViewer(); ctrlImagePanel.ScrollTo(0); } }
private void GoToBgLayer(int layer) { int bpp = _layerBpp[_state.Ppu.BgMode, layer]; TileFormat format = TileFormat.Bpp2; if (_state.Ppu.BgMode == 7) { format = _state.Ppu.DirectColorMode ? TileFormat.Mode7DirectColor : TileFormat.Mode7; } else if (bpp == 4) { format = TileFormat.Bpp4; } else if (bpp == 8) { format = _state.Ppu.DirectColorMode ? TileFormat.DirectColor : TileFormat.Bpp8; } cboMemoryType.SetEnumValue(SnesMemoryType.VideoRam); cboFormat.SetEnumValue(format); if (_state.Ppu.BgMode == 7) { _selectedTile = 0; RefreshViewer(); ctrlImagePanel.ScrollTo(0); } else { int bytesPerRow = GetBytesPerTile() / 8 * _options.Width; int scrollRow = ((_state.Ppu.Layers[layer].ChrAddress << 1) / bytesPerRow) & 0xFFF8; _selectedTile = scrollRow * bytesPerRow / GetBytesPerTile(); RefreshViewer(); ctrlImagePanel.ScrollTo(scrollRow * ctrlImagePanel.ImageScale); } }
public FileTileCache(string directory, TileFormat format) : this(directory, format, TimeSpan.Zero) { }
public SphericalMercatorTileSchema(TileFormat format) : this(GetZoomLevels(defaultZoomLevelNumbers), TileFormat.Png) { }
/// <summary> /// Creates and Serves vector tiles /// </summary> /// <param name="boundVariables"></param> /// <param name="operationInput"></param> /// <param name="outputFormat"></param> /// <param name="requestProperties"></param> /// <param name="responseProperties"></param> /// <returns></returns> private byte[] VectorTileHandler(NameValueCollection boundVariables, JsonObject operationInput, string outputFormat, string requestProperties, out string responseProperties) { //responseProperties = null; responseProperties = null; //"Content-Type:application/json"; ESRI.ArcGIS.SOESupport.AutoTimer timer = new AutoTimer(); const string methodName = "VectorTileHandler"; try { long? layerIndex; long? zoom; long? row; long? col; string jsonFormatParam; TileFormat jsonFormat = TileFormat.EsriJson; // Defaulting to EsriJson if (!operationInput.TryGetAsLong("l", out layerIndex)) { throw new ArgumentNullException("layer"); } if (!operationInput.TryGetAsLong("z", out zoom)) { throw new ArgumentNullException("zoom"); } if (!operationInput.TryGetAsLong("y", out row)) { throw new ArgumentNullException("row"); } if (!operationInput.TryGetAsLong("x", out col)) { throw new ArgumentNullException("col"); } if (operationInput.TryGetString("jf", out jsonFormatParam)) { if (!string.IsNullOrEmpty(jsonFormatParam)) { jsonFormatParam = jsonFormatParam.ToLower().Trim(); Enum.GetNames(typeof(TileFormat)).ToList().ForEach(n => { if (n.ToLower() == jsonFormatParam) { jsonFormat = (TileFormat)Enum.Parse(typeof(TileFormat), jsonFormatParam, true); } }); } } //System.Diagnostics.Debug.WriteLine(string.Format("l:{0}, r:{1}, c:{2}", zoom, row, col)); // Check to see if the tile exists on disk... // <cache-root>\<layerId>\<zoom>\<row>\<col>.esrijson; //i.e. to be consistent with Esri tile caching structure string tilePath = string.Format(@"{0}\{1}\{2}\{3}\{4}.{5}", _vectorCacheRootDirectory, layerIndex, zoom.Value, row.Value, col.Value, jsonFormat.ToString().ToLower()); if (File.Exists(tilePath)) { // Fetch tile contents from disk _dtsLogger.LogInfo(soe_name, methodName, "Time: " + timer.Elapsed.ToString()); logger.LogMessage(ServerLogger.msgType.infoSimple, methodName, -1, "Time: " + timer.Elapsed.ToString()); return(this.ReadTileFile(tilePath)); } else { // Write new files to disk IMapServer3 mapServer = serverObjectHelper.ServerObject as IMapServer3; if (mapServer == null) { throw new InvalidOperationException("Unable to access the map server."); } // Get the bbox. Returns an envelope in WGS84 (4326). IEnvelope env102100 = TileUtil.GetEnvelopeFromZoomRowCol((int)zoom.Value, (int)row.Value, (int)col.Value); //_dtsLogger.LogInfo(soe_name, methodName, this.GeometryToXml(env4326)); // Convert envelope to polygon b/c QueryData does not support spatialfilter geometry using envelope IPolygon polygon102100 = this.CreatePolygonFromEnvelope(env102100); // Use QueryData and generalize result geometries based on zoom level IQueryResultOptions resultOptions = new QueryResultOptionsClass(); // i.e; IRecordSet to support BOTH json and geojson resultOptions.Format = esriQueryResultFormat.esriQueryResultRecordSetAsObject; IMapTableDescription tableDescription = this.GetTableDescription(mapServer, (int)layerIndex, (int)zoom); // Create spatial filter ISpatialFilter spatialFilter = new SpatialFilterClass(); spatialFilter.Geometry = polygon102100; spatialFilter.GeometryField = "Shape"; spatialFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects; //TODO: Subfields should be configurable spatialFilter.SubFields = "*"; // Execute query IQueryResult result = mapServer.QueryData(mapServer.DefaultMapName, tableDescription, spatialFilter, resultOptions); byte[] json = null; // TODO: Support writing tiles for no data // Need a way to do this for GeoJson; parse Esri JSON recordset into GeoJson if (result == null || !this.RecordsetHasFeatures(result.Object as IRecordSet)) { // Write "no data" tile if (jsonFormat == TileFormat.EsriJson) { resultOptions.Format = esriQueryResultFormat.esriQueryResultJsonAsMime; result = mapServer.QueryData(mapServer.DefaultMapName, tableDescription, spatialFilter, resultOptions); json = result.MimeData; } else { json = StrToByteArray(NO_DATA_GEOJSON); } } else { //We have features... IRecordSet features = result.Object as IRecordSet; // Get geometry type for query layer esriGeometryType geometryType = this.GetLayerGeometryType(mapServer.GetServerInfo(mapServer.DefaultMapName).MapLayerInfos, (int)layerIndex); switch (geometryType) { case esriGeometryType.esriGeometryPoint: // Do nothing... already intersected json = ESRI.ArcGIS.SOESupport.Conversion.ToJson(features); break; case esriGeometryType.esriGeometryPolyline: // Polylines must be clipped to envelope IFeatureCursor cursor = null; this.ClipFeaturesToTile(ref cursor, ref features, env102100); json = ESRI.ArcGIS.SOESupport.Conversion.ToJson(features); this.ReleaseComObject(cursor); break; case esriGeometryType.esriGeometryMultipoint: case esriGeometryType.esriGeometryPolygon: // Get IDs of features whose centroid is contained by tile envelope List <int> ids = this.GetIdsOfContainedFeatureCentroids(features, polygon102100); if (ids.Count == 0) { // Write no data tile if (jsonFormat == TileFormat.EsriJson) { // Query to get empty featureset and serialize to disk resultOptions.Format = esriQueryResultFormat.esriQueryResultJsonAsMime; IQueryFilter queryFilter = new QueryFilterClass(); queryFilter.SubFields = "*"; queryFilter.WhereClause = "1=2"; result = mapServer.QueryData(mapServer.DefaultMapName, tableDescription, queryFilter, resultOptions); json = result.MimeData; } else { json = StrToByteArray(NO_DATA_GEOJSON); } } else { // Execute new query for IDs IQueryFilter queryFilter = new QueryFilterClass(); queryFilter.SubFields = "*"; // TODO: Account for sql query syntax based on datasource // FGDB/Shapefile then "OBJECTID"; quotes required // PGDB then [OBJECTID]; brackets required // SDE then OBJECTID; nothing but the fieldname queryFilter.WhereClause = string.Format("\"OBJECTID\" IN({0})", ids.ToDelimitedString <int>(",")); // FGDB result = mapServer.QueryData(mapServer.DefaultMapName, tableDescription, queryFilter, resultOptions); features = result.Object as IRecordSet; // Do some checking here... var featureCount = this.GetRecordsetFeatureCount(features); if (featureCount != ids.Count) { System.Diagnostics.Debug.WriteLine(string.Format("Query Problem: ID search results IS NOT EQUAL to contained IDs count - [{0}:{1}]", featureCount, ids.Count)); System.Diagnostics.Debug.WriteLine("Query: " + queryFilter.WhereClause); } json = ESRI.ArcGIS.SOESupport.Conversion.ToJson(features); } break; default: throw new NotSupportedException(string.Format("Geometry type {0} is not supported by {1}", geometryType.ToString(), soe_name)); } } //store the json to disk this.WriteTileFile(json, tilePath, (int)layerIndex, (int)zoom, (int)row); _dtsLogger.LogInfo(soe_name, methodName, "Time: " + timer.Elapsed.ToString()); logger.LogMessage(ServerLogger.msgType.infoSimple, methodName, -1, "Time: " + timer.Elapsed.ToString()); return(json); } } catch (Exception ex) { // Log the error _dtsLogger.LogError(soe_name, methodName, "n/a", ex); logger.LogMessage(ServerLogger.msgType.error, methodName, 9999, ex.StackTrace); return(StrToByteArray("{}")); } }