SE_RegisterVectorStyle: return -1 with .sld file

32 views
Skip to first unread message

mj10777

unread,
Jul 15, 2015, 7:29:53 AM7/15/15
to spatiali...@googlegroups.com
After, belatedly seeing that all the Style commands are documented in the spatialite-documentation, I have started the process of learning how to deal with the Styles for a RasterLite2 Database.

I first started with the 'monochrome_red.xml' file, that came along with the alpha-documentation for trento-ctr
SELECT SE_RegisterRasterStyle
( -- The registered Style will be identified either by its unique Style ID or by its Style Name automatically retrieved from SLD/SE XML
 XB_Create
 
( -- <Name>monochrome_red</Name>
  XB_LoadXML('../
monochrome_styles/monochrome_red.xml'),
  1, -- compression
  1  -- with validation
 )
);

The 'SE_raster_styles' had an entry with style_name='monochrome_red'.
- 'XmlBLOB-RasterStyle' SchemaValidated

---

I then attempted to import a sld file that Andrea 'Geopaparazzi' had sent me, together with the geotiff's they belonged to
* I believe he also sent you these files
Goal: was to display the given geotiff with style in LibreWMS and check that the result was the same as the png that showed the expected result

this however fails with a -1.

SELECT XB_Create
( -- <sld:Name>DIFF1.3_2012_000370_geo_1m</sld:Name>
 XB_LoadXML('../
chm_geotiff/DIFF1.3_2012_000415_geo_1m.sld'),
 
1 -- compression
)

returns (in spatialite_gui, with 'SPATIALITE_SECURITY=relaxed') a blob as
- 'XmlBLOB-VectorStyle'
-- with the parameter validation, NULL is returned 

---

Never having worked with sld files, I am not sure how they should look, this however (as apposed to your sample) seems to be a gml file
* is this normal ?


<sld:StyledLayerDescriptor xmlns="http://www.opengis.net/sld" xmlns:sld="http://www.opengis.net/sld" xmlns:ogc="http://www.opengis.net/ogc" xmlns:gml="http://www.opengis.net/gml" version="1.0.0">

 
Mark


a.fu...@lqt.it

unread,
Jul 15, 2015, 8:26:32 AM7/15/15
to spatiali...@googlegroups.com
On Wed, 15 Jul 2015 04:29:53 -0700 (PDT), mj10777 wrote:
> After, belatedly seeing that all the Style commands are documented in
> the spatialite-documentation, I have started the process of learning
> how to deal with the Styles for a RasterLite2 Database.
>

Hi Mark,

it seems that there is some confusion about SE and SLD styles.
- all this stuff started in 2002 when OGC released the initial
SLD 1.0.0 specification.
- anyway in 2006/2007 many relevant changes happened.
a significantly different SLD 1.1.0 was released, and even more
important, there was a brand new companion SE 1.1.0 specification.
- so SLD 1.0.0 is now clearly obsolete but unhappily many sw
implementations seems to be still stuck to this superseded
specification.
- the intended goal of Spatialite+Rasterlite is supporting SE
and SLD 1.1.0, not the archaic SLD 1.0.0

just a may be useful explanation:
- the initial SLD specification was to much closely modelled
around WMS, and there wasn't any clear distinction separating
the style itself and the more complex rules (based on scale
or depending on attribute values) allowing to support a
very dynamic styling.
- the new 1.1.0 specifications are more generic and easily
reusable also in contexts completely unrelated to WMS.
the styling problem is split in two halves:
* SE (Stying Encoding) is just supposed to represent a single
style aka symbolizer, and could be one between RasterSymbolizer,
PointSymbolizer, LineSymbolizer, PolygonSymbolizer or
TextSymbolizer.
* SLD (Style Layer Descriptor) is a more complex object
possibly based on several distinct SE items, and is intended
to represent complex and may be highly dynamic rendering rules.
Just as an example, you could eventually define a complex
SLD for the same Polygon Layer based on:
- a PolygonSymbolizer (e.g. based on a thick black stroke
and a semi-transparent red fill).
- a PointSymbolizer (e.g. a green star centered on the
polygon's centroid)
- and finally a TextSymbolizer (e.g. displaying some label,
and properly aligned around the polygon's centroid).
- all three Symbolizers will be then rendered

both specifications are available for free download;

http://portal.opengeospatial.org/files/?artifact_id=16700
http://portal.opengeospatial.org/files/?artifact_id=22364

they are quite complex (and may be a little boring) but studying
these documents with due care and attention is surely worth for
anyone seriously interested into SE and SLD.

I suggest you to build a copy of spatialite_gui configured as:
./configure --enable-rl2extra=yes

this way you'll enable several wizards supporting an user friendly
approach to SE and SLD; each wizard can directly insert an SE/SLD
style into the DB, but you can easily export the corresponding XML
documents.
All these wizards are still half-finished and may be bug ridden,
anyway they are surefuly useful as didactic tools.
I imagine this could be the faster and easier approach to the
many SE and SLD intricacies.

have your fun,
Sandro

mj10777

unread,
Jul 15, 2015, 12:02:01 PM7/15/15
to spatiali...@googlegroups.com
Have downloaded these and will look into them.
Had a quick look and saw that QGIS can export its vector-Style as sld 1.1.0
<?xml version="1.0" encoding="UTF-8"?>
  <NamedLayer>
    <se:Name>gcp_master</se:Name>
    <UserStyle>
      <se:Name>gcp_master</se:Name>
      <se:FeatureTypeStyle>
        <se:Rule>
          <se:Name>Single symbol</se:Name>
          <se:PointSymbolizer>
            <se:Graphic>
              <se:Mark>
                <se:WellKnownName>regular_star</se:WellKnownName>
                <se:Fill>
                  <se:SvgParameter name="fill">#ff0000</se:SvgParameter>
                </se:Fill>
                <se:Stroke>
                  <se:SvgParameter name="stroke">#ff0000</se:SvgParameter>
                  <se:SvgParameter name="stroke-opacity">0.00</se:SvgParameter>
                </se:Stroke>
              </se:Mark>
              <se:Size>6</se:Size>
            </se:Graphic>
          </se:PointSymbolizer>
          <se:PointSymbolizer>
            <se:Graphic>
              <se:Mark>
                <se:WellKnownName>circle</se:WellKnownName>
                <se:Fill>
                  <se:SvgParameter name="fill">#ffff7f</se:SvgParameter>
                </se:Fill>
                <se:Stroke>
                  <se:SvgParameter name="stroke">#000000</se:SvgParameter>
                  <se:SvgParameter name="stroke-opacity">0.00</se:SvgParameter>
                </se:Stroke>
              </se:Mark>
              <se:Size>2</se:Size>
            </se:Graphic>
          </se:PointSymbolizer>
        </se:Rule>
      </se:FeatureTypeStyle>
    </UserStyle>
  </NamedLayer>
</StyledLayerDescriptor>


- but SE_RegisterVectorStyle fails with 0 (XB_Create shows XmlBLOB-VectorStyle SchemaValidated)

Do you have a sld that works with SE_RegisterVectorStyle?
they are quite complex (and may be a little boring) but studying
these documents with due care and attention is surely worth for
anyone seriously interested into SE and SLD.

I suggest you to build a copy of spatialite_gui configured as:
./configure --enable-rl2extra=yes
I did this, and just tried to import the above sld, but it failed also
- will look at the pdf tomorrow, where hopefully a sample exist that will not fail 

a.fu...@lqt.it

unread,
Jul 15, 2015, 7:01:00 PM7/15/15
to spatiali...@googlegroups.com
On Wed, 15 Jul 2015 09:02:01 -0700 (PDT), mj10777 wrote:
> Had a quick look and saw that QGIS can export its vector-Style as sld
> - but SE_RegisterVectorStyle fails with 0 (XB_Create shows
> XmlBLOB-VectorStyle SchemaValidated)
>

Hi Mark,

that style exported from QGIS fails to pass full validation simply
because it's a complete SLD style exclusively intended for an
external WMS.

Rasterlite2 doesn't expects a style declaration starting from
<StyledLayerDescriptor>, because the actual name of the vector
coverage(s) supporting this style will be fully defined by internal
DB relations.
and the same identical style could be eventually shared by several
different coverages stored into the same DB, so directly declaring
some layer name internally into the SLD document iyseòf (as strictly
required by <StyledLayerDescriptor>) will be someway inappropriate.

any SE style accepted by rasterlite must always start with one
between the following tags:
<FeatureTypeStyle>
<CoverageTypeStyle>
<RasterSymbolizer>
<PointSymbolizer>
<LineSymbolizer>
<PolygonSymbolizer>
<TextSymbolizer>

> Do you have a sld that works with SE_RegisterVectorStyle?
>

you'll find several valid styles passiing full validation into the
attached zipfile.

bye Sandro
styles.zip
Reply all
Reply to author
Forward
0 new messages