Exemple #1
0
        public void readListFromDatabase(string connectionstring)
        {
            using (var conn = new NpgsqlConnection(connectionstring))
            {
                conn.Open();
                conn.TypeMapper.UseNetTopologySuite();
                CMapTileList aMapTileList = new CMapTileList();

                // note that it is overkill to do bulk import for two objects, but as example...
                using (var reader = conn.BeginBinaryExport("COPY public.tiletest(id_tile_250, the_geom ) TO STDOUT (FORMAT BINARY)"))
                {
                    while (reader.StartRow() > 0)
                    {
                        long       aMapId      = reader.Read <long>(NpgsqlDbType.Bigint);
                        Polygon    aPolygon    = reader.Read <Polygon>(NpgsqlDbType.Geometry);
                        Coordinate aCoordinate = aPolygon.Coordinates[0];
                        CMapTile   aCmapTile   = new CMapTile((long)aCoordinate.X, (long)aCoordinate.Y);
                        aCmapTile.TileID = aMapId;
                        aMapTileList.theMapList.Add(aCmapTile);
                    }
                    reader.Cancel();
                }
                conn.Close();
            }
        }
Exemple #2
0
        public CMapTileList(CStartParameters aStartParameters)
        {
            Int64 total_number_tiles      = (aStartParameters.x_max - aStartParameters.x_min) / 250 * (aStartParameters.y_max - aStartParameters.y_min) / 250;
            Int64 number_of_tiles_created = 0;

            theMapList = new List <CMapTile>();
            //            for (Int64 x = 236000; x < 6076000;x=x+250)
            for (Int64 x = aStartParameters.x_min; x < aStartParameters.x_max; x = x + 250)
            {
                for (Int64 y = aStartParameters.y_min; y < aStartParameters.y_max; y = y + 250)
                {
                    CMapTile aChapTile = new CMapTile(x, y);
                    theMapList.Add(aChapTile);

                    number_of_tiles_created++;
                    if (number_of_tiles_created % 100 == 0 && number_of_tiles_created != 0)
                    {
                        Console.Write("\r{0}   {1}", number_of_tiles_created, " The target number is " + total_number_tiles);
                    }
                }
            }
            Console.WriteLine("\r " + total_number_tiles + " tiles were created                                     ");
        }