-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[GEOS-8395] Add NSG WMTS profile community module
- Loading branch information
Nuno Oliveira
committed
Nov 15, 2017
1 parent
b19ba62
commit 2a15fc0
Showing
54 changed files
with
264 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> | ||
|
136 changes: 136 additions & 0 deletions
136
...ty/nsg-profiles/nsg-wmts-profile/src/main/java/org/geoserver/nsg/wmts/GridSetsLoader.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
src/community/nsg-profiles/nsg-wmts-profile/src/main/resources/applicationContext.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters