MapGuide Studio, the MapGuide authoring environment, has the capability to create symbols that use bitmaps, but there is no corresponding capability in Topobase. There is, however, a way to manually create layers using images as symbols.
To start with, you'll need a .png file with 32 bit depth. You can check the bit depth of an existing file by right-clicking on the file in Windows Explorer and viewing the properties. There, in the Details tab of Vista or the Summary tab of XP, the bit depth will be listed as either 8, 24 or 32 bits. If you don't already have a .png format file or it isn't 32 bits, you can use any one of many programs to edit it, for example Paint.Net, but unfortunately you can't use the Paint program that ships with Windows as that will only create 24 bit .png files.
To be able to place the image into an XML layer file, which is only text, the image file needs to be converted to text. For this, the Base64 encoding is used. Of course you could convert an image to Base64 by hand, but it's much easier and faster to write a program to do it. The tiny program supplied below does just that.
It is a command line program that takes as arguments the name of the file to encode and the name of the text file that will be produced. For example, if you are converting the file Wikipedia-logo.png to Wikipedia-logo.txt the command would be:
Base64Encoder Wikipedia-logo.png Wikipedia-logo.txt
Now for a little text editing. Start by creating a layer of a point feature class using enhanced stylization. Style the layer to set the size context to Map and adjust the width and height to get the desired size. Apply the stylization. Right-click on the layer in Display Manager and choose Save Layer... to create the XML file.
Edit the saved .layer file with a text editor and replace all references to the name Circle to something more meaningful. Next, remove the contents of the <Graphics> element, i.e. remove from <Path> up to the </Path>, and replace this Path element with an Image element. The <Image> element must contain a <Content> element. The <Content> element contains the text produced by the Base64Encoder program. The Base64 encoding for a converted .png file will start with the letters iVBOR and be rather substantial in size, so the bulk of it is replaced by ellipses in the following example:
<SimpleSymbolDefinition>
<Name>Wikipedia</Name>
<Description>Wikipedia Logo</Description>
<Graphics>
<Image>
<Content>
iVBOR...
... this is the rather large output from the Base64Encoder program
...CYII=
</Content>
</Image>
</Graphics>
As described in the OsGeo documentation, you can also add SizeX and SizeY elements to specify the size of the symbol in millimeters, an Angle element to specify the rotation angle of the image, and PositionX and PositionY elements to specify the image center in millimeters within the symbol. Of course these can be parameterized if desired.
Now you can drag and drop your edited layer file into the Display Manager or add your layer to a Display Model and you should see your point features represented as your image symbols.
Note: If you have areas in the image that should allow the background color to show through, i.e. the alpha or transparency value of those pixels is zero, then you must use Topobase 2011 as this is not supported in Topobase 2010.
AUTODESK DOES NOT GUARANTEE THAT YOU WILL BE ABLE TO SUCCESSFULLY DOWNLOAD OR IMPLEMENT ANY SAMPLE CODE. SAMPLE CODE IS SUBJECT TO CHANGE WITHOUT NOTICE TO YOU.
AUTODESK PROVIDES SAMPLE CODE "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED, INCLUDING WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
PARTICULAR PURPOSE. IN NO EVENT SHALL AUTODESK OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS
OF DATA, OR LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, THAT MAY OCCUR AS A RESULT OF IMPLEMENTING OR USING ANY SAMPLE CODE, EVEN IF AUTODESK OR ITS SUPPLIERS
HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
cool stuff, I like it!
Posted by: Brigl | January 13, 2010 at 09:22 AM