Skip to content

Commit

Permalink
Support 6697
Browse files Browse the repository at this point in the history
  • Loading branch information
nokonoko1203 committed Jan 28, 2025
1 parent 3263347 commit 3aa93dd
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 12 deletions.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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 \
Expand Down
10 changes: 7 additions & 3 deletions app/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
36 changes: 29 additions & 7 deletions pcd-transformer/src/projection.rs
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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);
Expand All @@ -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<EpsgCode>,
output_epsg: Option<EpsgCode>,
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;
Expand All @@ -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);
}
}
}

0 comments on commit 3aa93dd

Please sign in to comment.