From 3263347ac92b51f117f8ea726ee40747f6e930e7 Mon Sep 17 00:00:00 2001 From: nokonoko1203 Date: Tue, 28 Jan 2025 16:13:54 +0900 Subject: [PATCH 1/2] add todo --- pcd-transformer/src/projection.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/pcd-transformer/src/projection.rs b/pcd-transformer/src/projection.rs index 23bddeb..574ea3e 100644 --- a/pcd-transformer/src/projection.rs +++ b/pcd-transformer/src/projection.rs @@ -57,6 +57,7 @@ fn transform_from_jgd2011( ) -> Point { let output_epsg = EPSG_WGS84_GEOGRAPHIC_3D; + // TODO: 6697のまま(ジオイド高を足さない)の処理に対応する match output_epsg { EPSG_WGS84_GEOGRAPHIC_3D => { let x = point.x; From 3aa93dd7782f4f76781d82bac8bf47d554d9707b Mon Sep 17 00:00:00 2001 From: nokonoko1203 Date: Tue, 28 Jan 2025 16:48:04 +0900 Subject: [PATCH 2/2] Support 6697 --- README.md | 6 ++++-- app/src/main.rs | 10 ++++++--- pcd-transformer/src/projection.rs | 36 +++++++++++++++++++++++++------ 3 files changed, 40 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 5ee0c67..e9b3aa2 100644 --- a/README.md +++ b/README.md @@ -29,7 +29,8 @@ After installing Rust, download this repository. - `input`: Specify the `.las/.laz/.csv/.txt` file. Multiple files can be input separated by spaces. - `output`: Specify the output folder. Output `tileset.json` and glb. -- `epsg`: Input the epsg code of the las file. All point clouds are recognized as being in the same coordinate system.(Currently, only the Japanese plane rectangular coordinate system is supported.) +- `input-epsg`: Input the epsg code of the las file. All point clouds are recognized as being in the same coordinate system.(Currently, only the Japanese plane rectangular coordinate system is supported.) +- `output-epsg`: Supports conversion to WGS84 Geographic 3D (EPSG:4979), which is the standard for Cesium, and JGD2011 Geographic 3D (EPSG:6697), which is frequently used in Japan. - `min`: Specify the minimum zoom level you want to output. - `max`: Specify the maximum zoom level you want to output. - `max-memory-mb`: Specify the number of MB of memory available for conversion. @@ -40,7 +41,8 @@ In the repository root, the following commands can be executed. ```sh point_tiler --input app/examples/data/sample.las \ --output app/examples/data/output \ - --epsg 6677 \ + --input-epsg 6677 \ + --output-epsg 4979 \ --min 15 \ --max 18 \ --max-memory-mb 8192 \ diff --git a/app/src/main.rs b/app/src/main.rs index bcc8247..026b395 100644 --- a/app/src/main.rs +++ b/app/src/main.rs @@ -60,7 +60,10 @@ struct Cli { output: String, #[arg(short, long, required = true)] - epsg: u16, + input_epsg: u16, + + #[arg(short, long, required = true)] + output_epsg: u16, #[arg(long, default_value_t = 15)] min: u8, @@ -364,7 +367,8 @@ fn main() { log::info!("input files: {:?}", args.input); log::info!("output folder: {}", args.output); - log::info!("input EPSG: {}", args.epsg); + log::info!("input EPSG: {}", args.input_epsg); + log::info!("output EPSG: {}", args.output_epsg); log::info!("min zoom: {}", args.min); log::info!("max zoom: {}", args.max); log::info!("max memory mb: {}", args.max_memory_mb); @@ -437,7 +441,7 @@ fn main() { let mut keyed_points: Vec<(SortKey, Point)> = chunk .into_iter() .map(|p| { - let transformed = transform_point(p, args.epsg, &jgd2wgs); + let transformed = transform_point(p, args.input_epsg, args.output_epsg, &jgd2wgs); let tile_coords = tiling::scheme::zxy_from_lng_lat(max_zoom, transformed.x, transformed.y); diff --git a/pcd-transformer/src/projection.rs b/pcd-transformer/src/projection.rs index 574ea3e..f4f4e00 100644 --- a/pcd-transformer/src/projection.rs +++ b/pcd-transformer/src/projection.rs @@ -1,7 +1,12 @@ use pcd_core::pointcloud::point::Point; use projection_transform::{crs::*, jprect::JPRZone, vshift::Jgd2011ToWgs84}; -pub fn transform_point(point: Point, input_epsg: EpsgCode, jgd2wgs: &Jgd2011ToWgs84) -> Point { +pub fn transform_point( + point: Point, + input_epsg: EpsgCode, + output_epsg: EpsgCode, + jgd2wgs: &Jgd2011ToWgs84, +) -> Point { match input_epsg { EPSG_JGD2011_JPRECT_I | EPSG_JGD2011_JPRECT_II @@ -35,7 +40,7 @@ pub fn transform_point(point: Point, input_epsg: EpsgCode, jgd2wgs: &Jgd2011ToWg | EPSG_JGD2011_JPRECT_XI_JGD2011_HEIGHT | EPSG_JGD2011_JPRECT_XII_JGD2011_HEIGHT | EPSG_JGD2011_JPRECT_XIII_JGD2011_HEIGHT => { - transform_from_jgd2011(point, Some(input_epsg), jgd2wgs) + transform_from_jgd2011(point, Some(input_epsg), Some(output_epsg), jgd2wgs) } _ => { panic!("Unsupported input CRS: {}", input_epsg); @@ -53,12 +58,10 @@ fn rectangular_to_lnglat(x: f64, y: f64, height: f64, input_epsg: EpsgCode) -> ( fn transform_from_jgd2011( point: Point, rectangular: Option, + output_epsg: Option, jgd2wgs: &Jgd2011ToWgs84, ) -> Point { - let output_epsg = EPSG_WGS84_GEOGRAPHIC_3D; - - // TODO: 6697のまま(ジオイド高を足さない)の処理に対応する - match output_epsg { + match output_epsg.unwrap() { EPSG_WGS84_GEOGRAPHIC_3D => { let x = point.x; let y = point.y; @@ -80,8 +83,27 @@ fn transform_from_jgd2011( attributes: point.attributes.clone(), } } + EPSG_JGD2011_GEOGRAPHIC_3D => { + let x = point.x; + let y = point.y; + let z = point.z; + + let (lng, lat, height) = if let Some(input_epsg) = rectangular { + rectangular_to_lnglat(x, y, z, input_epsg) + } else { + (x, y, z) + }; + + Point { + x: lng, + y: lat, + z: height, + color: point.color.clone(), + attributes: point.attributes.clone(), + } + } _ => { - panic!("Unsupported output CRS: {}", output_epsg); + panic!("Unsupported output CRS: {:?}", output_epsg); } } }