예제 #1
0
    public static Map InitializeMapGdal(Size size)
    {
        HttpContext.Current.Trace.Write("Initializing map...");

        //Initialize a new map of size 'imagesize'
        Map map = new Map(size);

        //Set up the gdal layer
        LayerGroup g = new LayerGroup("OS");

        g.SRID = 27700;
        //D:\Raster\Ordnance Survey\OS Street View SM\data\sm
        System.IO.DirectoryInfo di = new System.IO.DirectoryInfo(HttpContext.Current.Server.MapPath(@"~\App_Data\Gdal"));
        foreach (System.IO.FileInfo fi in di.GetFiles("*.tif"))
        {
            try
            {
                SharpMap.Layers.GdalRasterLayer layer =
                    new SharpMap.Layers.GdalRasterLayer(
                        fi.Name, HttpContext.Current.Server.MapPath(@"~\App_Data\Gdal\" + fi.Name));
                //layer.SRID = 27700;
                g.Layers.Add(layer);
            }
            catch (TypeInitializationException ex)
            {
                throw new Exception(
                          "Please copy the umanaged dll's into your bin folder from javascript:window.location.href='http://www.codeplex.com/SharpMap/Wiki/View.aspx?title=Extensions';.");
            }
        }
        map.Layers.Add(g);
        map.ZoomToExtents();

        HttpContext.Current.Trace.Write("Map initialized");
        return(map);
    }
예제 #2
0
 public void AddRasterLayer(string layerName, string path)
 {
     string fileName = Path.GetFileNameWithoutExtension(path);
     GdalRasterLayer rasterLayer = new GdalRasterLayer(fileName,path);
     rasterLayer.ReprojectToMap(this.map);
     this.map.Layers.Add(rasterLayer);
     this.map.ZoomToExtents();
 }
예제 #3
0
    public static Map InitializeMapGdal(Size size)
    {
        HttpContext.Current.Trace.Write("Initializing map...");

        //Initialize a new map of size 'imagesize'
        Map map = new Map(size);

        //Set up the gdal layer
        LayerGroup g = new LayerGroup("OS");
        g.SRID = 27700;
        //D:\Raster\Ordnance Survey\OS Street View SM\data\sm
        System.IO.DirectoryInfo di = new System.IO.DirectoryInfo(HttpContext.Current.Server.MapPath(@"~\App_Data\Gdal"));
        foreach (System.IO.FileInfo fi in di.GetFiles("*.tif"))
        {
            try
            {
                SharpMap.Layers.GdalRasterLayer layer =
                    new SharpMap.Layers.GdalRasterLayer(
                        fi.Name, HttpContext.Current.Server.MapPath(@"~\App_Data\Gdal\" + fi.Name));
                //layer.SRID = 27700;
                g.Layers.Add(layer);
            }
            catch (TypeInitializationException ex)
            {
                if (ex.GetType() == typeof(TypeInitializationException))
                    throw new Exception(
                        "Please copy the umanaged dll's into your bin folder from javascript:window.location.href='http://www.codeplex.com/SharpMap/Wiki/View.aspx?title=Extensions';.");
            }
        }
        map.Layers.Add(g);
        map.ZoomToExtents();

        HttpContext.Current.Trace.Write("Map initialized");
        return map;
    }
예제 #4
0
 public GdalRasterLayerCachingProxy(string strLayerName, string imageFilename)
 {
     LayerName   = strLayerName;
     _innerLayer = new GdalRasterLayer(strLayerName, imageFilename);
 }
예제 #5
0
 public GdalRasterLayerCachingProxy(GdalRasterLayer innerLayer)
 {
     _innerLayer = innerLayer;
     LayerName   = innerLayer.LayerName;
 }
예제 #6
0
 public GdalRasterLayerCachingProxy(string strLayerName, string imageFilename)
     : base(new Style(), new NullRenderer())
 {
     LayerName   = strLayerName;
     _innerLayer = new GdalRasterLayer(strLayerName, imageFilename);
 }
예제 #7
0
 public GdalRasterLayerCachingProxy(GdalRasterLayer innerLayer)
     : base(new Style(), new NullRenderer())
 {
     _innerLayer = innerLayer;
     LayerName   = innerLayer.LayerName;
 }