2 Replies Latest reply on Jan 16, 2013 10:15 AM by 980279

    Creating MapBuilder import files with fill patterns as images

      I am looking for help creating an import file that includes images suitable for MapBuilder or an alternative solution to the problem outlined below.

      Why? I need to map Oracle spatial tables where the style will be determined by an attribute with 60 or more possible values and will replicate the complex fill patterns used in other GIS Systems. They will be drawn on a map as FOI layers so users can interrogate values associated with the polygons. A lot of this data has recently been moved into Oracle spatial tables and is still in use in other GIS formats.

      I have found that I had to use images to replicate the complex fill patterns used in my organization when adding Geometry Themes in MapBuilder.

      If we take a layer of Habitat polygons as an example I have to deal with a large number of discrete habitat codes each of which will require a corresponding image to use as a fill pattern. I intend to use an Advanced Style of type Collection Bucket to style it.

      I intended to write a script to extract the existing styling of spatial data in non-Oracle format and write a file that MapBuilder can import. I can write XML easily as this is just text. The problem is that I do not know how to convert my fill pattern images into the encoding used within an import file suitable for MapBuilder.

      I have not found any documentation on the format used in MapBuilder import / export files.

      I have created test data and test styles in three formats ( JPEG, GIF and PNG) and examined the resulting encoding in a MapBuilder export file but it did not help.

      I am using MapBuilder version 11_1_1_5_B110527.

      Philip Jutson
        • 1. Re: Creating MapBuilder import files with fill patterns as images
          Hi Philip,
          One first option, which is not related with the metadata file format that you are mentioning, would be to build a script that reads your image pattern into a BLOB and writes a style record directly in user_sdo_styles database view. In this case there would be no need to use MapBuilder for the import.

          This MapBuilder metadata file for import/export is internal and undocumented.
          Each metadata section in MapBuilder import/export file is enclosed by lines defining the start and the end of section.
          For each metadata element, its attributes are separated by a delimiter (usually a "|"), and for style images the data is in BASE64 encoding.

          The following is a template code in java that shows how the data contents (styles in this case) could be saved.
          The Base64OutputStream class is part of an internal MapViewer library sdovis.jar (you find it in MapViewer WEB-INF/lib directory).
          You could try to use it on your own (it is an internal library and unsupported). The piece of code in this case is simple.
                   FileOutputStream fos = new FileOutputStream("outmeta.dat");
                   PrintStream os = new PrintStream(fos);
                   String delim = "|";
                   os.println("--------STYLES BEGIN--------");
                   #for each style to be saved#
                      os.println(style.getDescription().replaceAll("\\|", "|")+delim);   // replaceAll is to escape
                      os.println(style.getDefinition().replaceAll("\\|", "|")+delim);           
                      byte[] img = style.getImageData();
                         ByteArrayOutputStream bytes = new ByteArrayOutputStream();
                         Base64OutputStream bo = new Base64OutputStream(bytes, false);
                   os.println("--------STYLES END--------");
          • 2. Re: Creating MapBuilder import files with fill patterns as images
            Thank you for the reply.

            Intend to try your second example. My Java skills are a little rusty but I will try and extend the code to include colour replacement on black (forground) and white (background) fill patterns.

            My work priorities have been changed since I posted this question so there will be a delay in letting you know how things are going.

            Philip Jutson