Closed GoogleCodeExporter closed 9 years ago
Tested with MORIS v. 0.35
Original comment by Aleda.Fr...@state.ma.us
on 18 Feb 2011 at 2:15
Original comment by Aleda.Fr...@state.ma.us
on 24 Feb 2011 at 7:11
Original comment by Aleda.Fr...@state.ma.us
on 24 Feb 2011 at 9:00
This works, but you have to edit the image to remove everything but the map.
Original comment by tom.spei...@gmail.com
on 11 Mar 2011 at 4:38
Do you have this installed?
http://docs.geoserver.org/stable/en/user/community/printing/
Sadly, the examples that are buried in that documentation don't work, so I
don't know if I want to use GeoServer's printing to work its way into the
right-click approach that you asked for. But if you have it installed, I might
want to play w/ it.
Original comment by cpl...@gmail.com
on 24 Aug 2011 at 6:37
I have heard of this. Unfortunately no we don't have that installed at the
moment. When we upgrade GeoServer next I can look into adding it, but it's not
something we can do quickly.
Original comment by Aleda.Fr...@state.ma.us
on 24 Aug 2011 at 7:09
I think the tricky part about creating an image for a user to take home will be
putting together the baselayer tiles. Assuming I could get that done, this
post seems to suggest that google would be off limits.
http://lists.osgeo.org/pipermail/openlayers-users/2011-July/021532.html
Should we force the user to only be allowed to print w/ the 'Blank' basemap
(projection)?
Original comment by cpl...@gmail.com
on 25 Aug 2011 at 7:01
COuld the Google satellite basemap be replaced with the MassGIS orthos as the
basemap when "save image as" initiated?
Original comment by daniel.s...@state.ma.us
on 25 Aug 2011 at 7:06
I would worry that would be too much of a shock to have both the basemap change
& the zoom level (possibly) change in order to print. If a user were in
non-blank and hit save/print, we should give alert them w/ an ok/cancel to
change to 'Blank'. That way they have a chance to realign / zoom if need be.
Original comment by cpl...@gmail.com
on 25 Aug 2011 at 7:12
Oh, I see what you mean . . . still stay in the google projection but add the
orthos underneath. That's interesting!
Original comment by cpl...@gmail.com
on 25 Aug 2011 at 7:19
If you try that use massgis:GISDATA.IMG_COQ2005
Because that is statewide.
2008 and 2009 each cover different parts of the state.
Original comment by Aleda.Fr...@state.ma.us
on 25 Aug 2011 at 7:21
That layer takes a very long time to draw and it often times out on me. Is
there another option?
Original comment by cpl...@gmail.com
on 26 Aug 2011 at 1:53
Unfortunately we are experiencing extreme slowness with our large raster layers
right now. It's an SDE problem - it happens in every client, not just
GeoServer. (for ex. ArcMap). We had good performance in the spring and it has
degraded. We had not time with the big server project to address it until now,
but Michael and I have supplied an ESRI consultant with a lot of diagnostic
info and we're hoping for some feedback soon (I'll ask right now for an
update).
I'm not sure that switching to another ortho is good idea anyway, it may not
show the same thing. I think we may have to tell the user to do a screenshot
or file/print instead if they want that image with Google... if we're not
allowed to save it. I looked again at the Terms of Service and I didn't see
any reference to this, but I'm not a lawyer and the OpenLayers post was pretty
specific. I could ask Saul, he might know.
Original comment by Aleda.Fr...@state.ma.us
on 26 Aug 2011 at 12:59
Bing?
Original comment by daniel.s...@state.ma.us
on 26 Aug 2011 at 1:01
No matter what base layer we use, I'd like to use the ImageMagick libraries to
glue the images together. Aleda, would the installation of
http://php.net/manual/en/book.imagick.php be a problem on your end?
Original comment by cpl...@gmail.com
on 26 Aug 2011 at 1:43
I have just submitted a save / print routine. I'm sure we'll need to tweak it.
In the new print.php, you'll need to define these to suit your setup:
$tmp_dir = '/tmp/';
$tmp_url = '/tmp/';
$tmp_dir is the system path to somewhere that is writable by the web user.
$tmp_url is how it can be accessed via URL.
This requires a PHP-friendly ImageMagick to work. See the previous post.
Committed revision 82.
Original comment by cpl...@gmail.com
on 26 Aug 2011 at 3:40
Re. the base layer . . . I'm only adding things to the map that are listed and
checked-on in the active data layers panel.
Original comment by cpl...@gmail.com
on 26 Aug 2011 at 3:50
Why do you need ImageMagick? What are you sticking together? Can't you just
request one large WMS image with all the layers listed? If you really need
this I'm going to have to figure out how to install it, I may need Saul's help.
Original comment by Aleda.Fr...@state.ma.us
on 26 Aug 2011 at 5:34
re: I'm only adding things to the map that are listed and checked-on in the
active data layers panel.
I would also only add to the map layers that are in scale. (is that happening
already? We can't test this until I install ImageMagick I guess. Charlton, do
you have a dev version up somewhere that we can hit?)
Original comment by Aleda.Fr...@state.ma.us
on 26 Aug 2011 at 5:35
ImageMagick allows me to add things like layer titles to each legend (which do
need to be stitched together). I suppose I could create 1 WMS link for all the
layers, but I'm not sure how I'd pass along all the styles / layer.
All the printing does is march through the layers that are turned on, even ones
that are out of scale. The bad-scale requests are passed along to geoserver,
and if a blank image comes back, it shouldn't make a difference. Or does
geoserver throw an error for out-of-scale requests? I can't remember if I'm
filtering from the map app or not.
Attached is what would have been sent to a printer -- a .pdf in this case.
The print page that pops up does not shrink the map.
Original comment by cpl...@gmail.com
on 26 Aug 2011 at 6:17
Attachments:
GeoServer will create a blank image for out-of-scale requests. For example,
here is a statewide request for 2005 Landuse:
http://giswebservices.massgis.state.ma.us/geoserver/wms?VERSION=1.1.1&REQUEST=Ge
tMap&SERVICE=WMS&LAYERS=massgis:GISDATA.LANDUSE2005_POLY&SRS=EPSG:26986&BBOX=338
61.264,777514.311,330846.094,959747.441&WIDTH=570&HEIGHT=435&FORMAT=image/png&ST
YLES=&TRANSPARENT=TRUE
Creating one WMS for all the layers - you just list the layers with ,
separating them, and the style too. For example here's a map with 3 layers:
http://giswebservices.massgis.state.ma.us/geoserver/wms?VERSION=1.1.1&REQUEST=Ge
tMap&SERVICE=WMS&LAYERS=massgis:GISDATA.TOWNS_POLYM,massgis:GISDATA.NAVTEQRDS_AR
C,massgis:GISDATA.NAVTEQRDS_ARC_INT&SRS=EPSG:26986&BBOX=232325.38526025353,89870
5.3447384972,238934.49648710093,903749.1401484597&WIDTH=570&HEIGHT=435&FORMAT=im
age/png&STYLES=Black_Lines,GISDATA.NAVTEQRDS_ARC::ForOrthos,GISDATA.NAVTEQRDS_AR
C_INT::Default&TRANSPARENT=TRUE
We would want titles for the legend. If ImageMagick is the only way I guess
I'll start reading the documentation...
Original comment by Aleda.Fr...@state.ma.us
on 26 Aug 2011 at 6:26
IM is not the only way. It's just something I'm familiar w/ and whipped out
the code pretty quickly. It's also something that I could install w/ apt in 1
step. Maybe you won't be so lucky. :(
Original comment by cpl...@gmail.com
on 26 Aug 2011 at 6:30
Well, it's a Linux machine. And maps is a production server which means
changes need to be scheduled. Let me read and check in with Saul though, maybe
by the time you come back from vacation we can get it in place..
Original comment by Aleda.Fr...@state.ma.us
on 26 Aug 2011 at 6:36
Saul gave instructions to the Linux Team.
He said:
The package is listed here:
https://rhn.redhat.com/rhn/software/packages/details/Overview.do?pid=592273
The Linux Team installed it onto our staging maps GISPRWAPP2:
They said:
[jchou@gisprwapp2 ~]$ rpm -qa | grep ImageMagick
ImageMagick-6.2.8.0-4.el5_5.3
I edited print.php to have it read this:
$tmp_dir = '/opt/massgis/wwwroot/temp/OL_MORIS_print/';
$tmp_url = '/opt/massgis/wwwroot/temp/OL_MORIS_print/';
OL_MORIS_print is next to the GeoServer_extract dir (with the same permissions).
(GeoServer_extract is where the zip files go).
I created a test file in that dir and I can see it in a web browser.
Now, if I use the Print button (with a Custom basemap for now), I get a very
quick flash of blue bar but nothing ends up in the OL_MORIS_print dir.
I get a JSON.parse error (attached).
JSON.parse: unexpected end of data
http://yui.yahooapis.com/combo?3.1.2/build/json/json-parse-min.js
Line 8
When I hover over I get this:
YUI.add("json-parse",function(Y){var
_JSON=(Y.config.win||{}).JSON,Native=(Object.prototype.toString.call(_JSON)==="[
object
JSON]"&&_JSON),useNative=!!Native,_UNICODE_EXCEPTIONS=/[\u0000\u00ad\u0600-\u060
4\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g
,_ESCAPES=/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,_VALUES=/"[^"\\\n\r]*"|true|fals
e|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,_BRACKETS=/(?:^|:|,)(?:\s*\[)+/g,_UNS
AFE=/[^\],:{}\s]/,_escapeException=function(c){return"\\u"+("0000"+(+(c.charCode
At(0))).toString(16)).slice(-4);},_revive=function(data,reviver){var
walk=function(o,key){var k,v,value=o[key];if(value&&typeof
value==="object"){for(k in
value){if(value.hasOwnProperty(k)){v=walk(value,k);if(v===undefined){delete
value[k];}else{value[k]=v;}}}}return reviver.call(o,key,value);};return typeof
reviver==="function"?walk({"":data},""):data;},_parse=function(s,reviver){if(typ
eof
s==="string"){s=s.replace(_UNICODE_EXCEPTIONS,_escapeException);if(!_UNSAFE.test
(s.replace(_ESCAPES,"@").replace(_VALUES,"]").replace(_BRACKETS,""))){return
_revive(eval("("+s+")"),reviver);}}throw new
SyntaxError("JSON.parse");};Y.namespace("JSON").parse=function(s,reviver){return
Native&&Y.JSON.useNativeParse?Native.parse(s,reviver):_parse(s,reviver);};functi
on workingNative(k,v){return
k==="ok"?true:v;}if(Native){try{useNative=(Native.parse('{"ok":false}',workingNa
tive)).ok;}catch(e){useNative=false;}}Y.JSON.useNativeParse=useNative;},"3.1.2")
;
Original comment by Aleda.Fr...@state.ma.us
on 30 Aug 2011 at 8:55
Attachments:
So, Charlton, as a follow up - does the error message mean anything to you? Is
there something I can do to figure out if ImageMagick is available to the app?
Original comment by Aleda.Fr...@state.ma.us
on 30 Aug 2011 at 8:57
NOTE: I tried the default 4 layers MORIS loads with in Custom.
I also tried with other layers - I always get the error.
Original comment by Aleda.Fr...@state.ma.us
on 30 Aug 2011 at 9:13
It's possible that ImageMagick may be installed, but perhaps not the PHP
component . . . or if it has, maybe Apache doesn't know about it.
If you create a new PHP file, say phpInfo.php w/ the contents:
<?php
phpinfo();
?>
It should have a block called 'imagick'. If it's not there, then the
installation didn't make it all the way to PHP & Apache. FYI Apache would
needed to have been bounced.
Original comment by cpl...@gmail.com
on 30 Aug 2011 at 11:54
OK, I tried stopping and starting Apache.
Then I did the phpInfo.php trick and I do not see a mention of ImageMagick.
There must be another step to do. I'll check with Saul.
I see in the instructions that "Imagemagick requires ghostscript to conduct PDF
operations." We'll have to see if we have/can get that too.
Original comment by Aleda.Fr...@state.ma.us
on 1 Sep 2011 at 1:26
Apparently we might also need a PECL extension.
Original comment by Aleda.Fr...@state.ma.us
on 1 Sep 2011 at 1:27
Saul looked and recommended and now I have asked the Linux Team to do this:
Could you please install on GISPRWAPP2 these items:
ImageMagick-devel
ghostscript-devel
and then run this as root:
pecl install imagick
Note - once this is working on GISPRWAPP2 (staging maps), I'll have to ask the
Linux Team to go through the install and these steps on maps.massgis.state.ma.us
Original comment by Aleda.Fr...@state.ma.us
on 8 Sep 2011 at 5:53
OK, the Linux Team has done this now and I stopped and started Apache, but the
print button still does not work on staging maps. I still get:
JSON.parse: unexpected end of data
http://yui.yahooapis.com/combo?3.1.2/build/json/json-parse-min.js
Line 8
It doesn't look like the phpInfo output has changed either.
Saul, do you want to screen share to look at GISPRWAPP2 and see what other
tweak might be required?
Original comment by Aleda.Fr...@state.ma.us
on 8 Sep 2011 at 6:37
Just asked the Linux Team to run "pecl install json".
Then I need to add a file in /etc/php.d like before for imagemagick (whatever
the name is in /usr/lib64/php/modules
Original comment by Aleda.Fr...@state.ma.us
on 9 Sep 2011 at 3:39
I have set the font to 'Helvetica'. See if that does the trick.
Original comment by cpl...@gmail.com
on 9 Sep 2011 at 4:59
OK, downloading again now
Original comment by Aleda.Fr...@state.ma.us
on 9 Sep 2011 at 5:00
OK, now I get this in the Apache error log:
[Fri Sep 09 13:18:16 2011] [error] [client 146.243.44.177] PHP Warning:
fopen(/opt/massgis/wwwroot/temp/OL_MORIS_print/1315588696.1608418836.png) [<a
href='function.fopen'>function.fopen</a>]: failed to open stream: Permission
denied in /opt/massgis/wwwroot/map_ol_mop/print.php on line 21, referer:
http://170.63.166.213/map_ol_mop/moris.php
[Fri Sep 09 13:18:16 2011] [error] [client 146.243.44.177] PHP Warning:
fwrite(): supplied argument is not a valid stream resource in
/opt/massgis/wwwroot/map_ol_mop/print.php on line 22, referer:
http://170.63.166.213/map_ol_mop/moris.php
[Fri Sep 09 13:18:16 2011] [error] [client 146.243.44.177] PHP Warning:
fclose(): supplied argument is not a valid stream resource in
/opt/massgis/wwwroot/map_ol_mop/print.php on line 23, referer:
http://170.63.166.213/map_ol_mop/moris.php
[Fri Sep 09 13:18:16 2011] [error] [client 146.243.44.177] PHP Fatal error:
Uncaught exception 'ImagickException' with message 'Unable to read the file:
/opt/massgis/wwwroot/temp/OL_MORIS_print/1315588696.1608418836.png' in
/opt/massgis/wwwroot/map_ol_mop/print.php:24\nStack trace:\n#0
/opt/massgis/wwwroot/map_ol_mop/print.php(24):
Imagick->__construct('/opt/massgis/ww...')\n#1 {main}\n thrown in
/opt/massgis/wwwroot/map_ol_mop/print.php on line 24, referer:
http://170.63.166.213/map_ol_mop/moris.php
Here are the permissions of the dir /opt/massgis/wwwroot/temp/OL_MORIS_print:
drwxrwxr-x 2 afreeman afreeman 4096 Aug 30 16:43 OL_MORIS_print
(I created a parallel dir to OL_MORIS_cache ...)
Is it something about the permissions of that dir?
Nothing ends up on OL_MORIS_print dir.
Original comment by Aleda.Fr...@state.ma.us
on 9 Sep 2011 at 5:21
It needs to be writable by your apache / web user.
Original comment by cpl...@gmail.com
on 9 Sep 2011 at 5:26
OK, when I compare it to GeoServer_extract which is writable by Apache because
the zips are making it in there:
drwxrwxr-x+ 3 afreeman afreeman 4096 Sep 9 13:29 GeoServer_extract
I see that there is a + at the end.
Maybe I need to add that.
Original comment by Aleda.Fr...@state.ma.us
on 9 Sep 2011 at 5:31
It works! I get an html file with 2 pngs in it. However, in that dir I get
even more pngs - looks like the 0,1,2 and 3 are legend bits that are compiled
into the legend image.
afreeman@gisprwapp2 OL_MORIS_print]$ ls -ltr
total 200
-rw-rw-r--+ 1 apache apache 649 Sep 9 13:37 1315589822.190878613.0.png
-rw-rw-r--+ 1 apache apache 227 Sep 9 13:37 1315589822.190878613.1.png
-rw-rw-r--+ 1 apache apache 227 Sep 9 13:37 1315589822.190878613.2.png
-rw-rw-r--+ 1 apache apache 134370 Sep 9 13:37 1315589822.190878613.png
-rw-rw-r--+ 1 apache apache 13849 Sep 9 13:37 1315589822.190878613.legend.png
-rw-rw-r--+ 1 apache apache 292 Sep 9 13:37 1315589822.190878613.html
-rw-rw-r--+ 1 apache apache 159 Sep 9 13:37 1315589822.190878613.3.png
I'll set ImageMagick up on maps and write a script on both servers (our dev
server and our prod server) to delete these files periodically (like for
GeoServer_extract).
Original comment by Aleda.Fr...@state.ma.us
on 9 Sep 2011 at 5:40
Are we treating #17 as a separate item in terms of having a title, north arrow
and scale bar?
Original comment by Aleda.Fr...@state.ma.us
on 9 Sep 2011 at 5:50
Oops - one thing I just noticed. On the html print page the legend bits are
upside down. (what's at the top should be at the bottom)
Original comment by Aleda.Fr...@state.ma.us
on 9 Sep 2011 at 6:03
If I'm Satellite vs. Custom it stays in "Assembling map" forever - is that
because we haven't figured out what to do about the Google images yet? Saul
agrees we can grab tiles to print.
Original comment by Aleda.Fr...@state.ma.us
on 9 Sep 2011 at 6:05
Re. comment 39. I wanted to wait for a thumbs-up on this approach before
continuing w/ the title, etc. Re. issue #17, specifically, that is what I
tried bringing up in an email . . . printing was not addressed in the SOW. I'm
not trying to split hairs, but I want to keep from overpromising and
underdelivering in terms of priorities.
If you agree that it didn't make the SOW cut, I'll run it by Eoin.
Original comment by cpl...@gmail.com
on 9 Sep 2011 at 6:22
Legend order has been fixed.
I can print OK from satellite mode (no background, of course). So google is an
official go? I was actually hoping it would not be. Computing what tiles to
fetch and positioning them will be very tricky.
Committed revision 91.
Original comment by cpl...@gmail.com
on 9 Sep 2011 at 6:41
No, Google is a "no". Saul read the Terms of Service and thinks that grabbing
tiles is not allowed. Sorry I mistyped above I meant to say "can't" not "can".
Original comment by Aleda.Fr...@state.ma.us
on 9 Sep 2011 at 6:43
OK, printing from Satellite just worked for me. All 3 basemaps work (I get the
overlays which is all I think we can do).
Original comment by Aleda.Fr...@state.ma.us
on 9 Sep 2011 at 6:45
Legend order is fixed, kind of.
If I have layer A on top on the map it comes out on the legend on top.
But then if I switch the order the legend doesn't do the same.
If I add layer C it does add layer C in the right place at first, but if I
rearrange it's order it's also not captured in subsequent legends.
Original comment by Aleda.Fr...@state.ma.us
on 9 Sep 2011 at 6:59
A couple of places in the code made incorrect assumption about layer ordering
when it came to listing them in a table (legends included). So try this fix.
Committed revision 94.
Original comment by cpl...@gmail.com
on 9 Sep 2011 at 7:18
Just redownloaded - I'm getting font errors again
[Fri Sep 09 15:29:54 2011] [error] [client 146.243.44.177] PHP Fatal error:
Uncaught exception 'ImagickDrawException' with message 'Font needs to be set
before annotating an image' in
/opt/massgis/wwwroot/map_ol_mop/print.php:46\nStack trace:\n#0
/opt/massgis/wwwroot/map_ol_mop/print.php(46): ImagickDraw->annotation(5, 15,
'Massachusetts M...')\n#1 {main}\n thrown in
/opt/massgis/wwwroot/map_ol_mop/print.php on line 46, referer:
http://170.63.166.213/map_ol_mop/moris.php
Original comment by Aleda.Fr...@state.ma.us
on 9 Sep 2011 at 7:31
Not sure I understand why. In that .php is the 'Helvetica' line there?
Original comment by cpl...@gmail.com
on 9 Sep 2011 at 7:36
sorry, my mistake. fixed now.
Original comment by Aleda.Fr...@state.ma.us
on 9 Sep 2011 at 7:43
Original issue reported on code.google.com by
Aleda.Fr...@state.ma.us
on 17 Feb 2011 at 5:01