-
Notifications
You must be signed in to change notification settings - Fork 12
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
nusamai-shapefile: クレート作成, MultiPointの変換 #203
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅ Additional details and impacted files
📢 Thoughts on this report? Let us know! |
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. 不要な .to_vec()
を抜いてみました。これでどうでしょう。
// Attribute fields for the features | ||
// FieldName byte representation cannot exceed 11 bytes | ||
let table_builder = dbase::TableWriterBuilder::new() | ||
.add_character_field("name".try_into().unwrap(), 50) | ||
.add_float_field("lon".try_into().unwrap(), 50, 10) | ||
.add_float_field("lat".try_into().unwrap(), 50, 10); |
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.
Shapefile もやはりはじめにテーブルを宣言しないといけない形式ですね。
ありがとうございます! |
#203 (MultiPoint)と同じ形で、nusamai-geometryのMultiLineString, MultiPolygonを、Shapefileの形式へ変換する。 ## 参考 ### ポリゴンは、複数のOuterリングを持つことができる https://github.com/tmontaigu/shapefile-rs/blob/cd52bcfde8ce24aeaffec0968f155119e02c5a66/src/record/polygon.rs#L198C1-L204C59 ``` /// # Notes /// - A Polygon ring is a connected sequence of 4 or more points /// **(this is not checked)** /// - Polygon's rings MUST be closed (the first and last points MUST be the same) (p 13/34) /// **(this is done by the constructors if you do not do it yourself)** /// - The order of rings is not significant (p 13/34) /// - A polygon may have multiple [`Outer`] rings (p12/34) ``` ### リングのオーダー https://github.com/tmontaigu/shapefile-rs/blob/cd52bcfde8ce24aeaffec0968f155119e02c5a66/src/record/polygon.rs#L26-L37 ``` /// In shapefile, the point ordering is what is used to know if /// a ring is an outer or inner one: /// - **Outer** ring => points in clockwise order /// - **Inner** ring => points in counter-clockwise order /// /// # Note /// /// Rings you get access from a [`GenericPolygon`] will always have its points ordered /// according to its type (outer, inner). /// /// But `PolygonRing`s you create won't be reordered until you move them into /// a [`GenericPolygon`]. ``` https://github.com/tmontaigu/shapefile-rs/blob/cd52bcfde8ce24aeaffec0968f155119e02c5a66/src/record/mod.rs#L118-L134 ``` /// Given the points, check if they represent an outer ring of a polygon /// /// As per ESRI's Shapefile 1998 whitepaper: /// ` /// The order of vertices or orientation for a ring indicates which side of the ring /// is the interior of the polygon. /// The neighborhood to the right of an observer walking along /// the ring in vertex order is the neighborhood inside the polygon. /// Vertices of rings defining holes in polygons are in a counterclockwise direction. /// Vertices for a single, ringed polygon are, therefore, always in clockwise order. /// ` /// /// Inner Rings defines holes -> points are in counterclockwise order /// Outer Rings's points are un clockwise order /// /// https://stackoverflow.com/questions/1165647/how-to-determine-if-a-list-of-polygon-points-are-in-clockwise-order/1180256#1180256 pub(crate) fn ring_type_from_points_ordering<PointType: HasXY>(points: &[PointType]) -> RingType { ```
概要
nusamai-shapefile
クレートの作成nusamai_geometry::MultiPoint
から Shapefile形式への変換examples/{read,write}.rs
- ファイル読み書きの参考例(tmp - 最終的に削除する)まず例として小さく、MultiPointの部分のみを作ったプルリクです。方向性に問題ないかご確認いただけますでしょうか!
外部クレート shapefile を用いて実装しています。
リファクタしてもらった
nusamai-geojson
の形(#154)をもとにしています(ので、それをやった @ciscorn さんを明示的にレビューアーへ入れてみました)。3D地物(
nusamai_geometry::MultiPoint::<3>
,shapefile::MultiPointZ
)のみで、2Dは考慮していません。その後の進め方
related #198
この方向性で問題なければ、それを踏まえて、以下の順に進めていく予定です: