Skip to content

Commit 2954ebf

Browse files
authored
ブロックの最低標高を0mに合わせる (#562)
<!-- Close or Related Issues --> Related #556 ### Description(変更内容) <!-- Please describe the motivation behind this PR and the changes it introduces. --> <!-- 何のために、どのような変更をしますか? --> - マインクラフトの高度は-64~320 - PLATEAUのデータは標高であるため、地域によっては最低標高がとても高く、ブロックが配置されない可能性がある - このため、ブロックを配置する際に、変換元データのbounding volumeの最低標高の分だけz座標を下げることで、配置されない可能性を減らす - さらに64.0m下げる方が良い可能性もある - 「元の標高」「0m」「-64m」 を可変にできるオプションも検討する ### Manual Testing(手動テスト) <!-- If manual testing is required, please describe the procedure. --> <!-- 手動での動作確認が必要なら、そのやり方を記述してください。--> Not required / 不要
1 parent ada0f00 commit 2954ebf

File tree

1 file changed

+16
-12
lines changed
  • nusamai/src/sink/minecraft

1 file changed

+16
-12
lines changed

nusamai/src/sink/minecraft/mod.rs

+16-12
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ impl DataSink for MinecraftSink {
117117
let mut chunk_map: HashMap<(Position2D, Position2D), usize> = HashMap::new();
118118
let mut section_map: HashMap<(Position2D, Position2D, i32), usize> = HashMap::new();
119119

120-
let mut local_bvol = BoundingVolume::default();
120+
let mut global_bvol = BoundingVolume::default();
121121

122122
// FIXME: Collecting all features in memory to calculate the bounding volume, which is not scalable.
123123
let parcels: Vec<crate::pipeline::Parcel> = upstream.into_iter().collect();
@@ -126,24 +126,24 @@ impl DataSink for MinecraftSink {
126126
let entity = &parcel.entity;
127127

128128
let geom_store = entity.geometry_store.read().unwrap();
129-
let mut parcel_bvol = BoundingVolume::default();
129+
let mut local_bvol = BoundingVolume::default();
130130

131131
// Calculation of bounding volume
132132
geom_store.vertices.iter().for_each(|v| {
133-
parcel_bvol.min_lng = parcel_bvol.min_lng.min(v[0]);
134-
parcel_bvol.max_lng = parcel_bvol.max_lng.max(v[0]);
135-
parcel_bvol.min_lat = parcel_bvol.min_lat.min(v[1]);
136-
parcel_bvol.max_lat = parcel_bvol.max_lat.max(v[1]);
137-
parcel_bvol.min_height = parcel_bvol.min_height.min(v[2]);
138-
parcel_bvol.max_height = parcel_bvol.max_height.max(v[2]);
133+
local_bvol.min_lng = local_bvol.min_lng.min(v[0]);
134+
local_bvol.max_lng = local_bvol.max_lng.max(v[0]);
135+
local_bvol.min_lat = local_bvol.min_lat.min(v[1]);
136+
local_bvol.max_lat = local_bvol.max_lat.max(v[1]);
137+
local_bvol.min_height = local_bvol.min_height.min(v[2]);
138+
local_bvol.max_height = local_bvol.max_height.max(v[2]);
139139
});
140140

141-
local_bvol.update(&parcel_bvol);
141+
global_bvol.update(&local_bvol);
142142
});
143143

144144
// Calculation of centre coordinates
145-
let center_lng = (local_bvol.min_lng + local_bvol.max_lng) / 2.0;
146-
let center_lat = (local_bvol.min_lat + local_bvol.max_lat) / 2.0;
145+
let center_lng = (global_bvol.min_lng + global_bvol.max_lng) / 2.0;
146+
let center_lat = (global_bvol.min_lat + global_bvol.max_lat) / 2.0;
147147

148148
let projection = ExtendedTransverseMercatorProjection::new(
149149
center_lng,
@@ -184,7 +184,11 @@ impl DataSink for MinecraftSink {
184184
.iter()
185185
.map(|v| match projection.project_forward(v[0], v[1], v[2]) {
186186
// To match the Minecraft coordinate system, the y-coordinate is multiplied by -1 and replaced with z
187-
Ok((x, y, z)) => [x, z, -y],
187+
Ok((x, y, mut z)) => {
188+
// Set the minimum altitude to 0 by subtracting the minimum altitude of the bounding volume.
189+
z -= global_bvol.min_height.min(v[2]);
190+
[x, z, -y]
191+
}
188192
Err(e) => {
189193
println!("conversion error: {:?}", e);
190194
[f64::NAN, f64::NAN, f64::NAN]

0 commit comments

Comments
 (0)