File Geodatabase not saving correctly

Aspose.GIS Shapes are saving incorrectly in File GeoDatabase.

GetFileReport(), below, is run passing a Dataset populated with a simple SQL query that returns a column named ‘Shape’. Several shapes are drastically distorted when viewing the gdb in QGIS. However, if saving as a shapefile, using the same PolygonFromDbGeometry() function, shapefile works perfectly.

    public Polygon PolygonFromDbGeometry(DbGeometry shape) {
        LinearRing ext = LinearRingFromDbGeometry(shape.ExteriorRing);
        List<LinearRing> interior = new List<LinearRing>();
        Polygon p;
        if(interior.Count > 0) {
            p = new Polygon(ext, interior);
        } else {
            p = new Polygon(ext);
        }
        if(!p.IsValid) {
            return null;
        }
        return p;
    }

    public LinearRing LinearRingFromDbGeometry(DbGeometry shape) {
        List<Point> pts = new List<Point>();
        DbGeometry pt;
        for(int i = 1; i <= shape.PointCount; ++i) {
            pt = shape.PointAt(i);
            pts.Add(new Point(pt.XCoordinate.Value, pt.YCoordinate.Value));
        }
        LinearRing ext = new LinearRing(pts);
        return ext;
    }

    public void GetFileReport(DataSet layers, string path) {
        using(Dataset ds = Dataset.Create(path, Drivers.Shapefile)) {
            foreach(DataTable l in layers.Tables) {
                using(var layer = ds.CreateLayer(l.TableName, SpatialReferenceSystem.Wgs84)) {
                    foreach(DataRow r in l.Rows) {
                        Feature ft = layer.ConstructFeature();
                        foreach(DataColumn c in l.Columns) {
                            if(c.ColumnName == "Shape") {
                                var sqlgeom = ((SqlGeometry)r[c]);
                                sqlgeom = sqlgeom.MakeValid();
                                var g = (DbGeometry)DbGeometry.FromBinary(sqlgeom.AsBinaryZM().Value);
                                if(g.IsValid) {
                                    if(g.SpatialTypeName.ToLower() == "multipolygon") {

                                    } else if(g.SpatialTypeName.ToLower() == "polygon") {
                                        var geom = PolygonFromDbGeometry(g);
                                        if(geom != null) {
                                            ft.Geometry = geom;
                                        }
                                    }
                                }
                            }
                        }
                        layer.Add(ft);
                    }
                }
            }
        }
    }

@mbright,

We were unable to reproduce the issue reported by you. We used the code given below to generate a polygon. The polygon generated is not distorted. We have attached the generated file for your testing.
polygon.gdb.zip (8.3 KB)

Console.WriteLine(Drivers.FileGdb.CanCreateDatasets);
var path = "polygon.gdb";

using (var dataset = Dataset.Create(path, Drivers.FileGdb))
{
    using (var layer = dataset.CreateLayer("layer_1"))
    {
        LinearRing ring = new LinearRing();
        ring.AddPoint(50.02, 36.22);
        ring.AddPoint(49.99, 36.26);
        ring.AddPoint(49.97, 36.23);
        ring.AddPoint(49.98, 36.17);
        ring.AddPoint(50.02, 36.22);

        var feature = layer.ConstructFeature();
        feature.Geometry = new Polygon(ring);
        layer.Add(feature);
    }
}

Please make sure that you are using the latest version of Aspose.GIS for .NET API for testing.
We hope that this resolved the issue that you were facing. If the issue still persists, please provide the generated files and a sample console application to reproduce the issue so that we can assist you further.

Try making the polygon in this well known text:

POLYGON ((-104.02400490768065 31.510267037463677, -104.01893964735666 31.510307800883538, -104.01770464260557 31.510317740152175, -104.01587178477865 31.510307054174518, -104.01587362452841 31.51743157451034, -104.01587368471559 31.517666132432623, -104.01588066732029 31.524752975644788, -104.03161999820912 31.524660012082791, -104.03162120464674 31.524771123606286, -104.03252294430877 31.524769822619589, -104.03252279159511 31.524652026970841, -104.03250417490915 31.510281197366282, -104.03145233754299 31.510279445088827, -104.02400490768065 31.510267037463677))

It is distorted when using Aspose.GIS to make a file geodatabase

        using(var dataset = Dataset.Create(path, Drivers.FileGdb)) {
            using(var layer = dataset.CreateLayer("layer_1", SpatialReferenceSystem.Wgs84)) {
                LinearRing ring = new LinearRing();
                ring.AddPoint(-104.02400490768065, 31.510267037463677);
                ring.AddPoint(-104.01893964735666, 31.510307800883538);
                ring.AddPoint(-104.01770464260557, 31.510317740152175);
                ring.AddPoint(-104.01587178477865, 31.510307054174518);
                ring.AddPoint(-104.01587362452841, 31.51743157451034);
                ring.AddPoint(-104.01587368471559, 31.517666132432623);
                ring.AddPoint(-104.01588066732029, 31.524752975644788);
                ring.AddPoint(-104.03161999820912, 31.524660012082791);
                ring.AddPoint(-104.03162120464674, 31.524771123606286);
                ring.AddPoint(-104.03252294430877, 31.524769822619589);
                ring.AddPoint(-104.03252279159511, 31.524652026970841);
                ring.AddPoint(-104.03250417490915, 31.510281197366282);
                ring.AddPoint(-104.03145233754299, 31.510279445088827);
                ring.AddPoint(-104.02400490768065, 31.510267037463677);

                var feature = layer.ConstructFeature();
                feature.Geometry = new Polygon(ring);
                layer.Add(feature);
            }
        }

Attached is an example of the source and the output. The left is the output read through qgis and the right is the source viewed in sql server management studio:

fgdb.png (43.6 KB)

@mbright,

We have reproduced the issue reported by you. We have logged a ticket as GISNET-226 in our issue tracking system against it. We will update you here as soon as additional information is available.

The issues you have found earlier (filed as GISNET-226) have been fixed in this update. This message was posted using BugNotificationTool from Downloads module by muhammadahmad