CSharp-Mapscript: setSymbolSet doesn't work?!

Christian Wilmes C.Wilmes at GMX.DE
Wed Jul 19 03:15:57 PDT 2006


Hi,

thanks for your quick response Tamas, but the symbols don't work up to now.

Normaly it should work with the gif-File in the parameterlist too, the gif-File exists on my System. But I tested it with your code for the symbolObj a lot of times, because that seems to be more simple. Directly before and after calling mapObj.draw() I saved the mapfile build by my Application. I tested both mapfiles in my Browser and both of them are working correct. I will insert the two mapfiles in this email.

Here is my original code I use with some expressions:

public class Controller
{
	//myMapHandler is a type of the class MapHandler which handels Objects of the class Map. Map is a Subclass of mapObj
	private MapHandler myMapHandler = new MapHandler();

	
	public void InitializeLayers()
	{

		//PipelineLayer is a Subclass from layerObj
		//The first parameter in the Constructor is the mapObj, the second one the status of the Layer, the third one is the Connectionstring to my WFS-Server
		//I've got good reasons for giving null in the parameterlist for the mapObj and using the InsertLayer-Method later.
		//I tested it with giving directly the mapObj in the constructor, it also doesn't work
		PipelineLayer trajektorie = new PipelineLayer(null, true, "http://localhost/cgi-bin/mapserv.exe?");
   		       
		//Building the Symbol:
		symbolObj symbol = new symbolObj("mySymbol", null);
		symbol.type = (int)MS_SYMBOL_TYPE.MS_SYMBOL_VECTOR;
		symbol.filled = mapscript.MS_TRUE;
		lineObj line = new lineObj();
		line.add(new pointObj(1, 5, 0, 0));
		line.add(new pointObj(1, 3, 0, 0));
		line.add(new pointObj(3, 2, 0, 0));
		line.add(new pointObj(1, 1, 0, 0));
		line.add(new pointObj(1, 3, 0, 0));
		symbol.setPoints(line);
	

		
´		myMapHandler.Map.SymbolSet.appendSymbol(symbol);



		classObj classtest = new classObj(trajektorie);
		classtest.name = "test";

		styleObj myStyle = new styleObj(classtest);
		myStyle.symbolname = "mySymbol";
       
		myStyle.size = 150;
		myStyle.color = new colorObj(255, 0, 0, -1);

		myMapHandler.Map.SymbolSet.save(Environment.CurrentDirectory + @"\test.sym");
    
		myMapHandler.Map.InsertLayer(trajektorie, -1);
		// the Method Refresh Map is displayed above
		myMapHandler.Map.RefreshMap();
	}
}

public class Map : mapObj
{
	:
	:
	public void RefreshMap()
        {
            Cursor.Current = Cursors.WaitCursor;
            try
            {
                lock (this)
                {
                    this.Save(Environment.CurrentDirectory + @"\testBefore.map");
                    using (imageObj image = this.draw())
                    {
                        this.Save(Environment.CurrentDirectory + @"\testAfter.map");
                        byte[] img = image.getBytes();
                        using (MemoryStream ms = new MemoryStream(img))
                        {	
                            myImageHandler.ImageMap = Image.FromStream(ms);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + "\n" + (ex.InnerException != null ? ex.InnerException.Message : "")
                    , "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                Cursor.Current = Cursors.Default;
            }
        }
	:
	:
}



I've got no idea where else I have to search the mistake, or is it even possible that there is a another Bug in the mapscript who is responsible for that?


Best Regards
Christian
-------- Original-Nachricht --------
Datum: Wed, 19 Jul 2006 00:57:19 +0200
Von: Tamas Szekeres <szekerest at gmail.com>
An: Christian Wilmes <C.Wilmes at gmx.de>
Betreff: Re: Re: [UMN_MAPSERVER-USERS] CSharp-Mapscript: setSymbolSet doesn\'t work?!

> Hi,
> 
> Constructing symbolObj you are using:
> 
> "symbolObj(string symbolname, string imagefile)"
> 
> The second parameter - if exists - point to an image for rendering that
> symbol.
> In your case the followings should work:
> 
> symbolObj mySymbol = new symbolObj("mySymbol", null);
> mySymbol.type = (int)MS_SYMBOL_TYPE.MS_SYMBOL_VECTOR;
> mySymbol.filled = mapscript.MS_TRUE;
> lineObj line = new lineObj();
> line.add(new pointObj(1, 5, 0, 0));
> line.add(new pointObj(1, 3, 0, 0));
> line.add(new pointObj(3, 2, 0, 0));
> line.add(new pointObj(1, 1, 0, 0));
> line.add(new pointObj(1, 3, 0, 0));
> mySymbol.setPoints(line);
> myMap.symbolset.appendSymbol(mySymbol);
> 
> I haven't tested it so additional properties might be set, apologies.
> 
> Tamas
> 
> 
> 2006/7/18, Christian Wilmes <C.Wilmes at gmx.de>:
> > Hi,
> >
> > sorry, myMapHandler.Map was my mistake. But he was only in the mail, I
> just tried to create a very simple sample. Now I've changed my code for
> using myMap.symbolset.appendSymbol but it still doesn't work:
> >
> > mapObj myMap = new mapObj("");
> > symbolObj symbol = new symbolObj("mySymbol", directory);
> > myMap.symbolSet.appendSymbol(symbol);
> > :
> > layerObj myLayer = new layerObj(null);
> > myLayer.name = "RosoftWFS";
> > myLayer.Type = MS_LAYER_TYPE.MS_LAYER_POINT;
> > myLayer.Connectiontype = MS_CONNECTION_TYPE.MS_WFS;
> > myLayer.Connection = "http://localhost/cgi-bin/mapserv.exe?";
> > myLayer.metadata.set("wfs_typename", "myWFS");
> > myLayer.metadata.set("wfs_version","1.0.0");
> > myLayer.metadata.set("wfs_request_method", "GET");
> > myLayer.metadata.set("wfs_service", "WFS");
> > myLayer.setProjection("EPSG:31467");
> >
> > classObj c = new classObj(myLayer);
> > c.name = "test";
> >
> > styleObj style = new styleObj(c);
> > style.symbolname = "mySymbol";
> > style.size = 150;
> > style.color = new colorObj(255, 0, 255, 0);
> > :
> > myMap.insertLayer(myLayer, -1);
> >
> >
> > Best Regards
> > Christian
> > -------- Original-Nachricht --------
> > Datum: Mon, 17 Jul 2006 23:40:09 +0200
> > Von: Tamas Szekeres <szekerest at GMAIL.COM>
> > An: MAPSERVER-USERS at LISTS.UMN.EDU
> > Betreff: Re: [UMN_MAPSERVER-USERS] CSharp-Mapscript: setSymbolSet
> doesn\'t work?!
> >
> > > Christian,
> > >
> > > I'm a bit uncertain if you have added that symbolset to your map
> > > (myMapHandler.Map may be another map reference :?  ).
> > > I would prefer using myMap.symbolset.appendSymbol instead of using
> > > setsymbolset.
> > >
> > > If you are using constructors like "new classObj(myLayer)" and "new
> > > styleObj(c)" you might want to use mapserver 4.8.4 to avoid nasty heap
> > > corruptions and memory reference errors ;-) In that case using new
> > > layerObj(mymap) seems better than insertLayer since the extra layer
> > > copy is avoided.
> > >
> > > Best Regards,
> > >
> > > Tamas
> > >
> > >
> > >
> > > 2006/7/17, Christian Wilmes <C.Wilmes at gmx.de>:
> > > > Hi All,
> > > >
> > > > I try to display a WFS-Layer with my application but I got only
> small
> > > points instead of the symbol in my Symbolset.
> > > >
> > > > My Symbolset looks like that:
> > > > SYMBOLSET
> > > >         SYMBOL
> > > >                 NAME "Fahne"
> > > >                 TYPE VECTOR
> > > >                 FILLED TRUE
> > > >                 POINTS
> > > >                         1 5
> > > >                         1 3
> > > >                         3 2
> > > >                         1 1
> > > >                         1 3
> > > >                 END
> > > >         END
> > > > END
> > > >
> > > > Some Code from the application:
> > > > mapObj myMap = new mapObj("");
> > > > myMapHandler.Map.setSymbolSet(Environment.CurrentDirectory +
> > > @"\test.sym");
> > > > :
> > > > layerObj myLayer = new layerObj(null);
> > > > myLayer.name = "RosoftWFS";
> > > > myLayer.Type = MS_LAYER_TYPE.MS_LAYER_POINT;
> > > > myLayer.Connectiontype = MS_CONNECTION_TYPE.MS_WFS;
> > > > myLayer.Connection = "http://localhost/cgi-bin/mapserv.exe?";
> > > > myLayer.metadata.set("wfs_typename", "myWFS");
> > > > myLayer.metadata.set("wfs_version","1.0.0");
> > > > myLayer.metadata.set("wfs_request_method", "GET");
> > > > myLayer.metadata.set("wfs_service", "WFS");
> > > >
> > > > myLayer.setProjection("EPSG:31467");
> > > > classObj c = new classObj(myLayer);
> > > > c.name = "test";
> > > > styleObj style = new styleObj(c);
> > > > style.symbolname = "Fahne";
> > > > style.size = 150;
> > > > style.color = new colorObj(255, 0, 255, 0);
> > > > :
> > > > myMap.insertLayer(myLayer, -1);
> > > >
> > > >
> > > > Does anybody have an idea where to find the mistake?
> > > >
> > > >
> > > > Best Regards
> > > > Christian
> > > > --
> > > >
> > > >
> > > > "Feel free" – 10 GB Mailbox, 100 FreeSMS/Monat ...
> > > > Jetzt GMX TopMail testen: http://www.gmx.net/de/go/topmail
> > > >
> >
> > --
> >
> >
> > "Feel free" – 10 GB Mailbox, 100 FreeSMS/Monat ...
> > Jetzt GMX TopMail testen: http://www.gmx.net/de/go/topmail
> >

-- 


Echte DSL-Flatrate dauerhaft für 0,- Euro*!
"Feel free" mit GMX DSL! http://www.gmx.net/de/go/dsl
-------------- next part --------------
MAP
  EXTENT 3396369.30902111 5800885 3402780.69097889 5804895
  IMAGECOLOR 230 230 230
  IMAGETYPE JPEG
  SHAPEPATH "C:\geodata\data\"
  SIZE 833 521
  STATUS ON
  UNITS METERS
  NAME "test.map"

  OUTPUTFORMAT
    NAME "jpeg"
    MIMETYPE "image/jpeg"
    DRIVER "GD/JPEG"
    EXTENSION "jpg"
    IMAGEMODE "RGB"
    TRANSPARENT FALSE
  END

  SYMBOL
    NAME "mySymbol"
    TYPE VECTOR
    FILLED TRUE
    POINTS
      1 5
      1 3
      3 2
      1 1
      1 3
    END
  END

  PROJECTION
    "init=epsg:31467"
  END
  LEGEND
    IMAGECOLOR 255 255 255
    KEYSIZE 20 10
    KEYSPACING 5 5
    LABEL
      SIZE MEDIUM
      TYPE BITMAP
      BUFFER 0
      COLOR 0 0 0
      FORCE FALSE
      MINDISTANCE -1
      MINFEATURESIZE -1
      OFFSET 0 0
      PARTIALS TRUE
      POSITION CC
    END
    POSITION LL
    STATUS OFF
  END

  QUERYMAP
    COLOR 255 255 0
    SIZE -1 -1
    STATUS OFF
    STYLE HILITE
  END

  SCALEBAR
    COLOR 0 0 0
    IMAGECOLOR 255 255 255
    INTERVALS 3
    LABEL
      SIZE MEDIUM
      TYPE BITMAP
      BUFFER 0
      COLOR 0 0 0
      FORCE FALSE
      MINDISTANCE -1
      MINFEATURESIZE -1
      OFFSET 0 0
      PARTIALS TRUE
      POSITION CR
    END
    POSITION LR
    POSTLABELCACHE TRUE
    SIZE 200 3
    STATUS EMBED
    STYLE 1
    UNITS METERS
  END

  WEB
    IMAGEPATH "c:/ms4w/tmp/ms_tmp"
    IMAGEURL "/ms_tmp/"
      METADATA
        "WMS_SRS"	"EPSG:4326"
        "WMS_ONLINERESOURCE"	"http://localhost/cgi-bin/mapserv.exe?Map=c:\ms4w\myMapHandler.MapPfile.map&"
        "WMS_ABSTRACT"	"This is an UMN MapServer Application Demonstrating the capabilities of a Web Mapping Application"
        "WMS_TITLE"	"Rosen World Base Map"
      END
    QUERYFORMAT text/html
    LEGENDFORMAT text/html
    BROWSEFORMAT text/html
  END

  LAYER
    CONNECTION "http://localhost/cgi-bin/mapserv.exe?"
    CONNECTIONTYPE WFS
    DUMP TRUE
      METADATA
        "wfs_request_method"	"GET"
        "wfs_maxfeatures"	"10"
        "wfs_typename"	"myWFS"
        "wfs_service"	"WFS"
        "wfs_connectiontimeout"	"60"
        "wfs_version"	"1.0.0"
      END
    NAME "RosoftWFS"
    PROJECTION
      "init=epsg:31467"
    END
    SIZEUNITS PIXELS
    STATUS ON
    TOLERANCEUNITS PIXELS
    TYPE POINT
    UNITS METERS
    CLASS
      NAME "test"
      METADATA
      END
      STYLE
        ANGLE 360
        COLOR 255 0 0
        SIZE 150
        SYMBOL "mySymbol"
      END
    END
  END

END
-------------- next part --------------
MAP
  EXTENT 3396369.30902111 5800885 3402780.69097889 5804895
  IMAGECOLOR 230 230 230
  IMAGETYPE JPEG
  SHAPEPATH "C:\geodata\data\"
  SIZE 833 521
  STATUS ON
  UNITS METERS
  NAME "test.map"

  OUTPUTFORMAT
    NAME "jpeg"
    MIMETYPE "image/jpeg"
    DRIVER "GD/JPEG"
    EXTENSION "jpg"
    IMAGEMODE "RGB"
    TRANSPARENT FALSE
  END

  SYMBOL
    NAME "mySymbol"
    TYPE VECTOR
    FILLED TRUE
    POINTS
      1 5
      1 3
      3 2
      1 1
      1 3
    END
  END

  PROJECTION
    "init=epsg:31467"
  END
  LEGEND
    IMAGECOLOR 255 255 255
    KEYSIZE 20 10
    KEYSPACING 5 5
    LABEL
      SIZE MEDIUM
      TYPE BITMAP
      BUFFER 0
      COLOR 0 0 0
      FORCE FALSE
      MINDISTANCE -1
      MINFEATURESIZE -1
      OFFSET 0 0
      PARTIALS TRUE
      POSITION CC
    END
    POSITION LL
    STATUS OFF
  END

  QUERYMAP
    COLOR 255 255 0
    SIZE -1 -1
    STATUS OFF
    STYLE HILITE
  END

  SCALEBAR
    COLOR 0 0 0
    IMAGECOLOR 255 255 255
    INTERVALS 3
    LABEL
      SIZE MEDIUM
      TYPE BITMAP
      BUFFER 0
      COLOR 0 0 0
      FORCE FALSE
      MINDISTANCE -1
      MINFEATURESIZE -1
      OFFSET 0 0
      PARTIALS TRUE
    END
    POSITION LR
    POSTLABELCACHE TRUE
    SIZE 200 3
    STATUS EMBED
    STYLE 1
    UNITS METERS
  END

  WEB
    IMAGEPATH "c:/ms4w/tmp/ms_tmp"
    IMAGEURL "/ms_tmp/"
      METADATA
        "WMS_SRS"	"EPSG:4326"
        "WMS_ONLINERESOURCE"	"http://localhost/cgi-bin/mapserv.exe?Map=c:\ms4w\myMapHandler.MapPfile.map&"
        "WMS_ABSTRACT"	"This is an UMN MapServer Application Demonstrating the capabilities of a Web Mapping Application"
        "WMS_TITLE"	"Rosen World Base Map"
      END
    QUERYFORMAT text/html
    LEGENDFORMAT text/html
    BROWSEFORMAT text/html
  END

  LAYER
    CONNECTION "http://localhost/cgi-bin/mapserv.exe?"
    CONNECTIONTYPE WFS
    DUMP TRUE
      METADATA
        "wfs_request_method"	"GET"
        "wfs_maxfeatures"	"10"
        "wfs_typename"	"myWFS"
        "wfs_service"	"WFS"
        "wfs_connectiontimeout"	"60"
        "wfs_version"	"1.0.0"
      END
    NAME "RosoftWFS"
    PROJECTION
      "init=epsg:31467"
    END
    SIZEUNITS PIXELS
    STATUS ON
    TOLERANCEUNITS PIXELS
    TYPE POINT
    UNITS METERS
    CLASS
      NAME "test"
      METADATA
      END
      STYLE
        ANGLE 360
        COLOR 255 0 0
        SIZE 150
        SYMBOL "mySymbol"
      END
    END
  END

END


More information about the MapServer-users mailing list