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

KML Sink:建物ごとにPlacemarkを作成するように変更 #278

Merged
merged 5 commits into from
Feb 15, 2024

Conversation

xinmiaooo
Copy link
Member

@xinmiaooo xinmiaooo commented Feb 14, 2024

建物が一つの地物(Placemark)にまとまるように修正しました。

2024-02-14.15.12.37.mov

kmlデータ上では、
1gmlファイル...1Folder...nPlacemark...1MultiGeometry...nPolygon
の構成になっています。

<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2">
    <Folder>
        <Placemark>
            <MultiGeometry>
                <Polygon>
                    ...
                </Polygon>
                <Polygon>
                   ...
                </Polygon>
            </MultiGeometry>
        </Placemark>
        <Placemark>
            ...
        </Placemark>
        <Placemark>
            ...
        </Placemark>
    </Folder>
</kml>

Summary by CodeRabbit

  • 新機能
    • multipolygon_to_kml関数の返り値をVec<KmlPolygon}に変更しました。
    • indexed_multipolygon_to_kml関数の返り値をVec<KmlPolygon}に変更しました。
    • multipolygon_to_kml_with_mapping関数の返り値をVec<KmlPolygon}に変更しました。
    • polygon_to_kml_polygon_with_mappingという新しい関数を追加し、KmlPolygonを返します。
    • polygon_to_kml_with_mapping関数の返り値をVec<KmlPolygon}に変更しました。
    • polygon_to_kml関数の返り値をVec<KmlPolygon}に変更しました。
    • indexed_polygon_to_kml関数の返り値をVec<KmlPolygon}に変更しました。
  • リファクタ
    • KMLタイプの命名と構造を再編成しました。

@xinmiaooo xinmiaooo self-assigned this Feb 14, 2024
Copy link

coderabbitai bot commented Feb 14, 2024

Walkthrough

この変更は、nusamai-kmlライブラリのKML変換機能全体の高レベルな要約です。MultiGeometryの代わりにVec<KmlPolygon>を返すように関数が変更され、新しい関数が追加され、既存の関数の戻り値が調整されました。これにより、KMLポリゴンの取り扱いがより柔軟になります。

Changes

ファイルパス 変更概要
.../conversion.rs, .../sink/kml/mod.rs - multipolygon_to_kml, indexed_multipolygon_to_kml, multipolygon_to_kml_with_mapping, polygon_to_kml, polygon_to_kml_with_mapping, polygon_to_kml_polygon_with_mapping, indexed_polygon_to_kmlMultiGeometryの代わりにVec<KmlPolygon>を返すように変更されました。
- kml/mod.rsファイルでは、entity_to_kml_mutilgeomentity_to_kml_polygonsに改名され、ジオメトリの処理が調整され、KmlPolygonインスタンスが作成されるように変更されました。また、これらの変更に対応するようにMultiGeometryPlacemarkインスタンスの構築が修正されました。

🐰✨
変更の風、新たなる章
KMLの葉、ポリゴンに変わりゆく
結び目解き、形を変え
コードのうさぎ、跳ねる喜びを歌う
🌟🌿🌈


Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit-tests for this file.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit tests for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository from git and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit tests.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • The JSON schema for the configuration file is available here.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/coderabbit-overrides.v2.json

CodeRabbit Discord Community

Join our Discord Community to get help, request features, and share feedback.

@xinmiaooo xinmiaooo marked this pull request as ready for review February 14, 2024 06:19
@xinmiaooo xinmiaooo requested a review from a team February 14, 2024 06:19
Copy link

@coderabbitai coderabbitai bot left a 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: 4

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between fb48e44 and 773ecf8.
Files selected for processing (2)
  • nusamai-kml/src/conversion.rs (4 hunks)
  • nusamai/src/sink/kml/mod.rs (3 hunks)
Additional comments: 4
nusamai-kml/src/conversion.rs (4)
  • 10-29: multipolygon_to_kmlindexed_multipolygon_to_kml、およびmultipolygon_to_kml_with_mapping関数の変更は適切です。Vec<KmlPolygon>への変更は、建物ごとにPlacemarkを作成する目的に合致しています。
  • 31-43: 新しい関数polygon_to_kml_polygon_with_mappingは、個々のポリゴンをKmlPolygonに変換するための適切なアプローチを提供します。この関数は、提案された変更の目的をサポートするために重要です。
  • 101-114: polygon_to_kml_with_mappingおよびindexed_polygon_to_kml関数の変更も、Vec<KmlPolygon>への変更を反映しており、適切です。
  • 217-229: テストケースtest_polygon_to_kmlは、変更された関数の動作を適切に検証しています。ポリゴンの外部リングと内部リングの座標が正しく変換されていることを確認しています。

nusamai/src/sink/kml/mod.rs Show resolved Hide resolved
nusamai/src/sink/kml/mod.rs Show resolved Hide resolved
nusamai/src/sink/kml/mod.rs Show resolved Hide resolved
nusamai/src/sink/kml/mod.rs Show resolved Hide resolved
@xinmiaooo xinmiaooo marked this pull request as draft February 14, 2024 07:35
Copy link

codecov bot commented Feb 14, 2024

Codecov Report

Attention: 1 lines in your changes are missing coverage. Please review.

Files Patch % Lines
nusamai-kml/src/conversion.rs 99.50% 1 Missing ⚠️
Additional details and impacted files
Components Coverage Δ
GUI ∅ <ø> (∅)
Backend 80.92% <100.00%> (-0.03%) ⬇️
Libraries 90.56% <99.50%> (+0.10%) ⬆️

📢 Thoughts on this report? Let us know!

@xinmiaooo xinmiaooo marked this pull request as ready for review February 14, 2024 08:10
Copy link

@coderabbitai coderabbitai bot left a 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: 4

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 773ecf8 and 80be9aa.
Files selected for processing (1)
  • nusamai-kml/src/conversion.rs (4 hunks)
Additional comments: 1
nusamai-kml/src/conversion.rs (1)
  • 101-102: polygon_to_kml_with_mapping関数で、戻り値をVec<KmlPolygon>に変更していますが、この関数は常に1つのKmlPolygonを含むベクターを返します。この設計は意図的なものでしょうか?もし単一のKmlPolygonのみを扱う場合は、戻り値の型をVec<KmlPolygon>ではなくKmlPolygonにすることを検討してください。

nusamai-kml/src/conversion.rs Outdated Show resolved Hide resolved
nusamai-kml/src/conversion.rs Outdated Show resolved Hide resolved
nusamai-kml/src/conversion.rs Show resolved Hide resolved
nusamai-kml/src/conversion.rs Show resolved Hide resolved
Copy link

@coderabbitai coderabbitai bot left a 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

Commits Files that changed from the base of the PR and between 80be9aa and 3496603.
Files selected for processing (1)
  • nusamai-kml/src/conversion.rs (5 hunks)
Additional comments: 9
nusamai-kml/src/conversion.rs (9)
  • 10-10: multipolygon_to_kml関数の変更は、戻り値の型をVec<KmlPolygon>に変更しています。この変更は目的に合致しています。
  • 17-17: indexed_multipolygon_to_kml関数も同様に、戻り値の型をVec<KmlPolygon>に変更しています。適切な変更です。
  • 24-29: multipolygon_to_kml_with_mapping関数の変更により、Vec<KmlPolygon>が戻り値となっています。この変更は、建物ごとにPlacemarkを作成する目的に沿っています。
  • 31-43: 新しく追加されたpolygon_to_kml_polygon_with_mapping関数は、単一のポリゴンをKmlPolygonに変換します。この関数は、提案された変更の一環として適切に追加されています。
  • 101-102: polygon_to_kml_with_mapping関数の戻り値の型がVec<KmlPolygon>に変更されています。この変更は、提案された目的に沿っています。
  • 106-107: polygon_to_kml関数の戻り値の型がVec<KmlPolygon>に変更されています。この変更は、提案された目的に沿っています。
  • 111-115: indexed_polygon_to_kml関数の戻り値の型がVec<KmlPolygon>に変更されています。この変更は、提案された目的に沿っています。
  • 106-106: 過去のレビューコメントで指摘されたpoly.clone()の使用について、この変更では直接的な修正が見られません。不必要なクローン操作を避けるための改善が必要かもしれません。
  • 111-114: 過去のレビューコメントで指摘されたpoly_idx.clone()の使用についても、この変更では直接的な修正が見られません。不必要なクローン操作を避けるための改善が必要かもしれません。

@ciscorn
Copy link
Member

ciscorn commented Feb 14, 2024

@xinmiaooo @coderabbitai
適切に参照を使うようにして clone()の使用を除去しました 3496603

Copy link

coderabbitai bot commented Feb 14, 2024

@ciscorn このコミットの変更を確認しました。clone()の使用を避け、参照を適切に利用することで、メモリ効率の改善が見込まれます。特に、Polygon型のデータを関数に渡す際に、所有権を移動させる代わりに参照を渡すように変更されています。これにより、不必要なデータの複製を避け、パフォーマンスが向上する可能性があります。Rustの所有権と借用のルールを適切に活用した良い例です。

Analysis chain
Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Fetch the diff of the specified commit to analyze the changes made.
git diff 3496603d598106dd105c09f137622c813d4a8fbe^ 3496603d598106dd105c09f137622c813d4a8fbe

Length of output: 3001

Copy link

@coderabbitai coderabbitai bot left a 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

Commits Files that changed from the base of the PR and between 3496603 and 07aa483.
Files selected for processing (1)
  • nusamai-kml/src/conversion.rs (3 hunks)
Files skipped from review as they are similar to previous changes (1)
  • nusamai-kml/src/conversion.rs

Copy link
Member

@ciscorn ciscorn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm!

@xinmiaooo xinmiaooo merged commit 199acd3 into main Feb 15, 2024
4 checks passed
@xinmiaooo xinmiaooo deleted the kml-multipolygon branch February 15, 2024 04:45
xinmiaooo added a commit that referenced this pull request Feb 15, 2024
#278
のマージが前提です。

属性をKML地物に付与し、Google Earth上で表示可能なSchemaを付与。

ExtendedDataなので、機械的にも可読である
![スクリーンショット 2024-02-15 12 15
28](https://github.com/MIERUNE/nusamai/assets/83005951/2cd4b12a-b4a1-4f59-9d47-dac7b2adf11d)

<img width="1582" alt="スクリーンショット 2024-02-15 12 12 28"
src="https://github.com/MIERUNE/nusamai/assets/83005951/4ab95d92-705c-4642-b247-12992ca83265">

TODO:
- 属性の階層を処理していないので、文字列になっている


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## 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を使用してプロジェクト内の異なるコンポーネントとテストをデバッグするための様々な起動構成を設定
- 実行可能ファイル、ユニットテスト、統合テスト、ライブラリ、およびワークスペース内の複数のパッケージの例をデバッグするための構成のセットアップ

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants