Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ameshアップデート2022/05 #997

Merged
merged 49 commits into from
Nov 5, 2022
Merged

ameshアップデート2022/05 #997

merged 49 commits into from
Nov 5, 2022

Conversation

m77so
Copy link
Contributor

@m77so m77so commented May 7, 2022

ameshの改良( #640 )

  • マップ描画部分を書き直して切り出し
    • 指定した緯度・経度の場所にマーカーや線を描画しやすく
    • マップの上に追加の地図タイルを描画しやすく
  • 指定した地点が地図の中心ではなかったのを中心にするように修正
  • 指定した地点の場所がわかりやすいように、10km, 20km, 30km, 50km, 100kmの同心円を描画
  • 雨雲レーダーの更新時刻がわかるように、画像内にタイムスタンプを記述

雷レーダーの追加( closes: #983 )

  • 雷レーダーの表示

m77so added 2 commits May 7, 2022 13:51
formatが間違ってたので直してあげたよ!PRをマージしてね! #997
@massongit
Copy link
Member

ipag.ttf をgitの管理下に置く代わりにDockerfile内でダウンロード・配置すると、バージョンが明記されて良い説?

@massongit
Copy link
Member

いや、それするとテストうまくいかない説あるか。

formatが間違ってたので直してあげたよ!PRをマージしてね! #997
@m77so m77so changed the title 新しいマップエンジンにする ameshアップデート2022 May 7, 2022
@m77so m77so changed the title ameshアップデート2022 ameshアップデート2022/05 May 7, 2022
library/hatomap.py Outdated Show resolved Hide resolved
library/hatomap.py Outdated Show resolved Hide resolved
library/jma_amesh.py Outdated Show resolved Hide resolved
library/hatomap.py Outdated Show resolved Hide resolved
library/hatomap.py Outdated Show resolved Hide resolved
Co-authored-by: Goryudyuma(Kei.Matsumoto) <[email protected]>
library/hatomap.py Outdated Show resolved Hide resolved
library/hatomap.py Outdated Show resolved Hide resolved
library/hatomap.py Outdated Show resolved Hide resolved
library/hatomap.py Outdated Show resolved Hide resolved
data = [TimeJsonElement(**i) for i in json.loads(response.text)]
timejson += data

elements = list(set([e for i in timejson for e in i.elements]))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
elements = list(set([e for i in timejson for e in i.elements]))
elements = list(set(e for i in timejson for e in i.elements))

こんな感じでもできるはず。

m77so and others added 2 commits June 4, 2022 17:04
…amesh-new-engine

.pre-commit-config.yamlを直してあげたよ!PRをマージしてね! #997
library/hatomap.py Outdated Show resolved Hide resolved
formatが間違ってたので直してあげたよ! #997
self.mapbox.height = height - offset_top
if width is not None:
self.mapbox.width = width
body_img = None
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
body_img = None
body_img: Optional[np.ndarray] = None

https://github.com/dev-hato/hato-bot/actions/runs/2783525807/jobs/4380588635

library/hatomap.py:462:27: E1136: Value 'body_img' is unsubscriptable (unsubscriptable-object)

は上記のようにすると良さそう?

.T
)

def geocoords2pixel(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://github.com/dev-hato/hato-bot/actions/runs/2783525807/jobs/4380588635

library/hatomap.py:145: error: Argument 1 to "_ndarray_geocoords2pixel" of "WebMercatorPixelBBox" has incompatible type "Union[ndarray[Any, Any], GeoCoord, List[GeoCoord]]"; expected "ndarray[Any, Any]"
library/hatomap.py:148: error: Argument 1 to "geocoord2pixel" of "WebMercatorPixelBBox" has incompatible type "Union[ndarray[Any, Any], GeoCoord, List[GeoCoord]]"; expected "GeoCoord"
library/hatomap.py:150: error: Item "GeoCoord" of "Union[ndarray[Any, Any], GeoCoord, List[GeoCoord]]" has no attribute "__iter__" (not iterable)

geocoords の型ごとにメソッドを分けた方が良い説。

np.asarray(bytearray(requests.get(url).content), dtype=np.uint8), -1
)

def request(self, bbox: WebMercatorPixelBBox = None) -> np.ndarray:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
def request(self, bbox: WebMercatorPixelBBox = None) -> np.ndarray:
def request(self, bbox: WebMercatorPixelBBox = None) -> Optional[np.ndarray]:

https://github.com/dev-hato/hato-bot/actions/runs/2783525807/jobs/4380588635

library/hatomap.py:185: error: Incompatible return value type (got "None", expected "ndarray[Any, Any]")

上記が正しそう。

color: Tuple[int, int, int, int] = (255, 0, 255, 255)

def get_image(self, bbox: WebMercatorPixelBBox = None) -> np.ndarray:
img = np.zeros((bbox.height, bbox.width, 4), np.uint8)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://github.com/dev-hato/hato-bot/actions/runs/2783525807/jobs/4380588635

library/hatomap.py:225: error: Item "None" of "Optional[WebMercatorPixelBBox]" has no attribute "height"
library/hatomap.py:225: error: Item "None" of "Optional[WebMercatorPixelBBox]" has no attribute "width"
library/hatomap.py:235: error: Item "None" of "Optional[WebMercatorPixelBBox]" has no attribute "geocoords2pixel"

ここの前に bboxNone かどうかのチェックを入れる必要がありそう。


@dataclass
class LineTrace:
coords: Union[List["np.ndarray"], List[List[GeoCoord]]]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://github.com/dev-hato/hato-bot/actions/runs/2783525807/jobs/4380588635

library/hatomap.py:230: error: Value of type "Union[Any, GeoCoord]" is not indexable
library/hatomap.py:263: error: Value of type "Union[Any, GeoCoord]" is not indexable

coords をそれぞれの型ごとに設けると良さそう?


@dataclass
class RasterLayer:
url: Union[List[str], str]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://github.com/dev-hato/hato-bot/actions/runs/2783525807/jobs/4380588635

library/hatomap.py:354: error: Incompatible types in assignment (expression has type "Union[List[str], str]", variable has type "str")

url をそれぞれの型ごとに設けると良さそう?


mapbox: MapBox = MapBox()
basemap: str = "open-street-map"
extra_basemap_server: str = None
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
extra_basemap_server: str = None
extra_basemap_server: Optional[str] = None

https://github.com/dev-hato/hato-bot/actions/runs/2783525807/jobs/4380588635

library/hatomap.py:395: error: Incompatible types in assignment (expression has type "None", variable has type "str")

mapbox: MapBox = MapBox()
basemap: str = "open-street-map"
extra_basemap_server: str = None
layers: List[Union[RasterLayer, LineTrace]] = None
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
layers: List[Union[RasterLayer, LineTrace]] = None
layers: Optional[List[Union[RasterLayer, LineTrace]]] = None

https://github.com/dev-hato/hato-bot/actions/runs/2783525807/jobs/4380588635

library/hatomap.py:396: error: Incompatible types in assignment (expression has type "None", variable has type "List[Union[RasterLayer, LineTrace]]")

basemap: str = "open-street-map"
extra_basemap_server: str = None
layers: List[Union[RasterLayer, LineTrace]] = None
title: str = None
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
title: str = None
title: Optional[str] = None

https://github.com/dev-hato/hato-bot/actions/runs/2783525807/jobs/4380588635

library/hatomap.py:397: error: Incompatible types in assignment (expression has type "None", variable has type "str")

1 - layer_img[..., 3:] / 255
) + layer_img[..., :3] * (layer_img[..., 3:] / 255)

