-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c3fc8e7
commit 7be09f8
Showing
5 changed files
with
79 additions
and
105 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,36 @@ | ||
use crate::transform::{CompositeTransform, Transform}; | ||
use std::sync::Arc; | ||
|
||
use projection_transform::{crs::EpsgCode, vshift::Jgd2011ToWgs84}; | ||
|
||
use crate::transform::{projection::ProjectionTransform, SerialTransform, Transform}; | ||
|
||
pub trait TransformBuilder { | ||
fn build(&self) -> Box<dyn Transform>; | ||
} | ||
|
||
pub struct ProjectionTransformerBuilder; | ||
pub struct PointCloudTransformBuilder { | ||
output_epsg: EpsgCode, | ||
jgd2wgs: Arc<Jgd2011ToWgs84>, | ||
} | ||
|
||
impl TransformBuilder for ProjectionTransformerBuilder { | ||
impl TransformBuilder for PointCloudTransformBuilder { | ||
fn build(&self) -> Box<dyn Transform> { | ||
let projection_transform = | ||
Box::new(crate::transform::projection::ProjectionTransform::new()); | ||
let mut transformers = SerialTransform::default(); | ||
|
||
let composite = CompositeTransform::new(vec![projection_transform]); | ||
transformers.push(Box::new(ProjectionTransform::new( | ||
self.jgd2wgs.clone(), | ||
self.output_epsg, | ||
))); | ||
|
||
Box::new(transformers) | ||
} | ||
} | ||
|
||
Box::new(composite) | ||
impl PointCloudTransformBuilder { | ||
pub fn new(output_epsg: EpsgCode) -> Self { | ||
Self { | ||
output_epsg, | ||
jgd2wgs: Jgd2011ToWgs84::default().into(), | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,24 @@ | ||
use pcd_core::pointcloud::point::PointCloud; | ||
|
||
use crate::transform::Transform; | ||
use crate::TransformBuilder; | ||
|
||
pub trait Transformer { | ||
fn execute(&self, point_cloud: PointCloud) -> Vec<PointCloud>; | ||
fn execute(&self, point_cloud: PointCloud) -> PointCloud; | ||
} | ||
|
||
pub struct PointCloudTransformer { | ||
transform: Box<dyn Transform>, | ||
builder: Box<dyn TransformBuilder>, | ||
} | ||
|
||
impl PointCloudTransformer { | ||
pub fn new(transform: Box<dyn Transform>) -> Self { | ||
Self { transform } | ||
pub fn new(builder: Box<dyn TransformBuilder>) -> Self { | ||
Self { builder } | ||
} | ||
} | ||
|
||
impl Transformer for PointCloudTransformer { | ||
fn execute(&self, point_cloud: PointCloud) -> Vec<PointCloud> { | ||
self.transform.transform(point_cloud) | ||
fn execute(&self, point_cloud: PointCloud) -> PointCloud { | ||
let transform = self.builder.build(); | ||
transform.transform(point_cloud) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters