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

feat: CSV, Excel and JSON writer - reduce to single geometries if dat… #1173

Merged
merged 1 commit into from
Jun 3, 2024

Conversation

emanuelaepure10
Copy link
Contributor

@emanuelaepure10 emanuelaepure10 commented May 14, 2024

…a does not contain multi geometry

CSV, Excel and JSON writer have been reduced to single geometries if data contains single geometry.

ING-3570
Closes #986

@emanuelaepure10 emanuelaepure10 force-pushed the feat/ING-3570 branch 5 times, most recently from 2ec4e30 to e4336a3 Compare May 23, 2024 12:31
if (!headerRow.contains(propertyTypeName)) {
headerRow.add(propertyTypeName);
}

if (property instanceof DefaultGeometryProperty<?>) {
Copy link
Member

Choose a reason for hiding this comment

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

The instanceof check and the cast later should be done with the interface GeometryProperty and not the implementation class.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@stempler the property that comes in the line 242 is a GeometryProperty<?> and not a GeometryCollection.

Copy link
Member

Choose a reason for hiding this comment

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

I don't quite understand. This comment was about using GeometryProperty instead of DefaultGeometryProperty, which you also did, so what is the open point here from your view?


if (geometry instanceof GeometryCollection
&& ((GeometryCollection) geometry).getNumGeometries() == 1) {
property = geometryProperty.getGeometry().getGeometryN(0);
Copy link
Member

Choose a reason for hiding this comment

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

Like this the CRS information gets lost.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@stempler what it was done here was just after taking the geometry from the property, so after (GeometryProperty<?>) property. If you tell me that I need to check if the property is an instanceof GeometryCollection then that condition it will never be true.
In the InstanceToJson is another story, already in the method comes a parameter which is a GeometryProperty<?>.

Copy link
Member

Choose a reason for hiding this comment

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

I'm afraid I don't understand the context of your comment.

If you tell me that I need to check if the property is an instanceof GeometryCollection then that condition it will never be true

If you refer to my comment here

  1. this comment was on another place in the code where the JTS geometry is handled, not the geometry property
  2. I did not tell you anything, I just asked if there was a specific reason for the change to check for some GeometryCollection subclasses instead of the base class

Comment on lines 260 to 277
if (geometry instanceof MultiPoint) {
MultiPoint multiPoint = (MultiPoint) geometry;
if (multiPoint.getNumGeometries() == 1) {
return multiPoint.getGeometryN(0);
}
}
else if (geometry instanceof MultiLineString) {
MultiLineString multiLineString = (MultiLineString) geometry;
if (multiLineString.getNumGeometries() == 1) {
return multiLineString.getGeometryN(0);
}
}
else if (geometry instanceof MultiPolygon) {
MultiPolygon multiPolygon = (MultiPolygon) geometry;
if (multiPolygon.getNumGeometries() == 1) {
return multiPolygon.getGeometryN(0);
}
}
Copy link
Member

Choose a reason for hiding this comment

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

I think the logic before with the GeometryCollection was fine, any specific reason to change it?

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 haven't change that. Before I have used DefaultGeometryProperty and now GeometryProperty.

Copy link
Member

Choose a reason for hiding this comment

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

Yes, you changed it. In the original version you did it the same way as in your changes to InstanceToJson, just checking for GeometryCollection and not these three subtypes. That's why I wondered if there is a specific reason to do it like that here.

Copy link
Contributor Author

@emanuelaepure10 emanuelaepure10 May 27, 2024

Choose a reason for hiding this comment

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

Please see the comments above regarding your question.

I have already implemented the solution you proposed but for me it is not valid. Therefore, I won't be committing it. Could you please reconsider your approach? I would greatly appreciate it.

Copy link
Member

Choose a reason for hiding this comment

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

I can't really follow you. What proposal do you mean?

I see in the current commit you changed the logic back to checking GeometryCollection instead of the three subclasses that were checked in the code related to the original comment in this thread. The only thing I did was asking about if there was a specific reason for the change to check the three subclasses instead of only GeometryCollection as you did in your first implementation.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No specific reason. In my opinion was a good approach but just using getGeometryN(0) it's enough for all the cases so I dropped the method.

@emanuelaepure10 emanuelaepure10 force-pushed the feat/ING-3570 branch 2 times, most recently from 71d3459 to 5f2927c Compare May 24, 2024 20:25
@stempler
Copy link
Member

Is the second commit intended to be a fixup commit?

Then it should start with fixup! followed by the message (first line) of the original commit.
You can also use git commit --fixup <commit-sha> to create such a commit.

Copy link
Member

@stempler stempler left a comment

Choose a reason for hiding this comment

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

Please rebase locally to combine the commits (since the PR is from a fork, the /autosquash command does not work, also the commit message of the fixup commit seems to not reference the original commit correctly)

@emanuelaepure10 emanuelaepure10 force-pushed the feat/ING-3570 branch 6 times, most recently from c8e554d to a544940 Compare June 3, 2024 09:29
@emanuelaepure10 emanuelaepure10 added the challenged For PRs to indicate that the implementation has been challenged label Jun 3, 2024
…a does not contain multi geometry

CSV, Excel and JSON writer have been reduced to single geometries if data contains single geometry.

ING-3570
Closes halestudio#986
@emanuelaepure10 emanuelaepure10 merged commit 3aa38bf into halestudio:master Jun 3, 2024
4 checks passed
Copy link

we-release bot commented Jun 19, 2024

🎉 This PR is included in version 5.2.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@we-release we-release bot added the released label Jun 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
challenged For PRs to indicate that the implementation has been challenged released
Projects
None yet
Development

Successfully merging this pull request may close these issues.

CSV writer: Reduce multi geometries to single geometries if no multi geometry is contained
2 participants