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

Conversion from TileXYZ into extendedSpatialID and SpatialID #29

Merged
merged 25 commits into from
Aug 23, 2024
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
d39f4bb
feature_4481
Jul 11, 2024
e5825d3
changed calculation of ConvertQuadkeysAndAltitudekeysToExtendedSpatia…
mi-24v Jul 26, 2024
ff8a838
fixed lack of vertical index when zBaseOffset is not power of 2
mi-24v Jul 29, 2024
74b6a07
added examples to ConvertQuadkeysAndAltitudekeysToExtendedSpatialIDs …
mi-24v Jul 30, 2024
8e5b8f1
added documentation of ConvertQuadkeysAndAltitudekeysToExtendedSpatia…
mi-24v Jul 31, 2024
c4053a2
make public altitude conversion
mi-24v Aug 2, 2024
08c980c
added docs about current converting functions
mi-24v Aug 8, 2024
a064f23
changed `ConvertQuadkeysAndAltitudekeysToExtendedSpatialIDs()` into `…
mi-24v Aug 12, 2024
98478fb
reduce outputHZoom parameter in `ConvertTileXYZToExtendedSpatialIDs()`
mi-24v Aug 16, 2024
787a10a
added excluding duplication outputIDs in `ConvertTileXYZToExtendedSpa…
mi-24v Aug 16, 2024
74ebcc5
added conversion from extendedSpatialId into SpatialId
mi-24v Aug 16, 2024
e9aefb5
added conversion from TileXYZ into SpatialId
mi-24v Aug 19, 2024
c140e99
updated documentation of conversion functions
mi-24v Aug 19, 2024
ebbb029
refactored function name and parameters
mi-24v Aug 20, 2024
dcbf46a
updated documentation for TileXYZ->SpatialID conversion
mi-24v Aug 20, 2024
1aec8a9
refactored conversion function
mi-24v Aug 21, 2024
2163f75
reduced type casting of `objects.TileXYZ`
mi-24v Aug 21, 2024
17c6c8d
moved example of converting TileXYZ to SpatialID
mi-24v Aug 21, 2024
7830aa2
updated documentation of conversion function
mi-24v Aug 22, 2024
662019c
refactored conversion from altitudeKey to Z-index
mi-24v Aug 22, 2024
9dbe76d
refactored conversion from Z-index to altitudeKey
mi-24v Aug 22, 2024
b78f77a
updated dependencies
mi-24v Aug 22, 2024
da2aacb
updated workflow's go version
mi-24v Aug 22, 2024
270570e
reverted to not using test table at `TestConvertZToMinMaxAltitudekey`…
mi-24v Aug 23, 2024
ebe0d0e
refactored convertZToMinAltitudeKey
mi-24v Aug 23, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions common/consts/consts.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,13 @@ const OrthCrs = 3857 // OrthCrs 直交座標系のEPSGコード
const SpatialIDDelimiter = "/" // SpatialIDDelimiter 空間IDの区切り文字

const Minima = 1e-10 // Minima 浮動小数点誤差

const MaxTileXYZZoom = 35 // MaxTileXYZZoom TileXYZにおける最大ズームレベル(水平、垂直共通)
HarutakaMatsumoto marked this conversation as resolved.
Show resolved Hide resolved

// FromExtendedSpatialIDToQuadkeyAndAltitudekey.innerIDの並び順
const (
// InnerIDQuadkeyIndex quadkeyはinnerID[0]
InnerIDQuadkeyIndex = 0
// InnerIDAltitudekeyIndex altitudekeyはinnerID[1]
InnerIDAltitudekeyIndex = 1
)
194 changes: 194 additions & 0 deletions common/object/id_object.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
// 拡張空間IDパッケージ
package object

import (
"fmt"
"github.com/trajectoryjp/spatial_id_go/v4/common/consts"
"github.com/trajectoryjp/spatial_id_go/v4/common/errors"
)

// FromExtendedSpatialIDToQuadkeyAndAltitudekey 拡張空間IDから変換したquadkeyとaltitudekeyの組み合わせを管理する構造体
type FromExtendedSpatialIDToQuadkeyAndAltitudekey struct {
// quadkeyの精度
Expand Down Expand Up @@ -507,3 +513,191 @@ func (qh QuadkeyAndVerticalID) MaxHeight() float64 {
func (qh QuadkeyAndVerticalID) MinHeight() float64 {
return qh.minHeight
}

// TileXYZ 水平方向TileKey(x,y)と垂直方向TileKey(z)の組み合わせを管理する構造体
type TileXYZ struct {
// 水平精度 0-(consts.MaxTileXYZZoom)の非負整数
HarutakaMatsumoto marked this conversation as resolved.
Show resolved Hide resolved
hZoom uint16
HarutakaMatsumoto marked this conversation as resolved.
Show resolved Hide resolved
// x 水平方向key x軸
x int64
// y 水平方向key y軸
y int64
// 垂直精度 0-(consts.MaxTileXYZZoom)の非負整数
HarutakaMatsumoto marked this conversation as resolved.
Show resolved Hide resolved
vZoom uint16
// 垂直方向key
z int64
}

// NewTileXYZ TileXYZ初期化関数
//
// quadkeyに数値以外が含まれていた場合エラーとなる。
//
// 引数:
//
// hZoom: 水平ズームレベル
// x: 水平方向xインデックス
// y: 水平方向yインデックス
// vZoom: 垂直ズームレベル
// z: 高さ方向のインデックス
//
// 戻り値:
//
// 初期化したTileXYZオブジェクト
//
// 戻り値(エラー):
//
// 以下の条件に当てはまる場合、エラーインスタンスが返却される。
// ズームレベル不正:hZoomまたはvZoomに0-(consts.MaxTileXYZZoom)以外の数値が含まれていた場合
HarutakaMatsumoto marked this conversation as resolved.
Show resolved Hide resolved
func NewTileXYZ(hZoom uint16, x int64, y int64, vZoom uint16, z int64) (*TileXYZ, error) {
tile := &TileXYZ{}

// 水平精度設定
err := tile.SetHZoom(hZoom)
if err != nil {
return nil, err
}

// X設定
tile.SetX(x)
// Y設定
tile.SetY(y)

// 垂直精度設定
err = tile.SetVZoom(vZoom)
if err != nil {
return nil, err
}

// 高さのインデックス設定
tile.SetZ(z)

return tile, nil
}

// SetHZoom 水平精度設定関数
//
// TileXYZオブジェクトのhZoomを引数の入力値に設定する。
//
// input 引数:
//
// hZoom:水平精度
//
// 戻り値(エラー):
//
// 以下の条件に当てはまる場合、エラーインスタンスが返却される。
// ズームレベル不正:hZoomに0-(consts.MaxTileXYZZoom)以外の数値が含まれていた場合
func (a *TileXYZ) SetHZoom(hZoom uint16) error {
if !(hZoom <= consts.MaxTileXYZZoom) {
return errors.NewSpatialIdError(errors.InputValueErrorCode, fmt.Sprintf("hZoom must be in 0-%v, but got %v", consts.MaxTileXYZZoom, hZoom))
}
a.hZoom = hZoom
return nil
}

// SetX xインデックス設定関数
//
// TileXYZオブジェクトのxを引数の入力値に設定する。
//
// input 引数:
//
// x:xインデックス値
func (a *TileXYZ) SetX(x int64) {
a.x = x
}

// SetY yインデックス設定関数
//
// TileXYZオブジェクトのyを引数の入力値に設定する。
//
// input 引数:
//
// y:yインデックス値
func (a *TileXYZ) SetY(y int64) {
a.y = y
}

// SetVZoom 垂直精度設定関数
//
// TileXYZオブジェクトのvZoomを引数の入力値に設定する。
//
// input 引数:
//
// vZoom:垂直精度
//
// 戻り値(エラー):
//
// 以下の条件に当てはまる場合、エラーインスタンスが返却される。
// ズームレベル不正:はvZoomに0-35以外の数値が含まれていた場合
func (a *TileXYZ) SetVZoom(vZoom uint16) error {
if !(vZoom <= consts.MaxTileXYZZoom) {
return errors.NewSpatialIdError(errors.InputValueErrorCode, fmt.Sprintf("vZoom must be in 0-%v, but got %v", consts.MaxTileXYZZoom, vZoom))
}
a.vZoom = vZoom
return nil
}

// SetZ zインデックス設定関数
//
// TileXYZオブジェクトのzを引数の入力値に設定する。
//
// input 引数:
//
// z:zインデックス値
func (a *TileXYZ) SetZ(z int64) {
a.z = z
}

// HZoom HZoom設定値取得関数
//
// TileXYZオブジェクトに設定されているhZoomの値を取得する。
//
// output 戻り値:
//
// TileXYZオブジェクトに設定されているHZoomの値
func (a *TileXYZ) HZoom() uint16 {
return a.hZoom
}

// X x設定値取得関数
//
// TileXYZオブジェクトに設定されているxの値を取得する。
//
// output 戻り値:
//
// TileXYZオブジェクトに設定されているxの値
func (a *TileXYZ) X() int64 {
return a.x
}

// Y y設定値取得関数
//
// TileXYZオブジェクトに設定されているyの値を取得する。
//
// output 戻り値:
//
// TileXYZオブジェクトに設定されているyの値
func (a *TileXYZ) Y() int64 {
return a.y
}

// VZoom vZoom設定値取得関数
//
// TileXYZオブジェクトに設定されているvZoomの値を取得する。
//
// output 戻り値:
//
// TileXYZオブジェクトに設定されているvZoomの値
func (a *TileXYZ) VZoom() uint16 {
return a.vZoom
}

// Z z設定値取得関数
//
// TileXYZオブジェクトに設定されているzの値を取得する。
//
// output 戻り値:
//
// TileXYZオブジェクトに設定されているzの値
func (a *TileXYZ) Z() int64 {
return a.z
}
Loading
Loading