New Year resolutions

每当新年的钟声响起,新概念英语中“New Year Resolutions”这篇文章的标题就在脑海中闪现一下,我们不妨重温一下,是否有诸多相似在自己身上再现?
 --------------------------------------------------------------------------------------------------------------------------------------------------- 
   The New Year is a time for resolutions. Mentally , at least, most of us could compile formidable lists of ' dos ' and ' don'ts ' . The same old favourites recur year in year out with monotonous regularity. We resolve to get up earlier each morning , eat less. find more time to play with the children, do a thousand and one jobs about the house, be nice to people we don't like, drive carefully, and take the dog for a walk every day. Past experience has taught us that ceratin accomplishments are beyond attainment. If we remain inveterate smokers, it is only because we have so often experienced the frustration that results from failure. Most of us fail in our efforts at self-improvement because our schemes are too ambitious and we never have time carry them out. We also make the fundamental error of announcing our resolutions to everybody so that we look even more foolish when we slip back into our bad old ways. A ware of these pitfalls , this year I attempted to keep my resolutions to myself. I limited myself to two modest ambitions :to do physical exercises every morning and to read more of an evening. An all-night party on New Year's Eve provided me with a good excuse for not carrying out either of these new resolution on the first day of the year, but on the second, I applied myself assiduously to the task.
    The daily exercises lasted only eleven minutes and I proposed to do them early in the morning before anyone had got up. The self-discipline required to dray myself out of bed eleven minutes earlier than usual was considerable. Nevertheless , I managed to creep down into the living room for two days before anyone found me out. After jumping about on the carpet and twisting the human frame. into uncomfortable positions , I sat down at the breakfast table in an exhausted condition , It was this that betrayed me. The next morning the whole family trooped in to watch the performance. That was really unsettling , but I fended off the taunts and jibes of the family good-humouredly and soon everybody got used to the idea. However, my enthusiasm waned. The time I spent at exercises gradusally diminished. Little by little the eleven minutes fell to zero. By January 10th, T was back to where I had started from. I argued that if I spent less time exhausting myself at exercises in the morning, I would keep my mind fresh for reading when I got home from work. Resisting the hypnotizing effect of television, I sat in my room for a  few evenings with my eyes glued to a book. One night, however, feeling cold and lonely , I went downstairs and sat in front of the television pretending to read . That proved to be my undoing, for I soon got back to my old bad habit of dozing off in front of the screen. I still haven't given up my resolution to do more reading. In fact , I have just bought a book entitled How to Read a Thousand Words a Minute. Perhaps it will solve my problem, but I just haven't had time to read it !

### OpenLayers 中 Resolutions 配置与用法 在 OpenLayers 中,`resolutions` 是一个非常重要的概念,它用于定义地图的不同缩放级别对应的地面分辨率。这直接影响到地图的显示效果以及图层的数据加载策略。下面详细介绍 `resolutions` 的配置及其用途。 #### 1. **Resolutions 基础** `resolutions` 表示地图每一级缩放的比例尺大小。通常情况下,`resolutions` 数组中的每一个值对应于地图的一个缩放级别(zoom level),并且这些值按照从大到小的顺序排列。较大的数值表示较低的缩放级别(即更远的距离视图),而较小的数值则代表更高的缩放级别(即更近的距离视图)[^5]。 #### 2. **手动指定 Resolutions** 当使用某些特定的地图服务(如 WMS 或 WMTS)时,可能需要手动指定 `resolutions` 来适配服务端的要求。例如,在创建 `TileLayer` 或 `ImageLayer` 时,可以通过设置 `source` 属性下的 `tileGrid` 参数来定义自定义的 `resolutions`: ```javascript import TileLayer from 'ol/layer/Tile'; import XYZSource from 'ol/source/XYZ'; import { createXYZ } from 'ol/tilegrid'; const resolutions = [ 156543.03392804097, 78271.51696402048, 39135.75848201024, 19567.87924100512, 9783.93962050256, 4891.96981025128, 2445.98490512564, 1222.99245256282, 611.49622628141, 305.748113140705, 152.8740565703525, 76.43702828517625, 38.21851414258813, 19.109257071294063, 9.554628535647032, 4.777314267823516, 2.388657133911758, 1.194328566955879, 0.5971642834779395 ]; const tileGrid = createXYZ({ resolutions: resolutions, }); const layer = new TileLayer({ source: new XYZSource({ url: 'https://{a-c}.tile.openstreetmap.org/{z}/{x}/{y}.png', tileGrid: tileGrid, }), }); ``` 在此代码片段中,我们通过 `createXYZ` 创建了一个带有自定义 `resolutions` 的瓦片网格,并将其应用于 `XYZSource` 实例。这样可以确保地图的服务请求严格遵循预设的分辨率列表[^2]。 #### 3. **动态调整 Resolutions** 有时开发者希望基于用户的操作或者外部条件的变化实时修改 `resolutions`。虽然直接更改已存在的 `tileGrid` 并不会立即生效,但是可以通过重新初始化整个 `source` 对象并更新图层的方式实现这一目标: ```javascript function updateResolutions(newResolutions) { const updatedTileGrid = createXYZ({ resolutions: newResolutions }); const newSource = new XYZSource({ url: 'https://{a-c}.tile.openstreetmap.org/{z}/{x}/{y}.png', tileGrid: updatedTileGrid, }); layer.setSource(newSource); } // 示例调用 updateResolutions([ ...resolutions.slice(0, 10), // 截断原数组的一部分作为新的分辨率集合 ]); ``` 这段脚本展示了如何构建一个新的 `tileGrid` 和 `source`,并将它们应用回现有的图层实例上,从而达到动态改变分辨率的效果[^4]。 #### 4. **Resolution 监听与响应** 为了依据当前地图的 resolution 动态切换资源或样式,可以监听 `moveend` 事件,并获取最新的 resolution 进行处理: ```javascript map.on('moveend', function () { const currentResolution = map.getView().getResolution(); console.log(`Current Resolution is ${currentResolution}`); if (currentResolution > someThresholdValue) { // 执行高分辨率下特有的逻辑... } }); ``` 这里利用了 `getView().getResolution()` 方法取得当前视角的实际分辨率值,进而判断是否满足某种业务规则[^1]。 --- ###
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值