jma

package module
v0.0.0-...-2772e45 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 9, 2021 License: MPL-2.0 Imports: 9 Imported by: 0

README

jma

Download helper for https://www.jma.go.jp/bosai/nowc and https://www.jma.go.jp/bosai/kaikotan, written in Go.

Usage

package main

import (
	"fmt"
	"github.com/tak0kada/jma"
	"time"
)

func main() {
	now, _ := time.Parse(time.RFC3339, "2021-09-05T13:32:38Z")

	g := jma.GeoCoordinate{33.737131, 137.226929}
	var zoom uint = 8

	if !g.IsValid() {
		fmt.Println("invalid geocoordinate %s. normalizing...")
		g = g.Normalize()
	}
	fmt.Printf("GeoCoordinate: %s\n", g) // => GeoCoordinate: {Lat: 33.737131, Lon: 137.226929}

	t := g.GetTile(zoom)
	fmt.Printf("Tile: %s\n", t) // => Tile: {Level: 8, X: 225, Y: 102}

	err := jma.DownloadImageTile(t, now, 0, "./tile.png")
	if err != nil {
		fmt.Println(err)
	}
	err = jma.DownloadImage(g, zoom, jma.Rect{600, 800}, now, 0, "./example.png")
	if err != nil {
		fmt.Printf(err.Error())
	}
}

Output

  • tile.png

tile image downloaded from jma.go.jp

  • example.png

example image downloaded from jma.go.jp

Reference

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CalcCorner

func CalcCorner(tc TileCoordinate, height float64, width float64) (TileCoordinate, TileCoordinate)

func ConcatImages

func ConcatImages(imgs [][]image.Image) image.Image

func CropImage

func CropImage(img image.Image, center TileCoordinate, rect Rect) image.Image

func DownloadImage

func DownloadImage(gc GeoCoordinate, zoom uint, rect Rect, now time.Time, duration time.Duration, filepath string) error

func DownloadImageTile

func DownloadImageTile(tile Tile, now time.Time, duration time.Duration, filepath string) error

func FetchBorderImage

func FetchBorderImage(gc GeoCoordinate, zoom uint, rect Rect) (image.Image, error)

func FetchImage

func FetchImage(gc GeoCoordinate, zoom uint, rect Rect, now time.Time, duration time.Duration) (image.Image, error)

func FetchImageTile

func FetchImageTile(tile Tile, now time.Time, duration time.Duration) (image.Image, error)

func FetchJmaImage

func FetchJmaImage(gc GeoCoordinate, zoom uint, rect Rect, now time.Time, duration time.Duration) (image.Image, error)

func FetchMapImage

func FetchMapImage(gc GeoCoordinate, zoom uint, rect Rect, datatype string) (image.Image, error)

func Overlay

func Overlay(bottom image.Image, middle image.Image, top image.Image) (image.Image, error)

Types

type GeoCoordinate

type GeoCoordinate struct {
	Lat float64 `validate:"gte=-85.0511287798,lte=85.0511287798,required"`
	Lon float64 `validate:"required"`
}

func (GeoCoordinate) GetTile

func (g GeoCoordinate) GetTile(zoom uint) Tile

func (GeoCoordinate) GetTileCoordinate

func (g GeoCoordinate) GetTileCoordinate(zoom uint) TileCoordinate

func (GeoCoordinate) IsValid

func (g GeoCoordinate) IsValid() bool

func (GeoCoordinate) Normalize

func (g GeoCoordinate) Normalize() GeoCoordinate

func (GeoCoordinate) String

func (g GeoCoordinate) String() string

type Rect

type Rect struct {
	H uint // pixels
	W uint // pixels
}

type Tile

type Tile struct {
	Zoom uint `validate:"gte=0,lte=18,required"`
	X    uint `json:"tile_x" validate:"required"`
	Y    uint `json:"tile_y" validate:"required"`
}

For the definition of Tile struct, see: https://maps.gsi.go.jp/development/siyou.html#siyou-url .

func (Tile) IsValid

func (t Tile) IsValid() bool

func (Tile) String

func (t Tile) String() string

func (Tile) ToBorderMapURL

func (t Tile) ToBorderMapURL(ext string) string

func (Tile) ToJmaURL

func (t Tile) ToJmaURL(now time.Time, duration time.Duration, ext string) (string, error)

Japan Meteorological Agency(気象庁)

func (Tile) ToMapURL

func (t Tile) ToMapURL(datatype string, ext string) string

Geospatial Information Authority(国土地理院)

type TileCoordinate

type TileCoordinate struct {
	Zoom uint    `validate:"gte=0,lte=18,required"`
	X    float64 `json:"tilecoordinate_x" validate:"required"`
	Y    float64 `json:"tilecoordinate_y" validate:"required"`
}

func (TileCoordinate) GetTile

func (tc TileCoordinate) GetTile() Tile

func (TileCoordinate) IsValid

func (tc TileCoordinate) IsValid() bool

func (TileCoordinate) String

func (tc TileCoordinate) String() string

func (TileCoordinate) ToGeoCoordinate

func (tc TileCoordinate) ToGeoCoordinate() GeoCoordinate

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL