Skip to content

Commit

Permalink
feat(engine): enhance URI path handling with dynamic separator support (
Browse files Browse the repository at this point in the history
#552)

* feat(engine): enhance URI path handling with dynamic separator support

* fix
  • Loading branch information
miseyu authored Oct 4, 2024
1 parent 7aff8cd commit f54e758
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -748,7 +748,7 @@ graphs:
with:
format: tsv
output: |
file::join_path(file::join_path(env.get("outputPath"), env.get("__value").destDataset), "不正な面の向きエラー.tsv")
file::join_path(env.get("outputPath"), "不正な面の向きエラー.tsv")
- id: 0c30b482-b241-4d47-9a88-175c5f98ff8d
name: AttributeMapperInvalidSurface
type: action
Expand Down Expand Up @@ -783,7 +783,7 @@ graphs:
with:
format: tsv
output: |
file::join_path(file::join_path(env.get("outputPath"), env.get("__value").destDataset), "不正な面エラー.tsv")
file::join_path(env.get("outputPath"), "不正な面エラー.tsv")
- id: e51e64b4-6cc0-4698-b677-e5f7f667f24f
name: FeatureMerger
type: action
Expand Down
4 changes: 0 additions & 4 deletions engine/plateau-gis-quality-checker/src-tauri/src/handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,6 @@ pub(crate) struct QualityCheckWorkflow {

pub(crate) static QUALITY_CHECK_WORKFLOWS: Lazy<Vec<QualityCheckWorkflow>> = Lazy::new(|| {
vec![
QualityCheckWorkflow {
id: "common".to_string(),
name: "共通".to_string(),
},
QualityCheckWorkflow {
id: "tran-rwy-trk-squr-wwy".to_string(),
name: "道路".to_string(),
Expand Down
38 changes: 27 additions & 11 deletions engine/runtime/common/src/uri.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,11 @@ pub struct Uri {
}

impl Uri {
pub fn separator(&self) -> String {
let sep = self.protocol.separator();
sep.to_string()
}

pub fn for_test(uri: &str) -> Self {
Self::from_str(uri).unwrap()
}
Expand Down Expand Up @@ -157,16 +162,27 @@ impl Uri {

pub fn path(&self) -> PathBuf {
let p = &self.uri[self.protocol.as_str().len() + PROTOCOL_SEPARATOR.len()..];
let sub_path = p
.split(self.protocol.separator())
.skip(1)
.collect::<Vec<&str>>()
.join("/")
.to_string();
if self.is_dir() {
PathBuf::from(format!("/{}/", sub_path))
} else {
PathBuf::from(format!("/{}", sub_path))
match self.protocol {
Protocol::Google | Protocol::Http | Protocol::Https => PathBuf::from(format!(
"{}{}",
self.separator().as_str(),
p.split(self.protocol.separator())
.skip(1)
.collect::<Vec<&str>>()
.join(self.separator().as_str())
)),
Protocol::File | Protocol::Ram => {
let sub_path = p
.split(self.protocol.separator())
.collect::<Vec<&str>>()
.join(self.separator().as_str())
.to_string();
if self.is_dir() {
PathBuf::from(format!("{}{}", sub_path, self.separator().as_str()))
} else {
PathBuf::from(sub_path)
}
}
}
}

Expand Down Expand Up @@ -609,7 +625,7 @@ mod tests {
#[test]
fn test_sub_path() {
assert_eq!(
Uri::for_test("file:///foo/hoge")._path(),
Uri::for_test("file:///foo/hoge").path(),
PathBuf::from_str("/foo/hoge").unwrap()
);
assert_eq!(
Expand Down

0 comments on commit f54e758

Please sign in to comment.