Smathermather's Weblog

Remote Sensing, GIS, Ecology, and Oddball Techniques

Posts Tagged ‘GeoWebCache’

Copying GWC Directory efficiently– Linux

Posted by smathermather on September 20, 2011

There has been discussion recently amongst some of the web cache builders of switching from file-based tile caching to SQLite or other database driven systems.  I haven’t kept close tabs– perhaps this is already implemented for some.  For GeoWebCache, we’re working with files (lots of them), so copying efficiently if we need to move our cache is important.  The tar command helps here, e.g. (run in GWC cache directory)

 tar cf - * | ( cd /path-to-target-dir/; tar xfp -) 

 

Posted in GeoWebCache | Tagged: | 2 Comments »

WMS vs. WMTS and GetFeatureInfo Requests

Posted by smathermather on July 12, 2011

How to get GetFeatureInfo requests to perform against GeoWebCache?  Just don’t.  I’m unclear as to whether it is problematic to do this because of a known bug or known implementation differences between the (unofficial) WMTS standard as implemented by OpenLayers and GeoServer, but in Googling for answers to how to perform a GetFeatureInfo request against GeoWebCache, I discovered a workaround (logged here for example).  The trick is to specify the url for the WMSGetFeatureInfo request as your WMS service, and layersUrls as your GeoWebCache, if that’s what you’re using for all your layers, like in my case.

Here is a control all fleshed out (thanks to my intern John for writing/modifying all but two of these lines… ):


var info = new OpenLayers.Control.WMSGetFeatureInfo({
	drillDown: false,
	queryVisible: true,
	url: GeoserverWMS,
	layerUrls: [GeowebcacheURL],
	eventListeners: {
		getfeatureinfo: function(event) {
			popup = new OpenLayers.Popup.FramedCloud(
				"popinfo",
				map.getLonLatFromPixel(event.xy),
				null,
				event.text,
				null,
				true
			);

			map.addPopup(popup, true);
		}
	}
});

map.addControl(info);

info.activate();

Posted in GeoServer, GeoWebCache | Tagged: , , , | 1 Comment »

GeoWebCache Configuration

Posted by smathermather on June 21, 2011

I’ve long delayed the configuration of GeoWebCache (GWC).  Automatic configuration within GeoServer’s deployment of it has been adequate until now.   Until now that I want to deploy tiles in something other than Google Mercator… .

I’ve developed a cache setup for Ohio State Plane North, Feet (epsg:3734).  At first it was a going to be a cache just for our service area, then I thought I’d include surrounding counties, and by the time I was done, I just decided that having a cache definition for the entire state plane ohio north coverage area made as much sense as anything else– it could make things easier to share and integrate as part of a regional standard for WMS-C, assuming I get buy-in from others… .  It could also be easily adapted for State Plane South.

The definition for a cache requires three things:  coordinate extent, resolutions (or equivalent), and tilesize (height and width).  For coordinate extent, I chose the extents of epsg:3734 as defined by spatialreference.org, and snapped them to the nearest 5000 foot interval:

1320000

160000

2525000

976000

Then, choosing resolution based on a series of measurable scales (1:600 or 1″=50′, 1:1200 or 1″=100′, etc) we get the resolutions:

918.6351706036746

229.65879265091866

58.20472440944883

45.931758530183735

29.102362204724415

22.047244094488192

14.220472440944883

11.023622047244096

8.818897637795276

8.267716535433072

5.511811023622048

4.409448818897638

2.204724409448819

1.1023622047244095

0.5511811023622047*

Finally, we’ll use a predictable tilesize:

<tileHeight>256</tileHeight>

<tileWidth>256</tileWidth>

Now we have a portable tilecache recommendation that should work for all of Northern Ohio:
GWC Example

Posted in GeoServer, GeoWebCache | Tagged: , , | 3 Comments »

Debian Configuration– Tomcat on Boot

Posted by smathermather on January 24, 2011

Start-up scripts in Debian Linux aren’t exactly straight forward for the un-initiated.  Actually, if memory serves me, they aren’t any more straight forward on Ubuntu Linux either, but such is heredity.

We are transitioning some of our GeoServer instances over to 64-bit Debian Linux.  In my test Ubuntu environment, I had a hack in place to force the Tomcat Java Servlet to launch on startup, but it was a hack and not very deep in understanding.  Here, I will go somewhat deeper.

So, why not just use a package manager to install Tomcat, thus bi-passing the need for setting up my own service?  GeoWebCache’s configuration guide discouraged me:

Due to licensing issues, many Linux distributions come with a variety of Java environments. Additionally, to minimize the chance of a security breach with default settings, most versions of Tomcat are configured to not allow access to the file system. Therefore, it is highly recommended to follow these instructions, even if you already have a servlet container set up.

Well, ok then.  I’ll roll my own.

Following the installation instructions for GeoWebCache is straightforward, but I have no interest in starting Tomcat manually, except when necessary.

Enter, the google:

I modified code from this source:

http://linux.derkeiler.com/Mailing-Lists/Debian/2008-12/msg00099.html

to get something that looks like this as my script to run a Tomcat6 startup shell:


#!/bin/sh
# /etc/init.d/tomcat6: start Tomcat6 server.


test -f /opt/apache-tomcat-6.0.30/bin/startup.sh || exit 0

case "$1" in

start) export JAVA_HOME=/opt/jre1.6.0_23/bin/
logger -t Tomcat6 "Starting Tomcat 6..."
exec /opt/apache-tomcat-6.0.30/bin/startup.sh | logger -t Tomcat6
;;

stop) export JAVA_HOME=/opt/jre1.6.0_23/bin/
logger -t Tomcat6 "Shutting down Tomcat 6..."
exec /opt/apache-tomcat-6.0.30/bin/shutdown.sh | logger -t Tomcat6
;;

*) echo "Usage: /etc/init.d/tomcat6 {start|stop}"
exit 2
;;
esac
exit 0

I still need to deploy this as a service. The first step is to sudo or su root and place this in my /etc/init.d directory.

sudo cp tomcat6.sh /etc/init.d/.

Now this needs loaded as a service.  Normal multi-user run levels for debian are 2-5.  0, 1 and 6 are “System Halt”, “Single User Mode”, and Reboot, so we set the start flag to run on multi-user logins, and to stop in the other run levels, like reboot.

update-rc.d apache2 start 99 2 3 4 5 . stop 99 0 1 6 .

Ah, now it works a charm.  FYI, I did my testing of the script while logged in as root, so I wouldn’t have to restart with every change.  I figured being logged in as root would simulate, pretty closely, the boot environment, relative to being an ordinary user.

Posted in Other | Tagged: , , , , , , | 3 Comments »