Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow ExternalGraphic image to be used for GetCapabilities and GetLegendGraphics #551

Closed
wants to merge 13 commits into from

Conversation

jodygarnett
Copy link
Member

This is a replacement for #400 adding LegendInfo to StyleInfo for use in WMS GetCapabilities generation. The data structure (if available) is also used in GetLegendGraphics.

The scope of this feature has been refined to restrict these external graphic references to images that are being served by GeoServer (for example from the styles directory). This allows GeoServer to still be responsible for all the information it is publishing, and ensure that the images are available for the GetLegendGraphics operation.

Update: Due to feedback from @aaime the above restriction is lifted, a warning will be provided in the user interface if you configure GeoServer with an absolute URL pointing to an external server. An absolute URL that starts with the base url is fine. During GetLegendGraphics any online resource that cannot be resolved will result in a warning in the logs, and the code will proceed with dynamic generation.

To do:

@jodygarnett
Copy link
Member Author

Discussion with Andrea resulted in the request to relax the restriction on locating external graphic in the styles directory.

Compromise shown below checks the external graphic and offers a warning if it is located outside of GeoServer.

warning

@jodygarnett
Copy link
Member Author

Style preview (ie GetLegendGraphic request with no layer) working:

style_preview

@jodygarnett
Copy link
Member Author

To test the above branch:

  1. From the styles page edit the "grass" style to have grass_fill.png
  2. Click Auto-detect image size and type
  3. Test WMS GetCapabilities links
  4. Use Demo Request page to test use (no rescale)

http://localhost:8080/geoserver/wms?REQUEST=GetLegendGraphic&VERSION=1.0.0&FORMAT=image/png&WIDTH=32&HEIGHT=32&LAYER=tiger:poly_landmarks&STYLE=grass

  1. Use Demo Request page to test with rescale

http://localhost:8080/geoserver/wms?REQUEST=GetLegendGraphic&VERSION=1.0.0&FORMAT=image/png&WIDTH=22&HEIGHT=22&LAYER=tiger:poly_landmarks&STYLE=grass

grass_fill_legend

@jodygarnett
Copy link
Member Author

Test with group layer.

legend_group

@mike-es
Copy link
Contributor

mike-es commented Mar 31, 2014

Jody, thanks for working on this. I'm sorry for not getting back to you sooner. I'll checkout your branch and do some testing.

Michael Romero

@jodygarnett
Copy link
Member Author

Thanks @mike-es - um I actually have a question you may be able to help me with. I am happy with this pull request, but need to confirm that the original #400 is covered by a contribution agreement :)

The document is here: http://docs.geoserver.org/stable/en/developer/policies/committing.html

The PDF needs to be printed, signed and emailed. Perhaps you are in position to check if this has been done already?

@mike-es
Copy link
Contributor

mike-es commented Mar 31, 2014

Mike Benowitz, the author of #400, went through the process of getting a contribution agreement signed for a different pull request (geotools/geotools#286). I believe that should cover him for #400 as well.

@jodygarnett
Copy link
Member Author

Excellent! It will indeed. Okay so we have GSIP 111 to wait for and we should be good to go.

@mike-es
Copy link
Contributor

mike-es commented Apr 1, 2014

Jody, I did some testing and relative paths for the image works well. I tried various things:

  • Different image sizes: 32x32, 20x20, and 40x40
  • Subdirectory in styles dir
  • WMS Capabilities document, 1.3.0 and 1.1.1
  • Layer group with default style as shown in image above and setting grass with grass_fill.png as the default.

I notice a couple issues with using a full URL:

@aaime
Copy link
Member

aaime commented Apr 1, 2014

Jody and Mike, a contributor assignement signed for GeoTools does not cover GeoServer, the copyright assignment does not go to the same organisation (OsGeo vs OpenPlans).

@jodygarnett
Copy link
Member Author

