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

[go] fix geometry parts build #355

Merged
merged 2 commits into from
Apr 9, 2024

Conversation

durandAD
Copy link
Contributor

First thank you for this great go package. When using this package I had a few issues while trying to write multipolygons and using parts of geometry.

I had 2 issues that are fixed by this PR.

  • When writing the geometry that contains parts, the build always caused a panic:

panic: Incorrect creation order: object must not be nested.

  • When providing only parts of a geometry the geometry was not indexed as the parts where not used to create it.

I added a test to show what kind of feature was not working before

@bruno-ga
Copy link
Contributor

Thanks for your PR. I will try to review it by EOD today.

@bjornharrtell
Copy link
Member

LGTM. @bruno-ga you ok with merge?

Copy link
Contributor

@bruno-ga bruno-ga left a comment

Choose a reason for hiding this comment

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

Looks good generally. Just a few changes suggested to make this a bit clearer.

@@ -77,6 +77,9 @@ func TestCreateFGBFileAndBasicSearch(t *testing.T) {
createSquareFeature(-1, 0, 0, 1, 2),
createSquareFeature(-1, -1, 0, 0, 3),
createSquareFeature(0, -1, 1, 0, 4),
createMultiPolygonFeature([][]float64{
Copy link
Contributor

Choose a reason for hiding this comment

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

Would you mind moving this to its own test? It seems important enough to deserve this (also it might not match the basic test here).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point, I created another test

Copy link

Choose a reason for hiding this comment

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

Thanks.

@@ -90,7 +93,7 @@ func TestCreateFGBFileAndBasicSearch(t *testing.T) {
header := writer.NewHeader(headerBuilder).
SetName("Households ShapeFile Data").
SetTitle("Households ShapeFile Data").
SetGeometryType(flattypes.GeometryTypePolygon)
SetGeometryType(flattypes.GeometryTypeUnknown)
Copy link
Contributor

Choose a reason for hiding this comment

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

If you move the changes to their own test, you do not need to use Unknown here (which again, goes for the "basic" part of this test). :)

@@ -137,6 +140,8 @@ func TestCreateFGBFileAndBasicSearch(t *testing.T) {
expectedResultProperties: []int{1, 2, 3, 4}},
{searchMinX: 2, searchMinY: 2, searchMaxX: 3, searchMaxY: 3,
expectedResultProperties: []int{}},
{searchMinX: 4.5, searchMinY: 4.5, searchMaxX: 4.6, searchMaxY: 4.6,
Copy link
Contributor

Choose a reason for hiding this comment

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

Ditto. More to own test.

firstPartEnd := len(g.xy)
if firstPartEnd == 0 {
// Nothing to do.
return
}

if len(g.ends) != 0 {
firstPartEnd = int(g.ends[0])
firstPartEnd = int(g.ends[0]) * 2
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you add a comment here to explain why you are multiplying by 2? It is not obvious form the code around it and it is also not clear to me why you need to do it (although I might be missing something).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I added a comment. don't hesitate to tell me if it is not clear enough

Copy link

Choose a reason for hiding this comment

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

LGTM.

@bruno-ga
Copy link
Contributor

bruno-ga commented Apr 8, 2024

LGTM. @bruno-ga you ok with merge?

Sorry, I punted reviewing it and then forgot about it. Just did it now. Will wait for the author's reply.

@bjornharrtell BTW, heads up that I will start using my personal account to work on this, @brunoga (no dash).

@bjornharrtell
Copy link
Member

@brunoga thanks for your input and contribution. :)

@brunoga
Copy link

brunoga commented Apr 8, 2024

@brunoga thanks for your input and contribution. :)

Thanks. :)

@brunoga
Copy link

brunoga commented Apr 9, 2024

@bjornharrtell Apparently I can not approve with either account so up to you. :)

@bjornharrtell
Copy link
Member

Thanks for your contribution @durandAD!

@bjornharrtell bjornharrtell merged commit ac924bd into flatgeobuf:master Apr 9, 2024
11 checks passed
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.

None yet

4 participants