wms: debugging reprojection
This commit is contained in:
parent
9873b22c4c
commit
09d5a31a07
@ -13,13 +13,14 @@
|
|||||||
<script type="importmap">
|
<script type="importmap">
|
||||||
{
|
{
|
||||||
"imports": {
|
"imports": {
|
||||||
"three": "./js/vendor/three/build/three.module.js",
|
"three": "./js/vendor/three/build/three.module.js",
|
||||||
"@photo-sphere-viewer/core": "./js/vendor/@photo-sphere-viewer/core/index.module.js",
|
"@photo-sphere-viewer/core": "./js/vendor/@photo-sphere-viewer/core/index.module.js",
|
||||||
"@hotwired/stimulus": "./js/vendor/@hotwired/stimulus/dist/stimulus.js"
|
"@hotwired/stimulus": "./js/vendor/@hotwired/stimulus/dist/stimulus.js"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
<script src="js/vendor/leaflet/dist/leaflet.js"></script>
|
<script src="./js/vendor/proj4/dist/proj4.js"></script>
|
||||||
|
<script src="js/vendor/leaflet/dist/leaflet-src.js"></script>
|
||||||
<script src="js/vendor/leaflet.markercluster/dist/leaflet.markercluster.js"></script>
|
<script src="js/vendor/leaflet.markercluster/dist/leaflet.markercluster.js"></script>
|
||||||
<script src="js/vendor/@kalisio/leaflet-graphicscale/dist/Leaflet.GraphicScale.min.js"></script>
|
<script src="js/vendor/@kalisio/leaflet-graphicscale/dist/Leaflet.GraphicScale.min.js"></script>
|
||||||
<script src="js/index.js" type="module"></script>
|
<script src="js/index.js" type="module"></script>
|
||||||
|
@ -9,16 +9,15 @@ import { GisState } from "./state.js";
|
|||||||
const MAPBOX_TOKEN = 'pk.eyJ1Ijoibmljb3BhIiwiYSI6ImNseWNwZjJjbjFidzcya3BoYTU0bHg4NnkifQ.3036JnCXZTEMt6jVgMzVRw';
|
const MAPBOX_TOKEN = 'pk.eyJ1Ijoibmljb3BhIiwiYSI6ImNseWNwZjJjbjFidzcya3BoYTU0bHg4NnkifQ.3036JnCXZTEMt6jVgMzVRw';
|
||||||
const BASE_URL = location.href;
|
const BASE_URL = location.href;
|
||||||
|
|
||||||
let API_URL = '';
|
let API_URL = API_CONFIG.prod;
|
||||||
if (BASE_URL.includes('localhost')) {
|
|
||||||
|
if (!BASE_URL.includes('cnr.it')) {
|
||||||
API_URL = API_CONFIG.dev;
|
API_URL = API_CONFIG.dev;
|
||||||
} else {
|
|
||||||
API_URL = API_CONFIG.prod;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GisState.apiUrl = API_URL;
|
GisState.apiUrl = API_URL;
|
||||||
|
|
||||||
// Global leaflet
|
// Global leaflet and proj4
|
||||||
/**
|
/**
|
||||||
* @namespace GIS
|
* @namespace GIS
|
||||||
*/
|
*/
|
||||||
@ -124,6 +123,21 @@ GIS.initMap = async function (mapId, zoomLevel = this.INIT_ZOOM) {
|
|||||||
|
|
||||||
GisState.map = map;
|
GisState.map = map;
|
||||||
|
|
||||||
|
// DEBUG - Test reprojected WMS
|
||||||
|
const reprojectedWMSLayer = GIS.reprojectWMS();
|
||||||
|
const wmsLayer = new reprojectedWMSLayer(
|
||||||
|
'https://wms.cartografia.agenziaentrate.gov.it/inspire/wms/ows01.php?',
|
||||||
|
{
|
||||||
|
layers: 'fabbricati',
|
||||||
|
format: 'image/png',
|
||||||
|
transparent: true,
|
||||||
|
version: '1.1.1',
|
||||||
|
attribution: '© Agenzia Entrate',
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
wmsLayer.addTo(map);
|
||||||
|
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
@ -159,7 +173,7 @@ GIS.getImageOverlay = async function (imageId) {
|
|||||||
`/webgis/img/geo/${imageData.filename}`,
|
`/webgis/img/geo/${imageData.filename}`,
|
||||||
bounds,
|
bounds,
|
||||||
{
|
{
|
||||||
opacity: 0.8,
|
opacity: 0.6,
|
||||||
alt: `Immagine georeferita (${imageData.label})`,
|
alt: `Immagine georeferita (${imageData.label})`,
|
||||||
label: `geoimage:${imageData.id}:${imageData.label}`,
|
label: `geoimage:${imageData.id}:${imageData.label}`,
|
||||||
}
|
}
|
||||||
@ -558,6 +572,51 @@ GIS.featurePopup = function (layerName, feature) {
|
|||||||
|
|
||||||
return content[layerName];
|
return content[layerName];
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* Reproject WMS layer to map's CRS
|
||||||
|
* @todo Parametrize CRS?
|
||||||
|
* @returns {L.TileLayer.WMS}
|
||||||
|
*/
|
||||||
|
GIS.reprojectWMS = function (crs = 'EPSG:4258') {
|
||||||
|
// Define EPSG:4258
|
||||||
|
proj4.defs('EPSG:4258', "+proj=longlat +ellps=GRS80 +no_defs +type=crs");
|
||||||
|
|
||||||
|
const reprojectedWMSLayer = L.TileLayer.WMS.extend({
|
||||||
|
getTileUrl(tilePoint) {
|
||||||
|
const map = GisState.map;
|
||||||
|
const crs = map.options.crs;
|
||||||
|
const tileSize = this.getTileSize();
|
||||||
|
|
||||||
|
//const geoPoint = L.point(tilePoint.x, tilePoint.y);
|
||||||
|
const nwPoint = L.point(
|
||||||
|
tilePoint.x * tileSize.x,
|
||||||
|
tilePoint.y * tileSize.y,
|
||||||
|
)
|
||||||
|
const sePoint = nwPoint.add(L.point(tileSize));
|
||||||
|
|
||||||
|
const nw = crs.project(map.unproject(nwPoint, tilePoint.z));
|
||||||
|
const se = crs.project(map.unproject(sePoint, tilePoint.z));
|
||||||
|
|
||||||
|
const [minX, minY] = proj4('EPSG:4326', 'EPSG:4258', [nw.x, se.y]);
|
||||||
|
const [maxX, maxY] = proj4('EPSG:4326', 'EPSG:4258', [se.x, nw.y]);
|
||||||
|
|
||||||
|
const bbox = [minX, minY, maxX, maxY].join(',');
|
||||||
|
|
||||||
|
return this._url + L.Util.getParamString({
|
||||||
|
...this.wmsParams,
|
||||||
|
bbox,
|
||||||
|
width: tileSize.x,
|
||||||
|
height: tileSize.y,
|
||||||
|
srs: 'EPSG:4258'
|
||||||
|
},
|
||||||
|
this._url,
|
||||||
|
true
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return reprojectedWMSLayer;
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* Fetch data from API
|
* Fetch data from API
|
||||||
* @param {string} recordUri The URI to be appendend to the API's base URL
|
* @param {string} recordUri The URI to be appendend to the API's base URL
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
"fontawesome-free": "^1.0.4",
|
"fontawesome-free": "^1.0.4",
|
||||||
"leaflet": "^1.9.4",
|
"leaflet": "^1.9.4",
|
||||||
"leaflet.markercluster": "^1.5.3",
|
"leaflet.markercluster": "^1.5.3",
|
||||||
|
"proj4": "^2.9.4",
|
||||||
"spotlight.js": "^0.7.8"
|
"spotlight.js": "^0.7.8"
|
||||||
},
|
},
|
||||||
"devDependencies": {}
|
"devDependencies": {}
|
||||||
|
@ -39,6 +39,19 @@ leaflet@^1.9.4:
|
|||||||
resolved "https://registry.yarnpkg.com/leaflet/-/leaflet-1.9.4.tgz#23fae724e282fa25745aff82ca4d394748db7d8d"
|
resolved "https://registry.yarnpkg.com/leaflet/-/leaflet-1.9.4.tgz#23fae724e282fa25745aff82ca4d394748db7d8d"
|
||||||
integrity sha512-nxS1ynzJOmOlHp+iL3FyWqK89GtNL8U8rvlMOsQdTTssxZwCXh8N2NB3GDQOL+YR3XnWyZAxwQixURb+FA74PA==
|
integrity sha512-nxS1ynzJOmOlHp+iL3FyWqK89GtNL8U8rvlMOsQdTTssxZwCXh8N2NB3GDQOL+YR3XnWyZAxwQixURb+FA74PA==
|
||||||
|
|
||||||
|
mgrs@1.0.0:
|
||||||
|
version "1.0.0"
|
||||||
|
resolved "https://registry.yarnpkg.com/mgrs/-/mgrs-1.0.0.tgz#fb91588e78c90025672395cb40b25f7cd6ad1829"
|
||||||
|
integrity sha512-awNbTOqCxK1DBGjalK3xqWIstBZgN6fxsMSiXLs9/spqWkF2pAhb2rrYCFSsr1/tT7PhcDGjZndG8SWYn0byYA==
|
||||||
|
|
||||||
|
proj4@^2.9.4:
|
||||||
|
version "2.19.4"
|
||||||
|
resolved "https://registry.yarnpkg.com/proj4/-/proj4-2.19.4.tgz#38cf347309f523309ead94d565788de94f07098f"
|
||||||
|
integrity sha512-1l6JiJ2ZOzXIoo6k64diOQVOvHIF0IACMrHTaFHrEQmuo1tY1vb73mrWfTSyPH+muc0Lut4zuj5encvB1Ccuhg==
|
||||||
|
dependencies:
|
||||||
|
mgrs "1.0.0"
|
||||||
|
wkt-parser "^1.5.1"
|
||||||
|
|
||||||
spotlight.js@^0.7.8:
|
spotlight.js@^0.7.8:
|
||||||
version "0.7.8"
|
version "0.7.8"
|
||||||
resolved "https://registry.yarnpkg.com/spotlight.js/-/spotlight.js-0.7.8.tgz#0620371701508222d736e0658e8db3fbe9ddc53b"
|
resolved "https://registry.yarnpkg.com/spotlight.js/-/spotlight.js-0.7.8.tgz#0620371701508222d736e0658e8db3fbe9ddc53b"
|
||||||
@ -48,3 +61,8 @@ three@^0.169.0:
|
|||||||
version "0.169.0"
|
version "0.169.0"
|
||||||
resolved "https://registry.yarnpkg.com/three/-/three-0.169.0.tgz#4a62114988ad9728d73526d1f1de6760c56b4adc"
|
resolved "https://registry.yarnpkg.com/three/-/three-0.169.0.tgz#4a62114988ad9728d73526d1f1de6760c56b4adc"
|
||||||
integrity sha512-Ed906MA3dR4TS5riErd4QBsRGPcx+HBDX2O5yYE5GqJeFQTPU+M56Va/f/Oph9X7uZo3W3o4l2ZhBZ6f6qUv0w==
|
integrity sha512-Ed906MA3dR4TS5riErd4QBsRGPcx+HBDX2O5yYE5GqJeFQTPU+M56Va/f/Oph9X7uZo3W3o4l2ZhBZ6f6qUv0w==
|
||||||
|
|
||||||
|
wkt-parser@^1.5.1:
|
||||||
|
version "1.5.2"
|
||||||
|
resolved "https://registry.yarnpkg.com/wkt-parser/-/wkt-parser-1.5.2.tgz#a8eaf86ac2cc1d0a2e6a8082a930f5c7ebdb5771"
|
||||||
|
integrity sha512-1ZUiV1FTwSiSrgWzV9KXJuOF2BVW91KY/mau04BhnmgOdroRQea7Q0s5TVqwGLm0D2tZwObd/tBYXW49sSxp3Q==
|
||||||
|
Loading…
Reference in New Issue
Block a user