img = np.zeros((height, width, 3), np.uint8)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://github.com/dev-hato/hato-bot/actions/runs/2783525807/jobs/4380588635

library/hatomap.py:466: error: Argument 1 to "zeros" has incompatible type "Tuple[Optional[int], Optional[int], int]"; expected "Union[SupportsIndex, Sequence[SupportsIndex]]"

ここより前に heightwidthNone だった時の処理を入れると良さそう。

Comment on lines +126 to +145
layers=[
RasterLayer(
url=get_jma_image_server(jma_timestamp["hrpns_nd"]), opacity=128 / 256
)
]
+ [
LineTrace(
coords=[get_circle(lat, lng, d * 1000)], color=(100, 100, 100, 255)
)
for d in range(10, 60, 10)
]
+ [
MarkerTrace(
[GeoCoord(e[0], e[1]) for e in get_liden(jma_timestamp["liden"])],
size=14,
symbol="thunder",
fill_color=(0, 255, 255, 255),
border_color=(0, 64, 64, 255),
)
],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://github.com/dev-hato/hato-bot/actions/runs/2783525807/jobs/4380588635

library/jma_amesh.py:126: error: Argument "layers" to "HatoMap" has incompatible type "List[RasterLayer]"; expected "List[Union[RasterLayer, LineTrace]]"
library/jma_amesh.py:126: note: "List" is invariant -- see https://mypy.readthedocs.io/en/stable/common_issues.html#variance
library/jma_amesh.py:126: note: Consider using "Sequence" instead, which is covariant
library/jma_amesh.py:132: error: List comprehension has incompatible type List[LineTrace]; expected List[RasterLayer]
library/jma_amesh.py:138: error: List item 0 has incompatible type "MarkerTrace"; expected "RasterLayer"

RasterLayer, LineTrace, LineTrace の各配列を List[Union[RasterLayer, LineTrace]] として変数定義して結合させれば良さそう?

]
+ [
MarkerTrace(
[GeoCoord(e[0], e[1]) for e in get_liden(jma_timestamp["liden"])],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://github.com/dev-hato/hato-bot/actions/runs/2783525807/jobs/4380588635

library/jma_amesh.py:139: error: Item "None" of "Optional[List[Tuple[float, float, int]]]" has no attribute "__iter__" (not iterable)

ここより前で get_liden(jma_timestamp["liden"])None かのチェックを入れると良さそう。

@massongit
Copy link
Member

massongit commented Sep 24, 2022

blackisort の指摘事項についてはコンフリクトを解消すればformat修正のPRとして出されるはず: #1504

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

ameshの雷レーダー版
4 participants