2 Replies Latest reply: Jun 20, 2013 2:02 AM by Spatial RSS

    Direct creation and update of Advanced Collection Style through XML in SDO_STYLES

    Spatial

      Hi,

       

      I am using Mapviewer 11.1.1.6, Oracle 11.2.0.1.

       

      To add Style to Collection Bucket, I use this procedure

      In this procedure char operations are used to create XML definition of Collection Style.

      As result, Mapviewer gives errors.

      Why?

      Thank You very much for help in advance.

       

      create or replace PROCEDURE "OBJ_STYLE_ADD_TO_SDOSTYLESN"(

          GEOM_STYLE_NAME IN VARCHAR2,

          LABEL_STYLE_NAME VARCHAR2)

      IS

          STYLE_POS        NUMBER (10);

          CUR_SEQ          NUMBER (10);

          LAYER_STYLE_CNT        NUMBER (5);

          SD               CLOB;

          NEW_BUCKET       CLOB;

          LABEL_STYLE_STR  VARCHAR2 (100);

          OBJ_STYLE_STR    VARCHAR2 (100);

          SEQ_STR          VARCHAR2 (100);

          CUR_LAYER_NAME   VARCHAR2 (20);

      BEGIN

        

       

              -- '<CollectionBucket seq="'||CUR_SEQ||'" type="string" style="'||GEOM_STYLE_NAME||' '||LABEL_STYLE_STR||

              -- GEOM_ID ||'</CollectionBucket>'

              SELECT   TO_CLOB(

                        ST || '<CollectionBucket seq="'|| CUR_SEQ || '" type="string" style="'|| GEOM_STYLE_NAME || '" '

                     || LABEL_STYLE_STR||'>' || GEOM_STYLE_NAME|| '</CollectionBucket>'|| E )

                INTO SD

                FROM (SELECT D, SUBSTR (D, 1, CB_POS - 1) ST, SUBSTR (D, CB_POS) E

                      FROM (SELECT DEFINITION D, INSTR (DEFINITION,  '</Buckets>',-1)    CB_POS

                                FROM ALL_SDO_STYLES

                               WHERE (NAME = CUR_LAYER_NAME)));

       

       

              UPDATE MDSYS.SDO_STYLES_TABLE

                 SET DEFINITION = SD

               WHERE (SDO_OWNER = CUR_OWNER ()) AND (NAME = CUR_LAYER_NAME);

              COMMIT;

       

      END;

       

       

       

      In this procedure SD is CLOB.

      SD  updates Definition column in SDO_STYLES

       

      This is SQL which shown during debugging

       

      UPDATE "BLM"."SDO_STYLES" SET DEFINITION = '<?xml version="1.0" ?>

      <AdvancedStyle>

      <BucketStyle>

      <Buckets>

      <CollectionBucket seq="0" type="string" style="A6">A6</CollectionBucket>

      <CollectionBucket seq="1" type="string" style="A10">A10</CollectionBucket>

      <CollectionBucket seq="2" type="string" style="A9">A9</CollectionBucket>

      <CollectionBucket seq="3" type="string" style="A3">A3</CollectionBucket>

      <CollectionBucket seq="4" type="string" style="A4">A4</CollectionBucket>

      </Buckets>

      </BucketStyle>

      </AdvancedStyle>' WHERE ROWID = 'AAAPVDAACAAAqTVAAI'

       

      Commit Successful

       

       

       

      When using this Collection style Mapviewer gives errors

       

       

      14.06.2013 23:30:32 oracle.lbs.mapserver.core.MapperConfig loadConfigFile

      INFO: Map Recycling thread started.

      14.06.2013 23:30:32 oracle.lbs.mapserver.oms$ColdStart run

      INFO: *** Oracle MapViewer started. ***

      14.06.2013 23:30:33 oracle.lbs.foi.FOIServer init

      INFO: *** Oracle Feature of Interest (FOI) Server started. ***

      14.06.2013 23:30:33 oracle.lbs.mapcache.config.CacheInstanceConfig loadCacheStor

      ageDef

      WARNING: Invalid cache root directory:/scrtach/mvdemomaps\. Cache root directory

       

      14.06.2013 23:30:33 oracle.lbs.mapcache.cache.MapCache <init>

      INFO: Tile layer initialized.

      14.06.2013 23:30:33 oracle.lbs.mapcache.cache.MapCache <init>

      INFO: Initialize tile layer MVDEMO.GOOGLE_MAP

      14.06.2013 23:30:33 oracle.lbs.mapcache.MCSServlet$ColdStart run

      INFO: *** Oracle MapTileServer started. ***

      14.06.2013 23:30:46 oracle.sdovis.theme.DynGeomThemeProducer prepareData

      INFO: [JDBC_THEME] sql exec time: 30ms, total time loading 12 feature:181ms

      14.06.2013 23:30:46 oracle.sdovis.theme.DynGeomThemeProducer prepareData

      INFO: [JDBC_THEME] sql exec time: 10ms, total time loading 1 feature:351ms

      Message:Invalid Bucket style definition.

       

              at oracle.sdovis.stylex.BucketStyle.<init>(BucketStyle.java:245)

              at oracle.sdovis.StyleFactory.createAdvancedStyle(StyleFactory.java:385)

       

              at oracle.sdovis.StyleFactory.createStyleObject(StyleFactory.java:854)

              at oracle.sdovis.style.AllStyleTable.getStyleObject(AllStyleTable.java:2

      79)

              at oracle.sdovis.style.AllStyleTable.getStyleObject(AllStyleTable.java:2

      12)

              at oracle.sdovis.StyleCache.get(StyleCache.java:156)

              at oracle.sdovis.MapMaker.getStyleWithName(MapMaker.java:1380)

              at oracle.lbs.foi.FOIImageRenderer.isHeatMapRequest(FOIImageRenderer.jav

      a:2125)

              at oracle.lbs.foi.ThemeRenderingThread.setWholeImageAndClickable(ThemeRe

      nderingThread.java:1573)

              at oracle.lbs.foi.ThemeRenderingThread.render(ThemeRenderingThread.java:

      373)

              at oracle.lbs.foi.ThemeRenderingThread.run(ThemeRenderingThread.java:212

      )

      Message:Invalid Bucket style definition.

       

              at oracle.sdovis.stylex.BucketStyle.<init>(BucketStyle.java:245)

              at oracle.sdovis.StyleFactory.createAdvancedStyle(StyleFactory.java:385)

       

              at oracle.sdovis.StyleFactory.createStyleObject(StyleFactory.java:854)

              at oracle.sdovis.style.AllStyleTable.getStyleObject(AllStyleTable.java:2

      79)

              at oracle.sdovis.style.AllStyleTable.getStyleObject(AllStyleTable.java:2

      12)

              at oracle.sdovis.StyleCache.get(StyleCache.java:156)

              at oracle.sdovis.VisContext.resolveStyle(VisContext.java:1043)

              at oracle.sdovis.VisContext.resolveStyle(VisContext.java:1022)

              at oracle.lbs.foi.ThemeRenderingThread.resolveFeatureStyle(ThemeRenderin

      gThread.java:1623)

              at oracle.lbs.foi.ThemeRenderingThread.render(ThemeRenderingThread.java:

      431)

              at oracle.lbs.foi.ThemeRenderingThread.run(ThemeRenderingThread.java:212

      )

      14.06.2013 23:30:46 oracle.sdovis.theme.DynGeomThemeProducer prepareData

      INFO: [JDBC_THEME] sql exec time: 10ms, total time loading 1 feature:401ms

      14.06.2013 23:30:47 oracle.sdovis.theme.DynGeomThemeProducer prepareData

      INFO: [JDBC_THEME] sql exec time: 0ms, total time loading 0 feature:501ms

      14.06.2013 23:30:47 oracle.sdovis.theme.DynGeomThemeProducer prepareData

      INFO: [JDBC_THEME] sql exec time: 0ms, total time loading 0 feature:561ms

        • 1. Re: Direct creation and update of Advanced Collection Style through XML in SDO_STYLES
          jsharma

          The style definition looks OK at first glance.

          Does a similar style created via mapbuilder work?

           

          Anyway, two things to note/check:

          1) Is the style name (e.g.V.MY_COLLECTION) all uppercase rather than lower or mixed case (e.g. V.My_Collection)? The latter (lower/mixed) may not work (this is a bug if it does not).

          2) You only need to update user_sdo_styles (or all_sdo_styles). You don't need to insert into the sdo_styles_table directly.

          and third you could also just use replace() to insert a bucket as in

          SQL> select definition from user_sdo_styles where name='CITY_COLLECTION';

           

          DEFINITION

          --------------------------------------------------------------------------------

           

          <?xml version="1.0" ?>

          <AdvancedStyle>

             <BucketStyle>

              <Buckets default_style="M.CIRCLE">

                <CollectionBucket seq="0" keep_white_space="true" type="string" style="M.BOOK">SAN FRANCISCO</CollectionBucket>

                <CollectionBucket seq="1" keep_white_space="true" type="string" style="M.PIN">SAN MATEO</CollectionBucket>

                <CollectionBucket seq="2" keep_white_space="true" type="string" style="M.SMALL TRIANGLE">ALAMEDA</CollectionBucket>

                <CollectionBucket seq="3" keep_white_space="true" type="string" style="M.STAR">MARIN</CollectionBucket>

                <CollectionBucket seq="4" keep_white_space="true" type="string" style="M.CYAN PIN">SANTA CLARA</CollectionBucket>

              </Buckets>

             </BucketStyle>

          </AdvancedStyle>

           

          SQL> update user_sdo_styles set definition = replace(definition,'</Buckets>',

            2  '<CollectionBucket seq="5" keep_white_space="true" type="string" style="M.P

          ERSON">SAN JOSE</CollectionBucket></Buckets>')

            3  where name='CITY_COLLECTION';

           

          1 row updated.

          SQL> select definition from user_sdo_styles where name='CITY_COLLECTION';

           

          DEFINITION

          --------------------------------------------------------------------------------

           

          <?xml version="1.0" ?>

          <AdvancedStyle>

             <BucketStyle>

              <Buckets default_style="M.CIRCLE">

                <CollectionBucket seq="0" keep_white_space="true" type="string" style="M.BOOK">SAN FRANCISCO</CollectionBucket>

                <CollectionBucket seq="1" keep_white_space="true" type="string" style="M.PIN">SAN MATEO</CollectionBucket>

                <CollectionBucket seq="2" keep_white_space="true" type="string" style="M.SMALL TRIANGLE">ALAMEDA</CollectionBucket>

                <CollectionBucket seq="3" keep_white_space="true" type="string" style="M.STAR">MARIN</CollectionBucket>

                <CollectionBucket seq="4" keep_white_space="true" type="string" style="M.CYAN PIN">SANTA CLARA</CollectionBucket>

              <CollectionBucket seq="5" keep_white_space="true" type="string" style="M.PERSON">SAN JOSE</CollectionBucket></Buckets>

             </BucketStyle>

          </AdvancedStyle>

           

           

          SQL>

          • 2. Re: Direct creation and update of Advanced Collection Style through XML in SDO_STYLES
            Spatial

            Thank You very much for reply. This will help me much.

            Especially, replace method is very effective.

            Also I found second way of solving this issue, by using XMLType.CreateXML( ).getClobVal().

            After updating with XMLType, Mapviewer said Ok.