// Documentation : http://randochartreuse.free.fr/mobac2.x/documentation/#bsh // Version : 16/10/2023 // Nom de la carte affiché dans MOBAC name = "Grand-Est, SHD1_GR_6_M_LVIB1C_38_0005_H"; // Nom du serveur String MyServer = "www.datagrandest.fr"; // MyUserAgent correspond à celui créé notamment avec la clé IGN // Par défaut, on trouve souvent MyUserAgent = "Mozilla/5.0 Gecko/20100101 Firefox/49.0"; String MyUserAgent = "Mozilla/5.0 Gecko/20100101 Firefox/49.0"; // MyReferer peut être demandé String MyReferer = ""; // MyFolder au format "dossier" ou "dossier1/dossier2/etc" String MyFolder = "geoserver/shd1/ows"; // Paramètres communs String MyService = "WMS"; // Service : le type de service (ici : “WMS”) String MyVersion = "1.3.0"; // Version : la Version du service utilisée (1.1.1 ou 1.3.0) String MyRequest = "GetMap"; // Request : la requête adressée au serveur (GetCapabilities, GetTile ou GetFeatureInfo) // Paramètres spécifiques GetMap String MyFormat = "image/png"; // Format : le format de sortie - type-mime - du fichier image (“image/png”, “image/jpg”, …) String MyLayers = "SHD1_GR_6_M_LVIB1C_38_0005_H"; // Layers : la ou les "nom1,nom2" ressources à utiliser pour calculer l’image. C’est le nom technique de la ressource qui est utilisé String MyStyles = ""; // Styles : le style de rendu des couches String MyCrs = "EPSG:3857"; // Crs : indique le système de coordonnées utilisé en WMS 1.3.0 (ex :900913, 3857) String MyWidth = "256"; // Width : largeur de l’image finale en pixels String MyHeight = "256"; // Height : hauteur de l’image finale en pixels String MyExeptions = "INIMAGE"; // Exeptions : Texte dans une image décrivant la nature de l’erreur String MyTransparent = "TRUE"; tileType = "png"; // Type d’image fourni par le serveur (png, jpg or gif) tileSize = 256; // Facultatif : Supprimer la ligne dans le doute minZoom = 2; // Facultatif : Zoom minimal souhaité (et/ou fourni par le serveur) maxZoom = 22; // Facultatif : Zoom maximal souhaité (et/ou fourni par le serveur) -> Maximum 22 pour Mobac import static Tools.*; String getTileUrl(int Zoom, int X, int Y) { if (Zoom < 7) { // gestion Zoom < 7, on prend une carte générique Google pour voir le monde entier return "http://mt0.google.com/vt/lyrs=m@176103410&hl=fr&s=Galileo&scale=1&z=" + Zoom + "&x=" + X + "&y=" + Y; }else{ // url2_de_test = "https://www.datagrandest.fr/geoserver/shd1/ows?SERVICE=WMS&LAYERS=SHD1_GR_6_M_LVIB1C_38_0005_H&EXCEPTIONS=XML&FORMAT=image%2Fpng&TRANSPARENT=TRUE&VERSION=1.3.0&REQUEST=GetMap&STYLES=&CRS=EPSG%3A3857&BBOX=797990.63480081,6023225.8883754,798626.01759844,6023861.2711731&WIDTH=256&HEIGHT=256"; return "https://" + MyServer + "/" + MyFolder + "?EXCEPTIONS=" + MyExeptions + "&TRANSPARENT=" + MyTransparent + "&LAYERS=" + MyLayers + "&STYLES=" + MyStyles + "&SERVICE=" + MyService + "&REQUEST=" + MyRequest + "&Version=" + MyVersion + "&FORMAT=" + MyFormat + "&CRS=" + MyCrs + "&BBOX=" + MercatorTileEdges(X,Y,Zoom) + "&WIDTH=" + MyWidth + "&HEIGHT=" + MyHeight; } } void addHeaders(java.net.HttpURLConnection conn) { conn.addRequestProperty("Referer",MyReferer); conn.addRequestProperty("User-Agent",MyUserAgent); } // // Fonction projection - https://wiki.openstreetmap.org/wiki/Slippy_map_tilenames // Simplifiée par par Manfred Wollny (wollny.m at freenet.de) // et Raimund Held (raimundheld at gmx.de) // Adaptée pour les Versions 1.1.1 par Nicolas PAOUR (http://randochartreuse.free.fr) // import java.lang.Math; static double tile2lon(int x, int z) { return x / Math.pow(2.0, z) * 360.0 - 180; } static double tile2lat(int y, int z) { double n = Math.PI - (2.0 * Math.PI * y) / Math.pow(2.0, z); return Math.toDegrees(Math.atan(Math.sinh(n))); } // Fonction projecion de WSG 1984 // https://en.wikipedia.org/wiki/World_Geodetic_System#WGS84 // Unité = degrés (coordonnées géographiques) if (MyVersion == "1.1.1") { // BBOX=xmin,ymin,xmax,ymax NON-FLIPPED axes en Version 1.1.1 String TileEdges(int x, int y, int zoom) { // "WGS 84" (EPSG:4326) return tile2lon(x ,zoom) + "," + // west (°) tile2lat(y + 1,zoom) + "," + // south (°) tile2lon(x + 1,zoom) + "," + // east (°) tile2lat(y ,zoom) ; // north (°) } } else { // BBOX=ymin,xmin,ymax,xmax FLIPPED axes en Version 1.3.0 String TileEdges(int x, int y, int zoom) { // "WGS 84" (EPSG:4326) return tile2lat(y + 1,zoom) + "," + // south (°) tile2lon(x ,zoom) + "," + // west (°) tile2lat(y ,zoom) + "," + // north (°) tile2lon(x + 1,zoom) ; // east (°) } } // Fonction projecion de Mercator // https://en.wikipedia.org/wiki/Web_Mercator_projection // R = 6378137.0 m -> P / 2 = 20037508.34 double lon2mercator(double l) { return (l * 20037508.34 / 180); } double lat2mercator(double l) { r = Math.toRadians(l); lat = Math.log((1 + Math.sin(r)) / (1 - Math.sin(r))); return (lat * 20037508.34 / 2 / Math.PI); } // Unité = mètre (coordonnées projetées) // BBOX=xmin,ymin,xmax,ymax NON-FLIPPED axes String MercatorTileEdges(int x, int y , int zoom) { // "WGS 84 / Pseudo-Mercator" (EPSG:3857) - "GOOGLE" (EPSG:900913) - "Popular Visualization CRS / Mercator" (EPSG:3785) return lon2mercator(tile2lon(x ,zoom)) + "," + // west (m) lat2mercator(tile2lat(y + 1,zoom)) + "," + // south (m) lon2mercator(tile2lon(x + 1,zoom)) + "," + // east (m) lat2mercator(tile2lat(y ,zoom)) ; // north (m) } // // FIN projection //