Added the issues to the todo list. It was my intention to provide "Recommended use of styles" warnings. The use of URLs are not served by GeoServer is a danger (as breaks web clients).

I do not understand your issue with generation of WMS Capabilities document creating a file. Edit your comment to provide more detail.

I may need some advice on handling of wicket warnings (I also note that validation occurs when clicking on the link, but not when hitting "Submit").

@mike-es
Copy link
Contributor

mike-es commented Apr 2, 2014

I realized I should have tested WMS 1.1.1, not 1.0.0. You can disregard the comment about creating the file.

@aaime
Copy link
Member

aaime commented Apr 19, 2014

Any progress? How are we doing contribution agreement wise?

@jodygarnett
Copy link
Member Author

I am still waiting.

On Saturday, April 19, 2014, Andrea Aime notifications@github.com wrote:

Any progress? How are we doing contribution agreement wise?


Reply to this email directly or view it on GitHubhttps://github.com//pull/551#issuecomment-40864738
.

Jody Garnett

@aaime
Copy link
Member

aaime commented May 14, 2014

Hi, it's been another month, are the copyright assignments moving on?

@jodygarnett
Copy link
Member Author

@mike-es can you check on the paperwork please?

@mike-es
Copy link
Contributor

mike-es commented May 16, 2014

I just sent an email to the person responsible for getting the signed agreement and CC'd both of you.

@aaime
Copy link
Member

aaime commented Jul 15, 2014

Are we still waiting on the agreements?

@jodygarnett
Copy link
Member Author

I told management on my end that they were too slow...

Even with this agreement in-hand today there would be QA needed based on the issues @mike-es listed above. I guess I could just turn off wicket validation (rather than figure out how to cascade clear the warnings from the subform).

@aaime
Copy link
Member

aaime commented Oct 5, 2014

Hem... any progress with the CA?

@jodygarnett
Copy link
Member Author

Um - yes there is progress. We changed out organisation - and this crew had already signed for GeoTools ...

So we should be good now?

@aaime
Copy link
Member

aaime commented Oct 6, 2014

License wise it would seem that way. The code base has shifted enough during the last six months that the pull request cannot be merged anymore though.

@aaime
Copy link
Member

aaime commented Jan 17, 2015

So... I guess this one will be merged for 2.8.x?

@jodygarnett
Copy link
Member Author

Unless I get to it tomorrow :) Need to rebase and see if it is any good...

@aaime
Copy link
Member

aaime commented Feb 22, 2015

2.8.x ready to receive this (just sayin... :-p )

@aaime
Copy link
Member

aaime commented Apr 18, 2015

Another couple of months passed since last comment. Still in the pipeline for being worked on?

@jodygarnett
Copy link
Member Author

Yeah I asked Travis to take it to a branch so we could both look at it:
https://github.com/boundlessgeo/geoserver/tree/legend-capabilities

Near as I can tell he got stuck in wicket code.

Jody Garnett

On 18 April 2015 at 10:21, Andrea Aime notifications@github.com wrote:

Another couple of months passed since last comment. Still in the pipeline
for being worked on?


Reply to this email directly or view it on GitHub
#551 (comment).

@aaime
Copy link
Member

aaime commented Aug 18, 2015

Any relationship between this pull request and this ticket?
https://osgeo-org.atlassian.net/browse/GEOS-7160

Maybe they are similar but not same, cannot decide :)

@jodygarnett
Copy link
Member Author

I think this feature (ability to parse out a LegendGraphic from SLD) may in
fact be covered.

Jody Garnett

On 18 August 2015 at 04:57, Andrea Aime notifications@github.com wrote:

Any relationship between this pull request and this ticket?
https://osgeo-org.atlassian.net/browse/GEOS-7160

Maybe they are similar but not same, cannot decide :)


Reply to this email directly or view it on GitHub
#551 (comment).

jodygarnett and others added 13 commits September 1, 2015 10:41
…etLegendGraphic service in the WMS GetCapabilities LegendURL

