Repository navigation
weather: 天气应用 - #3
Open
SagitPixel wants to merge 3 commits into
Open
SagitPixel wants to merge 3 commits into
SagitPixel wants to merge 3 commits into
Conversation
按 IP 定位到市(ipapi 的库对中国移动不准,改用 myip.ipip.net 拿地名, 再去小米接口换坐标)。支持手动选省/市/区县,三级列表不需要输入法。 数据来自小米天气的公开接口,含当前天气、逐小时、15 天预报、 空气质量(CNEMC)、日出日落。 背景动画移植自 GeometricWeather(LGPL-3.0):晴/流星雨/雨/雪/冰雹/ 风沙/云 七种,参数和配色照抄,代码用 Canvas 重写。
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
新增应用:天气(weather)
功能
tools/check.py本地结果:ok weather,0 errors。数据来源
小米天气的公开接口,不需要注册或申请 key:
空气质量来源是中国环境监测总站(CNEMC),随天气接口一起返回。
定位用
myip.ipip.net而不是常见的ip-api.com:实测同一个移动网络 IP,ip-api报的城市与实际位置相差三千多公里,myip.ipip.net准确。拿到地名之后再去小米的
city/search换坐标,比直接用经纬度准。背景动画
七种动画的算法、参数和配色移植自 GeometricWeather
(LGPL-3.0)的
theme/weatherView/materialWeatherView/implementor/:SunImplementorMeteorShowerImplementorRainImplementorSnowImplementorHailImplementorWindImplementorCloudImplementor原版是 Android Canvas 逐帧绘制,这里用 HTML5 Canvas 重写——
translate/rotate/fillRect语义一致,基本能一一对应。参数(个数、速度、尺寸比例)和配色照抄,代码是 JS 新写的。
背景配色也照抄
MaterialWeatherThemeDelegate.innerGetBackgroundColor(晴#FDBC4C、雨
#4297E7、雪#68BAFF等)。依赖
weatherapi.market.xiaomi.com、myip.ipip.netcurl:目标机型自带,取数据用已知限制
cities.json从国家统计局行政区划整理,行政区划调整后要手动更新。测试情况
在中兴畅行60(OpenWrt,384×559 屏)上实测:
?wx=<天气代码>逐个验证过)调试
?wx=<代码>强制某天气的动画,比如?wx=9看大雨许可
LGPL-3.0(见
LICENSE),和 GeometricWeather 同许可。天气数据版权归小米 / 中国气象局所有,本应用仅做展示。