Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
25 changes: 23 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,29 @@ jobs:
cache: 'gradle'

- name: Build core and compose locally
env:
HEAD_REF: ${{ github.head_ref }}
run: |
git clone --depth 1 https://github.com/MapConductor/android-sdk-core.git _core
# コア側に PR と同名のブランチがあるなら、そちらを組む。
#
# ここを default ブランチ固定にしていると、**コアの未マージな変更に追随する
# PR は永久に赤いまま**になる。実際 CameraBearing をコアへ足したとき、
# プロバイダ側の PR が 10 本まとめて Unresolved reference で落ちた。
# コアが先にマージされるまで待つ、という運用は取り込み順の事故を呼ぶので、
# 同名ブランチがあれば拾う形にしてある(無ければ従来どおり default)。
clone_matching() {
repo="$1"; dir="$2"
url="https://github.com/MapConductor/$repo.git"
if [ -n "$HEAD_REF" ] && git ls-remote --exit-code --heads "$url" "$HEAD_REF" >/dev/null 2>&1; then
echo "$repo: matching branch $HEAD_REF"
git clone --depth 1 --branch "$HEAD_REF" "$url" "$dir"
else
echo "$repo: default branch"
git clone --depth 1 "$url" "$dir"
fi
}

clone_matching android-sdk-core _core
cd _core
./gradlew --no-daemon publishToMavenLocal
cd ..
Expand All @@ -53,7 +74,7 @@ jobs:
}
EOF

git clone --depth 1 https://github.com/MapConductor/android-sdk-compose.git _compose
clone_matching android-sdk-compose _compose
cd _compose
./gradlew --no-daemon publishToMavenLocal
cd ..
Expand Down
5 changes: 4 additions & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
[versions]
composeLibs = "1.7.8"
# material3 は compose-ui とは別のバージョン系列。composeLibs(ui 系)を流用すると
# 存在しない material3:1.7.8 を要求してクラスパスごと解決に失敗する。
material3 = "1.4.0"
openmobilemaps = "4.0.0"
coroutines = "1.9.0"
agp = "9.2.1"
Expand Down Expand Up @@ -37,7 +40,7 @@ play-services-maps = { module = "com.google.android.gms:play-services-maps", ver

# Sample app
androidx-activity-compose = { group = "androidx.activity", name = "activity-compose", version.ref = "activityCompose" }
androidx-material3 = { group = "androidx.compose.material3", name = "material3", version.ref = "composeLibs" }
androidx-material3 = { group = "androidx.compose.material3", name = "material3", version.ref = "material3" }
androidx-ui-tooling = { group = "androidx.compose.ui", name = "ui-tooling", version.ref = "composeLibs" }

# Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import com.mapconductor.core.controller.BaseMapViewController
import com.mapconductor.core.features.GeoPoint
import com.mapconductor.core.features.GeoPointInterface
import com.mapconductor.core.features.GeoRectBounds
import com.mapconductor.core.map.CameraBearing
import com.mapconductor.core.map.MapCameraPosition
import com.mapconductor.core.map.MapCapabilityStatus
import com.mapconductor.core.map.MapUISettings
Expand Down Expand Up @@ -475,20 +476,20 @@ class OpenMobileMapsMapViewController(

companion object {
/**
* 方位の符号。**SDK は MapConductor と逆回りである。**
* 方位の符号。**SDK の `setRotation` は MapConductor の bearing と同じ向き**
* (どちらも「地図を時計回りに回す量」)なので、変換は恒等になる。
*
* MapConductor の bearing は Google 準拠で「カメラが向いている方位を北から時計回りに測る」。
* SDK の `setRotation` は地図を反時計回りに回す量なので、符号を反転する。
* 反転を忘れると bearing 270 の地図が 90 として描かれ、**ちょうど 180 度ずれる**
* (tilt ページを MapLibre と並べて気づいた。単独で見ると「回っている」ので正しく見える)。
* ここは机上ではなく端末で決めた値である。基準は「MapLibre と並べて同じ向きに
* 描かれること」で、MapLibre 側が heading 系(bearing の符号反転)に変わったのに
* 合わせてこちらも反転させてある。**符号を触ったら必ず tilt ページを MapLibre と
* 並べて確認すること。** 単独で見ると「回っている」ので正しく見えてしまう。
*/
internal fun nativeRotationFromBearing(bearing: Double): Float = (-bearing).toFloat()
internal fun nativeRotationFromBearing(bearing: Double): Float =
CameraBearing.toNativeRotation(bearing).toFloat()

/** SDK の回転角 → MapConductor の bearing(0 以上 360 未満)。 */
internal fun bearingFromNativeRotation(rotation: Float): Double {
val bearing = -rotation.toDouble() % 360.0
return if (bearing < 0) bearing + 360.0 else bearing
}
internal fun bearingFromNativeRotation(rotation: Float): Double =
CameraBearing.bearingFromNativeRotation(rotation.toDouble())

/**
* ズームの往復換算。
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.mapconductor.openmobilemaps

import com.mapconductor.core.features.GeoPoint
import com.mapconductor.core.features.GeoPointInterface
import com.mapconductor.core.map.CameraBearing
import com.mapconductor.core.map.MapCameraPosition
import com.mapconductor.core.spherical.Spherical
import com.mapconductor.core.zoom.AbstractZoomAltitudeConverter
Expand Down Expand Up @@ -53,7 +54,7 @@ internal object OpenMobileMapsTiltEmulation {
val tiltAbsRad = Math.toRadians(tiltAbsDeg)
val altitude = altitudeFor(position.zoom, position.position.latitude)
val distanceForward = altitude * cos(tiltAbsRad) * tan(tiltAbsRad) * TARGET_DISTANCE_SCALE
val target = Spherical.computeOffset(position.position, distanceForward, position.bearing)
val target = Spherical.computeOffset(position.position, distanceForward, CameraBearing.toNativeHeading(position.bearing))
return target to zoom
}

Expand All @@ -71,7 +72,7 @@ internal object OpenMobileMapsTiltEmulation {
val tiltAbsRad = Math.toRadians(tiltAbsDeg)
val altitude = altitudeFor(originalZoom, center.latitude)
val distanceBackward = altitude * cos(tiltAbsRad) * tan(tiltAbsRad) * TARGET_DISTANCE_SCALE
val originalPosition: GeoPoint = Spherical.computeOffset(center, distanceBackward, bearing + 180.0)
val originalPosition: GeoPoint = Spherical.computeOffset(center, distanceBackward, CameraBearing.toNativeHeading(bearing) + 180.0)
return originalPosition to originalZoom
}

Expand Down
Loading