Skip to content

Commit

Permalink
[GEOS-8259] Add WMTS RESTful API
Browse files Browse the repository at this point in the history
  • Loading branch information
Nuno Oliveira committed Oct 21, 2017
1 parent ac2e804 commit 2b9f5b6
Show file tree
Hide file tree
Showing 6 changed files with 219 additions and 20 deletions.
28 changes: 18 additions & 10 deletions doc/en/user/source/geowebcache/webadmin/defaults.rst
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,14 @@ Enables the Web Map Tiled Service (WMTS) endpoint in GeoWebCache. When this sett

When the service is disabled, calls to the capabilities document will return a ``Service is disabled`` message.

HTTP RESTful API is available through the existing GWC integration allowing clients to retrieve the following resources:

* capabilities document
* tile
* feature info

For more information read `GWC WMTS documentation <http://geowebcache.org/docs/current/services/wmts.html>`_.

Enable Data Security
~~~~~~~~~~~~~~~~~~~~

Expand Down Expand Up @@ -123,53 +131,53 @@ In Memory BlobStore Options
These options are used for enabling/disabling In Memory Caching for GeoWebCache. This feature can be used for saving GWC tiles directly in memory, for a fast data retrieval.

Enable
`````````````
``````
This parameter allows to enable or disable in memory caching. By default it is disabled.

Avoid Persistence
```````````````````
`````````````````
This parameter can be used in order to avoid to save any file in the file system, keeping all the GWC tiles only in memory. By default it is disabled.

Available Caches
```````````````````
````````````````
This parameter defines which Cache method can be used for In Memory Caching. By default the Guava Caching is used. Note that if a caching method
requires an immutable configuration at GeoServer startup like HazelCast, the *Hard Memory limit*, *Eviction Policy*, *Eviction Time* and *Concurrency Level*
parameters are disabled.

More informations on how to configure a new Cache object can be found in the GeoWebCache :ref:`gwc_config` page.

Cache Hard Memory limit (Mb)
```````````````````````````````````````
````````````````````````````
Parameter for configuring in memory cache size in MB.

Cache Eviction Policy
```````````````````````````````````````
`````````````````````
Parameter for configuring in memory cache eviction policy, it may be: LRU, LFU, EXPIRE_AFTER_WRITE, EXPIRE_AFTER_ACCESS, NULL

This eviction policies may not be supported by all caches implementations. For example, Guava Caching only supports the eviction policies: EXPIRE_AFTER_WRITE, EXPIRE_AFTER_ACCESS and NULL.

Note, only the eviction policies accepted by the selected cache will be shown on the UI.

Cache Eviction Time (in Seconds)
```````````````````````````````````````
````````````````````````````````
Paramter for configuring in memory cache eviction time. It is in Seconds.

.. note:: Note that this parameter is also used for configuring an internal thread which performs a periodical cache cleanup.

Cache Concurrency Level
```````````````````````````````````````
```````````````````````
Paramter for configuring in memory cache concurrency.

Clear In Memory Cache
```````````````````````````````````````
`````````````````````
Button for clearing all the tiles in the in-memory cache.

Cache Statistics
```````````````````````````````````````
````````````````
Various statistics parameters associated to the in memory cache.

Update Cache Statistics
```````````````````````````````````````
```````````````````````
Button for updating cache statistics seen above. The statistics are always related to the local cached entries, even in case of distributed in-memory caching

.. note:: Note that some Caches do not provide all the statistics parameters, in that case the user will only see *"Unavailable"* for those parameters.
Expand Down
5 changes: 4 additions & 1 deletion src/gwc/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,10 @@
<artifactId>javax.servlet-api</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
</dependency>

<!-- test dependencies -->
<dependency>
Expand Down Expand Up @@ -144,7 +148,6 @@
<groupId>org.geoserver</groupId>
<artifactId>gs-rest</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>
</dependencies>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,11 @@
import org.geoserver.gwc.dispatch.GwcServiceDispatcherCallback;
import org.geoserver.ows.Dispatcher;
import org.geoserver.ows.LocalWorkspace;
import org.geoserver.ows.Request;
import org.geoserver.ows.URLMangler;
import org.geoserver.ows.util.RequestUtils;
import org.geoserver.platform.GeoServerExtensions;
import org.geoserver.rest.RequestInfo;
import org.geoserver.wms.GetLegendGraphicRequest;
import org.geoserver.wms.GetMapRequest;
import org.geoserver.wms.WMS;
Expand Down Expand Up @@ -479,7 +481,7 @@ private Map<String, String> buildGetFeatureInfo(ConveyorTile convTile, BoundingB
wmsParams.put("FEATURE_COUNT", featureCount);
}

Map<String, String> fullParameters = convTile.getFullParameters();
Map<String, String> fullParameters = convTile.getFilteringParameters();
if (fullParameters.isEmpty()) {
fullParameters = getDefaultParameterFilters();
}
Expand Down Expand Up @@ -689,7 +691,7 @@ private Map<String, String> buildGetMap(final ConveyorTile tile, final MetaTile
params.put("TRANSPARENT", "true");
params.put(GWC_SEED_INTERCEPT_TOKEN, "true");

Map<String, String> filteredParams = tile.getFullParameters();
Map<String, String> filteredParams = tile.getFilteringParameters();
if (filteredParams.isEmpty()) {
filteredParams = getDefaultParameterFilters();
}
Expand Down Expand Up @@ -1185,7 +1187,7 @@ public void proxyRequest(ConveyorTile tile) throws GeoWebCacheException {
throw new GeoWebCacheException("Failed to cascade request", e);
}
}

@Override
public List<MetadataURL> getMetadataURLs() {
List<MetadataLinkInfo> gsMetadataLinks;
Expand All @@ -1205,7 +1207,7 @@ public List<MetadataURL> getMetadataURLs() {
}
}
}
String baseUrl = RequestUtils.baseURL(Dispatcher.REQUEST.get().getHttpRequest());
String baseUrl = baseUrl();
for(MetadataLinkInfo gsMetadata : gsMetadataLinks) {
String url = ResponseUtils.proxifyMetadataLink(gsMetadata, baseUrl);
try {
Expand Down Expand Up @@ -1257,11 +1259,12 @@ public Map<String, org.geowebcache.config.legends.LegendInfo> getLayerLegendsInf
org.geoserver.catalog.LegendInfo legendInfo = styleInfo.getLegend();
LegendInfoBuilder gwcLegendInfo = new LegendInfoBuilder();
if (legendInfo != null) {
String baseUrl = baseUrl();
gwcLegendInfo.withStyleName(styleInfo.getName())
.withWidth(legendInfo.getWidth())
.withHeight(legendInfo.getHeight())
.withFormat(legendInfo.getFormat())
.withCompleteUrl(buildURL(RequestUtils.baseURL(Dispatcher.REQUEST.get().getHttpRequest()),
.withCompleteUrl(buildURL(baseUrl,
legendInfo.getOnlineResource(), null, URLMangler.URLType.RESOURCE));
legends.put(styleInfo.prefixedName(), gwcLegendInfo.build());
} else {
Expand Down Expand Up @@ -1292,12 +1295,12 @@ public Map<String, org.geowebcache.config.legends.LegendInfo> getLayerLegendsInf
if (!styleInfo.getName().equals(layerInfo.getDefaultStyle().getName())) {
params.put("style", styleInfo.getName());
}
String baseUrl = baseUrl();
gwcLegendInfo.withStyleName(styleInfo.getName())
.withWidth(finalWidth)
.withHeight(finalHeight)
.withFormat(finalFormat)
.withCompleteUrl(buildURL(RequestUtils.baseURL(
Dispatcher.REQUEST.get().getHttpRequest()), "ows", params, URLMangler.URLType.SERVICE));
.withCompleteUrl(buildURL(baseUrl, "ows", params, URLMangler.URLType.SERVICE));
legends.put(styleInfo.prefixedName(), gwcLegendInfo.build());
}
}
Expand Down Expand Up @@ -1333,4 +1336,26 @@ void setLegendSample(LegendSample legendSample) {
void setWms(WMS wms) {
this.wms = wms;
}

/**
* Gets the base URL of the server, this value is retrieved from the current HTTP request.
* If no HTTP request is in progress NULL is returned. Only the use cases where an OWS
* service or a REST end-point was target are handled.
*/
private static String baseUrl() {
// let's see if a OWS service was targeted
Request owsRequest = Dispatcher.REQUEST.get();
if (owsRequest != null) {
// retrieve the base URL from the dispatcher request
return RequestUtils.baseURL(Dispatcher.REQUEST.get().getHttpRequest());
}
// let's see if a REST end-point was targeted
RequestInfo restRequest = RequestInfo.get();
if (restRequest != null) {
// retrieve the base URL from REST request
return restRequest.getBaseURL();
}
// no HTTP request is in progress
return null;
}
}
2 changes: 1 addition & 1 deletion src/gwc/src/main/resources/geowebcache-rest-context.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd">

<context:component-scan base-package="org.geowebcache.rest, org.geowebcache.diskquota.rest.controller" />
<context:component-scan base-package="org.geowebcache.rest, org.geowebcache.diskquota.rest.controller, org.geowebcache.service.wmts" />

</beans>

0 comments on commit 2b9f5b6

Please sign in to comment.