示例#1
0
        public TileGenerator(string mapfile, string savePath, string tileListId)
        {
            try
            {
                id = tileListId;

                string version = Apis.MapServer.VersionSupport;

                var gdalPlugins = new DirectoryInfo(Path.Combine(Environment.CurrentDirectory, "gdalplugins"));
                Apis.Gdal.Driver.GdalDriverPath = gdalPlugins;

                Apis.Gdal.Driver.Register();
                Apis.Ogr.Driver.Register();

                var curlCaBundleCrt = new FileInfo(Path.Combine(Environment.CurrentDirectory, "curl-ca-bundle.crt"));
                Apis.Curl.SetCurlCertificateAuthorityBundleEnvironment(curlCaBundleCrt);

                var projLib = new DirectoryInfo(Path.Combine(Environment.CurrentDirectory, "ProjLib"));
                Apis.Proj.ProjLibDirectory = projLib;

                Apis.Gdal.Data.GdalDataDirectory = new DirectoryInfo(Environment.CurrentDirectory);

                map = new mapObj(mapfile);

                ProcessTileList(savePath, tileListId);
            }
            catch (Exception ex)
            {
                ExceptionDump(ex);
            }
        }
示例#2
0
        public static bool RenameDuplicatedNames(mapObj map)
        {
            bool hasDuplicate = false;

            for (int i = 0; i < map.numlayers; i++)
            {
                layerObj layer = map.getLayer(i);

                if (layer.name == "__embed__scalebar" || layer.name == "__embed__legend")
                {
                    continue;
                }

                string originalName = layer.name;
                if (originalName == null)
                {
                    originalName = "layer";
                }
                layer.name = null;
                string versionedName = GetUniqueLayerName(map, originalName, 0);
                layer.name = originalName;
                if (originalName.Trim() != versionedName)
                {
                    hasDuplicate = true;
                    layer.name   = versionedName;
                }
            }
            return(hasDuplicate);
        }
示例#3
0
        public TileGenerator(string mapfile, string savePath, string tileListId)
        {
            try
            {
                id = tileListId;

                string version = mapscript.msGetVersion();

                if (Directory.Exists(Environment.CurrentDirectory + "\\gdalplugins"))
                    Gdal.SetConfigOption("GDAL_DRIVER_PATH", Environment.CurrentDirectory + "\\gdalplugins");

                Gdal.AllRegister();
                Ogr.RegisterAll();
                mapscript.SetEnvironmentVariable("CURL_CA_BUNDLE=" + Environment.CurrentDirectory + "\\curl-ca-bundle.crt");

                MapUtils.SetPROJ_LIB(Environment.CurrentDirectory + "\\ProjLib");

                Gdal.SetConfigOption("GDAL_DATA", Environment.CurrentDirectory);

                map = new mapObj(mapfile);

                ProcessTileList(savePath, tileListId);
            }
            catch (Exception ex)
            {
                ExceptionDump(ex);
            }
        }
示例#4
0
        /// <summary>
        /// Creating a new map.
        /// </summary>
        /// <returns>The wrapper containing the newly created map object.</returns>
        public static MapObjectHolder CreateMap()
        {
            mapObj map = new mapObj(null);

            map.setExtent(0, 0, 100, 100);
            return(new MapObjectHolder(map, null));
        }
示例#5
0
        public static void Load(string fileName)
        {
            styles           = MapUtils.OpenMap(fileName);
            map              = styles;
            styleLibFileName = fileName;

            // get symbolset file name
            string styleDir = Path.GetDirectoryName(fileName);

            if (File.Exists(map.symbolset.filename))
            {
                symbolsetFileName = map.symbolset.filename;
            }
            else
            {
                throw new Exception("Cannot load Symbolset file." + map.symbolset.filename);
            }

            if (File.Exists(map.fontset.filename))
            {
                fontsetFileName = map.fontset.filename;
            }
            else
            {
                throw new Exception("Cannot load Fontset file. " + map.fontset.filename);
            }

            ExpandFontStyles();
        }
示例#6
0
        /// <summary>
        /// Constructs a new AddWMSLayerForm class.
        /// </summary>
        public AddWMSLayerForm(MapObjectHolder target)
        {
            InitializeComponent();
            if (target.GetType() != typeof(mapObj))
            {
                throw new ApplicationException("Invalid object type.");
            }
            this.map    = target;
            this.target = target;

            var keyDown = Observable.FromEventPattern <KeyEventArgs>(this, "KeyDown");

            keyDown.Subscribe(evt =>
            {
                if (evt.EventArgs.KeyCode == Keys.Escape)
                {
                    Close();
                }
            });

            this.Bind(ViewModel, vm => vm.ServerUrl, v => v.textBoxServer.Text);
            this.BindCommand(ViewModel, a => a.Load, b => b.buttonLoadLayers); // TODO: Handle Loading in ViewModel

            ViewModel = new AddWMSLayerFormViewModel(target);

            UpdateControls();
        }
示例#7
0
 public static void SetDefaultLabel(labelObj label, mapObj map)
 {
     label.size     = 8;
     label.force    = mapscript.MS_FALSE;
     label.partials = mapscript.MS_TRUE;
     label.position = (int)MS_POSITIONS_ENUM.MS_CC;
     // trying to set truetype fonts
     if (map != null)
     {
         string key     = null;
         string lastkey = null;
         while ((key = map.fontset.fonts.nextKey(key)) != null)
         {
             if (File.Exists(map.fontset.fonts.get(key, "")))
             {
                 lastkey = key;
                 if (string.Compare(key, "arial", true) == 0)
                 {
                     // set the default font to Arial if exists
                     break;
                 }
             }
         }
         if (lastkey != null)
         {
             label.font = lastkey;
             label.size = 8;
         }
     }
 }
    public static void Main(string[] args)
    {
        if (args.Length < 2) usage();
        
        try 
        {
			mapObj map = new mapObj(args[0]);

			using(imageObj image = map.draw())
			{
				// solution 1
				Console.WriteLine ("Drawing map: '" + map.name + "' using imageObj.getBytes");
				
				byte[] img = image.getBytes();
				using (MemoryStream ms = new MemoryStream(img))
				{
					Image mapimage = Image.FromStream(ms);
					mapimage.Save(args[1]);
				}
				
				// solution 2
				Console.WriteLine ("Drawing map: '" + map.name + "' using imageObj.write");

				using (FileStream fs = File.Open("_" + args[1], FileMode.OpenOrCreate, FileAccess.ReadWrite))
				{
					image.write(fs);
				}
			}
        } 
        catch (Exception ex) 
        {
            Console.WriteLine( "GetBytes: ", ex.Message );
        }
    }
示例#9
0
    public static void Main(string[] args)
    {
        Console.WriteLine("");
		if (args.Length < 3 || args.Length > 4) usage();
        
        bool ZoomToResults = (args.Length == 4 && args[3] == "-zoom");

	    mapObj map = new mapObj(args[0]);	
	    Console.WriteLine ("# Map layers " + map.numlayers + "; Map name = " + map.name);
        
        QueryByAttribute(args[1], map, ZoomToResults);

        map.querymap.status = mapscript.MS_ON;
        map.querymap.color.setRGB(0,0,255,255);
        map.querymap.style = (int)MS_QUERYMAP_STYLES.MS_HILITE;

        try 
        {
            imageObj image = map.drawQuery();
            image.save(args[2],map);
        } 
        catch (Exception ex) 
        {
            Console.WriteLine( "QueryMap: ", ex.Message );
        }
    }
示例#10
0
        public TileGenerator(string mapfile, string savePath, string tileListId)
        {
            try
            {
                id = tileListId;

                string version = mapscript.msGetVersion();

                if (Directory.Exists(Environment.CurrentDirectory + "\\gdalplugins"))
                {
                    Gdal.SetConfigOption("GDAL_DRIVER_PATH", Environment.CurrentDirectory + "\\gdalplugins");
                }

                Gdal.AllRegister();
                Ogr.RegisterAll();
                mapscript.SetEnvironmentVariable("CURL_CA_BUNDLE=" + Environment.CurrentDirectory + "\\curl-ca-bundle.crt");

                MapUtils.SetPROJ_LIB(Environment.CurrentDirectory + "\\ProjLib");

                Gdal.SetConfigOption("GDAL_DATA", Environment.CurrentDirectory);

                map = new mapObj(mapfile);

                ProcessTileList(savePath, tileListId);
            }
            catch (Exception ex)
            {
                ExceptionDump(ex);
            }
        }
示例#11
0
    public static void Main(string[] args)
    {
        Console.WriteLine("");
        if (args.Length < 3 || args.Length > 4)
        {
            usage();
        }

        bool ZoomToResults = (args.Length == 4 && args[3] == "-zoom");

        mapObj map = new mapObj(args[0]);

        Console.WriteLine("# Map layers " + map.numlayers + "; Map name = " + map.name);

        QueryByAttribute(args[1], map, ZoomToResults);

        map.querymap.status = mapscript.MS_ON;
        map.querymap.color.setRGB(0, 0, 255, 255);
        map.querymap.style = (int)MS_QUERYMAP_STYLES.MS_HILITE;

        try
        {
            imageObj image = map.drawQuery();
            image.save(args[2], map);
        }
        catch (Exception ex)
        {
            Console.WriteLine("QueryMap: ", ex.Message);
        }
    }
