示例#1
0
        static void addOpeningEscapeRoutes(String connectionParams)
        {
            NpgsqlConnection connection = new NpgsqlConnection(connectionParams);

            connection.Open();
            NpgsqlTransaction transaction = connection.BeginTransaction();

            try
            {
                PolygonDB db = new PolygonDB(connection);
                db.addPolygonEscapePoint("Polygon1", 0, new DPoint(34.849061965942383, 32.099617405894811));
                db.addPolygonEscapePoint("Polygon1", 4, new DPoint(34.84963595867157, 32.098076863289826));
                db.addPolygonEscapePoint("Polygon1", 5, new DPoint(34.84862744808197, 32.0989584749222));
                db.addPolygonEscapePoint("Malam", 1, new DPoint(34.851486682891846, 32.098517670169642));
                transaction.Commit();
            }
            catch (Exception exception)
            {
                try
                {
                    transaction.Rollback();
                }
                catch (Exception rollbackException)
                {
                    Console.WriteLine("Rollback failed :(");
                }
            }

            connection.Close();
        }
示例#2
0
        static void addMalamPolygon(String connectionParams)
        {
            NpgsqlConnection connection = new NpgsqlConnection(connectionParams);

            connection.Open();
            NpgsqlTransaction transaction = connection.BeginTransaction();

            try
            {
                Polygon             polygon = new Polygon(Guid.NewGuid().ToString(), "Malam");
                List <PolygonPoint> points  = new List <PolygonPoint>();
                points.Add(new PolygonPoint(polygon.guid, 0, 34.850942194461823, 32.098860770959512));
                points.Add(new PolygonPoint(polygon.guid, 1, 34.85137939453125, 32.098815327220322));
                points.Add(new PolygonPoint(polygon.guid, 2, 34.851290881633759, 32.098213195541732));
                points.Add(new PolygonPoint(polygon.guid, 3, 34.850845634937286, 32.098260911781828));
                points.Add(new PolygonPoint(polygon.guid, 4, 34.85086977481842, 32.098408604747945));
                points.Add(new PolygonPoint(polygon.guid, 5, 34.851129949092865, 32.098381338372178));
                points.Add(new PolygonPoint(polygon.guid, 6, 34.8511728644371, 32.098667634911841));
                points.Add(new PolygonPoint(polygon.guid, 7, 34.850918054580688, 32.098697173392637));


                PolygonDB db = new PolygonDB(connection);

                db.addPolygonToDB(polygon);
                db.addPolygonPoints(polygon, points);

                int[] edgesToAdd = new int[] { 1 };

                foreach (int i in edgesToAdd)
                {
                    double         openingX = (points[i].x + points[(i + 1) % points.Count()].x) / 2;
                    double         openingY = (points[i].y + points[(i + 1) % points.Count()].y) / 2;
                    PolygonOpening opening  = new PolygonOpening(polygon.guid, i, openingX, openingY, 3);
                    db.addPolygonOpeningToPolygon(opening);
                }

                transaction.Commit();
            }
            catch (Exception exception)
            {
                try
                {
                    transaction.Rollback();
                }
                catch (Exception rollbackException)
                {
                    Console.WriteLine("Rollback failed :(");
                }
            }

            connection.Close();
        }
示例#3
0
        private static void addDubekPolygonOpenings(String connectionParams)
        {
            NpgsqlConnection connection = new NpgsqlConnection(connectionParams);

            connection.Open();
            NpgsqlTransaction transaction = connection.BeginTransaction();

            int[] edgesToAdd = new int[] { 0, 4, 5 };

            try
            {
                // get polygon points
                PolygonDB           db      = new PolygonDB(connection);
                Polygon             polygon = db.getPolygonByName("Polygon1");
                List <PolygonPoint> points  = db.getPolygonPointsByPolygonGUID(polygon.guid);

                // add an opening
                foreach (int i in edgesToAdd)
                {
                    double         openingX = (points[i].x + points[(i + 1) % points.Count()].x) / 2;
                    double         openingY = (points[i].y + points[(i + 1) % points.Count()].y) / 2;
                    PolygonOpening opening  = new PolygonOpening(polygon.guid, i, openingX, openingY, 3);
                    db.addPolygonOpeningToPolygon(opening);
                }

                transaction.Commit();
            }
            catch (Exception exception)
            {
                try
                {
                    transaction.Rollback();
                }
                catch (Exception rollbackException)
                {
                    Console.WriteLine("Rollback failed :(");
                }
            }

            connection.Close();
        }
