Giter VIP home page Giter VIP logo

Comments (5)

fraferrando avatar fraferrando commented on September 26, 2024 1

Hi Kuba,

I have tried the last version of the library and now with the options
var options = new ShapefileReaderOptions()
{
GeometryBuilderMode = GeometryBuilderMode.FixInvalidShapes
};

var currentFeatures = Shapefile.ReadAllFeatures(shpStream, dbfStream, options);
//we added the methods that use streams from the start

We can read both a6a6 and 3509 zips!

Thank you so very much!!!

Bye
Francesca

from nettopologysuite.io.esri.

fraferrando avatar fraferrando commented on September 26, 2024

Hi kubaszostak,

i have not found a solution yet but what i have noticed is that it is probably a question of decimal digits...

Because Multypoligon tmpA6A6 crashes
While Multypoligon tmp3509 works

points in tmpA6A6 where it crashes
11.9797646969949998
44.88052525112210134

11.97958996594410053
44.88039510494419915

11.97940691328200025
44.88051933463930254

11.97958164432600014
44.88064948109619934

11.9797646969949998
44.88052525112210134

points in tmp3509 where it works
11.98410995573788007
44.87705361570291984

11.98413715530627499
44.87705443978246223

11.98412541839736356
44.87681169189863084

11.98409970871640873
44.87681083371183632

11.98410995573788007
44.87705361570291984
[tmpA6A6
tmp3509.zip
.zip](https://github.com/NetTopologySuite/NetTopologySuite.IO.Esri/files/10093291/tmpA6A6.zip)

from nettopologysuite.io.esri.

KubaSzostak avatar KubaSzostak commented on September 26, 2024

Hi Francesca,
I've updated the code and now you can read your shapefiles:

var options = new ShapefileReaderOptions()
{
    GeometryBuilderMode = GeometryBuilderMode.IgnoreInvalidShapes
};
var shpPath = TestShapefiles.PathTo("Issues/009/tmpA6A6/Rx/PPPP29_0.shp");
var features = Shapefile.ReadAllFeatures(shpPath, options);
Assert.AreEqual(50, features.Count());

Console.WriteLine("Invalid shape geometries:");
foreach (var feature in features)
{
    if (!feature.Geometry.IsValid)
    {
        Console.WriteLine(string.Join(", ", feature.Attributes.GetValues()));
    }
}

You can also fix invalid geometries by using GeometryBuilderMode.FixInvalidShapes option. It will work for tmpA6A6 file, but not for tmp3509. The latter contains self-intersecting polygon shells, so it can't be fixed automatically.

image

from nettopologysuite.io.esri.

KubaSzostak avatar KubaSzostak commented on September 26, 2024

This also fixes Cannot read a polygon with a hole from a ShapeFile #70 issue.

from nettopologysuite.io.esri.

fraferrando avatar fraferrando commented on September 26, 2024

Hi Kuba,
thank you very much, I will try today.

I have a question.
I noticed that taking the file that didn't work (A6A6) and saving it with QGIS with UTF-8 encoding was then read correctly by the library.
Is it mandatory to use UTF-8 encoding or is it irrelevant?

Thank you
bye
Francesca

from nettopologysuite.io.esri.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.