Beispiel #1
0
        public void TeStPointFirstNegativeZValues()
        {
            using (OracleTransaction tr = _con.BeginTransaction())
            {
                for (decimal i = 0; i >= -CoordinatesSystem.Resolution * 100; i -= CoordinatesSystem.Resolution)
                {
                    string wkt = "POINT Z (0 0 " + i.ToString(CultureInfo.InvariantCulture) + ")";
                    StTestHelper.Write(wkt);

                    IEsriStGeometryType geo = StTestHelper.GetGeometry(wkt, _con);
                    StTestHelper.Write(geo.Points);
                    StTestHelper.Write(geo.Geometry);

                    // Create point with the same coordinates
                    var p1 = new StPoint(0, 0, i);
                    StTestHelper.Write(p1);

                    // Assert values are equal
                    StTestHelper.AssertAreEqual((StPoint)geo.Geometry, p1);

                    // Create point from shape
                    var p2 = new StPoint(geo.Points);
                    StTestHelper.Write(p2);

                    // Assert values are equal
                    StTestHelper.AssertAreEqual((StPoint)geo.Geometry, p2);
                }

                tr.Rollback();
            }
        }
Beispiel #2
0
        public void TeStPointZero()
        {
            using (OracleTransaction tr = _con.BeginTransaction())
            {
                string wkt = "POINT (0 0)";
                StTestHelper.Write(wkt);

                IEsriStGeometryType geo = StTestHelper.GetGeometry(wkt, _con);
                StTestHelper.Write(geo.Points);
                StTestHelper.Write(geo.Geometry);

                // Create point with the same coordinates
                var p1 = new StPoint(0m, 0m);
                StTestHelper.Write(p1);

                // Assert values are equal
                StTestHelper.AssertAreEqual((StPoint)geo.Geometry, p1);

                // Create point from shape
                var p2 = new StPoint(geo.Points);
                StTestHelper.Write(p2);

                // Assert values are equal
                StTestHelper.AssertAreEqual((StPoint)geo.Geometry, p2);

                tr.Rollback();
            }
        }
        public void TestCoordSystemLimitMinZ()
        {
            using (OracleTransaction tr = _con.BeginTransaction())
            {
                decimal val = CoordinatesSystem.MinZ;

                string wkt = "POINT Z (0 0 " + val.ToString("0.####", CultureInfo.InvariantCulture) + ")";
                StTestHelper.Write(wkt);

                IEsriStGeometryType geo = StTestHelper.GetGeometry(wkt, _con);
                StTestHelper.Write(geo.Points);
                StTestHelper.Write(geo.Geometry);

                // Create point with the same coordinates
                var p1 = new StPoint(0, 0, val);
                StTestHelper.Write(p1);

                // Assert values are equal
                StTestHelper.AssertAreEqual((StPoint)geo.Geometry, p1);

                // Create point from shape
                var p2 = new StPoint(geo.Points);
                StTestHelper.Write(p2);

                // Assert values are equal
                StTestHelper.AssertAreEqual((StPoint)geo.Geometry, p2);

                tr.Rollback();
            }
        }
        internal static void MapToCustomObject(IEsriStGeometryType geoType)
        {
            geoType.Entity = geoType.GetValue <int>("ENTITY");
            geoType.NumPts = geoType.GetValue <int>("NUMPTS");
            geoType.MinX   = geoType.GetValue <decimal>("MINX");
            geoType.MinY   = geoType.GetValue <decimal>("MINY");
            geoType.MaxX   = geoType.GetValue <decimal>("MAXX");
            geoType.MaxY   = geoType.GetValue <decimal>("MAXY");
            geoType.MinZ   = geoType.GetValue <decimal?>("MINZ");
            geoType.MaxZ   = geoType.GetValue <decimal?>("MAXZ");
            geoType.MinM   = geoType.GetValue <decimal?>("MINM");
            geoType.MaxM   = geoType.GetValue <decimal?>("MAXM");
            geoType.Area   = geoType.GetValue <decimal>("AREA");
            geoType.Len    = geoType.GetValue <decimal>("LEN");
            geoType.Srid   = geoType.GetValue <int>("SRID");
            geoType.Points = geoType.GetValue <byte[]>("POINTS");

            switch ((StGeometryType)geoType.Entity)
            {
            case StGeometryType.Point:
                geoType.Geometry = new StPoint(geoType.Points);
                break;

            case StGeometryType.LineString:
            case StGeometryType.LineStringZ:
                geoType.Geometry = new StLineString(geoType.Points);
                break;

            default:
                throw new NotSupportedException();
            }
        }
 public void TestCoordSystemLimitMaxZOverflow()
 {
     using (OracleTransaction tr = _con.BeginTransaction())
     {
         string wkt = "POINT Z (0 0 " + (CoordinatesSystem.MaxZ + 1).ToString(CultureInfo.InvariantCulture) + ")";
         StTestHelper.Write(wkt);
         IEsriStGeometryType geo = StTestHelper.GetGeometry(wkt, _con);
     }
 }
        internal static void CalculateOtherValuesFromGeometry(IEsriStGeometryType geoType)
        {
            if (geoType.Geometry is StPoint)
            {
                geoType.Entity = (int) StGeometryType.Point;

                var point = (StPoint) geoType.Geometry;
                geoType.NumPts = 1;
                geoType.MinX = geoType.MaxX = point.X.Value;
                geoType.MinY = geoType.MaxY = point.Y.Value;
                if (point.HasZ)
                    geoType.MinZ = geoType.MaxZ = point.Z.Value;
                if (point.HasM)
                    geoType.MinM = geoType.MaxM = point.M.Value;

                geoType.Area = 0;
                geoType.Len = 0;
                geoType.Srid = StParameters.CoordinatesSystem.Srid;

                geoType.Points = geoType.Geometry.Bytes;
            }
            else if (geoType.Geometry is StLineString)
            {
                var line = (StLineString) geoType.Geometry;
                if (line.HasZ)
                    geoType.Entity = (int) StGeometryType.LineStringZ;
                else
                    geoType.Entity = (int) StGeometryType.LineString;

                geoType.NumPts = line.Points.Count;

                geoType.MinX = line.MinX;
                geoType.MaxX = line.MaxX;
                geoType.MinY = line.MinY;
                geoType.MaxY = line.MaxY;
                if (line.HasZ)
                {
                    geoType.MinZ = line.MinZ;
                    geoType.MaxZ = line.MaxZ;
                }
                if (line.HasM)
                {
                    geoType.MinM = line.MinM;
                    geoType.MaxM = line.MaxM;
                }

                geoType.Area = 0;
                geoType.Len = line.Length2D;
                geoType.Srid = StParameters.CoordinatesSystem.Srid;

                geoType.Points = geoType.Geometry.Bytes;
            }
            else
                throw new NotSupportedException();
        }
 internal static void MapFromCustomObject(IEsriStGeometryType geoType)
 {
     geoType.SetValue("ENTITY", geoType.Entity);
     geoType.SetValue("NUMPTS", geoType.NumPts);
     geoType.SetValue("MINX", geoType.MinX);
     geoType.SetValue("MINY", geoType.MinY);
     geoType.SetValue("MAXX", geoType.MaxX);
     geoType.SetValue("MAXY", geoType.MaxY);
     geoType.SetValue("MINZ", geoType.MinZ);
     geoType.SetValue("MAXZ", geoType.MaxZ);
     geoType.SetValue("MINM", geoType.MinM);
     geoType.SetValue("MAXM", geoType.MaxM);
     geoType.SetValue("AREA", geoType.Area);
     geoType.SetValue("LEN", geoType.Len);
     geoType.SetValue("SRID", geoType.Srid);
     geoType.SetValue("POINTS", geoType.Points);
 }
Beispiel #8
0
        public void TeStPointZNotM()
        {
            using (OracleTransaction tr = _con.BeginTransaction())
            {
                string wkt = "POINT Z (0 0 1)";
                StTestHelper.Write(wkt);

                IEsriStGeometryType geo = StTestHelper.GetGeometry(wkt, _con);
                StTestHelper.Write(geo.Points);
                StTestHelper.Write(geo.Geometry);

                Assert.IsTrue(geo.Geometry.HasZ);
                Assert.IsFalse(geo.Geometry.HasM);

                tr.Rollback();
            }
        }
 internal static void MapFromCustomObject(IEsriStGeometryType geoType)
 {
     geoType.SetValue("ENTITY", geoType.Entity);
     geoType.SetValue("NUMPTS", geoType.NumPts);
     geoType.SetValue("MINX", geoType.MinX);
     geoType.SetValue("MINY", geoType.MinY);
     geoType.SetValue("MAXX", geoType.MaxX);
     geoType.SetValue("MAXY", geoType.MaxY);
     geoType.SetValue("MINZ", geoType.MinZ);
     geoType.SetValue("MAXZ", geoType.MaxZ);
     geoType.SetValue("MINM", geoType.MinM);
     geoType.SetValue("MAXM", geoType.MaxM);
     geoType.SetValue("AREA", geoType.Area);
     geoType.SetValue("LEN", geoType.Len);
     geoType.SetValue("SRID", geoType.Srid);
     geoType.SetValue("POINTS", geoType.Points);
 }