示例#4
0
文件: Program.cs 项目: ohadmanor/TDS
        private static void addDubekPolygonOpenings(String connectionParams)
        {
            NpgsqlConnection connection = new NpgsqlConnection(connectionParams);
            connection.Open();
            NpgsqlTransaction transaction = connection.BeginTransaction();

            int[] edgesToAdd = new int[] { 0, 4, 5 };

            try
            {
                // get polygon points
                PolygonDB db = new PolygonDB(connection);
                Polygon polygon = db.getPolygonByName("Polygon1");
                List<PolygonPoint> points = db.getPolygonPointsByPolygonGUID(polygon.guid);
                
                // add an opening
                foreach (int i in edgesToAdd)
                {
                    double openingX = (points[i].x + points[(i + 1) % points.Count()].x) / 2;
                    double openingY = (points[i].y + points[(i + 1) % points.Count()].y) / 2;
                    PolygonOpening opening = new PolygonOpening(polygon.guid, i, openingX, openingY, 3);
                    db.addPolygonOpeningToPolygon(opening);
                }

                transaction.Commit();
            }
            catch (Exception exception)
            {
                try
                {
                    transaction.Rollback();
                }
                catch (Exception rollbackException)
                {
                    Console.WriteLine("Rollback failed :(");
                }
            }

            connection.Close();
        }
示例#5
0
文件: Program.cs 项目: ohadmanor/TDS
        static void addOpeningEscapeRoutes(String connectionParams)
        {
            NpgsqlConnection connection = new NpgsqlConnection(connectionParams);
            connection.Open();
            NpgsqlTransaction transaction = connection.BeginTransaction();

            try
            {
                PolygonDB db = new PolygonDB(connection);
                db.addPolygonEscapePoint("Polygon1", 0, new DPoint(34.849061965942383, 32.099617405894811));
                db.addPolygonEscapePoint("Polygon1", 4, new DPoint(34.84963595867157, 32.098076863289826));
                db.addPolygonEscapePoint("Polygon1", 5, new DPoint(34.84862744808197, 32.0989584749222));
                db.addPolygonEscapePoint("Malam", 1, new DPoint(34.851486682891846, 32.098517670169642));
                transaction.Commit();
            }
            catch (Exception exception)
            {
                try
                {
                    transaction.Rollback();
                }
                catch (Exception rollbackException)
                {
                    Console.WriteLine("Rollback failed :(");
                }
            }

            connection.Close();
        }
示例#6
0
文件: Program.cs 项目: ohadmanor/TDS
        static void addMalamPolygon(String connectionParams)
        {
            NpgsqlConnection connection = new NpgsqlConnection(connectionParams);
            connection.Open();
            NpgsqlTransaction transaction = connection.BeginTransaction();

            try
            {
                Polygon polygon = new Polygon(Guid.NewGuid().ToString(), "Malam");
                List<PolygonPoint> points = new List<PolygonPoint>();
                points.Add(new PolygonPoint(polygon.guid, 0, 34.850942194461823, 32.098860770959512));
                points.Add(new PolygonPoint(polygon.guid, 1, 34.85137939453125, 32.098815327220322));
                points.Add(new PolygonPoint(polygon.guid, 2, 34.851290881633759, 32.098213195541732));
                points.Add(new PolygonPoint(polygon.guid, 3, 34.850845634937286, 32.098260911781828));
                points.Add(new PolygonPoint(polygon.guid, 4, 34.85086977481842, 32.098408604747945));
                points.Add(new PolygonPoint(polygon.guid, 5, 34.851129949092865, 32.098381338372178));
                points.Add(new PolygonPoint(polygon.guid, 6, 34.8511728644371, 32.098667634911841));
                points.Add(new PolygonPoint(polygon.guid, 7, 34.850918054580688, 32.098697173392637));


                PolygonDB db = new PolygonDB(connection);

                db.addPolygonToDB(polygon);
                db.addPolygonPoints(polygon, points);

                int[] edgesToAdd = new int[] { 1 };

                foreach (int i in edgesToAdd)
                {
                    double openingX = (points[i].x + points[(i + 1) % points.Count()].x) / 2;
                    double openingY = (points[i].y + points[(i + 1) % points.Count()].y) / 2;
                    PolygonOpening opening = new PolygonOpening(polygon.guid, i, openingX, openingY, 3);
                    db.addPolygonOpeningToPolygon(opening);
                }

                transaction.Commit();
            }
            catch (Exception exception)
            {
                try
                {
                    transaction.Rollback();
                }
                catch (Exception rollbackException)
                {
                    Console.WriteLine("Rollback failed :(");
                }
            }

            connection.Close();
        }