Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

transformer: Selectionの修正 #690

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions app/src-tauri/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
source::{citygml::CityGmlSourceProvider, DataSourceProvider},
transformer::{
self, MappingRules, MultiThreadTransformer, NusamaiTransformBuilder, TransformBuilder,
TransformerRegistry,
TransformerSettings,
},
};
use nusamai_plateau::models::TopLevelCityObject;
Expand Down Expand Up @@ -148,7 +148,7 @@
filetype: String,
epsg: u16,
rules_path: String,
transformer_registry: TransformerRegistry,
transformer_registry: TransformerSettings,

Check warning on line 151 in app/src-tauri/src/main.rs

View check run for this annotation

Codecov / codecov/patch

app/src-tauri/src/main.rs#L151

Added line #L151 was not covered by tests
sink_parameters: Parameters,
tasks_state: tauri::State<ConversionTasksState>,
app: tauri::AppHandle,
Expand Down Expand Up @@ -312,7 +312,7 @@

/// Get the transform options for a given sink type
#[tauri::command]
fn get_transform(filetype: String) -> Result<TransformerRegistry, Error> {
fn get_transform(filetype: String) -> Result<TransformerSettings, Error> {

Check warning on line 315 in app/src-tauri/src/main.rs

View check run for this annotation

Codecov / codecov/patch

app/src-tauri/src/main.rs#L315

Added line #L315 was not covered by tests
let sink_provider = select_sink_provider(&filetype).ok_or_else(|| {
let msg = format!("Invalid sink type: {}", filetype);
log::error!("{}", msg);
Expand Down
2 changes: 1 addition & 1 deletion app/src/lib/transformer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export interface BooleanConfig {

type TransformerParameterType = boolean | SelectionConfig<string>;

export type TransformerRegistry = {
export type TransformerSettings = {
configs: Array<TransformerConfig<TransformerParameterType>>;
};

Expand Down
4 changes: 2 additions & 2 deletions app/src/routes/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import { invoke } from '@tauri-apps/api/core';
import { attachConsole } from '@tauri-apps/plugin-log';
import type { SinkParameters } from '$lib/sinkparams';
import type { TransformerRegistry } from '$lib/transformer';
import type { TransformerSettings } from '$lib/transformer';

import Icon from '@iconify/svelte';
import InputSelector from './InputSelector.svelte';
Expand All @@ -23,7 +23,7 @@
let isConvertButtonDisabled = true;

$: isConvertButtonDisabled = !inputPaths.length || !outputPath || isRunning;
let transformerRegistry: TransformerRegistry;
let transformerRegistry: TransformerSettings;

async function convertAndSave() {
isRunning = true;
Expand Down
4 changes: 2 additions & 2 deletions app/src/routes/SettingSelector.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import { filetypeOptions } from '$lib/settings';
import { invoke } from '@tauri-apps/api/core';
import type { SinkParameters } from '$lib/sinkparams';
import type { TransformerRegistry } from '$lib/transformer';
import type { TransformerSettings } from '$lib/transformer';
import Icon from '@iconify/svelte';
import { } from '@tauri-apps/api';
import SinkOptions from '$lib/components/SinkOptions.svelte';
Expand All @@ -13,7 +13,7 @@ import * as dialog from "@tauri-apps/plugin-dialog"
export let epsg: number = 4979;
export let rulesPath: string;
export let sinkParameters: SinkParameters;
export let transformerRegistry: TransformerRegistry;
export let transformerRegistry: TransformerSettings;

$: epsgOptions = filetypeOptions[filetype]?.epsg || [];
$: disableEpsgOptions = epsgOptions.length < 2;
Expand Down
2 changes: 1 addition & 1 deletion nusamai-plateau/src/entity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use nusamai_citygml::{geometry::GeometryStore, object::Value};
use crate::appearance::AppearanceStore;

/// City objects, features, objects or data
#[derive(Debug, serde::Deserialize, serde::Serialize, Clone)]
#[derive(Debug, serde::Deserialize, serde::Serialize)]
pub struct Entity {
/// Attribute tree
pub root: Value,
Expand Down
1 change: 0 additions & 1 deletion nusamai/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
pub mod option;
pub mod parameters;
pub mod pipeline;
pub mod sink;
Expand Down
4 changes: 2 additions & 2 deletions nusamai/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use nusamai::{
source::{citygml::CityGmlSourceProvider, DataSource, DataSourceProvider},
transformer::{
self, MappingRules, MultiThreadTransformer, NusamaiTransformBuilder, ParameterType,
TransformBuilder, TransformerConfig, TransformerRegistry,
TransformBuilder, TransformerConfig, TransformerSettings,
},
BUILTIN_SINKS,
};
Expand Down Expand Up @@ -227,7 +227,7 @@ fn main() -> ExitCode {
.collect();

let updated_transformer_registry = match update_result {
Ok(configs) => TransformerRegistry { configs },
Ok(configs) => TransformerSettings { configs },
Err(error_message) => {
log::error!("{}", error_message);
return ExitCode::FAILURE;
Expand Down
24 changes: 0 additions & 24 deletions nusamai/src/option.rs

This file was deleted.

13 changes: 6 additions & 7 deletions nusamai/src/sink/cesiumtiles/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,10 @@ use url::Url;

use crate::{
get_parameter_value,
option::use_textured_lod_config,
parameters::*,
pipeline::{Feedback, PipelineError, Receiver, Result},
sink::{DataRequirements, DataSink, DataSinkProvider, SinkInfo},
transformer::TransformerRegistry,
transformer::{use_lod_config, TransformerSettings},
};
use utils::calculate_normal;

Expand Down Expand Up @@ -108,9 +107,9 @@ impl DataSinkProvider for CesiumTilesSinkProvider {
params
}

fn transformer_options(&self) -> TransformerRegistry {
let mut settings: TransformerRegistry = TransformerRegistry::new();
settings.insert(use_textured_lod_config("max_lod"));
fn transformer_options(&self) -> TransformerSettings {
let mut settings: TransformerSettings = TransformerSettings::new();
settings.insert(use_lod_config("max_lod", None));

settings
}
Expand All @@ -137,15 +136,15 @@ impl DataSinkProvider for CesiumTilesSinkProvider {

struct CesiumTilesSink {
output_path: PathBuf,
transform_settings: TransformerRegistry,
transform_settings: TransformerSettings,
limit_texture_resolution: Option<bool>,
gzip_compress: Option<bool>,
min_z: u8,
max_z: u8,
}

impl DataSink for CesiumTilesSink {
fn make_requirements(&mut self, properties: TransformerRegistry) -> DataRequirements {
fn make_requirements(&mut self, properties: TransformerSettings) -> DataRequirements {
let default_requirements = DataRequirements {
resolve_appearance: true,
key_value: crate::transformer::KeyValueSpec::JsonifyObjects,
Expand Down
13 changes: 6 additions & 7 deletions nusamai/src/sink/czml/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,10 @@ use rayon::prelude::*;

use crate::{
get_parameter_value,
option::use_lod_config,
parameters::*,
pipeline::{Feedback, PipelineError, Receiver, Result},
sink::{DataRequirements, DataSink, DataSinkProvider, SinkInfo},
transformer::TransformerRegistry,
transformer::{use_lod_config, TransformerSettings},
};

use super::option::output_parameter;
Expand All @@ -46,9 +45,9 @@ impl DataSinkProvider for CzmlSinkProvider {
params
}

fn transformer_options(&self) -> TransformerRegistry {
let mut settings: TransformerRegistry = TransformerRegistry::new();
settings.insert(use_lod_config("max_lod"));
fn transformer_options(&self) -> TransformerSettings {
let mut settings: TransformerSettings = TransformerSettings::new();
settings.insert(use_lod_config("max_lod", Some(&["textured_max_lod"])));

settings
}
Expand All @@ -66,11 +65,11 @@ impl DataSinkProvider for CzmlSinkProvider {

pub struct CzmlSink {
output_path: PathBuf,
transform_settings: TransformerRegistry,
transform_settings: TransformerSettings,
}

impl DataSink for CzmlSink {
fn make_requirements(&mut self, properties: TransformerRegistry) -> DataRequirements {
fn make_requirements(&mut self, properties: TransformerSettings) -> DataRequirements {
let default_requirements = DataRequirements::default();

for config in properties.configs.iter() {
Expand Down
13 changes: 6 additions & 7 deletions nusamai/src/sink/geojson/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,11 @@ use rayon::prelude::*;

use crate::{
get_parameter_value,
option::use_lod_config,
parameters::*,
pipeline::{Feedback, PipelineError, Receiver, Result},
sink::{DataRequirements, DataSink, DataSinkProvider, SinkInfo},
transformer,
transformer::TransformerRegistry,
transformer::{use_lod_config, TransformerSettings},
};

use super::option::output_parameter;
Expand All @@ -47,9 +46,9 @@ impl DataSinkProvider for GeoJsonSinkProvider {
params
}

fn transformer_options(&self) -> TransformerRegistry {
let mut settings: TransformerRegistry = TransformerRegistry::new();
settings.insert(use_lod_config("max_lod"));
fn transformer_options(&self) -> TransformerSettings {
let mut settings: TransformerSettings = TransformerSettings::new();
settings.insert(use_lod_config("max_lod", Some(&["textured_max_lod"])));

settings
}
Expand All @@ -67,11 +66,11 @@ impl DataSinkProvider for GeoJsonSinkProvider {

pub struct GeoJsonSink {
output_path: PathBuf,
transform_settings: TransformerRegistry,
transform_settings: TransformerSettings,
}

impl DataSink for GeoJsonSink {
fn make_requirements(&mut self, properties: TransformerRegistry) -> DataRequirements {
fn make_requirements(&mut self, properties: TransformerSettings) -> DataRequirements {
let default_requirements = DataRequirements {
tree_flattening: transformer::TreeFlatteningSpec::Flatten {
feature: transformer::FeatureFlatteningOption::AllExceptThematicSurfaces,
Expand Down
13 changes: 6 additions & 7 deletions nusamai/src/sink/gltf/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,10 @@ use url::Url;

use crate::{
get_parameter_value,
option::use_textured_lod_config,
parameters::*,
pipeline::{Feedback, PipelineError, Receiver, Result},
sink::{cesiumtiles::metadata, DataRequirements, DataSink, DataSinkProvider, SinkInfo},
transformer::TransformerRegistry,
transformer::{use_lod_config, TransformerSettings},
};

use super::option::{limit_texture_resolution_parameter, output_parameter};
Expand All @@ -59,9 +58,9 @@ impl DataSinkProvider for GltfSinkProvider {
params
}

fn transformer_options(&self) -> TransformerRegistry {
let mut settings: TransformerRegistry = TransformerRegistry::new();
settings.insert(use_textured_lod_config("max_lod"));
fn transformer_options(&self) -> TransformerSettings {
let mut settings: TransformerSettings = TransformerSettings::new();
settings.insert(use_lod_config("max_lod", None));

settings
}
Expand All @@ -81,7 +80,7 @@ impl DataSinkProvider for GltfSinkProvider {

pub struct GltfSink {
output_path: PathBuf,
transform_settings: TransformerRegistry,
transform_settings: TransformerSettings,
limit_texture_resolution: Option<bool>,
}

Expand Down Expand Up @@ -149,7 +148,7 @@ pub struct PrimitiveInfo {
pub type Primitives = HashMap<material::Material, PrimitiveInfo>;

impl DataSink for GltfSink {
fn make_requirements(&mut self, properties: TransformerRegistry) -> DataRequirements {
fn make_requirements(&mut self, properties: TransformerSettings) -> DataRequirements {
let default_requirements: DataRequirements = DataRequirements {
resolve_appearance: true,
key_value: crate::transformer::KeyValueSpec::JsonifyObjectsAndArrays,
Expand Down
13 changes: 6 additions & 7 deletions nusamai/src/sink/gpkg/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,11 @@ use url::Url;

use crate::{
get_parameter_value,
option::use_lod_config,
parameters::*,
pipeline::{Feedback, PipelineError, Receiver, Result},
sink::{DataRequirements, DataSink, DataSinkProvider, SinkInfo},
transformer,
transformer::TransformerRegistry,
transformer::{use_lod_config, TransformerSettings},
};

use super::option::output_parameter;
Expand All @@ -48,9 +47,9 @@ impl DataSinkProvider for GpkgSinkProvider {
params
}

fn transformer_options(&self) -> TransformerRegistry {
let mut settings: TransformerRegistry = TransformerRegistry::new();
settings.insert(use_lod_config("max_lod"));
fn transformer_options(&self) -> TransformerSettings {
let mut settings: TransformerSettings = TransformerSettings::new();
settings.insert(use_lod_config("max_lod", Some(&["textured_max_lod"])));

settings
}
Expand All @@ -68,7 +67,7 @@ impl DataSinkProvider for GpkgSinkProvider {

pub struct GpkgSink {
output_path: PathBuf,
transform_settings: TransformerRegistry,
transform_settings: TransformerSettings,
}

// An ephimeral container to wrap and pass the data in the pipeline
Expand Down Expand Up @@ -265,7 +264,7 @@ impl GpkgSink {
pub enum GpkgTransformOption {}

impl DataSink for GpkgSink {
fn make_requirements(&mut self, properties: TransformerRegistry) -> DataRequirements {
fn make_requirements(&mut self, properties: TransformerSettings) -> DataRequirements {
let default_requirements = DataRequirements {
tree_flattening: transformer::TreeFlatteningSpec::Flatten {
feature: transformer::FeatureFlatteningOption::AllExceptThematicSurfaces,
Expand Down
13 changes: 6 additions & 7 deletions nusamai/src/sink/kml/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,10 @@ use rayon::prelude::*;

use crate::{
get_parameter_value,
option::use_lod_config,
parameters::*,
pipeline::{Feedback, PipelineError, Receiver, Result},
sink::{DataRequirements, DataSink, DataSinkProvider, SinkInfo},
transformer::TransformerRegistry,
transformer::{use_lod_config, TransformerSettings},
};

use super::option::output_parameter;
Expand All @@ -45,9 +44,9 @@ impl DataSinkProvider for KmlSinkProvider {
params
}

fn transformer_options(&self) -> TransformerRegistry {
let mut settings: TransformerRegistry = TransformerRegistry::new();
settings.insert(use_lod_config("max_lod"));
fn transformer_options(&self) -> TransformerSettings {
let mut settings: TransformerSettings = TransformerSettings::new();
settings.insert(use_lod_config("max_lod", Some(&["textured_max_lod"])));

settings
}
Expand All @@ -65,11 +64,11 @@ impl DataSinkProvider for KmlSinkProvider {

pub struct KmlSink {
output_path: PathBuf,
transform_settings: TransformerRegistry,
transform_settings: TransformerSettings,
}

impl DataSink for KmlSink {
fn make_requirements(&mut self, properties: TransformerRegistry) -> DataRequirements {
fn make_requirements(&mut self, properties: TransformerSettings) -> DataRequirements {
let default_requirements = DataRequirements::default();

for config in properties.configs.iter() {
Expand Down
Loading
Loading