Beispiel #10
0
        public void TeStPointZerosNegativeLimitZ()
        {
            using (OracleTransaction tr = _con.BeginTransaction())
            {
                for (int j = 1; j < CoordinatesSystem.ByteFactors.Length; ++j)
                {
                    decimal diff = CoordinatesSystem.ByteFactors[j];

                    if (-diff < CoordinatesSystem.MinZ)
                    {
                        // Coordinates Limits are reached
                        // We do not test those values
                        continue;
                    }

                    for (int i = -5; i <= 5; ++i)
                    {
                        decimal val = -diff + (i * CoordinatesSystem.Resolution);

                        string wkt = "POINT Z (0 0 " + val.ToString("0.####", CultureInfo.InvariantCulture) + ")";
                        StTestHelper.Write(wkt);

                        IEsriStGeometryType geo = StTestHelper.GetGeometry(wkt, _con);
                        StTestHelper.Write(geo.Points);
                        StTestHelper.Write(geo.Geometry);

                        // Create point with the same coordinates
                        var p1 = new StPoint(0, 0, val);
                        StTestHelper.Write(p1);

                        // Assert values are equal
                        StTestHelper.AssertAreEqual((StPoint)geo.Geometry, p1);

                        // Create point from shape
                        var p2 = new StPoint(geo.Points);
                        StTestHelper.Write(p2);

                        // Assert values are equal
                        StTestHelper.AssertAreEqual((StPoint)geo.Geometry, p2);
                    }
                }

                tr.Rollback();
            }
        }
        internal static void MapToCustomObject(IEsriStGeometryType geoType)
        {
            geoType.Entity = geoType.GetValue<int>("ENTITY");
            geoType.NumPts = geoType.GetValue<int>("NUMPTS");
            geoType.MinX = geoType.GetValue<decimal>("MINX");
            geoType.MinY = geoType.GetValue<decimal>("MINY");
            geoType.MaxX = geoType.GetValue<decimal>("MAXX");
            geoType.MaxY = geoType.GetValue<decimal>("MAXY");
            geoType.MinZ = geoType.GetValue<decimal?>("MINZ");
            geoType.MaxZ = geoType.GetValue<decimal?>("MAXZ");
            geoType.MinM = geoType.GetValue<decimal?>("MINM");
            geoType.MaxM = geoType.GetValue<decimal?>("MAXM");
            geoType.Area = geoType.GetValue<decimal>("AREA");
            geoType.Len = geoType.GetValue<decimal>("LEN");
            geoType.Srid = geoType.GetValue<int>("SRID");
            geoType.Points = geoType.GetValue<byte[]>("POINTS");

            switch ((StGeometryType) geoType.Entity)
            {
                case StGeometryType.Point:
                    geoType.Geometry = new StPoint(geoType.Points);
                    break;
                case StGeometryType.LineString:
                case StGeometryType.LineStringZ:
                    geoType.Geometry = new StLineString(geoType.Points);
                    break;
                default:
                    throw new NotSupportedException();
            }
        }
        internal static void CalculateOtherValuesFromGeometry(IEsriStGeometryType geoType)
        {
            if (geoType.Geometry is StPoint)
            {
                geoType.Entity = (int)StGeometryType.Point;

                var point = (StPoint)geoType.Geometry;
                geoType.NumPts = 1;
                geoType.MinX   = geoType.MaxX = point.X.Value;
                geoType.MinY   = geoType.MaxY = point.Y.Value;
                if (point.HasZ)
                {
                    geoType.MinZ = geoType.MaxZ = point.Z.Value;
                }
                if (point.HasM)
                {
                    geoType.MinM = geoType.MaxM = point.M.Value;
                }

                geoType.Area = 0;
                geoType.Len  = 0;
                geoType.Srid = StParameters.CoordinatesSystem.Srid;

                geoType.Points = geoType.Geometry.Bytes;
            }
            else if (geoType.Geometry is StLineString)
            {
                var line = (StLineString)geoType.Geometry;
                if (line.HasZ)
                {
                    geoType.Entity = (int)StGeometryType.LineStringZ;
                }
                else
                {
                    geoType.Entity = (int)StGeometryType.LineString;
                }

                geoType.NumPts = line.Points.Count;

                geoType.MinX = line.MinX;
                geoType.MaxX = line.MaxX;
                geoType.MinY = line.MinY;
                geoType.MaxY = line.MaxY;
                if (line.HasZ)
                {
                    geoType.MinZ = line.MinZ;
                    geoType.MaxZ = line.MaxZ;
                }
                if (line.HasM)
                {
                    geoType.MinM = line.MinM;
                    geoType.MaxM = line.MaxM;
                }

                geoType.Area = 0;
                geoType.Len  = line.Length2D;
                geoType.Srid = StParameters.CoordinatesSystem.Srid;

                geoType.Points = geoType.Geometry.Bytes;
            }
            else
            {
                throw new NotSupportedException();
            }
        }