Example #1
0
 private void CreateMatrixMdb()
 {
     using (
         var connPoints =
             new Npgsql.NpgsqlConnection(
                 "server=127.0.0.1;port=5432;database=ivv-projekte;uid=postgres;password=1.Kennwort"))
     {
         connPoints.Open();
         using (
             var pointsReader =
                 new Npgsql.NpgsqlCommand(
                     "WITH t as (SELECT zellnr, st_pointonsurface(wkb_geometry) as g FROM \"DFN2950\".\"fuerimport\") " +
                     "SELECT zellnr, st_X(g), st_Y(g) FROM t ORDER BY zellnr;",
                     connPoints).ExecuteReader())
         {
             using (
                 var connMatrix =
                     new Npgsql.NpgsqlConnection(
                         "server=127.0.0.1;port=5432;database=ivv-projekte;uid=postgres;password=1.Kennwort"))
             {
                 connMatrix.Open();
                 using (
                     var matrixReader =
                         new Npgsql.NpgsqlCommand(
                             "SELECT origin, destin, val FROM \"DFN2950\".\"iv-kfz\" " +
                             "WHERE val > 10 " +
                             "ORDER BY origin, destin;",
                             connMatrix).ExecuteReader())
                     _matrix = new ODMatrix(pointsReader, matrixReader);
             }
         }
     }
 }
Example #2
0
        private void CreateMatrix()
        {
            var f = new NetTopologySuite.Geometries.GeometryFactory();

            _matrix = new ODMatrix(new[]
            {
                new KeyValuePair <ushort, GeoPoint>(0, f.CreatePoint(new Coordinate(-10, -10))),
                new KeyValuePair <ushort, GeoPoint>(1, f.CreatePoint(new Coordinate(-10, 10))),
                new KeyValuePair <ushort, GeoPoint>(2, f.CreatePoint(new Coordinate(10, 10))),
                new KeyValuePair <ushort, GeoPoint>(3, f.CreatePoint(new Coordinate(10, -10))),
                new KeyValuePair <ushort, GeoPoint>(4, f.CreatePoint(new Coordinate(0, 0))),
            });

            _matrix[0, 1]         = 10;
            _matrix[0, 2]         = 5;
            _matrix[0, 3]         = 10;
            _matrix[1, (ushort)0] = 10;
            _matrix[1, 2]         = 10;
            _matrix[1, 3]         = 5;
            _matrix[2, (ushort)0] = 5;
            _matrix[2, 1]         = 10;
            _matrix[2, 3]         = 10;
            _matrix[3, (ushort)0] = 10;
            _matrix[3, 1]         = 5;
            _matrix[3, 2]         = 10;
            _matrix[4, 4]         = 15;
        }