[Geoserver-users] Specify quantizer and caching options for a layer via Java API

[Sorry if a double post - my first message didn’t show up]

I’m adding data stores and layers in a WPS process. I’d like those layers to be tile-cached, non-antialiased and use the octree quantizer (non-default for this type of layer).

So two questions:

  1. Is there some way in the Java LayerInfo object (or some other catalog object) to force a layer to render as non-antialiased with the octree quantizer?

  2. How do I set attributes that appear on the Tile Caching tab of the layer admin pages, particularly the parameter filters, via the Java API?

I realize I can force the rendering options in WMS requests by adding this vendor param:
format_options=antialiasing:none;quantizer:octree

However, that causes caching misses without the appropriate GWC parameter filters set on the layer tile cache page (thus question #2).

Thanks in advance for any suggestions or pointers,

Eric Everman

CIDA - Center for Integrated Data Analytics
US Geological Survey
Middleton, WI
http://cida.usgs.gov/

Here is an example of my Java code adding a layer. How could I specify non-antialiased and the octree quantizer for this layer so that I don’t need to specify those options via WMS?

= = = = = = = = = = = = = = = = = = = = = = = =
= = = = = = = = = = = = = = = = = = = = = = = =

Map<String, Serializable> dsParams = new HashMap<>();
dsParams.put(“shapefile”, state.shapeFile.toURI().toURL());
dsParams.put(“dbase_file”, state.dbfFile.toURI().toURL());
dsParams.put(“namespace”, state.namespace.getURI());
dsParams.put(“dbase_field”, state.idFieldInDbf);
dsParams.put(“lastUsedMS”, System.currentTimeMillis());

DataStoreInfoImpl info = new DataStoreInfoImpl(catalog);

//A custom datastore created by Tom Kunicki
info.setType(DBASE_SHAPEFILE_JOIN_DATASTORE_NAME);
info.setWorkspace(state.workspace);
info.setEnabled(true);
info.setName(state.layerName);
info.setConnectionParameters(dsParams);

CatalogBuilder cb = new CatalogBuilder(catalog);
catalog.add(info);
DataAccess<? extends FeatureType, ? extends Feature> dataStore = info.getDataStore(new NullProgressListener());

List names = dataStore.getNames();
Name allData = names.get(0);

ProjectionPolicy srsHandling = ProjectionPolicy.FORCE_DECLARED;

cb.setWorkspace(info.getWorkspace());
cb.setStore(info);
FeatureTypeInfo fti = cb.buildFeatureType(dataStore.getFeatureSource(allData));
fti.setSRS(state.projectedSrs);
fti.setName(state.layerName);
fti.setTitle(state.layerName);
fti.setDescription(state.description);
fti.setAbstract(state.description);
fti.setProjectionPolicy(srsHandling);

cb.setupBounds(fti);
LayerInfo li = cb.buildLayer(fti);
if (state.defaultStyle != null) {
li.setDefaultStyle(state.defaultStyle);
}

catalog.add(fti);
catalog.add(li);

= = = = = = = = = = = = = = = = = = = = = = = =
= = = = = = = = = = = = = = = = = = = = = = = =

···

On Sun, Jan 18, 2015 at 3:25 PM, Everman, Eric <eeverman@anonymised.com> wrote:

[Sorry if a double post - my first message didn’t show up]

I’m adding data stores and layers in a WPS process. I’d like those layers to be tile-cached, non-antialiased and use the octree quantizer (non-default for this type of layer).

So two questions:

  1. Is there some way in the Java LayerInfo object (or some other catalog object) to force a layer to render as non-antialiased with the octree quantizer?

  2. How do I set attributes that appear on the Tile Caching tab of the layer admin pages, particularly the parameter filters, via the Java API?

I realize I can force the rendering options in WMS requests by adding this vendor param:
format_options=antialiasing:none;quantizer:octree

However, that causes caching misses without the appropriate GWC parameter filters set on the layer tile cache page (thus question #2).

Thanks in advance for any suggestions or pointers,

Eric Everman

CIDA - Center for Integrated Data Analytics
US Geological Survey
Middleton, WI
http://cida.usgs.gov/

Eric Everman
CIDA - Center for Integrated Data Analytics
US Geological Survey
Middleton, WI
651-269-4735
http://cida.usgs.gov/

I was able to figure out an answer to my question, so I’ll post it here for others to find.

For Question 1, it looks like there is no answer: There is no way to set any sort of layer attribute that will affect rendering options that are available via WMS requests. Looking at the org.geoserver.wms package, its pretty clear that the ONLY attributes that are considered when choosing rendering options like which quantizer to use are set by the incoming WMS parameters.

For Question 2, I found my solution. Working from a LayerInfo instance, its possible to work with a related GeoServerTileLayerInfo instance. Here is a chunk of example code.

The gwc reference was passed in during Spring bean construction via the gwcFacade reference, e.g.:

= = = = = = = = = = = = = = = = = = = = = = = =
= = = = = = = = = = = = = = = = = = = = = = = =

RegexParameterFilter filter = new RegexParameterFilter();
filter.setKey(“format_options");
filter.setRegex(“.*");
filter.setDefaultValue(“antialiasing:none;quantizer:octree;”);

LayerInfo li = catalog.getLayerByName(“MyLayerName");

GeoServerTileLayer tileLayer = gwc.getTileLayer(li);
GeoServerTileLayerInfo tileLayerInfo = tileLayer.getInfo();
tileLayerInfo.addParameterFilter(filter);

= = = = = = = = = = = = = = = = = = = = = = = =
= = = = = = = = = = = = = = = = = = = = = = = =

Cheers,

···

On Mon, Jan 19, 2015 at 3:59 PM, Everman, Eric <eeverman@anonymised.com> wrote:

Here is an example of my Java code adding a layer. How could I specify non-antialiased and the octree quantizer for this layer so that I don’t need to specify those options via WMS?

= = = = = = = = = = = = = = = = = = = = = = = =
= = = = = = = = = = = = = = = = = = = = = = = =

Map<String, Serializable> dsParams = new HashMap<>();
dsParams.put(“shapefile”, state.shapeFile.toURI().toURL());
dsParams.put(“dbase_file”, state.dbfFile.toURI().toURL());
dsParams.put(“namespace”, state.namespace.getURI());
dsParams.put(“dbase_field”, state.idFieldInDbf);
dsParams.put(“lastUsedMS”, System.currentTimeMillis());

DataStoreInfoImpl info = new DataStoreInfoImpl(catalog);

//A custom datastore created by Tom Kunicki
info.setType(DBASE_SHAPEFILE_JOIN_DATASTORE_NAME);
info.setWorkspace(state.workspace);
info.setEnabled(true);
info.setName(state.layerName);
info.setConnectionParameters(dsParams);

CatalogBuilder cb = new CatalogBuilder(catalog);
catalog.add(info);
DataAccess<? extends FeatureType, ? extends Feature> dataStore = info.getDataStore(new NullProgressListener());

List names = dataStore.getNames();
Name allData = names.get(0);

ProjectionPolicy srsHandling = ProjectionPolicy.FORCE_DECLARED;

cb.setWorkspace(info.getWorkspace());
cb.setStore(info);
FeatureTypeInfo fti = cb.buildFeatureType(dataStore.getFeatureSource(allData));
fti.setSRS(state.projectedSrs);
fti.setName(state.layerName);
fti.setTitle(state.layerName);
fti.setDescription(state.description);
fti.setAbstract(state.description);
fti.setProjectionPolicy(srsHandling);

cb.setupBounds(fti);
LayerInfo li = cb.buildLayer(fti);
if (state.defaultStyle != null) {
li.setDefaultStyle(state.defaultStyle);
}

catalog.add(fti);
catalog.add(li);

= = = = = = = = = = = = = = = = = = = = = = = =
= = = = = = = = = = = = = = = = = = = = = = = =

Eric Everman
CIDA - Center for Integrated Data Analytics
US Geological Survey
Middleton, WI
http://cida.usgs.gov/

Eric Everman
CIDA - Center for Integrated Data Analytics
US Geological Survey
Middleton, WI

http://cida.usgs.gov/

On Sun, Jan 18, 2015 at 3:25 PM, Everman, Eric <eeverman@anonymised.com> wrote:

[Sorry if a double post - my first message didn’t show up]

I’m adding data stores and layers in a WPS process. I’d like those layers to be tile-cached, non-antialiased and use the octree quantizer (non-default for this type of layer).

So two questions:

  1. Is there some way in the Java LayerInfo object (or some other catalog object) to force a layer to render as non-antialiased with the octree quantizer?

  2. How do I set attributes that appear on the Tile Caching tab of the layer admin pages, particularly the parameter filters, via the Java API?

I realize I can force the rendering options in WMS requests by adding this vendor param:
format_options=antialiasing:none;quantizer:octree

However, that causes caching misses without the appropriate GWC parameter filters set on the layer tile cache page (thus question #2).

Thanks in advance for any suggestions or pointers,

Eric Everman

CIDA - Center for Integrated Data Analytics
US Geological Survey
Middleton, WI
http://cida.usgs.gov/

On Thu, Jan 22, 2015 at 5:08 AM, Everman, Eric <eeverman@anonymised.com> wrote:

I was able to figure out an answer to my question, so I’ll post it here
for others to find.

For Question 1, it looks like there is no answer: There is no way to set
any sort of layer attribute that will affect rendering options that are
available via WMS requests. Looking at the org.geoserver.wms package, its
pretty clear that the ONLY attributes that are considered when choosing
rendering options like which quantizer to use are set by the incoming WMS
parameters.

For Question 2, I found my solution. Working from a LayerInfo instance,
its possible to work with a related GeoServerTileLayerInfo instance. Here
is a chunk of example code.

Thanks for sharing. Sorry for the lack of a quick response, we're using all
non working hours to finish the
2.7-beta release

Cheers
Andrea

--

GeoServer Professional Services from the experts! Visit
http://goo.gl/NWWaa2 for more information.

Ing. Andrea Aime
@geowolf
Technical Lead

GeoSolutions S.A.S.
Via Poggio alle Viti 1187
55054 Massarosa (LU)
Italy
phone: +39 0584 962313
fax: +39 0584 1660272
mob: +39 339 8844549

http://www.geo-solutions.it
http://twitter.com/geosolutions_it

*AVVERTENZE AI SENSI DEL D.Lgs. 196/2003*

Le informazioni contenute in questo messaggio di posta elettronica e/o
nel/i file/s allegato/i sono da considerarsi strettamente riservate. Il
loro utilizzo è consentito esclusivamente al destinatario del messaggio,
per le finalità indicate nel messaggio stesso. Qualora riceviate questo
messaggio senza esserne il destinatario, Vi preghiamo cortesemente di
darcene notizia via e-mail e di procedere alla distruzione del messaggio
stesso, cancellandolo dal Vostro sistema. Conservare il messaggio stesso,
divulgarlo anche in parte, distribuirlo ad altri soggetti, copiarlo, od
utilizzarlo per finalità diverse, costituisce comportamento contrario ai
principi dettati dal D.Lgs. 196/2003.

The information in this message and/or attachments, is intended solely for
the attention and use of the named addressee(s) and may be confidential or
proprietary in nature or covered by the provisions of privacy act
(Legislative Decree June, 30 2003, no.196 - Italy's New Data Protection
Code).Any use not in accord with its purpose, any disclosure, reproduction,
copying, distribution, or either dissemination, either whole or partial, is
strictly forbidden except previous formal approval of the named
addressee(s). If you are not the intended recipient, please contact
immediately the sender by telephone, fax or e-mail and delete the
information in this message that has been received in error. The sender
does not give any warranty or accept liability as the content, accuracy or
completeness of sent messages and accepts no responsibility for changes
made after they were sent or for other risks which arise as a result of
e-mail transmission, viruses, etc.

-------------------------------------------------------