GeoTools
  1. GeoTools
  2. GEOT-4000

Configurable resource locator in SLDParser

    Details

    • Type: Improvement Improvement
    • Status: Resolved Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.7.4
    • Fix Version/s: 2.7.5
    • Component/s: api, main
    • Labels:
      None
    • Testcase included:
      yes

      Description

      Extend the way in which external graphics can be
      resolved in the main Geotools SLD parser.

      As far as i know, you can now specify the location of an external
      graphic in two ways:

      • specify the location as a relative URL w.r.t. the SLD document URL
      • specify the location as a java classpath resource

      The first case assumes that the document URL is known and reachable,
      which is not always the case (e.g. transfer of SLD over the wire or
      configuring SLD in a database and so on). The second case is a nice
      fallback in many circumstances but for web applications it is very
      common to put graphics in a non-classpath location like the web context.

      My suggestion is to make the location more customizable by adding a
      resource locator to the SLD parser:
      setOnlineResourceLocator(ResourceLocator resourceLocator);

      where ResourceLocator would define the following:
      public URL locateResource(String uri);

      1. 2.7.4.patch
        9 kB
        Jan De Moerloose
      2. GEOT-4000_xsd.patch
        12 kB
        Justin Deoliveira

        Activity

        Hide
        Andrea Aime added a comment -
        The patch looks good, has a test, so I'm inclined to commit it.

        Justin, can I ask for a couple of sanity checks?
        - is this going to affect your work on per workspace styles in GeoServer?
        - what about gt-xsd SLD parsing, is the interface suitable to be used there as well? (thinking SLD 1.1 here)
        Show
        Andrea Aime added a comment - The patch looks good, has a test, so I'm inclined to commit it. Justin, can I ask for a couple of sanity checks? - is this going to affect your work on per workspace styles in GeoServer? - what about gt-xsd SLD parsing, is the interface suitable to be used there as well? (thinking SLD 1.1 here)
        Hide
        Justin Deoliveira added a comment -
        Looks good to me, and I think this could actually make per workspace styles a bit easier to pull off. Gives us the ability if need be to register a custom sld resource locator. But work there is sort of halted for the moment so can't comment to specifically.

        As for the xsd sld parser, this should work well there as well. The patch should be pretty straight forward there, SLDOnlineResourceBinding just needs to take one of these classes (falling back on the default) and pass the uri through it.
        Show
        Justin Deoliveira added a comment - Looks good to me, and I think this could actually make per workspace styles a bit easier to pull off. Gives us the ability if need be to register a custom sld resource locator. But work there is sort of halted for the moment so can't comment to specifically. As for the xsd sld parser, this should work well there as well. The patch should be pretty straight forward there, SLDOnlineResourceBinding just needs to take one of these classes (falling back on the default) and pass the uri through it.
        Hide
        Andrea Aime added a comment -
        Patch applied on 2.7.x and trunk. I did not do the gt-xsd part because... for the life of me I cannot remember how things get grabbed from the pico context into a binding...
        Show
        Andrea Aime added a comment - Patch applied on 2.7.x and trunk. I did not do the gt-xsd part because... for the life of me I cannot remember how things get grabbed from the pico context into a binding...
        Hide
        Justin Deoliveira added a comment -
        Reopening until the SLD/SE xsd parsers updated
        Show
        Justin Deoliveira added a comment - Reopening until the SLD/SE xsd parsers updated
        Hide
        Justin Deoliveira added a comment -
        Here is a patch... i had to move the default resource loader implementation out into its own class
        Show
        Justin Deoliveira added a comment - Here is a patch... i had to move the default resource loader implementation out into its own class
        Hide
        Andrea Aime added a comment -
        Looks good to me
        Show
        Andrea Aime added a comment - Looks good to me
        Hide
        Justin Deoliveira added a comment -
        Applied.
        Show
        Justin Deoliveira added a comment - Applied.

          People

          • Assignee:
            Andrea Aime
            Reporter:
            Jan De Moerloose
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: