-
Notifications
You must be signed in to change notification settings - Fork 10
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
KML Sink:属性(第一階層) #279
KML Sink:属性(第一階層) #279
Conversation
Walkthroughこの変更は、 変更
TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
Codecov ReportAll modified and coverable lines are covered by tests ✅ Additional details and impacted files
📢 Thoughts on this report? Let us know! |
nusamai/src/sink/kml/mod.rs
Outdated
// let mut kml_writer = KmlWriter::from_writer(&mut buf_writer); | ||
// let _ = kml_writer.write(&folder); | ||
|
||
let mut kml_writer = KmlWriter::from_writer(&mut buf_writer); | ||
let _ = kml_writer.write(&folder); | ||
let _ = kml_writer.write(&kml_doc); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
コメントアウトされたkml_writer
とfolder
の使用に関するコードは削除するか、将来的な使用のために残す意図がある場合は、その旨をコメントで説明することをお勧めします。
pub fn entity_to_properties(entity: &Entity) -> Option<geojson::JsonObject> { | ||
extract_properties(&entity.root) | ||
} | ||
|
||
pub fn property_to_schema_data_entries(properties: &geojson::JsonObject) -> Vec<SimpleData> { | ||
let mut simple_data_entries = Vec::new(); | ||
|
||
for (key, value) in properties.iter() { | ||
let simpledata = SimpleData { | ||
name: key.to_string(), | ||
value: serde_json::to_string(value).unwrap(), | ||
attrs: { | ||
let mut attrs = HashMap::new(); | ||
attrs.insert("name".to_string(), key.to_string()); | ||
attrs | ||
}, | ||
}; | ||
simple_data_entries.push(simpledata); | ||
} | ||
simple_data_entries | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
extract_properties
関数のpanic!
は、予期しない値型である場合にプログラムを強制終了させます。より安全なエラーハンドリングを検討してください。例えば、Result
型を返すようにして、呼び出し元で適切に処理する方法が考えられます。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Review Status
Actionable comments generated: 7
Configuration used: CodeRabbit UI
Files selected for processing (3)
- .gitignore (1 hunks)
- .vscode/launch.json (1 hunks)
- nusamai/src/sink/kml/mod.rs (6 hunks)
Files skipped from review due to trivial changes (1)
- .gitignore
Additional comments: 1
.vscode/launch.json (1)
- 1-889:
launch.json
ファイルの変更点については、特に問題は見受けられません。デバッグ設定が適切に追加されており、各設定項目も正しく構成されています。
nusamai/src/sink/kml/mod.rs
Outdated
@@ -79,6 +79,34 @@ impl DataSink for KmlSink { | |||
|
|||
let polygons = entity_to_kml_polygons(&parcel.entity); | |||
|
|||
let _properties = entity_to_properties(&parcel.entity).unwrap_or_default(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
entity_to_properties
関数の戻り値を_properties
変数に代入していますが、この変数は後続のコードで使用されていません。不要な変数代入はパフォーマンスと可読性の観点から避けるべきです。
pub fn entity_to_properties(entity: &Entity) -> Option<geojson::JsonObject> { | ||
extract_properties(&entity.root) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
extract_properties
関数内でpanic!
を使用していますが、これは予期しない値型である場合にプログラムを強制終了させます。より安全なエラーハンドリングを検討してください。例えば、Result
型を返すようにして、呼び出し元で適切に処理する方法が考えられます。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Review Status
Actionable comments generated: 0
Configuration used: CodeRabbit UI
Files selected for processing (1)
- nusamai/src/sink/kml/mod.rs (6 hunks)
Additional comments: 8
nusamai/src/sink/kml/mod.rs (8)
- 82-82:
entity_to_properties
関数の戻り値を_properties
変数に代入していますが、この変数は後続のコードで使用されています。変数名の先頭にアンダースコアを付けるのは、通常、その変数が使用されないことを示すためです。変数が使用される場合は、アンダースコアを削除することをお勧めします。- 83-83:
property_to_schema_data_entries
関数の戻り値を_simple_data_items
変数に代入していますが、この変数は後続のコードで使用されています。変数名の先頭にアンダースコアを付けるのは、通常、その変数が使用されないことを示すためです。変数が使用される場合は、アンダースコアを削除することをお勧めします。- 86-90: コメントアウトされたコードは削除するか、その理由を明記するコメントを追加することをお勧めします。未使用のコードは可読性を低下させ、メンテナンスの負担を増加させます。
- 131-167:
Schema
要素のchildren
プロパティがコメントアウトされていますが、この部分は将来的な使用を意図しているのでしょうか。もし使用予定がない場合は、コメントアウトされたコードを削除することをお勧めします。使用予定がある場合は、その旨をコメントで説明してください。- 192-196: コメントアウトされた
kml_writer
とfolder
の使用に関するコードは削除するか、将来的な使用のために残す意図がある場合は、その旨をコメントで説明することをお勧めします。- 192-194: コメントアウトされた
kml_writer
の使用に関するコードは削除するか、将来的な使用のために残す意図がある場合は、その旨をコメントで説明することをお勧めします。- 226-246:
extract_properties
関数のpanic!
は、予期しない値型である場合にプログラムを強制終了させます。より安全なエラーハンドリングを検討してください。例えば、Result
型を返すようにして、呼び出し元で適切に処理する方法が考えられます。- 226-228:
extract_properties
関数内でpanic!
を使用していますが、これは予期しない値型である場合にプログラムを強制終了させます。より安全なエラーハンドリングを検討してください。例えば、Result
型を返すようにして、呼び出し元で適切に処理する方法が考えられます。
@xinmiaooo もし Schema を使う場合は、データ側からスキーマを id で参照してあげる必要があるのかなと思います |
@ciscorn |
.vscode/launch.json
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
デバッガ用の設定が混入しているようです!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ciscorn
すみません!掃除しました。。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Review Status
Actionable comments generated: 1
Configuration used: CodeRabbit UI
Files selected for processing (2)
- .gitignore (1 hunks)
- nusamai/src/sink/kml/mod.rs (6 hunks)
Files skipped from review as they are similar to previous changes (1)
- .gitignore
Additional comments: 2
nusamai/src/sink/kml/mod.rs (2)
- 131-167:
Schema
要素のchildren
プロパティがコメントアウトされています。将来的な使用を意図している場合は、その旨をコメントで説明してください。使用予定がない場合は、コメントアウトされたコードを削除することをお勧めします。- 224-244:
extract_properties
関数内でpanic!
を使用していますが、これは予期しない値型である場合にプログラムを強制終了させます。より安全なエラーハンドリングを検討してください。例えば、Result
型を返すようにして、呼び出し元で適切に処理する方法が考えられます。
nusamai/src/sink/kml/mod.rs
Outdated
let _simple_data_items = property_to_schema_data_entries( | ||
&entity_to_properties(&parcel.entity).unwrap_or_default(), | ||
); | ||
let _schema_data = Element { | ||
name: "SchemaData".to_string(), | ||
attrs: { | ||
let mut attrs = HashMap::new(); | ||
attrs.insert("schemaUrl".to_string(), "#Schema_1".to_string()); | ||
attrs | ||
}, | ||
content: None, | ||
children: _simple_data_items | ||
.into_iter() | ||
.map(|simple_data| Element { | ||
name: "SimpleData".to_string(), | ||
attrs: simple_data.attrs, | ||
content: Some(simple_data.value), | ||
children: Vec::new(), | ||
}) | ||
.collect::<Vec<_>>(), | ||
}; | ||
let extended_data_entry = Element { | ||
name: "ExtendedData".to_string(), | ||
attrs: HashMap::new(), | ||
content: None, | ||
children: vec![_schema_data], | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
property_to_schema_data_entries
関数の戻り値を_simple_data_items
として受け取っていますが、この変数はその後のコードで使用されていません。不要な変数の割り当てを避けるために、この行を削除するか、変数を使用するようにコードを修正してください。
nusamai/src/sink/kml/mod.rs
Outdated
let _simple_data_items = property_to_schema_data_entries( | ||
&entity_to_properties(&parcel.entity).unwrap_or_default(), | ||
); | ||
let _schema_data = Element { | ||
name: "SchemaData".to_string(), | ||
attrs: { | ||
let mut attrs = HashMap::new(); | ||
attrs.insert("schemaUrl".to_string(), "#Schema_1".to_string()); | ||
attrs | ||
}, | ||
content: None, | ||
children: _simple_data_items |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
使われている変数のアンダースコアを外すとよさそうです
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Review Status
Actionable comments generated: 0
Configuration used: CodeRabbit UI
Files selected for processing (1)
- nusamai/src/sink/kml/mod.rs (6 hunks)
Files skipped from review as they are similar to previous changes (1)
- nusamai/src/sink/kml/mod.rs
// let placemarks = receiver.into_iter(); | ||
let placemarks = receiver.into_iter().collect::<Vec<_>>(); | ||
let folder = Kml::Folder { | ||
|
||
let kml_doc = Kml::Document { | ||
attrs: HashMap::new(), | ||
elements: placemarks.into_iter().map(Kml::Placemark).collect(), | ||
elements: { | ||
let mut elements = Vec::<Kml>::new(); | ||
elements.push(Kml::Element(schema_element)); | ||
elements.extend(placemarks.into_iter().map(Kml::Placemark)); | ||
elements | ||
}, | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
今後:
このへん、メモリに溜め込んでから、一気に書き出すのではなく、Placemarkストリーミングで書き出せるといいかもしれませんね(余裕があればPR出します)。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
#278
のマージが前提です。
属性をKML地物に付与し、Google Earth上で表示可能なSchemaを付与。
ExtendedDataなので、機械的にも可読である
TODO:
Summary by CodeRabbit
KmlPolygon
のVec<KmlPolygon>
への変更polygon_to_kml_polygon_with_mapping
の導入CityObjects
からGeoJSON
オブジェクトからKML
オブジェクトへの切り替えElement
,Geometry
,Polygon
,SimpleData
KML
要素の生成ロジックの更新KML
出力の構造の調整.gitignore
にdata/*
と*.kml
を追加して、これらのファイルとディレクトリをバージョン管理から除外.vscode/launch.json
にLLDBを使用してプロジェクト内の異なるコンポーネントとテストをデバッグするための様々な起動構成を設定