-
Notifications
You must be signed in to change notification settings - Fork 329
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #562 from openlayers/client_side_raster_reprojection
Add client side raster reprojection support
- Loading branch information
Showing
6 changed files
with
155 additions
and
36 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
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,17 @@ | ||
<?xml version='1.0' encoding='UTF-8'?> | ||
<!DOCTYPE HTML> | ||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> | ||
<head> | ||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> | ||
<meta name="robots" content="index, all" /> | ||
<title>ol3cesium example</title> | ||
<link rel="stylesheet" href="../node_modules/openlayers/css/ol.css" type="text/css"> | ||
</head> | ||
<body> | ||
<div id="map" style="width:600px;height:400px;"></div> | ||
<input type="button" value="Enable/disable" onclick="javascript:ol3d.setEnabled(!ol3d.getEnabled())" /> | ||
<script src="inject_ol_cesium.js"></script> | ||
<script src="http://cdnjs.cloudflare.com/ajax/libs/proj4js/2.3.6/proj4.js" integrity="sha384-M06Wz+wp7/Hfi8Ks7DJtWxAFDqihGPCsNmjmWhnUQ8vBTSwd/1Os0uhf2hcYXt2t" crossorigin="anonymous"></script> | ||
<script src="reprojection.js"></script> | ||
</body> | ||
</html> |
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,59 @@ | ||
/* eslint googshift/valid-provide-and-module: 0 */ | ||
|
||
goog.provide('examples.reprojection'); | ||
|
||
goog.require('olcs.OLCesium'); | ||
goog.require('ol.View'); | ||
goog.require('ol.Map'); | ||
goog.require('ol.Attribution'); | ||
goog.require('ol.proj'); | ||
goog.require('ol.layer.Tile'); | ||
goog.require('ol.source.TileWMS'); | ||
goog.require('olcs.core.OLImageryProvider'); | ||
|
||
olcs.core.OLImageryProvider.ENABLE_RASTER_REPROJECTION = true; | ||
|
||
proj4.defs('EPSG:21781', '+proj=somerc +lat_0=46.95240555555556 ' + | ||
'+lon_0=7.439583333333333 +k_0=1 +x_0=600000 +y_0=200000 +ellps=bessel ' + | ||
'+towgs84=674.4,15.1,405.3,0,0,0,0 +units=m +no_defs'); | ||
const proj21781 = ol.proj.get('EPSG:21781'); | ||
proj21781.setExtent([485071.54, 75346.36, 828515.78, 299941.84]); | ||
|
||
const source = new ol.source.TileWMS({ | ||
attributions: [new ol.Attribution({ | ||
html: '© ' + | ||
'<a href="http://www.geo.admin.ch/internet/geoportal/' + | ||
'en/home.html">' + | ||
'Pixelmap 1:1000000 / geo.admin.ch</a>' | ||
})], | ||
crossOrigin: 'anonymous', | ||
params: { | ||
'LAYERS': 'ch.swisstopo.pixelkarte-farbe-pk1000.noscale', | ||
'FORMAT': 'image/jpeg' | ||
}, | ||
url: 'http://wms.geo.admin.ch/', | ||
projection: 'EPSG:21781' | ||
}); | ||
|
||
|
||
const ol2d = new ol.Map({ | ||
layers: [ | ||
new ol.layer.Tile({ | ||
source | ||
}) | ||
], | ||
target: 'map', | ||
view: new ol.View({ | ||
projection: 'EPSG:21781', | ||
center: ol.proj.transform([6.56273, 46.51781], 'EPSG:4326', 'EPSG:21781'), | ||
zoom: 6 | ||
}) | ||
}); | ||
|
||
const ol3d = new olcs.OLCesium({map: ol2d}); | ||
const scene = ol3d.getCesiumScene(); | ||
const terrainProvider = new Cesium.CesiumTerrainProvider({ | ||
url: '//assets.agi.com/stk-terrain/world' | ||
}); | ||
scene.terrainProvider = terrainProvider; | ||
ol3d.setEnabled(true); |
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