NetTopologySuite / NetTopologySuite.IO.Esri

BSD 3-Clause "New" or "Revised" License
31 stars 16 forks source link

Handling of duplicate attribute-names #46

Open MaximilianBottin opened 3 months ago

MaximilianBottin commented 3 months ago

Hello Esri Team. First of all thanks for the hard work for the whole NetTopologySuite working with Polygons is so much easier than it should be thanks to your package.

Now to my current issue:

We recently got a bunch of shapefiles with duplicate attribute-names. I was able to implement my own workaround so i can at least open these files (otherwise NuGet Version 1.0.0 would throw an exception when trying to open it due to trying to Add duplicate Values to a Dictionary) However now we got shapefiles that actually contain needed Information in some of those dupllicate Attribute-Names.

I absolutely understand that this is not supported because I myself think it's in the exporters responsibility that all attributes have distinct names. However the Shapefiles are sent from government instituts and it's next to impossible to change anything in the near future there no matter how hard we would complain.

I've already pulled the Repository and created my own Version of it which can open shapefiles with duplicate attribute-names. So I'd be willing to implement the change for my version as well, however I'm not that familiar with the repository and if I could get an explanation on what I need to change I could do it myself. (And also pull the code back into the main-repository)

I was thinking of a similar solution to QGIS which imports all duplicate attributes with a trailing "_1" counting upwards for each found duplicate attribute-name. image

I would appreciate any help. Even if it's just hints about what I have to look out for when implementing this change.

Thanks :)

Antragsschläge 2024 (4).zip I've also attached a zip-file with this exact issue

KubaSzostak commented 2 weeks ago

Hi @MaximilianBottin, thank you for your kind words and for using the NetTopologySuite! We’re glad to hear that our package has made working with polygons easier for you.

As you rightly pointed out, ideally, shapefiles should not have duplicate attribute names, and this is typically the responsibility of the data exporter to ensure. However, given the constraints and the source of your shapefiles, we appreciate the need for a practical workaround. Your proposed solution to handle duplicate attribute names by appending a trailing "_1", "_2", etc., is fine.

Refer to the contribution documentation for details on how to implement this change.