示例#12
0
        /// <summary>
        /// Update the preview according to the current Editor state.
        /// In case of the preview a temporary object will only be updated.
        /// </summary>
        public void UpdateValues()
        {
            if (style == null)
            {
                return;
            }
            if (dirtyFlag)
            {
                Update(this.style);

                // copy symbol to the map if needed
                if (listView.SelectedItems.Count > 0 && listView.SelectedItems[0].Text != "Default")
                {
                    // try to find symbol
                    int    symbolIndex;
                    string symbolName = listView.SelectedItems[0].Text;
                    for (symbolIndex = 0; symbolIndex < map.symbolset.numsymbols; symbolIndex++)
                    {
                        if (map.symbolset.getSymbol(symbolIndex).name == symbolName)
                        {
                            break;
                        }
                    }
                    if (symbolIndex == map.symbolset.numsymbols &&
                        comboBoxCategory.Text != "Inline Symbols")
                    {
                        // copy symbol from style library
                        mapObj sourceMap = StyleLibrary.Styles;
                        // removing the embedded scalebar symbol from top (should be fixed in mapserver)
                        string lastsymbolName = map.symbolset.getSymbol(map.symbolset.numsymbols - 1).name;
                        if (lastsymbolName == "scalebar" || lastsymbolName == "legend")
                        {
                            map.symbolset.removeSymbol(map.symbolset.numsymbols - 1);
                        }
                        lastsymbolName = map.symbolset.getSymbol(map.symbolset.numsymbols - 1).name;
                        if (lastsymbolName == "scalebar" || lastsymbolName == "legend")
                        {
                            map.symbolset.removeSymbol(map.symbolset.numsymbols - 1);
                        }
                        symbolIndex = map.symbolset.appendSymbol(MapUtils.CloneSymbol(
                                                                     sourceMap.symbolset.getSymbolByName(symbolName)));
                    }
                    style.symbolname = symbolName;
                    style.symbol     = symbolIndex;
                }
                else
                {
                    // remove symbol
                    style.symbol     = 0;
                    style.symbolname = null;
                }

                SetDirty(false);
                if (target != null)
                {
                    target.RaisePropertyChanged(this);
                }
            }
        }
示例#13
0
    public static void Main(string[] args)
    {
        Console.WriteLine("");
        if (args.Length < 2) usage();

        mapObj map = new mapObj(args[0]);

        Console.WriteLine("# Map layers " + map.numlayers + "; Map name = " + map.name);
        for (int i = 0; i < map.numlayers; i++)
        {
        Console.WriteLine("Layer [" + i + "] name: " + map.getLayer(i).name);
        }

        try
        {
        WriteableBitmap mapImage = new WriteableBitmap(map.width, map.height, 96, 96, PixelFormats.Bgr32, null);
        Stopwatch stopwatch = new Stopwatch();
        stopwatch.Start();
        using (imageObj image = map.draw())
        {
            // Reserve the back buffer for updates.
            mapImage.Lock();
            try
            {
                if (image.getRawPixels(mapImage.BackBuffer) == (int)MS_RETURN_VALUE.MS_FAILURE)
                {
                    Console.WriteLine("Unable to get image contents");
                }
                // Specify the area of the bitmap that changed.
                mapImage.AddDirtyRect(new Int32Rect(0, 0, map.width, map.height));
            }
            finally
            {
                // Release the back buffer and make it available for display.
                mapImage.Unlock();
            }

            Console.WriteLine("Rendering time: " + stopwatch.ElapsedMilliseconds + "ms");

            // Save the bitmap into a file.
            using (FileStream stream = new FileStream(args[1], FileMode.Create))
            {
                PngBitmapEncoder encoder = new PngBitmapEncoder();
                encoder.Frames.Add(BitmapFrame.Create(mapImage));
                encoder.Save(stream);
            }
        }
        }
        catch (Exception ex)
        {
        Console.WriteLine( "\nMessage ---\n{0}", ex.Message );
        Console.WriteLine(
            "\nHelpLink ---\n{0}", ex.HelpLink );
        Console.WriteLine( "\nSource ---\n{0}", ex.Source );
        Console.WriteLine(
            "\nStackTrace ---\n{0}", ex.StackTrace );
        Console.WriteLine(
            "\nTargetSite ---\n{0}", ex.TargetSite );	}
    }
示例#14
0
        public ScriptConsoleForm(MapObjectHolder mapH)
        {
            InitializeComponent();
            this.mapH = mapH;
            this.map  = mapH;

            ListSupportedLanguages();
        }
示例#15
0
        public ScriptConsoleForm(MapObjectHolder mapH)
        {
            InitializeComponent();
            this.mapH = mapH;
            this.map = mapH;

            ListSupportedLanguages();
        }
示例#16
0
 /// <summary>
 /// Constructs a new AddWMSLayerForm class.
 /// </summary>
 public AddWMSLayerForm(MapObjectHolder target)
 {
     InitializeComponent();
     if (target.GetType() != typeof(mapObj))
         throw new ApplicationException("Invalid object type.");
     this.map = target;
     this.target = target;
     UpdateControls();
 }
示例#17
0
    public static void Main(string[] args)
    {
        Console.WriteLine("");
        if (args.Length < 2)
        {
            usage();
        }

        mapObj map = new mapObj(args[0]);

        Console.WriteLine("# Map layers " + map.numlayers + "; Map name = " + map.name);
        for (int i = 0; i < map.numlayers; i++)
        {
            Console.WriteLine("Layer [" + i + "] name: " + map.getLayer(i).name);
        }

        try
        {
            // Create the output format
            outputFormatObj of = new outputFormatObj("CAIRO/WINGDI", "cairowinGDI");
            map.appendOutputFormat(of);
            map.selectOutputFormat("cairowinGDI");

            Bitmap mapImage = new Bitmap(map.width, map.height, PixelFormat.Format32bppRgb);

            using (Graphics g = Graphics.FromImage(mapImage))
            {
                IntPtr hdc = g.GetHdc();
                try
                {
                    // Attach the device to the outputformat for drawing
                    of.attachDevice(hdc);
                    // Drawing directly to the GDI context
                    using (imageObj image = map.draw()) { };
                }
                finally
                {
                    of.attachDevice(IntPtr.Zero);
                    g.ReleaseHdc(hdc);
                }
            }

            mapImage.Save(args[1]);
        }
        catch (Exception ex)
        {
            Console.WriteLine("\nMessage ---\n{0}", ex.Message);
            Console.WriteLine(
                "\nHelpLink ---\n{0}", ex.HelpLink);
            Console.WriteLine("\nSource ---\n{0}", ex.Source);
            Console.WriteLine(
                "\nStackTrace ---\n{0}", ex.StackTrace);
            Console.WriteLine(
                "\nTargetSite ---\n{0}", ex.TargetSite);
        }
    }
示例#18
0
        public TileManagerForm(MainForm mainFormRef, string mapfile, MapControl mapobject)
        {
            InitializeComponent();

            // references from main form
            mainForm = mainFormRef;
            mapfilepath = mapfile;
            mapControl = mapobject;
            map = mapControl.map;
        }
示例#19
0
    public void testGetLayerObj()
    {
        mapObj   map      = new mapObj(mapfile);
        layerObj newLayer = map.getLayer(1);

        map = null;
        gc();
        assertNotNull(newLayer.map, "testGetLayerObj");
        assert(newLayer.refcount == 2, "testGetLayerObj refcount");
    }
示例#20
0
    public void testGetLayerObjByName()
    {
        mapObj   map      = new mapObj(mapfile);
        layerObj newLayer = map.getLayerByName("POLYGON");

        map = null;
        gc();
        assertNotNull(newLayer.map, "testGetLayerObjByName");
        assert(newLayer.refcount == 2, "testGetLayerObjByName refcount");
    }
示例#21
0
    public void testreferenceMapObj()
    {
        mapObj          map    = new mapObj(mapfile);
        referenceMapObj refmap = map.reference;

        refmap.markername = "This is a sample!";

        map = null;
        gc();
        assert(refmap.markername == "This is a sample!", "testreferenceMapObj");
    }
示例#22
0
    public void testlegendObj()
    {
        mapObj    map    = new mapObj(mapfile);
        legendObj legend = map.legend;

        legend.template = "This is a sample!";

        map = null;
        gc();
        assert(legend.template == "This is a sample!", "testlegendObj");
    }
示例#23
0
 internal static HandleRef getCPtrAndSetReference(mapObj obj, object parent) {
   if (obj != null)
   {
     obj.swigParentRef = parent;
     return obj.swigCPtr;
   }
   else
   {
     return new HandleRef(null, IntPtr.Zero);
   }
 }
示例#24
0
    public void testwebObj()
    {
        mapObj map = new mapObj(mapfile);
        webObj web = map.web;

        web.template = "This is a sample!";

        map = null;
        gc();
        assert(web.template == "This is a sample!", "testwebObj");
    }
示例#25
0
    public void testqueryMapObj()
    {
        mapObj      map      = new mapObj(mapfile);
        queryMapObj querymap = map.querymap;

        querymap.color.setHex("#13ba88");

        map = null;
        gc();
        assert(querymap.color.toHex() == "#13ba88", "testqueryMapObj");
    }
示例#26
0
    public void testGetClassObj()
    {
        mapObj   map      = new mapObj(mapfile);
        layerObj layer    = map.getLayer(1);
        classObj newClass = layer.getClass(0);

        map = null; layer = null;
        gc();
        assertNotNull(newClass.layer, "testGetClassObj");
        assert(newClass.refcount == 2, "testGetClassObj refcount");
    }
示例#27
0
 /// <summary>
 /// Constructs a new AddWMSLayerForm class.
 /// </summary>
 public AddWMSLayerForm(MapObjectHolder target)
 {
     InitializeComponent();
     if (target.GetType() != typeof(mapObj))
     {
         throw new ApplicationException("Invalid object type.");
     }
     this.map    = target;
     this.target = target;
     UpdateControls();
 }
示例#28
0
    public void testGetStyleObj()
    {
        mapObj   map      = new mapObj(mapfile);
        layerObj layer    = map.getLayer(1);
        classObj classobj = layer.getClass(0);
        styleObj style    = classobj.getStyle(0);

        map = null; layer = null; classobj = null;
        gc();
        assert(style.refcount == 2, "testGetStyleObj");
    }
示例#29
0
    public void testGetLayerObjByNameDestroy()
    {
        mapObj   map       = new mapObj(mapfile);
        layerObj newLayer  = map.getLayerByName("POLYGON");
        layerObj reference = map.getLayerByName("POLYGON");

        assert(newLayer.refcount == 3, "testGetLayerObjByNameDestroy precondition");
        //newLayer.Dispose(); // force the destruction needed for Mono on Windows
        newLayer = null;
        gc();
        assert(reference.refcount == 2, "testGetLayerObjByNameDestroy");
    }
示例#30
0
    public void testmapObjHashTable()
    {
        mapObj       map           = new mapObj(mapfile);
        hashTableObj configoptions = map.configoptions;

        configoptions.set("key", "test value");

        map = null;
        gc();

        assert(configoptions.get("key", "") == "test value", "testmapObjHashTable");
    }
示例#31
0
    public void testsymbolSetObj()
    {
        mapObj       map       = new mapObj(mapfile);
        symbolSetObj symbolset = map.symbolset;

        symbolset.filename = "filename";

        map = null;
        gc();

        assert(symbolset.filename == "filename", "testsymbolSetObj");
    }
示例#32
0
 internal static HandleRef getCPtrAndDisown(mapObj obj, object parent) {
   if (obj != null)
   {
     obj.swigCMemOwn = false;
     obj.swigParentRef = parent;
     return obj.swigCPtr;
   }
   else
   {
     return new HandleRef(null, IntPtr.Zero);
   }
 }
示例#33
0
    public void testInsertLayerObj()
    {
        mapObj   map      = new mapObj(mapfile);
        layerObj newLayer = new layerObj(null);

        map.insertLayer(newLayer, -1);

        map = null;
        gc();
        assertNotNull(newLayer.map, "testInsertLayerObj");
        assert(newLayer.refcount == 2, "testInsertLayerObj refcount");
    }
示例#34
0
    public void testLayerObjDestroy()
    {
        mapObj   map       = new mapObj(mapfile);
        layerObj newLayer  = new layerObj(map);
        layerObj reference = map.getLayer(map.numlayers - 1);

        assert(newLayer.refcount == 3, "testLayerObjDestroy precondition");
        newLayer.Dispose();         // force the destruction for Mono on Windows because of the constructor overload
        newLayer = null;
        gc();
        assert(reference.refcount == 2, "testLayerObjDestroy");
    }
示例#35
0
    public void testGetClassObjDestroy()
    {
        mapObj   map       = new mapObj(mapfile);
        layerObj layer     = map.getLayer(1);
        classObj newClass  = layer.getClass(0);
        classObj reference = layer.getClass(0);

        assert(newClass.refcount == 3, "testGetClassObjDestroy precondition");
        map = null; layer = null; newClass = null;
        gc();
        assert(reference.refcount == 2, "testGetClassObjDestroy");
    }
示例#36
0
    public void testimageObj()
    {
        mapObj          map    = new mapObj(mapfile);
        imageObj        image  = map.draw();
        outputFormatObj format = image.format;

        format.setOption("INTERLACE", "OFF");

        map = null;
        gc();
        assert(format.getOption("INTERLACE", "") == "OFF", "testimageObj");
    }
示例#37
0
 /// <summary>
 /// Constructs a new ChangeViewForm class.
 /// </summary>
 public StyleLibraryForm(MapObjectHolder target)
 {
     InitializeComponent();
     isTextValidating   = false;
     refresh            = new RefreshDelegate(this.Refresh);
     isInit             = true;
     isInitStyleLibText = true;
     // saving the reference to the base mapObj
     // In certain cases we require to reload the modified symbolset on the base mapfile too.
     this.target = target;
     this.map    = target;
 }
示例#38
0
    public void testRemoveLayerObj()
    {
        mapObj   map      = new mapObj(mapfile);
        layerObj newLayer = new layerObj(null);

        map.insertLayer(newLayer, 0);
        map.removeLayer(0);

        map = null;
        gc();
        assert(newLayer.refcount == 1, "testRemoveLayerObj");
    }
示例#39
0
    public static void Main(string[] args)
    {
        Console.WriteLine("");
        if (args.Length < 2)
        {
            usage();
        }

        mapObj map = new mapObj(args[0]);

        Console.WriteLine("# Map layers " + map.numlayers + "; Map name = " + map.name);
        for (int i = 0; i < map.numlayers; i++)
        {
            Console.WriteLine("Layer [" + i + "] name: " + map.getLayer(i).name);
        }

        try
        {
            Bitmap    mapImage  = new Bitmap(map.width, map.height, PixelFormat.Format32bppRgb);
            Stopwatch stopwatch = new Stopwatch();
            stopwatch.Start();
            using (imageObj image = map.draw())
            {
                BitmapData bitmapData = mapImage.LockBits(new Rectangle(0, 0, image.width, image.height), ImageLockMode.ReadWrite, PixelFormat.Format32bppRgb);
                try
                {
                    if (image.getRawPixels(bitmapData.Scan0) == (int)MS_RETURN_VALUE.MS_FAILURE)
                    {
                        Console.WriteLine("Unable to get image contents");
                    }
                }
                finally
                {
                    mapImage.UnlockBits(bitmapData);
                }

                Console.WriteLine("Rendering time: " + stopwatch.ElapsedMilliseconds + "ms");

                mapImage.Save(args[1]);
            }
        }
        catch (Exception ex)
        {
            Console.WriteLine("\nMessage ---\n{0}", ex.Message);
            Console.WriteLine(
                "\nHelpLink ---\n{0}", ex.HelpLink);
            Console.WriteLine("\nSource ---\n{0}", ex.Source);
            Console.WriteLine(
                "\nStackTrace ---\n{0}", ex.StackTrace);
            Console.WriteLine(
                "\nTargetSite ---\n{0}", ex.TargetSite);
        }
    }
示例#40
0
 /// <summary>
 /// Constructs a new ChangeViewForm class.
 /// </summary>
 public StyleLibraryForm(MapObjectHolder target)
 {
     InitializeComponent();
     isTextValidating = false;
     refresh = new RefreshDelegate(this.Refresh);
     isInit = true;
     isInitStyleLibText = true;
     // saving the reference to the base mapObj
     // In certain cases we require to reload the modified symbolset on the base mapfile too.
     this.target = target;
     this.map = target;
 }
示例#41
0
 public static void QueryByAttribute(string qstring, mapObj map, bool zoomToResults)
 {
     Console.WriteLine("\nPerforming QueryByAttribute:");
     try
     {
         layerObj layer;
         rectObj query_bounds = null;
         for (int i = 0; i < map.numlayers; i++)
         {
             layer = map.getLayer(i);
             if (layer.connection != null && IsLayerQueryable(layer))
             {
                 Console.WriteLine("Layer [" + i + "] name: " + layer.name);
                 BuildQuery(layer, qstring);
                 // zoom to the query results
                 using (resultCacheObj results = layer.getResults())
                 {
                     if (results != null && results.numresults > 0)
                     {
                         // calculating the extent of the results
                         if (query_bounds == null)
                             query_bounds = new rectObj(results.bounds.minx, results.bounds.miny,
                                 results.bounds.maxx, results.bounds.maxy,0);
                         else
                         {
                             if (results.bounds.minx < query_bounds.minx) query_bounds.minx = results.bounds.minx;
                             if (results.bounds.miny < query_bounds.miny) query_bounds.miny = results.bounds.miny;
                             if (results.bounds.maxx > query_bounds.maxx) query_bounds.maxx = results.bounds.maxx;
                             if (results.bounds.maxy > query_bounds.maxy) query_bounds.maxy = results.bounds.maxy;
                         }
                     }
                 }
             }
         }
         // setting the map extent to the result bounds
         if (query_bounds != null)
         {
             if (zoomToResults)
             {
                 map.setExtent(query_bounds.minx, query_bounds.miny, query_bounds.maxx, query_bounds.maxy);
                 map.scaleExtent(1.2, 0, 0); // increasing the visible area
                 Console.WriteLine("Current map scale: 1:" + (int)map.scaledenom);
             }
         }
         else
             Console.WriteLine("The query returned 0 results ...");
     }
     catch (Exception e)
     {
         Console.WriteLine("QueryByAttribute: " + e.Message);
     }
 }
示例#42
0
  public static void Main(string[] args)
  {
    Console.WriteLine("");
	if (args.Length < 2) usage();
    
	mapObj map = new mapObj(args[0]);

    Console.WriteLine("# Map layers " + map.numlayers + "; Map name = " + map.name);
    for (int i = 0; i < map.numlayers; i++) 
	{
        Console.WriteLine("Layer [" + i + "] name: " + map.getLayer(i).name);
	}

    try
    {
        // Create the output format
        outputFormatObj of = new outputFormatObj("CAIRO/WINGDI", "cairowinGDI");
        map.appendOutputFormat(of);
        map.selectOutputFormat("cairowinGDI");

        Bitmap mapImage = new Bitmap(map.width, map.height, PixelFormat.Format32bppRgb);

        using (Graphics g = Graphics.FromImage(mapImage))
        {
            IntPtr hdc = g.GetHdc();
            try
            {
                // Attach the device to the outputformat for drawing
                of.attachDevice(hdc);
                // Drawing directly to the GDI context
                using (imageObj image = map.draw()) { };
            }
            finally
            {
                of.attachDevice(IntPtr.Zero);
                g.ReleaseHdc(hdc);
            }
        }

        mapImage.Save(args[1]);
    } 
	catch (Exception ex) 
	{
                Console.WriteLine( "\nMessage ---\n{0}", ex.Message );
                Console.WriteLine( 
                    "\nHelpLink ---\n{0}", ex.HelpLink );
                Console.WriteLine( "\nSource ---\n{0}", ex.Source );
                Console.WriteLine( 
                    "\nStackTrace ---\n{0}", ex.StackTrace );
                Console.WriteLine( 
                    "\nTargetSite ---\n{0}", ex.TargetSite );	}	
  }
示例#43
0
    public static void Main(string[] args)
    {
        Console.WriteLine("");
        if (args.Length < 2) usage();

        mapObj map = new mapObj(args[0]);

        Console.WriteLine("# Map layers " + map.numlayers + "; Map name = " + map.name);
        for (int i = 0; i < map.numlayers; i++)
        {
        Console.WriteLine("Layer [" + i + "] name: " + map.getLayer(i).name);
        }

        try
        {
        Bitmap mapImage = new Bitmap(map.width, map.height, PixelFormat.Format32bppRgb);
        Stopwatch stopwatch = new Stopwatch();
        stopwatch.Start();
        using (imageObj image = map.draw())
        {
            BitmapData bitmapData = mapImage.LockBits(new Rectangle(0, 0, image.width, image.height), ImageLockMode.ReadWrite, PixelFormat.Format32bppRgb);
            try
            {
                if (image.getRawPixels(bitmapData.Scan0) == (int)MS_RETURN_VALUE.MS_FAILURE)
                {
                    Console.WriteLine("Unable to get image contents");
                }
            }
            finally
            {
                mapImage.UnlockBits(bitmapData);
            }

            Console.WriteLine("Rendering time: " + stopwatch.ElapsedMilliseconds + "ms");

            mapImage.Save(args[1]);
        }
        }
        catch (Exception ex)
        {
        Console.WriteLine( "\nMessage ---\n{0}", ex.Message );
        Console.WriteLine(
            "\nHelpLink ---\n{0}", ex.HelpLink );
        Console.WriteLine( "\nSource ---\n{0}", ex.Source );
        Console.WriteLine(
            "\nStackTrace ---\n{0}", ex.StackTrace );
        Console.WriteLine(
            "\nTargetSite ---\n{0}", ex.TargetSite );	}
    }
示例#44
0
    public static void Main(string[] args)
    {
        if (args.Length < 3) usage();
        
        mapObj map = new mapObj(args[0]);
		map.legend.template = args[1];
		map.web.imagepath = args[2];
		map.web.imageurl = "";
		string str = null;
		string[] names = null, values = null;
		names = new string[] {"map"};
		values = new string[] { args[0] };
		str = map.processLegendTemplate(names, values);
		Console.Write(str);
    }
示例#45
0
        public LabelEditorDialog(classObj inClass, mapObj map)
            : this(inClass)
        {
            m_pMap = map;

            if(m_pMap != null)
            {
                //add all the font int fontlist to the combox
                hashTableObj pFontList = m_pMap.fontset.fonts;
                string value = pFontList.nextKey(null);
                while(value != null)
                {
                    comboBoxFont.Items.Add(value);
                    value = pFontList.nextKey(value);
                }

            }
        }
示例#46
0
  public static void Main(string[] args)
  {
    Console.WriteLine("");
	if (args.Length < 2) usage();
    
	mapObj m_obj = new mapObj(args[0]);

	if (args.Length >= 3) 
	{
      Console.WriteLine("Setting the imagetype to " + args[2]);
	  m_obj.setImageType(args[2]);
	}

	Console.WriteLine ("# Map layers " + m_obj.numlayers + "; Map name = " + m_obj.name);	
	for (int i=0; i<m_obj.numlayers; i++) 
	{
	  Console.WriteLine("Layer [" + i + "] name: " + m_obj.getLayer(i).name);
	}
	
    imageObj i_obj = m_obj.draw();
	Console.WriteLine("Image URL = " + i_obj.imageurl + "; Image path = " + i_obj.imagepath);    
	Console.WriteLine("Image height = " + i_obj.height + "; width = " + i_obj.width); 
	try 
	{
	  i_obj.save(args[1],m_obj);
    } 
	catch (Exception ex) 
	{
                Console.WriteLine( "\nMessage ---\n{0}", ex.Message );
                Console.WriteLine( 
                    "\nHelpLink ---\n{0}", ex.HelpLink );
                Console.WriteLine( "\nSource ---\n{0}", ex.Source );
                Console.WriteLine( 
                    "\nStackTrace ---\n{0}", ex.StackTrace );
                Console.WriteLine( 
                    "\nTargetSite ---\n{0}", ex.TargetSite );	}	
  }
示例#47
0
	public void testRemoveClassObj() 
	{
		mapObj map=new mapObj(mapfile);
		layerObj layer=map.getLayer(1);
		classObj newClass=new classObj(null);
		layer.insertClass(newClass,0);
		layer.removeClass(0);
		
		map=null; layer=null;
		gc();
		assert(newClass.refcount == 1, "testRemoveClassObj");
	}
示例#48
0
	public void testGetStyleObjDestroy() 
	{
		mapObj map=new mapObj(mapfile);
		layerObj layer=map.getLayer(1);
		classObj classobj=layer.getClass(0);
		styleObj style=classobj.getStyle(0);
		styleObj reference=classobj.getStyle(0);
		
		assert(style.refcount == 3, "testGetStyleObjDestroy precondition");
		map=null; layer=null; classobj=null; style=null;
		gc();
		assert(reference.refcount == 2, "testGetStyleObjDestroy");
	}
示例#49
0
	public void testGetStyleObj() 
	{
		mapObj map=new mapObj(mapfile);
		layerObj layer=map.getLayer(1);
		classObj classobj=layer.getClass(0);
		styleObj style=classobj.getStyle(0);
		
		map=null; layer=null; classobj=null;
		gc();
		assert(style.refcount == 2, "testGetStyleObj");
	}
示例#50
0
	public void testGetClassObjDestroy() 
	{
		mapObj map=new mapObj(mapfile);
		layerObj layer=map.getLayer(1);
		classObj newClass=layer.getClass(0);
		classObj reference = layer.getClass(0);
		
		assert(newClass.refcount == 3, "testGetClassObjDestroy precondition");
		map=null; layer=null; newClass=null;
		gc();
		assert(reference.refcount == 2, "testGetClassObjDestroy");
	}
示例#51
0
	public void testGetClassObj() {
		mapObj map=new mapObj(mapfile);
		layerObj layer=map.getLayer(1);
		classObj newClass=layer.getClass(0);
		
		map=null; layer=null;
		gc();
		assertNotNull(newClass.layer, "testGetClassObj");
		assert(newClass.refcount == 2, "testGetClassObj refcount");
	}
