1 package fr.ifremer.dali.map.config;
2
3 import com.google.common.collect.ImmutableList;
4 import fr.ifremer.dali.config.DaliConfiguration;
5 import fr.ifremer.dali.map.GraticuleLayerDefinition;
6 import fr.ifremer.dali.map.MapLayerDefinition;
7 import fr.ifremer.dali.map.WMSMapConfiguration;
8 import org.geotools.data.ows.WMSCapabilities;
9 import org.geotools.data.wms.WebMapServer;
10 import org.geotools.geometry.jts.ReferencedEnvelope;
11 import org.geotools.ows.ServiceException;
12 import org.geotools.referencing.crs.DefaultGeographicCRS;
13
14 import java.io.IOException;
15 import java.net.URL;
16 import java.util.List;
17
18
19
20
21 public class SextantWMSMapConfiguration implements WMSMapConfiguration {
22
23
24 static final ReferencedEnvelope EUROPE_VIEW_ENVELOPE = new ReferencedEnvelope(-10, 13.3, 35, 55, DefaultGeographicCRS.WGS84);
25 static final ReferencedEnvelope FRANCE_VIEW_ENVELOPE = new ReferencedEnvelope(-8, 10, 41, 51, DefaultGeographicCRS.WGS84);
26 static final ReferencedEnvelope MARTINIQUE_VIEW_ENVELOPE = new ReferencedEnvelope(-62, -60, 14, 15.2, DefaultGeographicCRS.WGS84);
27 static final ReferencedEnvelope GUADELOUPE_VIEW_ENVELOPE = new ReferencedEnvelope(-62.5, -60.5, 15, 17, DefaultGeographicCRS.WGS84);
28 static final ReferencedEnvelope STMARTIN_VIEW_ENVELOPE = new ReferencedEnvelope(-63.5, -62, 17, 18.5, DefaultGeographicCRS.WGS84);
29 static final ReferencedEnvelope STPIERRE_VIEW_ENVELOPE = new ReferencedEnvelope(-56.8, -55.75, 46, 47.5, DefaultGeographicCRS.WGS84);
30 static final ReferencedEnvelope REUNION_VIEW_ENVELOPE = new ReferencedEnvelope(53.8, 57.2, -22.2, -19.9, DefaultGeographicCRS.WGS84);
31 static final ReferencedEnvelope MAYOTTE_VIEW_ENVELOPE = new ReferencedEnvelope(44.5, 46, -13.5, -12, DefaultGeographicCRS.WGS84);
32 static final ReferencedEnvelope GUYANE_VIEW_ENVELOPE = new ReferencedEnvelope(-54.7, -51.26, 3.8, 7, DefaultGeographicCRS.WGS84);
33 static final ReferencedEnvelope CALEDONIE_VIEW_ENVELOPE = new ReferencedEnvelope(155, 178, -31, -12, DefaultGeographicCRS.WGS84);
34
35
36 private static final List<MapLayerDefinition> WMS_SEXTANT_ORDERED_LAYER_LIST = ImmutableList.of(
37 new MapLayerDefinition("ETOPO1_BATHY_R", ReferencedEnvelope.EVERYTHING),
38 new MapLayerDefinition("continent_wgs84"),
39 new MapLayerDefinition("Europe", EUROPE_VIEW_ENVELOPE),
40 new MapLayerDefinition("france_metropolitaine", FRANCE_VIEW_ENVELOPE, false),
41 new MapLayerDefinition("SHOM_TCH_V1_MARTINIQUE_P", MARTINIQUE_VIEW_ENVELOPE),
42 new MapLayerDefinition("SHOM_TCH_V1_GUADELOUPE_P_v1", GUADELOUPE_VIEW_ENVELOPE),
43 new MapLayerDefinition("SHOM_TCH_V1_GUADELOUPE_stbarth_stmartin_P", STMARTIN_VIEW_ENVELOPE),
44 new MapLayerDefinition("SHOM_TCH_V1_STPIERRE_P", STPIERRE_VIEW_ENVELOPE),
45 new MapLayerDefinition("IFR_DOI_RUN_LIMITE_TERRE_MER_P", REUNION_VIEW_ENVELOPE),
46 new MapLayerDefinition("SHOM_TCH_V1_MAYOTTE_P", MAYOTTE_VIEW_ENVELOPE),
47 new MapLayerDefinition("SHOM_TCH_V1_GUYANE_P", GUYANE_VIEW_ENVELOPE),
48 new MapLayerDefinition("SHOM_TC_DITTT_NEW_CAL_P", CALEDONIE_VIEW_ENVELOPE),
49 new GraticuleLayerDefinition("graticule_4326"));
50
51
52 private WebMapServer wmsServer;
53 private WMSCapabilities wmsCapabilities;
54
55 @Override
56 public boolean isProgressiveRender() {
57 return false;
58 }
59
60 @Override
61 public String getUrl() {
62 return DaliConfiguration.getInstance().getMapSextantWMSUrl();
63 }
64
65 @Override
66 public WMSCapabilities getCapabilities() throws IOException, ServiceException {
67 if (wmsCapabilities == null) {
68 wmsCapabilities = getWebService().getCapabilities();
69 }
70
71 return wmsCapabilities;
72 }
73
74 @Override
75 public WebMapServer getWebService() throws IOException, ServiceException {
76 if (wmsServer == null) {
77 wmsServer = new WebMapServer(new URL(getUrl()));
78 }
79 return wmsServer;
80 }
81
82 @Override
83 public String getBaseLayerName() {
84 return null;
85 }
86
87 @Override
88 public List<MapLayerDefinition> getMapLayerDefinitions() {
89 return WMS_SEXTANT_ORDERED_LAYER_LIST;
90 }
91 }