Conflicts:
	src/main/src/test/java/org/geoserver/data/test/SystemTestData.java
Fix up ExternalGraphic panel to allow relative URL

Introduction of LegendRequest data structure to prevent more internal hashmaps

KVP parser now resolves relative graphics prior to use. Additional validation checks and warnings.

Validation now also checks image availability, and will provide warning if configured with an external graphic that does not match the request base url.

Update documentation for style editor
looks like validation and saving is not functioning
…buttons instead of links for show/hide legend
@jodygarnett
Copy link
Member Author

@tbarsballe thanks for the help on this one, can you review the checklist at the top of this pull request and cross off them items that were fixed?

I think we may be done?!

@tbarsballe
Copy link
Member

Of the remaining unchecked issues, I did not explicitly fix (or test) any of them, although from general testing I think both "prepending of styles directory" and "validation on submit" are fixed now.

Other fixes:

  • Wicket tests for Style Legend Graphic fixed - All the unit tests pass now
  • Discard Legend button now works as expected
  • Use buttons instead of links to show/hide the legend entry (for better consistency with the rest of the GeoServer UI.

@tbarsballe
Copy link
Member

Looks like @jodygarnett added test cases for the remaining issues last week. Now that all the test cases pass, we can consider these issues fixed.

@tbarsballe
Copy link
Member

#1237 broke the mergeability of this PR.

@tbarsballe
Copy link
Member

Manualy squashed and merged to master: 83bb4d6


String user_home = System.getProperty("user.home");
File home = new File(user_home);
ImageIO.write(expected, "png", new File(home,"expected.png"));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jodygarnett @tbarsballe please do not write test images to user home directory. Fixed in 4380977 on master. These images were not used in the test and I assume that they were for test development and inadvertently included in this PR. At the least, ensure that test images are confined to module target so they can be cleaned. See gt-render for examples of how to write test fixtures that enable interactive development of tests and by default write no files.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Ben, sorry we missed that in such a long lived patch.
On Wed, Nov 4, 2015 at 4:16 AM Ben Caradoc-Davies notifications@github.com
wrote:

In
src/wms/src/test/java/org/geoserver/wms/wms_1_1_1/GetLegendGraphicTest.java
#551 (comment):

  •    BufferedImage image = getAsImage(base, "image/png");
    
  •    Resource resource = getResourceLoader().get("styles/legend.png");
    
  •    BufferedImage expected = ImageIO.read( resource.file() );
    
  •    assertEquals( getPixelColor(expected,10,2).getRGB(), getPixelColor(image,10,2).getRGB() );
    
  •    // test rescale
    
  •    base = "wms?service=WMS&version=1.1.1&request=GetLegendGraphic" +
    
  •            "&layer=sf:states&style=custom" +
    
  •            "&format=image/png&width=16&height=16";
    
  •    image = getAsImage(base, "image/png");
    
  •    String user_home = System.getProperty("user.home");
    
  •    File home = new File(user_home);
    
  •    ImageIO.write(expected, "png",  new File(home,"expected.png"));
    

@jodygarnett https://github.com/jodygarnett @tbarsballe
https://github.com/tbarsballe please do not write test images to user
home directory. Fixed in 4380977
4380977
on master. These images were not used in the test and I assume that they
were for test development and inadvertently included in this PR. At the
least, ensure that test images are confined to module target so they can be
cleaned. See gt-render for examples of how to write test fixtures that
enable interactive development of tests and by default write no files.


Reply to this email directly or view it on GitHub
https://github.com/geoserver/geoserver/pull/551/files#r43839044.

Jody Garnett

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No worries, Jody.

On 04/11/15 17:11, Jody Garnett wrote:

Thanks Ben, sorry we missed that in such a long lived patch.

Ben Caradoc-Davies ben@transient.nz
Director
Transient Software Limited http://transient.nz/
New Zealand

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
7 participants