scalebar-problem with csharp-mapscript

Tamas Szekeres szekerest at GMAIL.COM
Mon Jun 19 12:08:09 EDT 2006


Christian,

scalebarObj is added to the map by default and also the labelObj is
added to the scalebar so you should use these objects in the following
way:

             scalebarObj scalebar = myMap.scalebar;
             scalebar.height = pictureBoxScalebar.Height;
             scalebar.width = pictureBoxScalebar.Width;
             scalebar.intervals = 5;
             scalebar.label = labelScalebar;
             scalebar.position = (int)MS_LABEL_POSITIONS.MS_UL;
             scalebar.style = 0; //0 or 1
             scalebar.status = mapscript.MS_EMBED;
             scalebar.units = (int)MS_UNITS.MS_KILOMETERS;
             labelObj labelScalebar = scalebar.label;
             labelScalebar.size = 12;
             labelScalebar.type = MS_FONT_TYPE.MS_BITMAP;
             labelScalebar.color = new colorObj(255, 0, 255, 0);

This problem is related to the following bug:
http://mapserver.gis.umn.edu/bugs/show_bug.cgi?id=1803

You should also avoid to use the object members mentioned there as
writeable properties.

Best Regards,

Tamas



2006/6/19, Christian Wilmes <C.Wilmes at gmx.de>:
> Hi All,
>
> if I try to add a scalebar to my map I get exceptions.The code for the scalebar:
>             labelObj labelScalebar = new labelObj();
>             labelScalebar.size = 12;
>             labelScalebar.type = MS_FONT_TYPE.MS_BITMAP;
>             labelScalebar.color = new colorObj(255, 0, 255, 0);
>
>             scalebarObj scalebar = new scalebarObj();
>             scalebar.height = pictureBoxScalebar.Height;
>             scalebar.width = pictureBoxScalebar.Width;
>             scalebar.intervals = 5;
>             scalebar.label = labelScalebar;
>             scalebar.position = (int)MS_LABEL_POSITIONS.MS_UL;
>             scalebar.style = 0; //0 or 1
>             scalebar.status = mapscript.MS_EMBED;
>             scalebar.units = (int)MS_UNITS.MS_KILOMETERS;
>
>             myMap.scalebar = scalebar;
>
>
>
>
>
>
> Using myMap.drawScalebar() I get the following exception:
> System.ApplicationException was unhandled
>   Message="msGetBitmapFont(): GD library error. Invalid bitmap font. Must be one of tiny, small, medium, large or giant."
>   Source="mapscript_csharp"
>   StackTrace:
>        at mapObj.drawScalebar()
>        at GeoDataPipelineViewer.GDPV.RefreshMap() in C:\src\Visual Studio 2005\Projects\GeoDataPipelineViewer\GeoDataPipelineViewer\GDPV.cs:line 415
>        at GeoDataPipelineViewer.GDPV.showMap() in C:\src\Visual Studio 2005\Projects\GeoDataPipelineViewer\GeoDataPipelineViewer\GDPV.cs:line 385
>        at GeoDataPipelineViewer.GDPV..ctor() in C:\src\Visual Studio 2005\Projects\GeoDataPipelineViewer\GeoDataPipelineViewer\GDPV.cs:line 45
>        at GeoDataPipelineViewer.Program.Main() in C:\src\Visual Studio 2005\Projects\GeoDataPipelineViewer\GeoDataPipelineViewer\Program.cs:line 19
>        at System.AppDomain.nExecuteAssembly(Assembly assembly, String[] args)
>        at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
>        at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
>        at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
>        at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
>        at System.Threading.ThreadHelper.ThreadStart()
>
>
>
>
>
>
> Using MyMap.draw() I get the following Exception:
> System.AccessViolationException was unhandled
>   Message="Attempted to read or write protected memory. This is often an indication that other memory is corrupt."
>   Source="mapscript_csharp"
>   StackTrace:
>        at mapscriptPINVOKE.mapObj_draw(HandleRef jarg1)
>        at mapObj.draw()
>        at GeoDataPipelineViewer.GDPV.RefreshMap() in C:\src\Visual Studio 2005\Projects\GeoDataPipelineViewer\GeoDataPipelineViewer\GDPV.cs:line 400
>        at GeoDataPipelineViewer.GDPV.showMap() in C:\src\Visual Studio 2005\Projects\GeoDataPipelineViewer\GeoDataPipelineViewer\GDPV.cs:line 385
>        at GeoDataPipelineViewer.GDPV..ctor() in C:\src\Visual Studio 2005\Projects\GeoDataPipelineViewer\GeoDataPipelineViewer\GDPV.cs:line 45
>        at GeoDataPipelineViewer.Program.Main() in C:\src\Visual Studio 2005\Projects\GeoDataPipelineViewer\GeoDataPipelineViewer\Program.cs:line 19
>        at System.AppDomain.nExecuteAssembly(Assembly assembly, String[] args)
>        at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
>        at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
>        at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
>        at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
>        at System.Threading.ThreadHelper.ThreadStart()
>
>
> I think the problem is the label, like it is described in the first exception but how could I set the bitmap-font, and where can I find a enum for that or some constants like MS_MEDIUM?
> Or is there just another reason why that doesn't work?
>
> Best Regards
> Christian
>
>
>
> --
>
>
> Echte DSL-Flatrate dauerhaft für 0,- Euro*!
> "Feel free" mit GMX DSL! http://www.gmx.net/de/go/dsl
>



More information about the mapserver-users mailing list