I am new to GeoServer and I am trying to add a legend on an existing map. I am not sure where to add the legend XML file?
In the GeoServer user manual, they briefly talk about legend but it is not very clear: http://docs.geoserver.org/stable/en/user/advanced/wmsdecoration.html
I think the legend XML file should be added in the web map services page (WMS). But I tried to search for the key word like legend or something on the page but I cannot find it. Am I on the right direction?
You are referring to WMS overlay decorations.
In the link http://docs.geoserver.org/stable/en/user/advanced/wmsdecoration.html that you included in the post, it gives the instructions needed to mimic the screenshot you've referenced.
To use decorations in a GetMap request, the administrator must first
configure a decoration layout. These layouts are stored in a
subdirectory called layouts in the GeoServer Data Directory as XML
files, one file per layout. Each layout file must have the extension
.xml. Once a layout foo.xml is defined, users can request it by adding
&format_options=layout:foo to the request parameters.
In essence, you:
create a descriptor file like what is offered in your post
Copy this file to the layouts folder that exists in the Data Directory on
the Geoserver (the specific path varies on the installation)
craft requests for the wms layer with querystring parameters to instruct
the server that you want to see the layer with the specified
overlay. i.e. &format_options=layout:foo to the request parameters.
This embeds the overlay onto the layer itself. This is in contrast with Jose's answer which involves an additional HTTP request (which could be referenced in a <img href=""/> tag).
In either case, the legend component can be influenced by also applying a style in the request for the layer. These are commonly coded with SLD. For information on that is available here
== Edit 01 ==
For Reference, the path to the data directory can be found here:
This is the path on the server where geoserver is installed where the data directory resides. The Structure of Data Directory link has some detail on what is in this folder and the purpose of each item.
I think the request you are looking for is GetLegendGraphic. With this request you are requesting Geoserver to return an image that corresponds to the default SLD of a layer or to a SLD specified in the request.
This is a sample request that you can find in the Geoserver documentation:
http://localhost:8080/geoserver/wms?REQUEST=GetLegendGraphic&VERSION=1.0.0&FORMAT=image/png&WIDTH=20&HEIGHT=20&LAYER=topp:states&legend_options=fontName:Times%20New%20Roman;fontAntiAliasing:true;fontColor:0x000033;fontSize:14;bgColor:0xFFFFEE;dpi:180
For more information and all the parameters that you can specify in the request:
http://docs.geoserver.org/latest/en/user/services/wms/get_legend_graphic/legendgraphic.html
If you are looking for a request to get the SLD file content instead of an image to handle it in the application you will need to do a GetStyle request.
I hope that helps.
Related
I have PDFs, images, and text files in S3. I want the ability to create a download link to the file, but only sometimes. Sometimes my users want to view files on the web, but sometimes they want to click a "download" button to grab them in a single step (vs opening them and clicking the disk icon in the PDF viewer or hitting CTRL + S, etc.). For the latter case, I'd like to be able to generate a link that tells S3 what to do. It'd be nice if I could also control the name of the attachment, but I'd be more than happy to just be able to make an attachment.
Footnote
I am aware that you can add such headers to your files ahead of time, but this removes the ability for me to choose "download" or "view online" after the fact.
You can dynamically add headers to response based on the URL, by passing extra parameters response-content-disposition=attachment; filename='mycustomFileName' as described in the s3 Get Obejct docs.
That, however, only works for the authenticated (time limited) URLS, otherwise, user will receive InvalidRequest error similar to the following:
<Error>
<Code>InvalidRequest</Code>
<Message>
Request specific response headers cannot be used for anonymous GET requests.
</Message>
<RequestId>C5066C8E8F647EA2</RequestId>
<HostId>
ik5oj4QfcJX+5+F/PdootFuq47bh6hLpDqhbeyWlw+AADvMPpOPio6eYwXW7Fnx+H/zpVBM7DbA=
</HostId>
</Error>
If you want this to work with a non-authenticated users, download tag might be an option. As it described in this example, you can specify user-friendly filename instead of hash:
<a href="/images/490/736d910771bc3ee2.jpeg" download="some_nice_image_name.jpg">
although that clearly helps scrapers to automatically annotate your content.
I'm trying to retrieve a picture from my file system after a good storage,(instead of putting it in the database I copy it to the disc and i put the path to the db)
I had store the picture to c:\images\ folder and supposing that the name the complete path is c:\images\mypic.jpg
when I try to retrieve it a set the img src attribute to <img src="c:\images\mypic.jps"> by using some java code
in the browser console I found this error Not allowed to load local resource: file:///C://images//mypic.jpg
Question: how to fix these path problem ? where Should I store the pictures ? and from where should I retrieve them ?
sending tag <img src="c:\images\mypic.jpg"> would cause user browser to access image from his filesystem.
if you have to store images in folder located in c:\images i would suggest to create an servlet like images.jsp, that as a parameter takes name of a file, then sets servlet response content to an image/jpg and then loads bytes of image from server location and put it to a response.
But what you use to create your application? is it pure servlet? Spring? JSF?
Here you can find some info about, how to do it.
In Chrome, you are supposed to be able to allow this capability with a runtime flag --allow-file-access-from-files
However, it looks like there is a problem with current versions of Chrome (37, 38) where this doesn't work unless you also pass the runtime flag --disable-web-security
That's an unacceptable solution, except perhaps as a short-term workaround, but it has been identified as an issue:
https://code.google.com/p/chromium/issues/detail?id=379206
You have Two alternatives :
First one is to create a ServletImageLoader that would take as a parameter an identifier of your image (the path of the image or a hash) that you will use inside the Servlet to handle your image, and it will print to the response stream the loaded image from the server.
Second one is to create a folder inside your application's ROOT folder and just save the relative path to your images.
Many browsers have changed their security policies to no longer allow reading data directly from file shares or even local resources. You need to either place the files somewhere that your tomcat instance can serve them up and put a "regular" http url in the html you generate. This can be accomplished by either providing a servlet which reads and provides the file putting the file into a directory where tomcat will serve it up as "static" content.
The concept of http location and disk location is different. What you need to do is:
for uploaded file summer.jpg
move that under a known (to the application) location to disk, e.g c:\images\summer.jpg
insert into db record representing the image with text summer.jpg
to display it use plain <img src="images/summer.jpg" />
you need something (e.g apache) that will serve c:\images\ under your application's /images. If you cannot do this then in step #2 you need to save somewhere under your web root, e.g c:\my-applications\demo-app\build\images
This error means you can not directly load data from file system because there are security issues behind this. The only solution that I know is create a web service to serve load files.
Here is a simple expressjs solution if you just want to run this app locally and security is not a concern:
On your server.js or app.js file, add the following:
app.use('/local-files', express.static('/'));
That will serve your ENTIRE root directory under /local-files. Needless to say this is a really bad idea if you're planning to deploy this app anywhere other than your local machine.
Now, you can simply do:
<img src="/local-files/images/mypic.jps"/>
note: I'm running macOS. If you're using Windows you may have to search and remove 'C:\' from the path string
Do not use ABSOLUTE PATH to refer to the name of the image for example: C:/xamp/www/Archivos/images/templatemo_image_02_opt_20160401-1244.jpg. You must use the reference to its location within webserver. For example using ../../Archivos/images/templatemo_image_02_opt_20160401-1244.jpg depending on where your process is running.
What I would like to achieve is to let AppEngine Image Service to generate a serving URL with file type as an extension.
For example, in my local, a serving url may look like:
http://0.0.0.0:8898/_ah/img/u4EXyF53eLVd8s5wHrE3tg
Is it possible to override it into the form of something like
http://0.0.0.0:8898/_ah/img/u4EXyF53eLVd8s5wHrE3tg/filename.jpg
The reason I need to do this is I am using Flowplayer and hope to add a splash image by using the playlist function. However, it looks like Flowplayer won't recognize image file without a proper image extension.
There are no "files" on the web, just resources. And every resource has an Url. The type of the resource is defined by Content-type header. There is no such thing as "file type as an extension" on the web.
Image service sets the Content-type properly so all standard clients should be able to display it.
Also, it seems that Flowplayer splash images are just a normal images displayed in HTML, so there should be no problem with this.
Can you display your Url normally in HTML?
Actually there is a workaround for the solution.
Basically, you can add a fake query parameter at the end of the url, and Google will treat them the same.
So, for instance, a url http://0.0.0.0:8898/_ah/img/u4EXyF53eLVd8s5wHrE3tg, you can make it
http://0.0.0.0:8898/_ah/img/u4EXyF53eLVd8s5wHrE3tg?.png or http://0.0.0.0:8898/_ah/img/u4EXyF53eLVd8s5wHrE3tg?.jpg
depending on your need. Google won't care about the query parameters, but I got what I need and my client software (Flowplayer) is happy about this new link.
I am writing a program in C that acts like a proxy server in a Linux system: Client asks it for a web page,
it sends an HTTP GET Request to a distant server, and it gets the servers response (web page), which is saved in an .html file.
Here goes my problem: Most web sites got some references to images, so when i try to view the .html file proxy created, the images don't appear.
I have searched a lot, but found nothing..Is there a way to write some code to GET images too?
Thank you in advance
You're going to have to write code that parses the HTML file you get back and looks for image references (img tags), then queries the server for those image files. This is what web browsers are doing under the hood.
You have an additional problem though which is that the image references in the HTML file are to the original server. I'm assuming that since they don't load for you the server that returned the original HTML isn't available. In that case after you get each image file you will need to give it a name on the local filesystem and then alter the reference in the HTML (programmatically) to point to your new local image name.
So for example:
<img src='http://example.com/image1.png'>
would become
<img src='localImage1.png'>
If you're querying arbitrary websites then you'll also find that there are various other files you'll need to do the same with like CSS files and JavaScript files. In general its hard to mirror arbitrary web pages accurately - browsers have complex object models they use to interpret web pages because they have to deal with things like CSS and Javascript and you may need to be able to 'run' all that dynamic code to even be sure what files to download from the server (e.g. JavaScript including other JavaScript etc).
I'm trying to send a PDF file from a WCF to silverlight client. PDF is generated by DevExpress XtraReports (in method XtraReport CreateReport(string reportTypeName, RootGenericReportParameterContainer reportInformation)).
Acually PDF is saved somewhere on clients computer after choosing save path in file save dialog - DevExpress takes care of everything - but I don't have a clue how to open the PDF in new tab in browser.
And here is another problem. Silverlight 4 has no access to local file system right? So information about local PDF location is useless. Maybe it would be better to save the PDF in WCF and send a link to it to the client - but how?
I would first question why you need to send the file to the Silverlight client. Get rid of that requirement and the solution becomes much simpler. Silverlight can provide a link that opens a new browser tab. That link would be handled by the web domain, processing it as an HttpHandler, generating the PDF file for the browser. Your PDF url doesn't have to reference a physical file, you can still generate it on request, handle querystring values, etc... Lots of different ways to do this.
Seems that the question isn't really about DevExpress or Silverlight - you're just looking to open a [document of some kind] in a new tab. Each browser natively handles things differently, and users can change tab handling to whatever they want. And (as you mentioned) once the user has downloaded the file, you no longer control it.
Your best bet (and the way I do it) is probably to have a link pointing to a handler/file using "target='_blank' " in the anchor tag on the webpage. From the server side, you would want to set the "Content-Disposition" header to "Inline" to indicate to the browser that the document should be displayed in place instead of downloaded ("Attachment").