示例#52
0
	public void testInsertStyleObjDestroy() 
	{
		mapObj map=new mapObj(mapfile);
		layerObj layer=map.getLayer(1);
		classObj classobj=layer.getClass(0);
		styleObj newStyle = new styleObj(null);
		classobj.insertStyle(newStyle,0);
		styleObj reference = classobj.getStyle(0);
		
		assert(newStyle.refcount == 3, "testInsertStyleObjDestroy precondition");
		newStyle.Dispose(); // force the destruction for Mono on Windows because of the constructor overload
		map=null; layer=null; classobj=null; newStyle=null;
		gc();
		assert(reference.refcount == 2, "testInsertStyleObjDestroy");
	}
示例#53
0
	public void testRemoveStyleObj() 
	{
		mapObj map=new mapObj(mapfile);
		layerObj layer=map.getLayer(1);
		classObj classobj=layer.getClass(0);
		styleObj newStyle = new styleObj(null);
		classobj.insertStyle(newStyle,0);
		classobj.removeStyle(0);
		
		map=null; layer=null; classobj=null;
		gc();
		assert(newStyle.refcount == 1, "testRemoveStyleObj");
	}
示例#54
0
	public void testInsertStyleObj() 
	{
		mapObj map=new mapObj(mapfile);
		layerObj layer=map.getLayer(1);
		classObj classobj=layer.getClass(0);
		styleObj newStyle = new styleObj(null);
		classobj.insertStyle(newStyle,-1);
		
		assert(newStyle.refcount == 2, "testInsertStyleObj precondition");
		map=null; layer=null; classobj=null;
		gc();
		assert(newStyle.refcount == 2, "testInsertStyleObj");
	}
示例#55
0
	public void testInsertClassObj() {
		mapObj map=new mapObj(mapfile);
		layerObj layer=map.getLayer(1);
		classObj newClass=new classObj(null);
		layer.insertClass(newClass,-1);
		
		assertNotNull(newClass.layer, "testInsertClassObj precondition");
		map=null; layer=null;
		gc();
		assertNotNull(newClass.layer, "testInsertClassObj");
		assert(newClass.refcount == 2, "testInsertClassObj refcount");
	}
示例#56
0
	public void testClassObjDestroy() 
	{
		mapObj map=new mapObj(mapfile);
		layerObj layer=map.getLayer(1);
		classObj newClass=new classObj(layer);
		classObj reference=layer.getClass(layer.numclasses-1);
		
		assert(newClass.refcount == 3, "testClassObjDestroy precondition");
		newClass.Dispose(); // force the destruction for Mono on Windows because of the constructor overload
		map=null; layer=null; newClass=null;
		gc();
		assert(reference.refcount == 2, "testClassObjDestroy");
	}
示例#57
0
	public void testGetLayerObjByNameDestroy() 
	{
		mapObj map=new mapObj(mapfile);
		layerObj newLayer=map.getLayerByName("POLYGON");
		layerObj reference=map.getLayerByName("POLYGON");
		
		assert(newLayer.refcount == 3, "testGetLayerObjByNameDestroy precondition");
		//newLayer.Dispose(); // force the destruction needed for Mono on Windows
		newLayer=null;
		gc();
		assert(reference.refcount == 2, "testGetLayerObjByNameDestroy");
	}
示例#58
0
	public void testGetLayerObjByName() {
		mapObj map=new mapObj(mapfile);
		layerObj newLayer=map.getLayerByName("POLYGON");
		
		map=null;
		gc();
		assertNotNull(newLayer.map, "testGetLayerObjByName");
		assert(newLayer.refcount == 2, "testGetLayerObjByName refcount");
	}
示例#59
0
	public void testGetLayerObj() {
		mapObj map=new mapObj(mapfile);
		layerObj newLayer=map.getLayer(1);
		
		map=null;
		gc();
		assertNotNull(newLayer.map, "testGetLayerObj");
		assert(newLayer.refcount == 2, "testGetLayerObj refcount");
	}
  public static void Main(string[] args)
  {
    Console.WriteLine("");
	if (args.Length < 2) usage();
    
	map = new mapObj(args[0]);

    Console.WriteLine("# Map layers " + map.numlayers + "; Map name = " + map.name);
    for (int i = 0; i < map.numlayers; i++) 
    {
        Console.WriteLine("Layer [" + i + "] name: " + map.getLayer(i).name);
    }

    try
    {
        PrintDocument doc = new PrintDocument();

        doc.PrintPage += new PrintPageEventHandler(doc_PrintPage);

        // Specify the printer to use.
        doc.PrinterSettings.PrinterName = args[1];

        doc.Print();
    } 
    catch (Exception ex) 
    {
                Console.WriteLine( "\nMessage ---\n{0}", ex.Message );
                Console.WriteLine( 
                    "\nHelpLink ---\n{0}", ex.HelpLink );
                Console.WriteLine( "\nSource ---\n{0}", ex.Source );
                Console.WriteLine( 
                    "\nStackTrace ---\n{0}", ex.StackTrace );
                Console.WriteLine( 
                    "\nTargetSite ---\n{0}", ex.TargetSite );	}	
    }