Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Graticule extension #456

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ Only a curated list of the [vast amount](http://geoserver.org/release/stable/) o
- cog
- importer
- imagepyramid
- graticules

Advanced ACL system is available through the project [GeoServer ACL](https://github.com/geoserver/geoserver-acl) which offers the same capacities as GeoFence.

Expand Down
5 changes: 5 additions & 0 deletions src/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -652,6 +652,11 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.geoserver.community</groupId>
<artifactId>gs-graticule</artifactId>
<version>${gs.community.version}</version>
</dependency>
<dependency>
<!--- Override old aws version without support for "IAM roles for service accounts" -->
<groupId>software.amazon.awssdk</groupId>
Expand Down
4 changes: 4 additions & 0 deletions src/starters/wms-extensions/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@
<groupId>org.geoserver.extension</groupId>
<artifactId>gs-vectortiles</artifactId>
</dependency>
<dependency>
<groupId>org.geoserver.community</groupId>
<artifactId>gs-graticule</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/*
* (c) 2024 Open Source Geospatial Foundation - all rights reserved This code is licensed under the
* GPL 2.0 license, available at the root application directory.
*/

package org.geoserver.cloud.autoconfigure.wms.extensions;

import org.geoserver.cloud.config.factory.FilteringXmlBeanDefinitionReader;
import org.geoserver.platform.ModuleStatus;
import org.geoserver.platform.ModuleStatusImpl;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.ImportResource;

@Configuration
public class GraticuleConfiguration {

@Configuration
@ConditionalOnProperty(
prefix = "geoserver.wms.graticule",
name = "enabled",
matchIfMissing = true)
@ImportResource( //
reader = FilteringXmlBeanDefinitionReader.class, //
locations = {"jar:gs-graticule-.*!/applicationContext.xml"})
static class Enabled {}

@Configuration
@ConditionalOnProperty(
prefix = "geoserver.wms.graticule",
name = "enabled",
havingValue = "false")
static class Disabled {

@Bean
ModuleStatus graticuleDisabledModuleStatus() {
ModuleStatusImpl mod = new ModuleStatusImpl();
mod.setAvailable(true);
mod.setEnabled(false);
mod.setMessage(
"Graticule module disabled through config property geoserver.wms.graticule.enabled=false");
mod.setComponent("GeoServer Graticule");
mod.setModule("gs-graticule");
mod.setName("Graticule");
return mod;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
@Import(
value = {
CssStylingConfiguration.class,
GraticuleConfiguration.class,
MapBoxStylingConfiguration.class,
VectorTilesConfiguration.class
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
* css.enabled: true
* mapbox.enabled: true
* wms:
* graticule.enabled: true
* outputFormats:
* vectorTiles:
* mapbox.enabled: true
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
/*
* (c) 2024 Open Source Geospatial Foundation - all rights reserved This code is licensed under the
* GPL 2.0 license, available at the root application directory.
*/

package org.geoserver.cloud.autoconfigure.wms.extensions;

import static org.assertj.core.api.Assertions.assertThat;

import org.geoserver.platform.ModuleStatus;
import org.junit.jupiter.api.Test;
import org.springframework.boot.autoconfigure.AutoConfigurations;
import org.springframework.boot.test.context.runner.ApplicationContextRunner;

/**
* Test suite for {@link GraticuleConfiguration}
*
* @since 1.8
*/
class GraticuleConfigurationTest {

private ApplicationContextRunner contextRunner =
new ApplicationContextRunner()
.withConfiguration(AutoConfigurations.of(GraticuleConfiguration.class));

@Test
void enabledByDefault() {
testEnabled();
}

@Test
void enabledExplicitly() {
contextRunner = contextRunner.withPropertyValues("geoserver.wms.graticule.enabled=true");
testEnabled();
}

@Test
void disabled() {
contextRunner = contextRunner.withPropertyValues("geoserver.wms.graticule.enabled=false");
contextRunner
.run(
context ->
assertThat(context)
.getBean(
"graticuleDisabledModuleStatus", ModuleStatus.class)
.hasFieldOrPropertyWithValue("enabled", false))
.run(
context ->
assertThat(context)
.doesNotHaveBean(GraticuleConfiguration.Enabled.class))
.run(context -> assertThat(context).doesNotHaveBean("graticuleStorePanel"));
}

void testEnabled() {
contextRunner
.run(
context ->
assertThat(context)
.hasSingleBean(GraticuleConfiguration.Enabled.class))
.run(context -> assertThat(context).hasBean("graticuleStorePanel"))
.run(
context ->
assertThat(context)
.doesNotHaveBean("graticuleDisabledModuleStatus"));
}
}