Skip to content

Commit

Permalink
[GEOS-8395] Add NSG WMTS profile community module
Browse files Browse the repository at this point in the history
  • Loading branch information
Nuno Oliveira committed Nov 15, 2017
1 parent b19ba62 commit 2a15fc0
Show file tree
Hide file tree
Showing 54 changed files with 264 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.geoserver</groupId>
<artifactId>community</artifactId>
<groupId>org.geoserver.community</groupId>
<artifactId>gs-nsg-profiles</artifactId>
<version>2.13-SNAPSHOT</version>
</parent>
<groupId>org.geoserver.community</groupId>
<artifactId>gs-nsg-profile</artifactId>
<artifactId>gs-nsg-wfs-profile</artifactId>
<packaging>jar</packaging>
<version>2.13-SNAPSHOT</version>
<name>NSG Profile</name>
<name>NSG WFS 2.0 Profile</name>
<dependencies>
<!-- geoserver dependencies -->
<dependency>
Expand Down Expand Up @@ -79,7 +79,7 @@
<dependency>
<groupId>org.geoserver.web</groupId>
<artifactId>gs-web-wfs</artifactId>
<version>2.13-SNAPSHOT</version>
<version>${project.version}</version>
</dependency>
</dependencies>
<build>
Expand Down
50 changes: 50 additions & 0 deletions src/community/nsg-profiles/nsg-wmts-profile/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.geoserver.community</groupId>
<artifactId>gs-nsg-profiles</artifactId>
<version>2.13-SNAPSHOT</version>
</parent>
<groupId>org.geoserver.community</groupId>
<artifactId>gs-nsg-wmts-profile</artifactId>
<packaging>jar</packaging>
<version>2.13-SNAPSHOT</version>
<name>NSG WMTS 1.0 Profile</name>
<dependencies>
<dependency>
<groupId>org.geoserver</groupId>
<artifactId>gs-gwc</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.geoserver</groupId>
<artifactId>gs-wms</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.geoserver</groupId>
<artifactId>gs-main</artifactId>
<classifier>tests</classifier>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.geoserver</groupId>
<artifactId>gs-wms</artifactId>
<classifier>tests</classifier>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-library</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
</project>

Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
/* (c) 2016 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.nsg.wmts;

import org.geoserver.gwc.GWC;
import org.geoserver.platform.ContextLoadedEvent;
import org.geowebcache.GeoWebCacheException;
import org.geowebcache.grid.BoundingBox;
import org.geowebcache.grid.GridSet;
import org.geowebcache.grid.GridSetFactory;
import org.geowebcache.grid.SRS;
import org.springframework.context.ApplicationListener;

/**
* Loads NSG WMTS profile mandatory grid sets: EPSG:3395, EPSG:5041 and EPSG:5042.
*/
public class GridSetsLoader implements ApplicationListener<ContextLoadedEvent> {

private static final String WORLD_MERCATOR_GRID_SET_NAME = "EPSG3395TiledMercator";
private static final SRS EPSG_3395 = decodeSrs("EPSG:3395");

private static final String EPSG_5041_GRID_SET_NAME = "EPSG:5041";
private static final SRS EPSG_5041 = decodeSrs("EPSG:5041");

private static final String EPSG_5042_GRID_SET_NAME = "EPSG:5042";
private static final SRS EPSG_5042 = decodeSrs("EPSG:5042");

@Override
public synchronized void onApplicationEvent(ContextLoadedEvent event) {

// world mercator 3395 grid set, resolutions
double[] resolutions = new double[]{
156543.03392804097, 78271.51696402048, 39135.75848201024, 19567.87924100512, 9783.93962050256, 4891.96981025128,
2445.98490512564, 1222.99245256282, 611.49622628141, 305.748113140705, 152.8740565703525, 76.43702828517625,
38.21851414258813, 19.109257071294063, 9.554628535647032, 4.777314267823516, 2.388657133911758, 1.194328566955879,
0.5971642834779395, 0.2985821417389697, 0.1492910708694849, 0.0746455354347424, 0.0373227677173712, 0.0186613838586856,
0.0093306919293428};
// world mercator 3395 grid set, scale names
String[] scaleNames = new String[]{
"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19",
"20", "21", "22", "23", "24"};
// world mercator 3395 grid set, bounding box
BoundingBox boundingBox = new BoundingBox(-2.0037508343E7, -2.0037508343E7, 2.0037508343E7, 2.0037508343E7);
// world mercator 3395 grid set, description
String description = "The World Mercator (EPSG::3395) well-known scale set is define in this " +
"NSG WMTS Implementation Interoperability Profile.";
// world mercator 3395 grid set, add grid set
addGridSet(WORLD_MERCATOR_GRID_SET_NAME, EPSG_3395, resolutions, scaleNames, boundingBox, description, 10.0);

// ups tiles EPSG::5041 grid set, resolutions
resolutions = new double[]{
26608.443104463353, 13304.221552231676, 6652.110776115838, 3326.055388057919, 1663.0276940289596, 831.5138470144798,
415.7569235072399, 207.87846175361994, 103.93923087680997, 51.969615438404986, 25.984807719202493, 12.992403859601247,
6.496201929800623, 3.2481009649003116, 1.6240504824501558, 0.8120252412250779, 0.406012620612539, 0.2030063103062695,
0.1015031551531347, 0.0507515775765674, 0.0253757887882837, 0.0126878943941418, 0.0063439471970709, 3.964966998169E-4,
1.982483499085E-4};
// ups tiles EPSG::5041 grid set, scale names
scaleNames = new String[]{
"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19",
"20", "21", "22", "23", "24"};
// ups tiles EPSG::5041 grid set, bounding box
boundingBox = new BoundingBox(-1405880.7173713096, -1405880.7173713096, 5405880.717371309, 5405880.717371309);
// ups tiles EPSG::5041 grid set, description
description = "WGS 84 / UPS North (E,N) is a projected CRS last revised on March 14, 2010 and is suitable for use " +
"in Northern hemisphere - north of 60°N onshore and offshore, including Arctic. WGS 84 / UPS North (E,N) " +
"uses the WGS 84 geographic 2D CRS as its base CRS and the Universal Polar Stereographic North (Polar " +
"Stereographic (variant A)) as its projection. WGS 84 / UPS North (E,N) is a CRS for Military mapping by " +
"NATO. It was defined by information from US National Geospatial-Intelligence Agency (NGA).";
// ups tiles EPSG::5041 grid set, add grid set
addGridSet(EPSG_5041_GRID_SET_NAME, EPSG_5041, resolutions, scaleNames, boundingBox, description, 10.0);

// ups tiles EPSG::5042 grid set, resolutions
resolutions = new double[]{
26608.443104463353, 13304.221552231676, 6652.110776115838, 3326.055388057919, 1663.0276940289596, 831.5138470144798,
415.7569235072399, 207.87846175361994, 103.93923087680997, 51.969615438404986, 25.984807719202493, 12.992403859601247,
6.496201929800623, 3.2481009649003116, 1.6240504824501558, 0.8120252412250779, 0.406012620612539, 0.2030063103062695,
0.1015031551531347, 0.0507515775765674, 0.0253757887882837, 0.0126878943941418, 0.0063439471970709, 3.964966998169E-4,
1.982483499085E-4};
// ups tiles EPSG::5042 grid set, scale names
scaleNames = new String[]{
"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19",
"20", "21", "22", "23", "24"};
// ups tiles EPSG::5042 grid set, bounding box
boundingBox = new BoundingBox(-1405880.7173713096, -1405880.7173713096, 5405880.717371309, 5405880.717371309);
// ups tiles EPSG::5042 grid set, description
description = "WGS 84 / UPS South (E,N) is a projected CRS last revised on 03/14/2010 and is suitable for use in " +
"Southern hemisphere - south of 60°S onshore and offshore - Antarctica. WGS 84 / UPS South (E,N) uses the " +
"WGS 84 geographic 2D CRS as its base CRS and the Universal Polar Stereographic South (Polar Stereographic " +
"(variant A)) as its projection. WGS 84 / UPS South (E,N) is a CRS for Military mapping by NATO. It was " +
"defined by information from US National Geospatial-Intelligence Agency (NGA).";
// ups tiles EPSG::5041 grid set, add grid set
addGridSet(EPSG_5042_GRID_SET_NAME, EPSG_5042, resolutions, scaleNames, boundingBox, description, 10.0);
}

/**
* Helper method that creates a grid set if he didn't exists and marks it a preconfigured one.
*/
private void addGridSet(String gridSetName, SRS srs, double[] resolutions, String[] scaleNames,
BoundingBox boundingBox, String description, double metersPerUnit) {
GWC gwc = GWC.get();
// this grid set should not be editable by the user
GridSet gridSet = gwc.getGridSetBroker().get(gridSetName);
if (gridSet != null) {
// this grid set already exists
return;
}
gwc.addEmbeddedGridSet(gridSetName);
// creating thee grid set
gridSet = GridSetFactory.createGridSet(gridSetName, srs, boundingBox, false, resolutions, null,
metersPerUnit, GridSetFactory.DEFAULT_PIXEL_SIZE_METER, scaleNames, 256, 256, false);
// set a proper description
gridSet.setDescription(description);
try {
// add the grid set
gwc.addGridSet(gridSet);
} catch (Exception exception) {
throw new RuntimeException(String.format(
"Error adding grid set '%s'.", gridSetName), exception);
}
}

/**
* Helper method that just takes care of decoding a certain SRS code taking care
* of the checked exceptions.
*/
private static SRS decodeSrs(String srsCode) {
try {
return SRS.getSRS(srsCode);
} catch (GeoWebCacheException exception) {
throw new RuntimeException(String.format(
"Error decoding SRS with code '%s'.", srsCode), exception);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd">
<bean id="nsgGridSetsLoaders" class="org.geoserver.nsg.wmts.GridSetsLoader"/>
</beans>
19 changes: 19 additions & 0 deletions src/community/nsg-profiles/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.geoserver</groupId>
<artifactId>community</artifactId>
<version>2.13-SNAPSHOT</version>
</parent>
<groupId>org.geoserver.community</groupId>
<artifactId>gs-nsg-profiles</artifactId>
<packaging>pom</packaging>
<version>2.13-SNAPSHOT</version>
<name>NSG Profiles</name>
<modules>
<module>nsg-wfs-profile</module>
<module>nsg-wmts-profile</module>
</modules>
</project>
16 changes: 12 additions & 4 deletions src/community/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@
<descriptor>release/ext-opensearch-eo.xml</descriptor>
<descriptor>release/ext-mbstyle.xml</descriptor>
<descriptor>release/ext-status-monitoring.xml</descriptor>
<descriptor>release/ext-nsg-wmts-profile.xml</descriptor>
</descriptors>
</configuration>
</plugin>
Expand Down Expand Up @@ -247,7 +248,8 @@
<module>mbstyle</module>
<module>s3-geotiff</module>
<module>status-monitoring</module>
<module>nsg-profile</module>
<module>nsg-profiles/nsg-wfs-profile</module>
<module>nsg-profiles/nsg-wmts-profile</module>
</modules>
</profile>
<profile>
Expand Down Expand Up @@ -550,10 +552,16 @@
</modules>
</profile>
<profile>
<id>nsg-profile</id>
<id>nsg-wfs-profile</id>
<modules>
<module>nsg-profile</module>
<module>nsg-profiles/nsg-wfs-profile</module>
</modules>
</profile>
</profiles>
<profile>
<id>nsg-wmts-profile</id>
<modules>
<module>nsg-profiles/nsg-wmts-profile</module>
</modules>
</profile>
</profiles>
</project>
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<assembly>
<id>nsg-profile</id>
<id>nsg-wfs-profile-plugin</id>
<formats>
<format>zip</format>
</formats>
Expand All @@ -9,7 +9,7 @@
<directory>release/target/dependency</directory>
<outputDirectory/>
<includes>
<include>gs-nsg-profile*.jar</include>
<include>gs-nsg-wfs-profile*.jar</include>
</includes>
</fileSet>
</fileSets>
Expand Down
16 changes: 16 additions & 0 deletions src/community/release/ext-nsg-wmts-profile.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<assembly>
<id>nsg-wmts-profile-plugin</id>
<formats>
<format>zip</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>
<fileSets>
<fileSet>
<directory>release/target/dependency</directory>
<outputDirectory/>
<includes>
<include>gs-nsg-wmts-profile*.jar</include>
</includes>
</fileSet>
</fileSets>
</assembly>
5 changes: 5 additions & 0 deletions src/community/release/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,11 @@
<artifactId>gs-status-monitoring</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.geoserver.community</groupId>
<artifactId>gs-nsg-wmts-profile</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
<build>
<plugins>
Expand Down
14 changes: 12 additions & 2 deletions src/web/app/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1561,11 +1561,21 @@
</dependencies>
</profile>
<profile>
<id>nsg-profile</id>
<id>nsg-wfs-profile</id>
<dependencies>
<dependency>
<groupId>org.geoserver.community</groupId>
<artifactId>gs-nsg-profile</artifactId>
<artifactId>gs-nsg-wfs-profile</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
</profile>
<profile>
<id>nsg-wmts-profile</id>
<dependencies>
<dependency>
<groupId>org.geoserver.community</groupId>
<artifactId>gs-nsg-wmts-profile</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
Expand Down

0 comments on commit 2a15fc0

Please sign in to comment.