GeoTools
  1. GeoTools
  2. GEOT-2910

Customizable ShapeMarkFactory for arbitrary shapes + rectangle mark + hatch mark with arbitrary angles

    Details

    • Type: New Feature New Feature
    • Status: Open Open
    • Priority: Minor Minor
    • Resolution: Unresolved
    • Affects Version/s: 2.6.1
    • Fix Version/s: 2.7.6
    • Component/s: main
    • Labels:
      None
    • Testcase included:
      yes

      Description

      The attached file contains a stand-alone plugin module for a "CustomShapeMarkFactory", which allows for creating customizable marks by registering arbitrary shapes. This factory may be used to replace the current ShapeMarkFactory, whose functionality is (hopefully) entirely replicated (i.e., all marks in ShapeMarkFactory have their equivalents in CustomShapeMarkFactory). It could also probably be used for user extensions in the way suggested by Andrea Aime in http://old.nabble.com/list-of-well-known-marks-and-%22shapes:--%22-in-SLD-td26064137.html.

      At the moment, usage is by using a well known string of the type "customshape://<markname>[?parameter1=value1&parameter2=value2&..]".

      Aside from the previously existing marks, two additional marks are provided:

      • A "rectangle" mark, where the user can specify something like "customshape://rectangle?aspect=2.0"
      • A "hatch" mark, where the user can specify something like "customshape://hatch?angle=30"

      Both additional marks require support for non-square marks in the GeoTools renderers (provided in patch for issue GEOT-2906)

        Issue Links

          Activity

          Hide
          Andrea Aime added a comment -
          Hi Milton, I'm looking into this one and I'd like to share some thoughts.

          I agree the shape factory could (and probably should) replace the existing shape factory. If it does I'd like to just keep the same name so that uses do not notice the difference.

          I have a couple of worries about the way this factory has been implemented though:
          - all the hatch like creators seem overkill to me, wouldn't it be better to prepare a translation table so that if the code is hit by "shape://pipe" it it just turned into "shape://hatch?angle=90" before being passed down to the creators?
          - the idea of creators that can be registered at runtime... it seems to very much replicate the mark factory concept itself. If I want to create more shape handles why not just create a separate mark factory? Like, the current approach seems to introduce a further level of pluggability when we already have one...
          Show
          Andrea Aime added a comment - Hi Milton, I'm looking into this one and I'd like to share some thoughts. I agree the shape factory could (and probably should) replace the existing shape factory. If it does I'd like to just keep the same name so that uses do not notice the difference. I have a couple of worries about the way this factory has been implemented though: - all the hatch like creators seem overkill to me, wouldn't it be better to prepare a translation table so that if the code is hit by " shape://pipe " it it just turned into " shape://hatch?angle=90 " before being passed down to the creators? - the idea of creators that can be registered at runtime... it seems to very much replicate the mark factory concept itself. If I want to create more shape handles why not just create a separate mark factory? Like, the current approach seems to introduce a further level of pluggability when we already have one...
          Hide
          Milton Jonathan added a comment -
          Hello Andrea.

          First of all, sure, we should keep the name if it replaces the current factory.

          - About the hatch-like creators issue, yeah, I guess we do have duplicate functionality right now, since the hatch shape creator includes the functionality of 4 other shape creators: 'vertline', 'horlize', 'slash' and 'backslash' (by the way, when you said 'shape://pipe&#39; did you mean 'shape://vertline&#39;?). The other shape creators would still be needed in any case ('dot', 'plus', 'times', etc). Anyway, I guess we just did it this way to make it clear that the original shapes were there.

          - About allowing to add shapes at runtime.. I thought I read it somewhere that you were interested in that, but I may have been mistaken. In fact, we are not using that so if you want to leave it out, feel free.. Ah, I guess I as reading at that nabble thread above: you were talking about wanting to make it extendable to allow users to add shapes by specifying a WKT somewhere. I guess that was the inspiration.

          Reading there, that idea of having a mark factory that read from SVG files is actually a little useful, so that we can play around with its color, etc. Has anybody taken interest in doing that?
          Show
          Milton Jonathan added a comment - Hello Andrea. First of all, sure, we should keep the name if it replaces the current factory. - About the hatch-like creators issue, yeah, I guess we do have duplicate functionality right now, since the hatch shape creator includes the functionality of 4 other shape creators: 'vertline', 'horlize', 'slash' and 'backslash' (by the way, when you said ' shape://pipe&#39; did you mean ' shape://vertline&#39;?) . The other shape creators would still be needed in any case ('dot', 'plus', 'times', etc). Anyway, I guess we just did it this way to make it clear that the original shapes were there. - About allowing to add shapes at runtime.. I thought I read it somewhere that you were interested in that, but I may have been mistaken. In fact, we are not using that so if you want to leave it out, feel free.. Ah, I guess I as reading at that nabble thread above: you were talking about wanting to make it extendable to allow users to add shapes by specifying a WKT somewhere. I guess that was the inspiration. Reading there, that idea of having a mark factory that read from SVG files is actually a little useful, so that we can play around with its color, etc. Has anybody taken interest in doing that?
          Hide
          Andrea Aime added a comment -
          Ok, I'll try to cook up a patch that merges your work in the existing shape factory and I'll submit it here for your review.

          As for SVG or WKT based factories, nope, no one taken the job so far. WKT wise it would be very easy, but we might miss something to visually build the WKT.
          SVG wise it might be a little tricky as we'd have to extract from the SVG a pure outline that we can fill and stroke as directed from the Mark parameters, but on the bright side it would be possible to create them visually using something like Inkscape.

          If you feel like tackling any of the above, sure, that would be great :-)
          Show
          Andrea Aime added a comment - Ok, I'll try to cook up a patch that merges your work in the existing shape factory and I'll submit it here for your review. As for SVG or WKT based factories, nope, no one taken the job so far. WKT wise it would be very easy, but we might miss something to visually build the WKT. SVG wise it might be a little tricky as we'd have to extract from the SVG a pure outline that we can fill and stroke as directed from the Mark parameters, but on the bright side it would be possible to create them visually using something like Inkscape. If you feel like tackling any of the above, sure, that would be great :-)
          Hide
          Andrea Aime added a comment -
          Luca Morandini has implemented a mark factory based on inline WKT definitions, as well as one based on an external property file with names associated with WKT definitions
          Show
          Andrea Aime added a comment - Luca Morandini has implemented a mark factory based on inline WKT definitions, as well as one based on an external property file with names associated with WKT definitions

            People

            • Assignee:
              Andrea Aime
              Reporter:
              Milton Jonathan
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated: