Skip to content

Commit

Permalink
gpkg: bbox管理のちょっとした改善 (#307)
Browse files Browse the repository at this point in the history
登場したテーブルのみのbboxを管理して、gpkg_contentsを更新するようにします。(ちょっとした変更なので他の作業とは特段コンプリクトしないと思います)。

(その他、いまの main に unused imports が色々と混入しているので、除去します)
  • Loading branch information
ciscorn authored Feb 21, 2024
1 parent 9d2519b commit a6cea59
Show file tree
Hide file tree
Showing 9 changed files with 15 additions and 28 deletions.
1 change: 0 additions & 1 deletion nusamai-czml/src/models/interpolatable_property.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use chrono::{DateTime, Utc};
use serde::{Deserialize, Serialize};
use std::default::Default;

#[derive(Serialize, Deserialize, Debug, PartialEq)]
#[serde(rename_all = "camelCase")]
Expand Down
3 changes: 1 addition & 2 deletions nusamai-gpkg/src/handler.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
use crate::table::TableInfo;
use indexmap::IndexMap;
use sqlx::{sqlite::*, ConnectOptions};
use sqlx::{Acquire, Row};
use sqlx::{Pool, Sqlite};
use sqlx::{Acquire, Pool, Row};
use std::path::Path;
use thiserror::Error;
use url::Url;
Expand Down
3 changes: 1 addition & 2 deletions nusamai-kml/src/conversion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,7 @@ pub fn multipoint_to_kml(mpoint: &MultiPoint<3>) -> MultiGeometry {
#[cfg(test)]
mod tests {
use super::*;
use kml::types::{Geometry, Point};
use nusamai_geometry::{MultiPoint, Polygon3};
use nusamai_geometry::Polygon3;

#[test]
fn test_multipoint_to_kml() {
Expand Down
2 changes: 1 addition & 1 deletion nusamai/src/sink/czml/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ mod tests {
use std::sync::RwLock;

use super::*;
use nusamai_citygml::{object::Object, GeometryRef, Value};
use nusamai_citygml::{object::Object, GeometryRef};
use nusamai_czml::{PositionListProperties, PositionListType};
use nusamai_geometry::MultiPolygon;
use nusamai_projection::crs::EPSG_JGD2011_GEOGRAPHIC_3D;
Expand Down
2 changes: 1 addition & 1 deletion nusamai/src/sink/geojson/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ mod tests {
use std::sync::RwLock;

use super::*;
use nusamai_citygml::{object::Object, GeometryRef, Value};
use nusamai_citygml::{object::Object, GeometryRef};
use nusamai_geometry::MultiPolygon;
use nusamai_projection::crs::EPSG_JGD2011_GEOGRAPHIC_3D;

Expand Down
2 changes: 0 additions & 2 deletions nusamai/src/sink/gltf/attributes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -239,8 +239,6 @@ pub fn to_gltf_property_table(

#[cfg(test)]
mod tests {
use ahash::RandomState;
use indexmap::IndexMap;
use nusamai_citygml::schema::FeatureTypeDef;

use super::*;
Expand Down
25 changes: 10 additions & 15 deletions nusamai/src/sink/gpkg/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ use indexmap::IndexMap;

use rayon::prelude::*;

use crate::parameters::Parameters;
use crate::parameters::*;
use crate::pipeline::{Feedback, PipelineError, Receiver, Result};
use crate::sink::{DataSink, DataSinkProvider, SinkInfo};
Expand Down Expand Up @@ -89,9 +88,6 @@ impl GpkgSink {
let mut created_tables = HashSet::<String>::new();

let mut table_bboxes = IndexMap::<String, Bbox>::new();
for table_name in table_infos.keys() {
table_bboxes.insert(table_name.clone(), Default::default());
}

let (sender, mut receiver) = tokio::sync::mpsc::channel(100);

Expand Down Expand Up @@ -195,13 +191,11 @@ impl GpkgSink {
.await
.unwrap();

table_bboxes.get_mut(&table_name).unwrap().merge(&bbox);
table_bboxes.entry(table_name).or_default().merge(&bbox);
}

for table_name in table_bboxes.keys() {
tx.update_bbox(table_name, table_bboxes.get(table_name).unwrap().to_tuple())
.await
.unwrap();
for (table_name, bbox) in table_bboxes {
tx.update_bbox(&table_name, bbox.to_tuple()).await.unwrap();
}

tx.commit().await.unwrap();
Expand All @@ -216,12 +210,13 @@ impl GpkgSink {
impl DataSink for GpkgSink {
fn make_transform_requirements(&self) -> transformer::Requirements {
transformer::Requirements {
tree_flattening: transformer::TreeFlatteningSpec::Flatten {
// TODO: set properly after the flattening transformer is implemented
feature: transformer::FeatureFlatteningOption::None,
data: transformer::DataFlatteningOption::None,
object: transformer::ObjectFlatteningOption::None,
},
// TODO: set properly after the flattening transformer is implemented
tree_flattening: transformer::TreeFlatteningSpec::None,
// transformer::TreeFlatteningSpec::Flatten {
// feature: transformer::FeatureFlatteningOption::None,
// data: transformer::DataFlatteningOption::None,
// object: transformer::ObjectFlatteningOption::None,
// },
..Default::default()
}
}
Expand Down
1 change: 0 additions & 1 deletion nusamai/src/sink/serde/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ use std::fs::File;
use std::io::{BufWriter, Write};
use std::path::PathBuf;

use bincode;
use nusamai_citygml::schema::Schema;
use rayon::prelude::*;

Expand Down
4 changes: 1 addition & 3 deletions nusamai/src/sink/shapefile/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ use crate::{get_parameter_value, transformer};
use nusamai_citygml::object::{ObjectStereotype, Value};
use nusamai_plateau::Entity;
use nusamai_shapefile::conversion::indexed_multipolygon_to_shape;
use shapefile;

pub struct ShapefileSinkProvider {}

Expand Down Expand Up @@ -184,9 +183,8 @@ mod tests {
use std::sync::RwLock;

use super::*;
use nusamai_citygml::{object::Object, GeometryRef, Value};
use nusamai_citygml::{object::Object, GeometryRef};
use nusamai_geometry::MultiPolygon;
use nusamai_plateau::Entity;
use nusamai_projection::crs::EPSG_JGD2011_GEOGRAPHIC_3D;
use shapefile::NO_DATA;

Expand Down

0 comments on commit a6cea59

Please sign in to comment.