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

From GeoZero (reverse conversion) #4

Merged
merged 5 commits into from
Jul 5, 2024
Merged

From GeoZero (reverse conversion) #4

merged 5 commits into from
Jul 5, 2024

Conversation

ciscorn
Copy link
Member

@ciscorn ciscorn commented Jul 5, 2024

Close #2

This PR implements the GeomProcessor trait for our geometries, enabling the conversion of other GeoZero geometries into our geometries.

Summary by CodeRabbit

  • New Features

    • Added extend methods to LineString and MultiPoint for appending coordinates.
    • Introduced GeometryCollection to handle collections of geometries.
    • Introduced ToFlatgeom trait for converting geometries to a flat representation.
  • Enhancements

    • The public API now includes reader and writer modules under geozero.
    • Enhanced FlatgeomWriter to support multi-dimensional geometries and collections.
  • Tests

    • Updated test functions and import statements to support the new flatgeom conversions and additional geometric types.

@ciscorn ciscorn changed the title From GeoZero (backward) From GeoZero (backward conversion) Jul 5, 2024
Copy link

coderabbitai bot commented Jul 5, 2024

Walkthrough

The updates introduce several improvements and new features. The LineString and MultiPoint structs now have an extend method for adding coordinates. The Geometry enum includes a new GeometryCollection variant. The geozero module exposes reader and writer, adds a ToFlatgeom trait, and enhances FlatgeomWriter to support multi-dimensional geometries. Additionally, test functions were adjusted for these changes, incorporating new conversions and processing methods.

Changes

Files/Directories Change Summaries
src/geometry/linestring.rs, multi_point.rs Added extend method to LineString and MultiPoint structs to append coordinates from an iterator.
src/geometry/mod.rs Added GeometryCollection variant to the Geometry enum, enabling handling of geometry collections.
src/geozero/mod.rs Made reader and writer modules public, added ToFlatgeom trait for converting geometries to a flat representation, and implemented it for GeozeroGeometry types.
src/geozero/reader.rs Centralized processing in a new process_geometry function within GeozeroGeometry trait.
src/geozero/writer.rs Enhanced FlatgeomWriter to support multi-dimensional geometries and collections, including various methods for managing geometry types and coordinates.
src/lib.rs Promoted the geozero module to be public based on the feature flag geozero.
tests/geozero.rs Updated import statements and test functions to accommodate changes, added inversion tests using to_flatgeom() for conversions.

Assessment against linked issues

Objective Addressed Explanation
GeozeroGeometry trait (from #2)
GeomProcessor trait (from #2)

Poem

In the world of code so bright and neat,
New functions now, our geometries greet.
LineString and MultiPoint extend,
Collections grow, with no end.
Flatgeom shines with dimension bold,
In tests, geometries unfold.
Interop achieved, tales of modules told.
Hopping forward, in changes, we're sold! 🐇✨


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 testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • 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 testing code 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 and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

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 an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @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.
  • Please see the configuration documentation for more information.
  • 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/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@ciscorn ciscorn changed the title From GeoZero (backward conversion) From GeoZero (reverse conversion) Jul 5, 2024
@ciscorn ciscorn self-assigned this Jul 5, 2024
Copy link

codecov bot commented Jul 5, 2024

Codecov Report

Attention: Patch coverage is 95.66667% with 13 lines in your changes missing coverage. Please review.

Project coverage is 96.87%. Comparing base (5b539b8) to head (0310d85).

Files Patch % Lines
src/geozero/writer.rs 93.15% 10 Missing ⚠️
src/geozero/reader.rs 97.87% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main       #4      +/-   ##
==========================================
+ Coverage   93.92%   96.87%   +2.94%     
==========================================
  Files           7        9       +2     
  Lines        1349     1566     +217     
==========================================
+ Hits         1267     1517     +250     
+ Misses         82       49      -33     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

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.

Actionable comments posted: 19

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 5b539b8 and 8d37c60.

Files selected for processing (8)
  • src/geometry/linestring.rs (1 hunks)
  • src/geometry/mod.rs (2 hunks)
  • src/geometry/multi_point.rs (1 hunks)
  • src/geozero/mod.rs (1 hunks)
  • src/geozero/reader.rs (2 hunks)
  • src/geozero/writer.rs (1 hunks)
  • src/lib.rs (1 hunks)
  • tests/geozero.rs (2 hunks)
Files skipped from review due to trivial changes (1)
  • src/lib.rs
Additional context used
GitHub Check: codecov/patch
src/geozero/writer.rs

[warning] 18-18: src/geozero/writer.rs#L18
Added line #L18 was not covered by tests


[warning] 30-30: src/geozero/writer.rs#L30
Added line #L30 was not covered by tests


[warning] 32-32: src/geozero/writer.rs#L32
Added line #L32 was not covered by tests


[warning] 38-40: src/geozero/writer.rs#L38-L40
Added lines #L38 - L40 were not covered by tests


[warning] 46-48: src/geozero/writer.rs#L46-L48
Added lines #L46 - L48 were not covered by tests


[warning] 70-70: src/geozero/writer.rs#L70
Added line #L70 was not covered by tests


[warning] 72-72: src/geozero/writer.rs#L72
Added line #L72 was not covered by tests


[warning] 78-78: src/geozero/writer.rs#L78
Added line #L78 was not covered by tests


[warning] 98-118: src/geozero/writer.rs#L98-L118
Added lines #L98 - L118 were not covered by tests


[warning] 120-123: src/geozero/writer.rs#L120-L123
Added lines #L120 - L123 were not covered by tests


[warning] 125-128: src/geozero/writer.rs#L125-L128
Added lines #L125 - L128 were not covered by tests

src/geozero/reader.rs

[warning] 7-8: src/geozero/reader.rs#L7-L8
Added lines #L7 - L8 were not covered by tests


[warning] 11-20: src/geozero/reader.rs#L11-L20
Added lines #L11 - L20 were not covered by tests


[warning] 22-23: src/geozero/reader.rs#L22-L23
Added lines #L22 - L23 were not covered by tests


[warning] 25-29: src/geozero/reader.rs#L25-L29
Added lines #L25 - L29 were not covered by tests


[warning] 50-58: src/geozero/reader.rs#L50-L58
Added lines #L50 - L58 were not covered by tests


[warning] 84-92: src/geozero/reader.rs#L84-L92
Added lines #L84 - L92 were not covered by tests


[warning] 120-128: src/geozero/reader.rs#L120-L128
Added lines #L120 - L128 were not covered by tests


[warning] 158-166: src/geozero/reader.rs#L158-L166
Added lines #L158 - L166 were not covered by tests


[warning] 198-206: src/geozero/reader.rs#L198-L206
Added lines #L198 - L206 were not covered by tests

Additional comments not posted (19)
src/geozero/mod.rs (3)

1-2: LGTM! Modules made public.

The reader and writer modules are correctly made public to enable interoperability.


8-10: LGTM! New trait ToFlatgeom introduced.

The ToFlatgeom trait is appropriately introduced to facilitate the conversion of geometries to a flat representation.


12-20: LGTM! Implementation of ToFlatgeom for GeozeroGeometry.

The implementation processes the geometry using FlatgeomWriter and handles errors appropriately.

src/geometry/mod.rs (1)

60-60: LGTM! New GeometryCollection variant added.

The addition of the GeometryCollection variant to the Geometry enum allows handling collections of geometries.

tests/geozero.rs (6)

4-7: LGTM! Import statements updated.

The import statements are correctly updated to include ToFlatgeom and various geometry types.


Line range hint 12-53:
LGTM! New test for MultiPolygon2 added.

The test correctly verifies the conversion to geo_types::Geometry::MultiPolygon and inversion to flatgeom::Geometry::MultiPolygon.


58-85: LGTM! New test for Polygon2 added.

The test correctly verifies the conversion to geo_types::Geometry::Polygon and inversion to flatgeom::Geometry::Polygon.


89-116: LGTM! New test for MultiLineString2 added.

The test correctly verifies the conversion to geo_types::Geometry::MultiLineString and inversion to flatgeom::Geometry::MultiLineString.


120-143: LGTM! New test for LineString2 added.

The test correctly verifies the conversion to geo_types::Geometry::LineString and inversion to flatgeom::Geometry::LineString.


146-170: LGTM! New test for MultiPoint2 added.

The test correctly verifies the conversion to geo_types::Geometry::MultiPoint and inversion to flatgeom::Geometry::MultiPoint.

src/geometry/multi_point.rs (1)

72-75: LGTM! New extend method added.

The extend method allows extending the MultiPoint with additional coordinates, enhancing its functionality.

src/geozero/writer.rs (8)

8-13: Ensure all fields are necessary and correctly initialized.

The FlatgeomWriter struct includes fields for geometries, collections, current geometry, and coordinates. Verify that all fields are necessary and correctly initialized.


20-25: Ensure the default capacity is appropriate.

The Vec::with_capacity(1) calls initialize the vectors with a capacity of 1. Verify that this is appropriate for expected use cases.


44-52: Ensure start_geometry handles all geometry types correctly.

The start_geometry method initializes a geometry or a collection. Verify that all geometry types are handled correctly.

Tools
GitHub Check: codecov/patch

[warning] 46-48: src/geozero/writer.rs#L46-L48
Added lines #L46 - L48 were not covered by tests


147-152: Ensure polygon_begin and polygon_end handle polygons correctly.

The polygon_begin and polygon_end methods handle the beginning and end of a polygon geometry. Verify that polygons are handled correctly and that test coverage is adequate.

Also applies to: 178-183


76-81: Ensure finish_geometry handles nested collections correctly.

The finish_geometry method finalizes a geometry, including nested collections. Verify that nested collections are handled correctly and that test coverage is adequate.

Tools
GitHub Check: codecov/patch

[warning] 78-78: src/geozero/writer.rs#L78
Added line #L78 was not covered by tests


55-74: Ensure finish_coords handles all geometry types correctly.

The finish_coords method processes coordinates for various geometry types. Verify that all geometry types are handled correctly and that test coverage is adequate.

Verification successful

Verified: finish_coords handles all geometry types correctly and test coverage is adequate.

The finish_coords method processes coordinates for various geometry types, and the test functions across the tests/geozero.rs, tests/serde.rs, and src/geometry/ files involve these geometry types, ensuring indirect coverage.

  • tests/geozero.rs: Functions multipolygon, polygon, multilinestring, linestring, multipoint.
  • tests/serde.rs: Function test_serde_serialize_deserialize.
  • src/geometry/: Various test functions in multi_point.rs, linestring.rs, polygon.rs, multi_polygon.rs, multi_linestring.rs.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify test coverage for `finish_coords`.

# Test: Ensure there are tests for `finish_coords`.
rg --type rust 'finish_coords' tests/

Length of output: 37


Script:

#!/bin/bash
# Search for references to `finish_coords` in the entire codebase.
rg 'finish_coords'

# Search for test functions that might indirectly test `finish_coords`.
rg '#\[test\]' --type rust

Length of output: 2082


Script:

#!/bin/bash
# Search for references to `finish_coords` and geometries it handles within test functions.
rg 'finish_coords' tests/ src/geometry/
rg 'MultiPoint' tests/ src/geometry/
rg 'LineString' tests/ src/geometry/
rg 'MultiLineString' tests/ src/geometry/
rg 'Polygon' tests/ src/geometry/
rg 'MultiPolygon' tests/ src/geometry/

Length of output: 23102


Script:

#!/bin/bash
# Inspect test functions in the identified files for references to geometries handled by `finish_coords`.

# List all test functions in `tests/geozero.rs`.
rg '#\[test\]' -A 2 tests/geozero.rs

# List all test functions in `tests/serde.rs`.
rg '#\[test\]' -A 2 tests/serde.rs

# List all test functions in `src/geometry/`.
rg '#\[test\]' -A 2 src/geometry/

Length of output: 7961

Tools
GitHub Check: codecov/patch

[warning] 70-70: src/geozero/writer.rs#L70
Added line #L70 was not covered by tests


[warning] 72-72: src/geozero/writer.rs#L72
Added line #L72 was not covered by tests


142-145: Ensure multilinestring_begin and multilinestring_end handle multilinestrings correctly.

The multilinestring_begin and multilinestring_end methods handle the beginning and end of a multilinestring geometry. Verify that multilinestrings are handled correctly and that test coverage is adequate.

Also applies to: 173-176


154-157: Ensure multipolygon_begin and multipolygon_end handle multipolygons correctly.

The multipolygon_begin and multipolygon_end methods handle the beginning and end of a multipolygon geometry. Verify that multipolygons are handled correctly and that test coverage is adequate.

Also applies to: 185-188

Verification successful

Ensure multipolygon_begin and multipolygon_end handle multipolygons correctly.

The multipolygon_begin and multipolygon_end methods are indirectly tested through the multipolygon function in tests/geozero.rs, which covers the creation, conversion, and validation of multipolygons.

  • tests/geozero.rs: multipolygon function
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify test coverage for `multipolygon_begin` and `multipolygon_end`.

# Test: Ensure there are tests for `multipolygon_begin` and `multipolygon_end`.
rg --type rust 'multipolygon_begin|multipolygon_end' tests/

Length of output: 61


Script:

#!/bin/bash
# Description: Verify usage and test coverage for `multipolygon_begin` and `multipolygon_end`.

# Search for all instances of `multipolygon_begin` in the codebase.
rg --type rust 'multipolygon_begin'

# Search for all instances of `multipolygon_end` in the codebase.
rg --type rust 'multipolygon_end'

Length of output: 391


Script:

#!/bin/bash
# Description: Verify test coverage for `multipolygon_begin` and `multipolygon_end` through reader tests.

# Search for test cases related to `src/geozero/reader.rs`.
rg --type rust 'reader' tests/

Length of output: 30


Script:

#!/bin/bash
# Description: Verify test coverage for multipolygon handling.

# Search for test files that might contain tests for multipolygon handling.
rg --type rust 'multipolygon' tests/

Length of output: 73


Script:

#!/bin/bash
# Description: Display the contents of `tests/geozero.rs` to verify test coverage for multipolygon handling.

# Display the contents of `tests/geozero.rs`.
cat tests/geozero.rs

Length of output: 5182

src/geozero/writer.rs Show resolved Hide resolved
src/geozero/writer.rs Show resolved Hide resolved
src/geozero/writer.rs Show resolved Hide resolved
src/geozero/writer.rs Show resolved Hide resolved
src/geozero/writer.rs Show resolved Hide resolved
src/geozero/reader.rs Show resolved Hide resolved
src/geozero/reader.rs Show resolved Hide resolved
src/geozero/reader.rs Show resolved Hide resolved
src/geozero/reader.rs Show resolved Hide resolved
src/geometry/linestring.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.

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 8d37c60 and 22f15cc.

Files selected for processing (1)
  • tests/geozero.rs (2 hunks)
Files skipped from review as they are similar to previous changes (1)
  • tests/geozero.rs

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.

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 22f15cc and a479aac.

Files selected for processing (1)
  • tests/geozero.rs (2 hunks)
Files skipped from review as they are similar to previous changes (1)
  • tests/geozero.rs

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.

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between a479aac and b60d393.

Files selected for processing (1)
  • tests/geozero.rs (2 hunks)
Files skipped from review as they are similar to previous changes (1)
  • tests/geozero.rs

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.

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between b60d393 and 86baf6f.

Files selected for processing (1)
  • tests/geozero.rs (2 hunks)
Files skipped from review as they are similar to previous changes (1)
  • tests/geozero.rs

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.

Actionable comments posted: 6

Outside diff range and nitpick comments (2)
tests/geozero.rs (2)

Line range hint 10-51: Enhance multipolygon test with more assertions.

The multipolygon test function is comprehensive. However, consider adding more assertions for interior rings to ensure complete coverage.

+            assert_eq!(geo_mpoly.0[1].interiors().len(), 1);
+            assert_eq!(geo_mpoly.0[2].interiors().len(), 0);

56-85: Enhance multipolygon3d test with more assertions.

The multipolygon3d test function is comprehensive. However, consider adding more assertions for interior rings to ensure complete coverage.

+            assert_eq!(mpoly[1].interiors().len(), 1);
+            assert_eq!(mpoly[2].interiors().len(), 0);
Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 86baf6f and 5e60479.

Files selected for processing (2)
  • src/geozero/writer.rs (1 hunks)
  • tests/geozero.rs (2 hunks)
Additional context used
Learnings (1)
src/geozero/writer.rs (1)
Learnt from: ciscorn
PR: MIERUNE/flatgeom-rs#4
File: src/geozero/writer.rs:16-19
Timestamp: 2024-07-05T11:29:53.447Z
Learning: In the `flatgeom-rs` library, `D` is a compile-time constant, and a value less than 2 indicates a programming error rather than a runtime condition.
GitHub Check: codecov/patch
src/geozero/writer.rs

[warning] 18-18: src/geozero/writer.rs#L18
Added line #L18 was not covered by tests


[warning] 30-30: src/geozero/writer.rs#L30
Added line #L30 was not covered by tests


[warning] 32-32: src/geozero/writer.rs#L32
Added line #L32 was not covered by tests


[warning] 38-40: src/geozero/writer.rs#L38-L40
Added lines #L38 - L40 were not covered by tests


[warning] 70-70: src/geozero/writer.rs#L70
Added line #L70 was not covered by tests


[warning] 72-72: src/geozero/writer.rs#L72
Added line #L72 was not covered by tests


[warning] 115-115: src/geozero/writer.rs#L115
Added line #L115 was not covered by tests


[warning] 127-127: src/geozero/writer.rs#L127
Added line #L127 was not covered by tests

Additional comments not posted (24)
src/geozero/writer.rs (13)

16-19: Panic in new method is acceptable for compile-time constant D.

Since D is a compile-time constant, the panic here is intended to catch programming errors early.

Tools
GitHub Check: codecov/patch

[warning] 18-18: src/geozero/writer.rs#L18
Added line #L18 was not covered by tests


120-123: Add tests for geometrycollection_begin method.

The geometrycollection_begin method is not covered by tests. Adding tests will ensure its functionality.


125-132: Add tests for geometrycollection_end method.

The geometrycollection_end method is not covered by tests. Adding tests will ensure its functionality.

Tools
GitHub Check: codecov/patch

[warning] 127-127: src/geozero/writer.rs#L127
Added line #L127 was not covered by tests


134-137: Add tests for multipoint_begin method.

The multipoint_begin method is not covered by tests. Adding tests will ensure its functionality.


139-144: Add tests for linestring_begin method.

The linestring_begin method is not covered by tests. Adding tests will ensure its functionality.


146-149: Add tests for multilinestring_begin method.

The multilinestring_begin method is not covered by tests. Adding tests will ensure its functionality.


151-156: Add tests for polygon_begin method.

The polygon_begin method is not covered by tests. Adding tests will ensure its functionality.


158-161: Add tests for multipolygon_begin method.

The multipolygon_begin method is not covered by tests. Adding tests will ensure its functionality.


163-167: Add tests for multipoint_end method.

The multipoint_end method is not covered by tests. Adding tests will ensure its functionality.


169-175: Add tests for linestring_end method.

The linestring_end method is not covered by tests. Adding tests will ensure its functionality.


177-180: Add tests for multilinestring_end method.

The multilinestring_end method is not covered by tests. Adding tests will ensure its functionality.


182-187: Add tests for polygon_end method.

The polygon_end method is not covered by tests. Adding tests will ensure its functionality.


189-192: Add tests for multipolygon_end method.

The multipolygon_end method is not covered by tests. Adding tests will ensure its functionality.

tests/geozero.rs (11)

87-116: LGTM!

The polygon test function is comprehensive and covers both conversion and inversion.


118-133: LGTM!

The polygon3d test function is comprehensive and covers both conversion and inversion.


137-164: LGTM!

The multilinestring test function is comprehensive and covers both conversion and inversion.


168-182: LGTM!

The multilinestring3d test function is comprehensive and covers both conversion and inversion.


186-208: LGTM!

The linestring test function is comprehensive and covers both conversion and inversion.


211-223: LGTM!

The linestring3d test function is comprehensive and covers both conversion and inversion.


227-251: LGTM!

The multipoint test function is comprehensive and covers both conversion and inversion.


255-267: LGTM!

The multipoint3d test function is comprehensive and covers both conversion and inversion.


271-297: LGTM!

The geometry test function is comprehensive and covers both conversion and inversion.


300-315: LGTM!

The geometry3d test function is comprehensive and covers both conversion and inversion.


318-343: LGTM!

The geometry_collection test function is comprehensive and covers both conversion and inversion.

Comment on lines +28 to +34
pub fn take_geometry(mut self) -> Option<Geometry<'static, [f64; D]>> {
match self.geoms.len() {
0 => None,
1 => Some(self.geoms.pop().unwrap()),
_ => Some(Geometry::GeometryCollection(self.geoms)),
}
}
Copy link

Choose a reason for hiding this comment

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

Add tests for take_geometry method.

The take_geometry method is not covered by tests. Adding tests will ensure its functionality.

Do you want me to generate the unit testing code or open a GitHub issue to track this task?

Tools
GitHub Check: codecov/patch

[warning] 30-30: src/geozero/writer.rs#L30
Added line #L30 was not covered by tests


[warning] 32-32: src/geozero/writer.rs#L32
Added line #L32 was not covered by tests

Comment on lines +37 to +40
impl<const D: usize> Default for FlatgeomWriter<D> {
fn default() -> Self {
Self::new()
}
Copy link

Choose a reason for hiding this comment

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

Add tests for Default implementation.

The Default implementation is not covered by tests. Adding tests will ensure its functionality.

Do you want me to generate the unit testing code or open a GitHub issue to track this task?

Tools
GitHub Check: codecov/patch

[warning] 38-40: src/geozero/writer.rs#L38-L40
Added lines #L38 - L40 were not covered by tests

Comment on lines +44 to +53
fn start_geometry(&mut self, geom: Geometry<'static, [f64; D]>) {
match geom {
Geometry::GeometryCollection(geoms) => {
self.collections.push(geoms);
}
geom => {
self.current = Some(geom);
}
}
}
Copy link

Choose a reason for hiding this comment

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

Add tests for start_geometry method.

The start_geometry method is not covered by tests. Adding tests will ensure its functionality.

Do you want me to generate the unit testing code or open a GitHub issue to track this task?

Comment on lines +55 to +74
fn finish_coords(&mut self, idx: usize) {
if let Some(geom) = self.current.as_mut() {
let iter = self.coords.iter().copied();
match geom {
Geometry::MultiPoint(mp) => mp.extend(iter),
Geometry::LineString(ls) => ls.extend(iter),
Geometry::MultiLineString(mls) => mls.add_linestring(iter),
Geometry::Polygon(poly) => poly.add_ring(iter),
Geometry::MultiPolygon(mpoly) => {
if idx == 0 {
mpoly.add_exterior(iter);
} else {
mpoly.add_interior(iter);
}
}
_ => {}
}
}
self.coords.clear();
}
Copy link

Choose a reason for hiding this comment

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

Add tests for finish_coords method.

The finish_coords method is not covered by tests. Adding tests will ensure its functionality.

Do you want me to generate the unit testing code or open a GitHub issue to track this task?

Tools
GitHub Check: codecov/patch

[warning] 70-70: src/geozero/writer.rs#L70
Added line #L70 was not covered by tests


[warning] 72-72: src/geozero/writer.rs#L72
Added line #L72 was not covered by tests

src/geozero/writer.rs Show resolved Hide resolved
src/geozero/writer.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.

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 5e60479 and 0310d85.

Files selected for processing (2)
  • src/lib.rs (1 hunks)
  • tests/geozero.rs (2 hunks)
Files skipped from review as they are similar to previous changes (1)
  • tests/geozero.rs
Additional comments not posted (3)
src/lib.rs (3)

6-6: Good practice: Added separation for readability.

The addition of a blank line improves the readability of the code.


7-7: Good practice: Conditional compilation for optional features.

Using the #[cfg(feature = "geozero")] attribute is a good way to manage optional features and reduce the binary size.


8-8: Enhancing interoperability: Conditional public geozero module.

Making the geozero module public conditionally aligns with the goal of enhancing interoperability with the GeoZero library.

@ciscorn ciscorn merged commit cc236eb into main Jul 5, 2024
3 checks passed
@ciscorn ciscorn deleted the geozero-backward branch July 5, 2024 13:46
@ciscorn ciscorn mentioned this pull request Jul 5, 2024
2 tasks
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.

GeoZero interoperability
1 participant