ラベル WMTS の投稿を表示しています。 すべての投稿を表示
ラベル WMTS の投稿を表示しています。 すべての投稿を表示

2015年12月31日木曜日

2 - ol3.12ex 142b - WMTS Tile Transitions 2

「wmts-dimensions.js(2142-ol3ex.js)」は、マップを表示するための JavaScript ファイルです。

「2142-ol3ex.js」
// create the WMTS tile grid in the google projection
// google 投影法で WMTS タイルグリッドを作成します
var projection = ol.proj.get('EPSG:3857');
/** ol.proj.get(projectionLike)
 * Fetches a Projection object for the code specified.
 * 指定されたコードのプロジェクション・オブジェクトを取得。
 * (ol3 API)
 * projectionLike
 * Either a code string which is a combination of authority 
 * and identifier such as "EPSG:4326", or an existing p
 * rojection object, or undefined.
 * 「EPSG:4326」のように権限と識別子の組み合わせのコード文字列、
 * または、既存の投影オブジェクト、または、未定義のいずれか。
 */
var tileSizePixels = 256;
var tileSizeMtrs = ol.extent.getWidth(projection.getExtent()) / tileSizePixels;
/** ol.extent.getWidth(extent)
 * Return: Width.(ol3 API)
 */
/** getExtent()
 * Get the validity extent for this projection.
 * この投影の有効範囲を取得。(ol3 API)
 */
var matrixIds = [];
var resolutions = [];
for (var i = 0; i <= 14; i++) {
 matrixIds[i] = i;
 resolutions[i] = tileSizeMtrs / Math.pow(2, i);
 /** Math.pow(base, exponent)
  * base を exponent 乗した値、つまり、base^exponent の
  * 値を返します。
  * (MDN[https://developer.mozilla.org/ja/docs/Web/
  * JavaScript/Reference/Global_Objects/Math/pow])
  */
}
var tileGrid = new ol.tilegrid.WMTS({
/** ol.tilegrid.WMTS
 * Set the grid pattern for sources accessing WMTS 
 * tiled-image servers.
 * WMTSタイル画像サーバにアクセスするソースのグリッドパターン
 * を設定(ol3 API)
 */
 origin: ol.extent.getTopLeft(projection.getExtent()),
 /** origin:
  * The tile grid origin, i.e. where the x and y axes meet 
  * ([z, 0, 0]). Tile coordinates increase left to right 
  * and upwards. If not specified, extent or origins must 
  * be provided.
  * タイルグリッドの原点(origin)、すなわちx軸とy軸が交わる
  * 場所([Z、0、0])。タイル座標は左から右へと上方へ増加しま
  * す。指定しない場合、範囲または origins が提供されなければ
  * なりません。
  * (ol3 API[説明は Stable Only のチェックを外すと表示])
  */
 /** ol.extent.getTopLeft
  * Return: Bottom left coordinate.
  */
 resolutions: resolutions,
 /** resolutions:
  * Resolutions. The array index of each resolution needs 
  * to match the zoom level. This means that even if a 
  * minZoom is configured, the resolutions array will have 
  * a length of maxZoom + 1.
  * 解像度。各解像度の配列インデックスは、ズームレベルに一致す
  * る必要があります。これは minZoom が設定されている場合でも、
  * 解像度アレイは、maxZoom+1 の長さを有することを意味します。
  * (ol3 API[説明は Stable Only のチェックを外すと表示])
  */
 matrixIds: matrixIds
 /** matrixIds
  * matrix IDs. The length of this array needs to match 
  * the length of the resolutions array.
  * 行列のID。この配列の長さは、解像度配列の数と一致する必要
  * があります。
  * (ol3 API[説明は Stable Only のチェックを外すと表示])
  */
});
var scalgoToken = 'CC5BF28A7D96B320C7DFBFD1236B5BEB';
var wmtsSource = new ol.source.WMTS({
/** ol.source.WMTS
 * Layer source for tile data from WMTS servers.
 * WMTSサーバからタイルデータのレイヤソース。(ol3 API)
 */
 url: 'http://ts2.scalgo.com/global/wmts?token=' + scalgoToken,
 /** url:
  * A URL for the service. For the RESTful request 
  * encoding, this is a URL template. For KVP encoding, 
  * it is normal URL. A {?-?} template pattern, for 
  * example subdomain{a-f}.domain.com, may be used i
  * nstead of defining each one separately in the urls 
  * option.
  * サービスのURL。 RESTful リクエストエンコーディングに対
  * して、これはURLテンプレートです。 KVPエンコーディングに
  * 対して、通常のURLです。 {?- ?}テンプレートパターン、たと
  * えば subdomain{a-f}.domain.com は、urls オプション
  * でそれぞれを個別に定義する替りに使用することができます。
  * (ol3 API)
  */
 layer: 'hydrosheds:sea-levels',
 /** layer:
  * Layer name as advertised in the WMTS capabilities. 
  * Required.
  * WMTS capabilities でアドバタイズとしてのレイヤ名。必須。
  * (ol3 API)
  */
 format: 'image/png',
 /**format:
  * Image format. Default is image/jpeg.(ol3 API)
  */
 matrixSet: 'EPSG:3857',
 /** Matrix 
  * Matrix set. Required.(ol3 API)
  */
 attributions: [
  new ol.Attribution({
  /** ol.Attribution
   * An attribution for a layer source.
   * レイヤソースの属性(ol3 API)
   */
   html: '<a href="http://scalgo.com">SCALGO</a>'
  }),
  new ol.Attribution({
   html: '<a href="http://www.cgiar-csi.org/data/' +
    'srtm-90m-digital-elevation-database-v4-1">CGIAR-CSI SRTM</a>'
  })
 ],
 tileGrid: tileGrid,
 style: 'default',
 /** style:
  * Style name as advertised in the WMTS capabilities. 
  * Required.
  * WMTS  capabilities で advertised(?)としての style 
  * 名。(ol3 API)
  */
 dimensions: {
 /** dimensions:
  * Additional "dimensions" for tile requests. This is an 
  * object with properties named like the advertised WMTS 
  * dimensions.
  * タイル要求に対する追加の「dimensions」。これは、advertised 
  * WMTS dimensions のような名前のプロパティを持つオブジェクト
  * です。(ol3 API)
  */
  'threshold': 100
 }
});
var map = new ol.Map({
 target: 'map',
 view: new ol.View({
  projection: projection,
  center: [-9871995, 3566245],
  zoom: 6
 }),
 layers: [
  new ol.layer.Tile({
  /** ol.layer.Tile 
   * For layer sources that provide pre-rendered, tiled 
   * images in grids that are organized by zoom levels for 
   * specific resolutions. 
   * プリレンダリング(事前描画)を提供するレイヤソースのため
   * の、特定の解像度でのズームレベルによって編成されているグ
   * リッドのタイルイメージ。(ol3 API)
   */
   source: new ol.source.OSM()
   /** ol.source.OSM 
    * Layer source for the OpenStreetMap tile server.
    * OpenStreetMap タイルサーバのレイヤソース。(ol3 API)
    */
  }),
  new ol.layer.Tile({
   opacity: 0.5,
   source: wmtsSource
  })
 ]
});
var updateSourceDimension = function(source, sliderVal) {
 source.updateDimensions({'threshold': sliderVal});
 /** updateDimensions(dimensions)
  * Update the dimensions.
  * dimensions を更新します。
  * (ol3 API[説明は Stable Only のチェックを外すと表示])
  */
 document.getElementById('theinfo').innerHTML = sliderVal + ' meters';
};
updateSourceDimension(wmtsSource, 10);
document.getElementById('slider').addEventListener('input',
 function() {
/** EventTarget.addEventListener
 * addEventListener は、 1 つのイベントターゲットにイベント 
 * リスナーを1つ登録します。イベントターゲットは、ドキュメント
 * 上の単一のノード、ドキュメント自身、ウィンドウ、あるいは、
 * XMLHttpRequest です。
 *(MDN[https://developer.mozilla.org/ja/docs/Web/API/
 * EventTarget.addEventListener])
 */
 updateSourceDimension(wmtsSource, this.value);
});

2 - ol3.12ex 142a - WMTS Tile Transitions 1

「WMTS Tile Transitions (wmts-dimensions.html)」を参考に地図を表示してみます。
説明に次のようにあります。

Demonstrates smooth reloading of layers when changing a dimension continously. The demonstration layer is a global sea-level computation (flooding computation from SCALGO, underlying data from CGIAR-CSI SRTM) where cells that are flooded if the sea-level rises to more than x m are colored blue. The user selects the sea-level dimension using a slider.

継続的に寸法を変更する際にレイヤの円滑な再読み込みを示します。デモレイヤは、海面がxメータ以上に上昇すると氾濫するセルが青色に着色されるグローバル海面計算(CGIAR-CSI SRTM からのデータを基礎とする、SCALGOからの氾濫計算)です。ユーザは、スライダを使用して、海面の位置を選択します。


SRTM は、SRTM 90m Digital Elevation Database v4.1(http://www.cgiar-csi.org/data/srtm-90m-digital-elevation-database-v4-1)に次のようにあります。

The NASA Shuttle Radar Topographic Mission (SRTM) has provided digital elevation data (DEMs) for over 80% of the globe. This data is currently distributed free of charge by USGS and is available for download from the National Map Seamless Data Distribution System, or the USGS ftp site.

NASAのシャトルレーダ地形ミッション(SRTM)は、世界の80%以上のデジタル標高データ(DEM)を提供しています。このデータは、現在、USGSによって無償で配布され、ナショナルマップシームレスデータ提供システム、または USGS FTP サイトからダウンロードすることができます。


SCALGO(http://scalgo.com/) は、(http://scalgo.com/solutions/)に次のようにあります。

The power of SCALGOs unique technology for processing big large-area high-resolution terrain data sets is available through three different product lines. SCALGO Desktop is a set of software packages that allow for efficient processing of big terrain data sets on a standard workstation. Through the SCALGO Analysis product line you get access to advanced state-of-the-art hydrology and modeling products. Finally SCALGO Live is a comprehensive online solution based on the simple philosophy that it is not the terrain data itself—but what you can learn from it—that matters. SCALGO Live is the ultimate tool to extract, maintain, visualize and distribute knowledge based on your terrain data.

大きな大面積高解像度の地形データセットを処理するための SCALGO のークな技術の力は、3つの異なる製品ラインで入手することができます。 SCALGO Desktop は、標準的なワークステーション上で大きな地形データセットの効率的な処理を可能にするソフトウェア・パッケージのセットです。 SCALGO Analysis 製品ラインを通して、高度な最先端の水文学とモデリング製品へのアクセスを取得します。最後に、 SCALGO Live は、それは自体地形データではありません、しかし、それから学ぶことができる、もの、というシンプルな理念に基づいた総合的なオンラインソリューションです。 SCALGO Live は、地形データに基づいた知識を抽出、維持、視覚化、そして配布するための究極のツールです。


HTML ファイルの作成
a Eclipse のメニューの「ファイル」->「ファイルを開く」をクリックします。





b 「ファイルを開く」ウィンドウで、「user」->「mapsite」->「ol3proj」->「v3.12.1」->「examples」->「wmts-dimensions.html」をクリックして選択し、「OK」ボタンをクリックします。
同じように「wmts-dimensions.js」を開きます。





c メニューの「ファイル」->「新規」 -> 「ファイル」をクリックします。




d 「ファイル」ウィンドウで「ol3proj」をクリックして選択し、「ファイル名」を「2142-ol3ex.html」と入力し、「次へ」ボタンをクリックします。








e 「File Template」ウィンドウで「HTML 5 Template」をクリックして選択し、「OK」ボタンをクリックします。











f 「wmts-dimensions.html」の内容をコピーして「2142-ol3ex.html」に貼り付け、修正します。
g 同じように、新規に「2142-ol3ex.js」ファイルを作成し、「File Template」ウィンドウで「JavaScript Template」をクリックして選択し、「完了」ボタンをクリックして、「wmts-dimensions.js」の内容をコピーして貼り付け、修正します。「wmts-dimensions-require.js」も「2142-ol3ex-require.js」に貼り付けます。

「2142-ol3ex.html」
<!doctype html>
<html lang="en">
 <head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="chrome=1">
  <meta name="viewport" content="initial-scale=1.0, user-scalable=no, width=device-width">
  <link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css" type="text/css">
  <link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap-combined.min.css" type="text/css">
  <!--
  <link rel="stylesheet" href="../css/ol.css" type="text/css">
  <link rel="stylesheet" href="./resources/layout.css" type="text/css">

  <link rel="stylesheet" href="./resources/prism/prism.css" type="text/css">
  <script src="./resources/zeroclipboard/ZeroClipboard.min.js"></script>

  「resources」の位置が変わりました。
  -->
  <!-- ディレクトリ修正 -->
  <link rel="stylesheet" href="v3.12.1/css/ol.css" type="text/css">
  <link rel="stylesheet" href="v3.12.1/examples/resources/layout.css" type="text/css">

  <link rel="stylesheet" href="v3.12.1/examples/resources/prism/prism.css" type="text/css">
  <script src="v3.12.1/examples/resources/zeroclipboard/ZeroClipboard.min.js"></script>
  <script src="https://cdn.polyfill.io/v2/polyfill.min.js?features=fetch"></script>
  <title>WMTS Tile Transitions</title>
 </head>
 <body>
  <!-- 
  bootstrap-combined.min.css, ol.css, layout.css,
  CSSファイルで設定されたセレクタを使用。
  -->
  <header class="navbar" role="navigation">
   <div class="container" id="navbar-inner-container">
    <!--
    <a class="navbar-brand" href="./"><img src="./resources/logo-70x70.png"> OpenLayers 3 Examples</a>
    -->
    <!-- ディレクトリ修正 -->
    <a class="navbar-brand" href="v3.12.1/examples/"><img src="v3.12.1/examples/resources/logo-70x70.png"> OpenLayers 3 Examples</a>
   </div>
  </header>
  <div class="container-fluid">
   <div class="row-fluid">
    <div class="span12">
     <h4 id="title">WMTS Tile Transitions</h4>
     <div id="map" class="map"></div>
     <label>
      Sea-level
      <input id="slider" type="range" value="10" max="100" min="-1">
     </label>
     <span id="theinfo"></span>
    </div>
   </div>
   <div class="row-fluid">
    <div class="span12">
     <p id="shortdesc">Example of smooth tile transitions when 
      changing the dimension of a WMTS layer. </p>
     <div id="docs"><p>Demonstrates smooth reloading 
      of layers when changing a dimension continously. The 
      demonstration layer is a global sea-level computation 
      (flooding computation from 
      <a href="http://scalgo.com">SCALGO</a>, 
      underlying data from 
      <a href="http://www.cgiar-csi.org/data/
      srtm-90m-digital-elevation-database-v4-1">
      CGIAR-CSI SRTM</a>) where cells that are flooded 
      if the sea-level rises to more than <em>x</em> 
      m are colored blue. The user selects the sea-level 
      dimension using a slider.</p>
     </div>
     <div id="api-links">Related API documentation: 
      <ul class="inline">
       <li>
        <!-- <a href="../apidoc/ol.Attribution.html" title="API documentation for ol.Attribution">ol.Attribution</a> -->
        <a href="v3.12.1/apidoc/ol.Attribution.html" title="API documentation for ol.Attribution">ol.Attribution</a>
       </li>,
       <li>
        <!-- <a href="../apidoc/ol.Map.html" title="API documentation for ol.Map">ol.Map</a> -->
        <a href="v3.12.1/apidoc/ol.Map.html" title="API documentation for ol.Map">ol.Map</a>
       </li>,
       <li>
        <!-- <a href="../apidoc/ol.View.html" title="API documentation for ol.View">ol.View</a> -->
        <a href="v3.12.1/apidoc/ol.View.html" title="API documentation for ol.View">ol.View</a>
       </li>,
       <li>
        <!-- <a href="../apidoc/ol.extent.html" title="API documentation for ol.extent">ol.extent</a> -->
        <a href="v3.12.1/apidoc/ol.extent.html" title="API documentation for ol.extent">ol.extent</a>
       </li>,
       <li>
        <!-- <a href="../apidoc/ol.layer.Tile.html" title="API documentation for ol.layer.Tile">ol.layer.Tile</a> -->
        <a href="v3.12.1/apidoc/ol.layer.Tile.html" title="API documentation for ol.layer.Tile">ol.layer.Tile</a>
       </li>,
       <li>
        <!-- <a href="../apidoc/ol.proj.html" title="API documentation for ol.proj">ol.proj</a> -->
        <a href="v3.12.1/apidoc/ol.proj.html" title="API documentation for ol.proj">ol.proj</a>
       </li>,
       <li>
        <!-- <a href="../apidoc/ol.source.OSM.html" title="API documentation for ol.source.OSM">ol.source.OSM</a> -->
        <a href="v3.12.1/apidoc/ol.source.OSM.html" title="API documentation for ol.source.OSM">ol.source.OSM</a>
       </li>,
       <li>
        <!-- <a href="../apidoc/ol.source.WMTS.html" title="API documentation for ol.source.WMTS">ol.source.WMTS</a> -->
        <a href="v3.12.1/apidoc/ol.source.WMTS.html" title="API documentation for ol.source.WMTS">ol.source.WMTS</a>
       </li>,
       <li>
        <!-- <a href="../apidoc/ol.tilegrid.WMTS.html" title="API documentation for ol.tilegrid.WMTS">ol.tilegrid.WMTS</a> -->
        <a href="v3.12.1/apidoc/ol.tilegrid.WMTS.html" title="API documentation for ol.tilegrid.WMTS">ol.tilegrid.WMTS</a>
       </li>
      </ui>
     </div>
    </div>
   </div>
   <div class="row-fluid">
    <div id="source-controls">
     <a id="copy-button">
      <i class="fa fa-clipboard"></i> Copy
     </a>
     <a id="jsfiddle-button">
      <i class="fa fa-jsfiddle"></i> Edit
     </a>
    </div>
    <form method="POST" id="jsfiddle-form" target="_blank" action="http://jsfiddle.net/api/post/jquery/1.11.0/">
    <textarea class="hidden" name="js">
// --- 省略 ---
&lt;/html&gt;</code></pre>
   </div>
  </div>
  <!--
  <script src="./resources/common.js"></script>
  <script src="./resources/prism/prism.min.js"></script>
  -->
  <!-- ディレクトリ修正
   CommonJS と
   prism.js
 -->
  <script src="v3.12.1/examples/resources/common.js"></script>
  <script src="v3.12.1/examples/resources/prism/prism.min.js"></script>
  <!-- 
  <script src="loader.js?id=wmts-dimensions"></script>
  -->
  <!-- ファイル修正 -->  <!-- ディレクトリ修正 -->
  <script src="loader.js?id=2142-ol3ex"></script>
  </body>
</html>


COMMONJS は

COMMONJS
http://webpack.github.io/docs/commonjs.html

に、次のようにあります。

The CommonJS group defined a module format to solve JavaScript scope issues by making sure each module is executed in its own namespace.
This is achieved by forcing modules to explicitly export those variables it wants to expose to the “universe”, and also by defining those other modules required to properly work.
To achieve this CommonJS give you two tools:
the require() function, which allows to import a given module into the current scope.
the module object, which allows to export something from the current scope.

CommonJSグループは、それ自身の名前空間内で実行されている各モジュールを確認することによって、JavaScriptのスコープ問題を解決するためのモジュールフォーマットを定義しました。
これは、それが「universe(?)」に公開したい変数を明示的にエクスポートするモジュールを強制することによって、同じように、正常に動作するのに必要な他のモジュールを定義することによって、達成されます。
この CommonJS を達成するために2つのツールを与えます:
require()関数、指定したモジュールを現在のスコープにインポートすることができます。
モジュールオブジェクト、現在のスコープからエクスポートすることができます。


Prism は、

Prism
http://prismjs.com/

に、次のようにあります。

Prism is a lightweight, extensible syntax highlighter, built with modern web standards in mind. It’s a spin-off from Dabblet and is tested there daily by thousands.
Prismは、最新のWeb標準に構築されたことを考慮し軽量で拡張可能なシンタックスハイライトです。それは Dabblet からスピンオフで、何千人も日々そこで試験されています。


ZeroClipboard は

ZeroClipboard v2.x
http://zeroclipboard.org/

に、次のようにあります。

The ZeroClipboard library provides an easy way to copy text to the clipboard using an invisible Adobe Flash movie and a JavaScript interface.
ZeroClipboard ライブラリは、見えない Adobe Flash ムービーとJavaScript のインターフェイスを使用してテキストをクリップボードにコピーする簡単な方法を提供します。

Debian 8 では動作しませんでした。ボタンを右クリックしたときに flash のコンテキストメニューが表示されると動作しています。

2015年7月9日木曜日

2 - ol3.7ex 124b - IGN WMTS example 2

「wmts-ign.js(2124-ol3ex.js)」は、マップを表示するための JavaScript ファイルです。

「2124-ol3ex.js」
var map = new ol.Map({
 target: 'map',
 controls: ol.control.defaults({
 /** controls
  * Controls initially added to the map. 
  * If not specified, ol.control.defaults() is used.
  * 初期設定で、マップに追加されたコントロール。
  * 明示されていなければ、ol.control.defaults() が使用されます。
  * (ol3 API)
  */
 /** ol.control.defaults()
  * デフォルトでは、マップに含まコントロールのセット。
  * 特に設定しない限り、これは、以下の各コントロールの
  * インスタンスを含むコレクションを返します。(ol3 API)
  * ol.control.Zoom, ol.control.Rotate, ol.control.Attribution
  */
  attributionOptions: /** @type {olx.control.AttributionOptions} */ ({
  /** @type 
   * 値のタイプ(型)の説明 - 式などで表示
   * (@use JSDoc[http://usejsdoc.org/]より)
   */
   collapsible: false // 折りたたみ
  })
 }),
 view: new ol.View({
  zoom: 5,
  center: ol.proj.transform([5, 45], 'EPSG:4326', 'EPSG:3857')
  /** ol.proj.transform(coordinate, source, destination)
   * Transforms a coordinate from source projection to 
   * destination projection. This returns a new coordinate 
   * (and does not modify the original).
   * ソース投影から変換先投影に座標変換します。これは、新しい座標
   * を返します(オリジナルを変更しません)。(ol3 API)
   */
 })
});
var resolutions = [];
var matrixIds = [];
var proj3857 = ol.proj.get('EPSG:3857');
/** ol.proj.get(projectionLike)
 * Fetches a Projection object for the code specified.
 * 指定されたコードのプロジェクション·オブジェクトを取得
 * (ol3 API)
 */
var maxResolution = ol.extent.getWidth(proj3857.getExtent()) / 256;
/** ol.extent.getWidth(extent)
 * Return: Width.(ol3 API)
 */
/** getExtent()
 * Get the validity extent for this projection.
 * この投影の有効範囲を取得。(ol3 API)
 */
for (var i = 0; i < 18; i++) {
 matrixIds[i] = i.toString();
 /** Number.prototype.toString( [ radix ] )
  * 指定された Number オブジェクトを表す 文字列を返します。
  * radix: 数値を表すために使われる基数を指定する、2 から 
  * 36 までの整数。省略したときは 10。
  * MDN([https://developer.mozilla.org/ja/docs/Web/
  * JavaScript/Reference/Global_Objects/Number/toString])
  */
 resolutions[i] = maxResolution / Math.pow(2, i);
 /** Math.pow(base, exponent)
  * base を exponent 乗した値、つまり、base^exponent の値を返
  * します。
  * (MDN[https://developer.mozilla.org/ja/docs/Web/
  * JavaScript/Reference/Global_Objects/Math/pow])
  */
}
var tileGrid = new ol.tilegrid.WMTS({
 /** ol.tilegrid.WMTS
  * Set the grid pattern for sources accessing WMTS 
  * tiled-image servers.
  * WMTSタイル画像サーバにアクセスするソースのグリッドパターン
  * を設定(ol3 API)
  */
 origin: [-20037508, 20037508],
 resolutions: resolutions,
 matrixIds: matrixIds
});
// API key valid for 'openlayers.org' and 'localhost'.
// API キーは、'openlayers.org' と 'localhost' に対して有効です。
// Expiration date is 06/29/2018.
var key = '2mqbg0z6cx7ube8gsou10nrt';
var ign_source = new ol.source.WMTS({
 url: 'http://wxs.ign.fr/' + key + '/wmts',
 layer: 'GEOGRAPHICALGRIDSYSTEMS.MAPS',
 matrixSet: 'PM',
 format: 'image/jpeg',
 projection: 'EPSG:3857',
 tileGrid: tileGrid,
 style: 'normal',
 attributions: [new ol.Attribution({
 /** ol.Attribution
  * An attribution for a layer source.
  * レイヤソースの属性(ol3 API)
  */
  html: '<a href="http://www.geoportail.fr/" target="_blank">' +
        '<img src="http://api.ign.fr/geoportail/api/js/latest/' +
        'theme/geoportal/img/logo_gp.gif"></a>'
 })]
});
var ign = new ol.layer.Tile({
/** ol.layer.Tile 
 * For layer sources that provide pre-rendered, tiled 
 * images in grids that are organized by zoom levels for 
 * specific resolutions. 
 * リレンダリング(事前描画)を提供するレイヤソースのための、
 * 特定の解像度でのズームレベルによって編成されているグリッドの
 * タイルイメージ。(ol3 API)
 */
 source: ign_source
});

map.addLayer(ign);
 
 

2 - ol3.7ex 124a - IGN WMTS example 1

「IGN WMTS example (wmts-ign.html)」を参考に地図を表示してみます。
説明に次のようにあります。

In this example an IGN WMTS layer is displayed. For more information on IGN's WMTS service see the IGN Géoportail API web page and Descriptif technique des web services du Géoportail (french).
この例では、IGN WMTS レイヤが表示されます。 IGN の WMTS サービスの詳細については IGN Géoportail API の Web ページと Descriptif technique des web services du Géoportail (フランス語)を参照してください。


HTML ファイルの作成
a Eclipse のメニューの「ファイル」->「ファイルを開く」をクリックします。





b 「ファイルを開く」ウィンドウで、「user」->「mapsite」->「ol3proj」->「v3.7.0」->「examples」->「wmts-ign.html」をクリックして選択し、「OK」ボタンをクリックします。
同じように「wmts-ign.js」を開きます。





c メニューの「ファイル」->「新規」 -> 「ファイル」をクリックします。



d 「ファイル」ウィンドウで「ol3proj」をクリックして選択し、「ファイル名」を「2124-ol3ex.html」と入力し、「次へ」ボタンをクリックします。








e 「File Template」ウィンドウで「HTML 5 Template」をクリックして選択し、「OK」ボタンをクリックします。











f 「wmts-ign.html」の内容をコピーして「2124-ol3ex.html」に貼り付け、修正します。
g 同じように、新規に「2124-ol3ex.js」ファイルを作成し、「File Template」ウィンドウで「JavaScript Template」をクリックして選択し、「完了」ボタンをクリックして、「wmts-ign.js」の内容をコピーして貼り付け、修正します。「wmts-ign-require.js」も「2124-ol3ex-require.js」に貼り付けます。

「2124-ol3ex.html」
<!doctype html>
<html lang="en">
 <head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="chrome=1">
  <meta name="viewport" content="initial-scale=1.0, user-scalable=no, width=device-width">
  <link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap-combined.min.css" type="text/css">
  <!--
  <link rel="stylesheet" href="../css/ol.css" type="text/css">
  <link rel="stylesheet" href="./resources/layout.css" type="text/css">

  <link rel="stylesheet" href="./resources/prism/prism.css" type="text/css">
  <script src="./resources/zeroclipboard/ZeroClipboard.min.js"></script>
  「resources」の位置が変わりました。
  -->
  <!-- ディレクトリ修正 -->
  <link rel="stylesheet" href="v3.7.0/css/ol.css" type="text/css">
  <link rel="stylesheet" href="v3.7.0/examples/resources/layout.css" type="text/css">

  <link rel="stylesheet" href="v3.7.0/examples/resources/prism/prism.css" type="text/css">
  <script src="v3.7.0/examples/resources/zeroclipboard/ZeroClipboard.min.js"></script>
  <title>IGN WMTS example</title>
 </head>
 <body>
  <!-- 
  bootstrap-combined.min.css, ol.css, layout.css,
  CSSファイルで設定されたセレクタを使用。
  -->
  <header class="navbar" role="navigation">
   <div class="container" id="navbar-inner-container">
    <!--
    <a class="navbar-brand" href="./"><img src="./resources/logo-70x70.png"> OpenLayers 3 Examples</a>
    -->
    <!-- ディレクトリ修正 -->
    <a class="navbar-brand" href="v3.7.0/examples/"><img src="v3.7.0/examples/resources/logo-70x70.png"> OpenLayers 3 Examples</a>
   </div>
  </header>
  <div class="container-fluid">
   <div class="row-fluid">
    <div class="span12">
     <div id="map" class="map"></div>
    </div>
   </div>
   <div class="row-fluid">
    <div class="span12">
     <h4 id="title">-fluid example</h4>
     <p id="shortdesc"&gtdisplaying IGN (France) WMTS 
      layers. </p>
     <div id="docs">
      <p>In this example an IGN WMTS layer is displayed. 
      For more information on IGN's WMTS service see the 
      <a href="http://professionnels.ign.fr/api-sig">IGN Géoportail API web page </a> 
      and <a href="http://www.geoportail.gouv.fr/depot/api/cgu/DT_APIGeoportail.pdf"> 
      Descriptif technique des web services du Géoportail</a> (french).</p>
     </div>
     <div id="tags">french, ign, geoportail, wmts
     </div>
     <div id="api-links">Related API documentation: 
      <ul class="inline">
       <li>
        <!--<a href="../apidoc/ol.Attribution.html" title="API documentation for ol.Attribution">ol.Attribution>/a> -->
        <a href="v3.7.0/apidoc/ol.Attribution.html" title="API documentation for ol.Attribution">ol.Attribution</a>
       </li>,
       <li>
        <!--<a href="../apidoc/ol.Map.html" title="API documentation for ol.Map">ol.Map>/a> -->
        <a href="v3.7.0/apidoc/ol.Map.html" title="API documentation for ol.Map">ol.Map</a>
       </li>,
       <li>
        <!-- <a href="../apidoc/ol.View.html" title="API documentation for ol.View">ol.View>/a> -->
        <a href="v3.7.0/apidoc/ol.View.html" title="API documentation for ol.View">ol.View</a>
       </li>,
       <li>
        <!-- <a href="../apidoc/ol.control.html" title="API documentation for ol.control">ol.control>/a> -->
        <a href="v3.7.0/apidoc/ol.control.html" title="API documentation for ol.control">ol.control</a>
       </li>,
       <li>
        <!-- <a href="../apidoc/ol.extent.html" title="API documentation for ol.extent">ol.extent>/a> -->
        <a href="v3.7.0/apidoc/ol.extent.html" title="API documentation for ol.extent">ol.extent</a>
       </li>,
       <li>
        <!-- <a href="../apidoc/ol.layer.Tile.html" title="API documentation for ol.layer.Tile">ol.layer.Tile>/a> -->
        <a href="v3.7.0/apidoc/ol.layer.Tile.html" title="API documentation for ol.layer.Tile">ol.layer.Tile</a>
       </li>,
       <li>
        <!-- <a href="../apidoc/ol.proj.html" title="API documentation for ol.proj">ol.proj>/a> -->
        <a href="v3.7.0/apidoc/ol.proj.html" title="API documentation for ol.proj">ol.proj</a>
       </li>,
       <li>
        <!-- <a href="../apidoc/ol.source.WMTS.html" title="API documentation for ol.source.WMTS">ol.source.WMTS>/a> -->
        <a href="v3.7.0/apidoc/ol.source.WMTS.html" title="API documentation for ol.source.WMTS">ol.source.WMTS</a>
       </li>,
       <li>
        <!-- <a href="../apidoc/ol.tilegrid.WMTS.html" title="API documentation for ol.tilegrid.WMTS">ol.tilegrid.WMTS>/a> -->
        <a href="v3.7.0/apidoc/ol.tilegrid.WMTS.html" title="API documentation for ol.tilegrid.WMTS">ol.tilegrid.WMTS</a>
       </li>
      </ui>
     </div>
   </div>
  </div>
  <div class="row-fluid">
   <hr>
   <form method="POST" target="_blank" action="http://jsfiddle.net/api/post/jquery/1.11.0/">
    <input type="button" class="btn btn-info" id="copy-button" value="Copy example code">
    <input type="submit" class="btn btn-primary" id="jsfiddle-button" value="Create JSFiddle">
    <textarea class="hidden" name="js">
// --- 省略 ---
&lt;/html&gt;</code></pre>
    </div>
   </div>
  </div>
  <script src="http://code.jquery.com/jquery-1.11.2.min.js"></script>
  <script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
  <!--
  <script src="./resources/common.js"></script>
  <script src="./resources/prism/prism.min.js"></script>
  -->
  <!-- ディレクトリ修正
   CommonJS と
   prism.js
 -->
  <script src="v3.7.0/examples/resources/common.js"></script>
  <script src="v3.7.0/examples/resources/prism/prism.min.js"></script>
  <!-- 
  <script src="loader.js?id=wmts-ign"></script>
  -->
  <!-- ファイル修正 -->  <!-- ディレクトリ修正 -->
  <script src="loader.js?id=2124-ol3ex"></script>
  </body>
</html>


COMMONJS は

COMMONJS
http://webpack.github.io/docs/commonjs.html

に、次のようにあります。

The CommonJS group defined a module format to solve JavaScript scope issues by making sure each module is executed in its own namespace.
This is achieved by forcing modules to explicitly export those variables it wants to expose to the “universe”, and also by defining those other modules required to properly work.
To achieve this CommonJS give you two tools:
the require() function, which allows to import a given module into the current scope.
the module object, which allows to export something from the current scope.

CommonJSグループは、それ自身の名前空間内で実行されている各モジュールを確認することによって、JavaScriptのスコープ問題を解決するためのモジュールフォーマットを定義しました。
これは、それが「universe(?)」に公開したい変数を明示的にエクスポートするモジュールを強制することによって、同じように、正常に動作するのに必要な他のモジュールを定義することによって、達成されます。
この CommonJS を達成するために2つのツールを与えます:
require()関数、指定したモジュールを現在のスコープにインポートすることができます。
モジュールオブジェクト、現在のスコープからエクスポートすることができます。


Prism は、

Prism
http://prismjs.com/

に、次のようにあります。

Prism is a lightweight, extensible syntax highlighter, built with modern web standards in mind. It’s a spin-off from Dabblet and is tested there daily by thousands.
Prismは、最新のWeb標準に構築されたことを考慮し軽量で拡張可能なシンタックスハイライトです。それは Dabblet からスピンオフで、何千人も日々そこで試験されています。


ZeroClipboard は

ZeroClipboard v2.x
http://zeroclipboard.org/

に、次のようにあります。

The ZeroClipboard library provides an easy way to copy text to the clipboard using an invisible Adobe Flash movie and a JavaScript interface.
ZeroClipboard ライブラリは、見えない Adobe Flash ムービーとJavaScript のインターフェイスを使用してテキストをクリップボードにコピーする簡単な方法を提供します。

Debian 8 では動作しませんでした。ボタンを右クリックしたときに flash のコンテキストメニューが表示されると動作しています。

2015年4月13日月曜日

2 - ol3.4ex 107b - WMTS HiDPI example 2

「wmts-hidpi.js(2107-ol3ex.js)」は、マップを表示するための JavaScript ファイルです。

使用するレイヤは、「basemap.at」が提供しています。

basemap.at
(http://www.basemap.at/index_en.html)

には、

You need an up-to-date basemap of Austria derived from administrative data? You are at the right place! basemap.at is a high-performance web basemap published under an OpenGovernmentData (OGD) license. It is based upon data provided by the nine Austrian provinces and their partners.

あなたは、管理データから入手されるオーストリアの最新のベースマップが必要ですか?あなたは正しい場所にいます! basemap.at は OpenGovernmentData(OGD)のライセンスで公開されている高性能の Web ベースマップです。これは、9つのオーストリアの州とそのパートナーによって提供されたデータに基づいています。

とあります。 「HIGH-DPI」には、

● double the resolution of the STANDARD layer
● perfect for high-resolution displays of smartphones and tablets and for prints

● スタンダードレイヤの2倍の解像度
● スマートフォンやタブレット、印刷の高解像度ディスプレイに最適

とあります。

「2107-ol3ex.js」
var template =
 '{Layer}/{Style}/{TileMatrixSet}/{TileMatrix}/{TileRow}/{TileCol}.jpeg';
var urls = [
 'http://maps1.wien.gv.at/basemap/' + template,
 'http://maps2.wien.gv.at/basemap/' + template,
 'http://maps3.wien.gv.at/basemap/' + template,
 'http://maps4.wien.gv.at/basemap/' + template,
 'http://maps.wien.gv.at/basemap/' + template
];
// HiDPI support:
// * Use 'bmaphidpi' layer (pixel ratio 2) for device pixel ratio > 1
// * Use 'geolandbasemap' layer (pixel ratio 1) for device pixel ratio == 1
var hiDPI = ol.has.DEVICE_PIXEL_RATIO > 1;
/** ol.has.DEVICE_PIXEL_RATIO
 * The ratio between physical pixels and 
 * device-independent pixels (dips) on the device 
 * (window.devicePixelRatio).
 * デバイス(window.devicePixelRatio)上の物理的な画素とデバイス
 * に依存しないピクセル(ディップ)との比率。(ol3 API)
 */
var source = new ol.source.WMTS({
 projection: 'EPSG:3857',
 layer: hiDPI ? 'bmaphidpi' : 'geolandbasemap',
 /** 条件演算子 condition ? expr1 : expr2 
  * condition: true か false かを評価する条件文です。
  * expr1, expr2: 各々の値の場合に実行する式です。
  * condition が true の場合、演算子は expr1 の値を選択します。
  * そうでない場合は expr2 の値を選択します。
  * (MDN[https://developer.mozilla.org/ja/docs/Web/
  * JavaScript/Guide/Expressions_and_Operators])
  */
 tilePixelRatio: hiDPI ? 2 : 1,
 /** tilePixelRatio
  * The pixel ratio used by the tile service. For example, 
  * if the tile service advertizes 256px by 256px tiles 
  * but actually sends 512px by 512px images (for 
  * retina/hidpi devices) then tilePixelRatio should be 
  * set to 2. Default is 1.
  * タイルサービスによって使用される画素比率。 例えば、タイルサー
  * ビスが 256px x 256px によるタイルを告知し、実際に(retina/
  * hidpiデバイス用)512px x 512pxで画像を送信した場合、その後 
  * tilePixelRatio を 2 に設定する必要があります。デフォルトは 
  * 1 です。
  * (ol3 API[説明は Stable Only のチェックを外すと表示])
  */
 style: 'normal',
 matrixSet: 'google3857', // Matrix set.
 urls: urls,
 requestEncoding: 'REST',
 /** requestEncoding
  * Request encoding. Default is KVP.(ol3 API)
  */
 tileGrid: new ol.tilegrid.WMTS({
 /** ol.tilegrid.WMTS
  * Set the grid pattern for sources accessing WMTS 
  * tiled-image servers.
  * WMTSタイル画像サーバにアクセスするソースのグリッドパターン
  * を設定(ol3 API)
  */
  origin: [-20037508.3428, 20037508.3428],
  resolutions: [
  /** resolutions
   * Resolutions. The array index of each resolution needs 
   * to match the zoom level. This means that even if a 
   * minZoom is configured, the resolutions array will have 
   * a length of maxZoom + 1.
   * 解像度。各解像度の配列インデックスは、ズームレベルに一致す
   * る必要があります。これは minZoom が設定されている場合でも、
   * 解像度アレイは、maxZoom+1 の長さを有することを意味します。
   * (ol3 API[説明は Stable Only のチェックを外すと表示])
   */
   559082264.029 * 0.28E-3,
   279541132.015 * 0.28E-3,
   139770566.007 * 0.28E-3,
   69885283.0036 * 0.28E-3,
   34942641.5018 * 0.28E-3,
   17471320.7509 * 0.28E-3,
   8735660.37545 * 0.28E-3,
   4367830.18773 * 0.28E-3,
   2183915.09386 * 0.28E-3,
   1091957.54693 * 0.28E-3,
   545978.773466 * 0.28E-3,
   272989.386733 * 0.28E-3,
   136494.693366 * 0.28E-3,
   68247.3466832 * 0.28E-3,
   34123.6733416 * 0.28E-3,
   17061.8366708 * 0.28E-3,
   8530.91833540 * 0.28E-3,
   4265.45916770 * 0.28E-3,
   2132.72958385 * 0.28E-3,
   1066.36479193 * 0.28E-3
  ],
  matrixIds: [
  /** matrixIds
   * matrix IDs. The length of this array needs to match 
   * the length of the resolutions array.
   * 行列のID。この配列の長さは、解像度配列の数と一致する必要
   * があります。
   * (ol3 API[説明は Stable Only のチェックを外すと表示])
   */
   0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19
  ]
 })
});
var map = new ol.Map({
 layers: [
  new ol.layer.Tile({
   extent: [977844.377599999, 5837774.6617, 1915609.8654, 6295560.8122],
   source: source
  })
 ],
 target: 'map',
 view: new ol.View({
  center: [1823849, 6143760],
  zoom: 11
 })
});
 
 

2 - ol3.4ex 107a - WMTS HiDPI example 1

「WMTS HiDPI example (wmts-hidpi.html)」を参考に地図を表示してみます。

HTML ファイルの作成
a Eclipse のメニューの「ファイル」->「ファイルを開く」をクリックします。





b 「ファイルを開く」ウィンドウで、「user」->「mapsite」->「ol3proj」->「v3.4.0」->「examples」->「wmts-hidpi.html」をクリックして選択し、「OK」ボタンをクリックします。
同じように「wmts-hidpi.js」を開きます。





c メニューの「ファイル」->「新規」 -> 「ファイル」をクリックします。



d 「ファイル」ウィンドウで「ol3proj」をクリックして選択し、「ファイル名」を「2107-ol3ex.html」と入力し、「次へ」ボタンをクリックします。








e 「File Template」ウィンドウで「HTML 5 Template」をクリックして選択し、「OK」ボタンをクリックします。











f 「wmts-hidpi.html」の内容をコピーして「2107-ol3ex.html」に貼り付け、修正します。
g 同じように、新規に「2107-ol3ex.js」ファイルを作成し、「File Template」ウィンドウで「JavaScript Template」をクリックして選択し、「完了」ボタンをクリックして、「wmts-hidpi.js」の内容をコピーして貼り付け、修正します。「wmts-hidpi-require.js」も「2107-ol3ex-require.js」に貼り付けます。

「2107-ol3ex.html」
<!doctype html>
<html lang="en">
 <head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="chrome=1">
  <meta name="viewport" content="initial-scale=1.0, user-scalable=no, width=device-width">
  <!--
  <link rel="stylesheet" href="../css/ol.css" type="text/css">
  <link rel="stylesheet" href="../resources/bootstrap/css/bootstrap.min.css" type="text/css">
  <link rel="stylesheet" href="../resources/layout.css" type="text/css">
  <link rel="stylesheet" href="../resources/bootstrap/css/bootstrap-responsive.min.css" type="text/css">
  -->
  <!-- ディレクトリ修正 -->
  <link rel="stylesheet" href="v3.4.0/css/ol.css" type="text/css">
  <link rel="stylesheet" href="v3.4.0/resources/bootstrap/css/bootstrap.min.css" type="text/css">
  <link rel="stylesheet" href="v3.4.0/resources/layout.css" type="text/css">
  <link rel="stylesheet" href="v3.4.0/resources/bootstrap/css/bootstrap-responsive.min.css" type="text/css">
  <title>WMTS HiDPI example</title>
  <style>
   .map {
    background: white;
   }
  </style>
 </head>
 <body>
  <!-- 
  bootstrap.min.css, bootstrap-responsive.min.css 
   Examples用 CSSファイルで設定されたセレクタを使用。
  -->
  <div class="navbar navbar-inverse navbar-fixed-top">
   <div class="navbar-inner">
    <div class="container">
     <!--
     <a class="brand" href="./"><img src="../resources/logo.png"> OpenLayers 3 Examples</a>
     -->
     <!-- ディレクトリ修正 -->
     <a class="brand" href="v3.4.0/examples/"><img src="v3.4.0/resources/logo.png"> OpenLayers 3 Examples</a>
    </div>
   </div>
  </div>
  <div class="container-fluid">
   <div class="row-fluid">
    <div class="span12">
     <div id="map" class="map"></div>
    </div>
   </div>
   <div class="row-fluid">
    <div class="span12">
     <h4 id="title">WMTS HiDPI example</h4>
     <p id="shortdesc">Example of a WMTS based HiDPI 
     layer.</p>
     <div id="docs">
      <!--
      <p>See the <a href="wmts-hidpi.js" target="_blank">wmts-hidpi.js source</a> to see how this is done.</p>
      -->
      <!-- ファイル修正 -->
      <p>See the <a href="2107-ol3ex.js" target="_blank">2107-ol3ex.js source</a> to see how this is done.</p>
     </div>
     <div id="tags">hidpi, retina, wmts</div>
    </div>
   </div>
  </div>
  <!--
  <script src="../resources/jquery.min.js" type="text/javascript"></script>
  <script src="../resources/example-behaviour.js" type="text/javascript"></script>
  -->
  <!-- ディレクトリ修正
   jQuery Minified版と
   example-behaviour.js(Examples用 JSコード[文字コードなど])
 -->
  <script src="v3.4.0/resources/jquery.min.js" type="text/javascript"></script>
  <script src="v3.4.0/resources/example-behaviour.js" type="text/javascript"></script>
  <!--
  <script src="loader.js?id=wmts-hidpi" type="text/javascript"></script>
  -->
  <!-- ファイル修正 -->  <!-- ディレクトリ修正 -->
  <script src="loader.js?id=2107-ol3ex" type="text/javascript"></script>
  </body>
</html>

2015年4月1日水曜日

2 - ol3.4ex 98b - WMTS example 2

「wmts.js(298-ol3ex.js)」は、マップを表示するための JavaScript ファイルです。

「298-ol3ex.js」
var projection = ol.proj.get('EPSG:3857');
// EPSG:900913 -> EPSG:3857 コード名変更(内容は同じ)
/** ol.proj.get(projectionLike)
 * Fetches a Projection object for the code specified.
 * 指定されたコードのプロジェクション·オブジェクトを取得
 * (ol3 API)
 */
var projectionExtent = projection.getExtent();
/** getExtent()
 * Get the validity extent for this projection.
 * この投影の有効範囲を取得。(ol3 API)
 */
var size = ol.extent.getWidth(projectionExtent) / 256;
/** ol.extent.getWidth(extent)
 * Return: Width.(ol3 API)
 */
var resolutions = new Array(14);
/** Array(arraylength)
 * JavaScript は配列を扱うことができます。配列とは順序を持つ複
 * 数のデータの集合であり、JavaScript のグローバルオブジェクト 
 * である Array は、高位の、(C言語等で云うところの)「リス
 * ト」の様な、配列のコンストラクタです。
 * arraylength
 * Array コンストラクタに渡される唯一の引数(arrayLength)に 
 * 0 から 4,294,967,295( 232-1 ) までの整数値を指定する場合
 * その値を要素数とする配列が作成されます。その際に範囲外の値
 * は、を指定した場合には、例外: RangeError がスローされます。
 * (MDN[https://developer.mozilla.org/ja/docs/Web/
 * JavaScript/Reference/Global_Objects/Array])
 */
var matrixIds = new Array(14);
for (var z = 0; z < 14; ++z) {
 // generate resolutions and matrixIds arrays for this WMTS
 // この WMTS の解像度と matrixIds 配列の生成。
 resolutions[z] = size / Math.pow(2, z);
 /** Math.pow(base, exponent)
  * base を exponent 乗した値、つまり、base^exponent の値を返
  * します。
  * (MDN[https://developer.mozilla.org/ja/docs/Web/
  * JavaScript/Reference/Global_Objects/Math/pow])
  */
 matrixIds[z] = z;
}
var attribution = new ol.Attribution({
 html: 'Tiles © <a href="http://services.arcgisonline.com/arcgis/rest/' +
  'services/Demographics/USA_Population_Density/MapServer/">ArcGIS</a>'
});

var map = new ol.Map({
 layers: [
  new ol.layer.Tile({
   source: new ol.source.OSM(),
   /** ol.source.OSM 
    * Layer source for the OpenStreetMap tile server.
    * OpenStreetMap タイルサーバのレイヤソース。(ol3 API)
    */
   opacity: 0.7 // 透過度
  }),
  new ol.layer.Tile({
   opacity: 0.7,
   source: new ol.source.WMTS({
   /** ol.source.WMTS
    * Layer source for tile data from WMTS servers.
    * WMTSサーバからタイルデータのレイヤソース。(ol3 API)
    */
    attributions: [attribution],
    url: 'http://services.arcgisonline.com/arcgis/rest/' +
     'services/Demographics/USA_Population_Density/MapServer/WMTS/',
    layer: '0',
    matrixSet: 'EPSG:3857',
    format: 'image/png',
    projection: projection,
    tileGrid: new ol.tilegrid.WMTS({
    /** ol.tilegrid.WMTS
     * Set the grid pattern for sources accessing WMTS 
     * tiled-image servers.
     * WMTSタイル画像サーバにアクセスするソースのグリッドパ
     * ターンを設定(ol3 API)
     */
     origin: ol.extent.getTopLeft(projectionExtent),
     /** ol.extent.getTopLeft
      * Return: Top left coordinate.
      */
     resolutions: resolutions,
     matrixIds: matrixIds
     /** matrixIds
      * matrix IDs. The length of this array needs to match 
      * the length of 
      * the resolutions array.
      * 行列のID。この配列の長さは、解像度配列の数と一致する必要
      * があります。
      * (ol3 API[説明は Stable Only のチェックを外すと表示])
      */
    }),
    style: 'default',
    wrapX: true
    /** wrapX:
     * Whether to wrap the world horizontally. Default is 
     * false.
     * 水平に世界を覆うかどうかを設定します。デフォルトはfalse
     * です。
     * (ol3 API[説明は Stable Only のチェックを外すと表示])
     */
   })
  })
 ],
 target: 'map',
 controls: ol.control.defaults({
 /** controls
  * Controls initially added to the map. 
  * If not specified, ol.control.defaults() is used.
  * 初期設定で、マップに追加されたコントロール。
  * 明示されていなければ、ol.control.defaults() が使用されます。
  * (ol3 API)
  */
 /** ol.control.defaults()
  * デフォルトでは、マップに含まコントロールのセット。
  * 特に設定しない限り、これは、以下の各コントロールの
  * インスタンスを含むコレクションを返します。(ol3 API)
  * ol.control.Zoom, ol.control.Rotate, ol.control.Attribution
  */
  attributionOptions: /** @type {olx.control.AttributionOptions} */ ({
  /** @type 
   * 値のタイプ(型)の説明 - 式などで表示
   * (@use JSDoc[http://usejsdoc.org/]より)
    */
   collapsible: false // 折りたたみ
  })
 }),
 view: new ol.View({
  center: [-11158582, 4813697],
  zoom: 4
 })
});

2 - ol3.4ex 98a - WMTS example 1

リリースノートにあるように「WMTS example (wmts.html)」に変更があるので地図を表示してみます。

HTML ファイルの作成
a Eclipse のメニューの「ファイル」->「ファイルを開く」をクリックします。





b 「ファイルを開く」ウィンドウで、「user」->「mapsite」->「ol3proj」->「v3.4.0」->「examples」->「wmts.html」をクリックして選択し、「OK」ボタンをクリックします。
同じように「wmts.js」を開きます。





c メニューの「ファイル」->「新規」 -> 「ファイル」をクリックします。



d 「ファイル」ウィンドウで「ol3proj」をクリックして選択し、「ファイル名」を「298-ol3ex.html」と入力し、「次へ」ボタンをクリックします。








e 「File Template」ウィンドウで「HTML 5 Template」をクリックして選択し、「OK」ボタンをクリックします。











f 「wmts.html」の内容をコピーして「298-ol3ex.html」に貼り付け、修正します。
g 同じように、新規に「298-ol3ex.js」ファイルを作成し、「File Template」ウィンドウで「JavaScript Template」をクリックして選択し、「完了」ボタンをクリックして、「wmts.js」の内容をコピーして貼り付け、修正します。「wmts-require.js」も「298-ol3ex-require.js」に貼り付けます。


「298-ol3ex.html」
<!doctype html>
<html lang="en">
 <head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="chrome=1">
  <meta name="viewport" content="initial-scale=1.0, user-scalable=no, width=device-width">
  <!--
  <link rel="stylesheet" href="../css/ol.css" type="text/css">
  <link rel="stylesheet" href="../resources/bootstrap/css/bootstrap.min.css" type="text/css">
  <link rel="stylesheet" href="../resources/layout.css" type="text/css">
  <link rel="stylesheet" href="../resources/bootstrap/css/bootstrap-responsive.min.css" type="text/css">
  -->
  <!-- ディレクトリ修正 -->
  <link rel="stylesheet" href="v3.4.0/css/ol.css" type="text/css">
  <link rel="stylesheet" href="v3.4.0/resources/bootstrap/css/bootstrap.min.css" type="text/css">
  <link rel="stylesheet" href="v3.4.0/resources/layout.css" type="text/css">
  <link rel="stylesheet" href="v3.4.0/resources/bootstrap/css/bootstrap-responsive.min.css" type="text/css">
  <title>WMTS example</title>
 </head>
 <body>
  <!-- 
   bootstrap.min.css, bootstrap-responsive.min.css 
    Examples用 CSSファイルで設定されたセレクタを使用。
  -->
  <div class="navbar navbar-inverse navbar-fixed-top">
   <div class="navbar-inner">
    <div class="container">
     <!--
     <a class="brand" href="./"><img src="../resources/logo.png"> OpenLayers 3 Examples</a>
     -->
     <!-- ディレクトリ修正 -->
     <a class="brand" href="v3.4.0/examples/"><img src="v3.4.0/resources/logo.png"> OpenLayers 3 Examples</a>
    </div>
   </div>
  </div>
  <div class="container-fluid">
   <div class="row-fluid">
    <div class="span12">
     <div id="map" class="map"></div>
    </div>
   </div>
   <div class="row-fluid">
    <div class="span12">
     <h4 id="title">WMTS example</h4>
     <p id="shortdesc">Example of a WMTS source.</p>
     <div id="docs">
      <!--
      <p>See the <a href="wmts.js" target="_blank">wmts.js source</a> to see how this is done.</p>
      -->
      <!-- ファイル修正 -->
      <p>See the <a href="298-ol3ex.js" target="_blank">298-ol3ex.js source</a> to see how this is done.</p>
     </div>
     <div id="tags">wmts</div>
    </div>
   </div>
  </div>
  <!--
  <script src="../resources/jquery.min.js" type="text/javascript"></script>
  <script src="../resources/example-behaviour.js" type="text/javascript"></script>
  -->
  <!-- ディレクトリ修正
   jQuery Minified版と
   example-behaviour.js(Examples用 JSコード[文字コードなど])
  -->
  <script src="v3.4.0/resources/jquery.min.js" type="text/javascript"></script>
  <script src="v3.4.0/resources/example-behaviour.js" type="text/javascript"></script>
  <!--
  <script src="loader.js?id=wmts" type="text/javascript"></script>
  -->
  <!-- ファイル修正 -->  <!-- ディレクトリ修正 -->
  <script src="loader.js?id=298-ol3ex" type="text/javascript"></script>
 </body>
</html>

2014年10月22日水曜日

2 - ol3ex 20b - WMTS example 2

WMTS データは、「独立行政法人 産業技術総合研究所(http://www.aist.go.jp/)」の「GSJ 地質調査総合センター(https://www.gsj.jp/HomePageJP.html)」の「地質情報配信サービス(https://gbank.gsj.jp/owscontents/)」の「20万分の1日本シームレス地質図 基本版(https://gbank.gsj.jp/seamless/tilemap/basic/WMTSCapabilities.xml)」を使用します。

「Webサイトでのご利用」に「OpenLayersでの利用例」があります。「OpenLayersでのWMTSサービス利用例 (実装例ソースコード)」は OpenLayers 2.x の例ですが、これを参考に ol3 に応用します。

「OpenLayersでのWMTSサービス利用例(https://gbank.gsj.jp/owscontents/ol_example.html#WMTS)」
実装例ソースコード(https://gbank.gsj.jp/owscontents/ol_example_wmts_html.txt)

「wmts.js(220-ol3ex.js)」は、地図を表示するのに必要な javascript です。
「220-ol3ex.js」
var projection = ol.proj.get('EPSG:3857');
// EPSG:900913 -> EPSG:3857 コード名変更(内容は同じ)
/** ol.proj.get(projectionLike)
 * Fetches a Projection object for the code specified.
 * 指定されたコードのプロジェクション·オブジェクトを取得
 * (ol3 API)
 */
var projectionExtent = projection.getExtent();
/** getExtent()
 * Get the validity extent for this projection.
 * この投影の有効範囲を取得。(ol3 API)
 */
var size = ol.extent.getWidth(projectionExtent) / 256;
/** ol.extent.getWidth(extent)
 * Return: Width.(ol3 API)
 */
var resolutions = new Array(14);
/** Array(arraylength)
 * JavaScript は配列を扱うことができます。配列とは順序を持つ複数
 * のデータの集合であり、JavaScript のグローバルオブジェクトであ 
 * る Array は、高位の、(C言語等で云うところの)「リスト」の様
 * な、配列のコンストラクタです。
 * arraylength
 * Array コンストラクタに渡される唯一の引数(arrayLength)に 0 
 * から 4,294,967,295( 232-1 ) までの整数値を指定する場合は、そ
 * の値を要素数とする配列が作成されます。その際に範囲外の値を指
 * 定した場合には、例外: RangeError がスローされます。
 * (MDN[https://developer.mozilla.org/ja/docs/Web/
 * JavaScript/Reference/Global_Objects/Array])
 */
var matrixIds = new Array(14);
for (var z = 0; z < 14; ++z) {
 // generate resolutions and matrixIds arrays for this WMTS
 // この WMTS の解像度と matrixIds 配列の生成。(ol3 API)
 resolutions[z] = size / Math.pow(2, z);
 /** Math.pow(base, exponent)
  * base を exponent 乗した値、つまり、base^exponent の値を返
  * します。
  * (MDN[https://developer.mozilla.org/ja/docs/Web/
  * JavaScript/Reference/Global_Objects/Math/pow])
  */
 matrixIds[z] = z;
}
var attribution = new ol.Attribution({
/** ol.Attribution
 * An attribution for a layer source.
 * レイヤソースの属性(ol3 API)
 */
/**
 * html: 'Tiles &copy; <a href="http://services.arcgisonline.com/arcgis/rest/' +
 * 'services/Demographics/USA_Population_Density/MapServer/">ArcGIS</a>'
 */
 html: 'Tiles &copy; 産総研地質調査総合センター 20万分の1日本シームレス地質図 (基本版) CC BY-ND'
});
var map = new ol.Map({
 layers: [
  new ol.layer.Tile({
  /** ol.layer.Tile 
   * For layer sources that provide pre-rendered, tiled 
   * images in grids that are organized by zoom levels for 
   * specific resolutions. 
   * プリレンダリング(事前描画)を提供するレイヤソースのための、
   * 特定の解像度でのズームレベルによって編成されているグリッドの
   * タイルイメージ。(ol3 API)
   */
   source: new ol.source.OSM(),
   /** ol.source.OSM 
    * Layer source for the OpenStreetMap tile server.
    * OpenStreetMap タイルサーバのレイヤソース。(ol3 API)
    */
   opacity: 0.7 // 透過度
  }),
  new ol.layer.Tile({
   opacity: 0.7,
   extent: projectionExtent, // 範囲
   source: new ol.source.WMTS({
   /** ol.source.WMTS
    * Layer source for tile data from WMTS servers.
    * WMTSサーバからタイルデータのレイヤソース。(ol3 API)
    */
    attributions: [attribution],
    /**
     * url: 'http://services.arcgisonline.com/arcgis/rest/' +
     * 'services/Demographics/USA_Population_Density/MapServer/WMTS/',
     */
    url: 'https://gbank.gsj.jp/seamless/tilemap/basic/glfn/{TileMatrix}/{TileRow}/{TileCol}.png',
    /** WMTSサービスのベースURLを設定します。
      * 標準形式のURLでない場合、URLのテンプレートを設定します。(地質調査総合センター)
      */
    // layer: '0', // The layer identifier.
    layer: 'glfn',
     /** ベースURLから取得するレイヤ名を設定します。
      * このサンプルでは、レイヤ名を固定的に持つURLテンプレートを
      * 設定しているため使用されることはありませんが、WMTS クラス
      * コンストラクタの必須パラメータなので省略できません。
      * (地質調査総合センター)
      */
    matrixSet: 'EPSG:3857',
    // EPSG:900913 -> EPSG:3857 コード名変更(内容は同じ)
    format: 'image/png',
    projection: projection,
    tileGrid: new ol.tilegrid.WMTS({
    /** ol.tilegrid.WMTS
     * Set the grid pattern for sources accessing WMTS tiled-image servers.
     * WMTSタイル画像サーバにアクセスするソースのグリッドパターンを設定(ol3 API)
     */
     origin: ol.extent.getTopLeft(projectionExtent),
     /** ol.extent.getTopLeft
      * Return: Top left coordinate.
      */
     resolutions: resolutions,
     matrixIds: matrixIds
     /** matrixIds
      * matrix IDs. The length of this array needs to match 
      * the length of 
      * the resolutions array.
      * 行列のID。この配列の長さは、解像度配列の数と一致する必要
      * があります。
      * (ol3 API[説明は Stable Only のチェックを外すと表示])
      */
    }),
    style: 'default',
    requestEncoding: "REST"
     /** リクエスト形式が REST か KVP を設定します。
      * 省略するとデフォルトの KVP が適用されます。
      * (地質調査総合センター)
      */
   })
  })
 ],
 target: 'map',
 controls: ol.control.defaults({
 /** controls
  * Controls initially added to the map. 
  * If not specified, ol.control.defaults() is used.
  * 初期設定で、マップに追加されたコントロール。
  * 明示されていなければ、ol.control.defaults() が使用されます。
  * (ol3 API)
  */
 /** ol.control.defaults()
  * デフォルトでは、マップに含まコントロールのセット。
  * 特に設定しない限り、これは、以下の各コントロールの
  * インスタンスを含むコレクションを返します。(ol3 API)
  * ol.control.Zoom, ol.control.Rotate, ol.control.Attribution
  */
  attributionOptions: /** @type {olx.control.AttributionOptions} */ ({
  /** @type 
   * 値のタイプ(型)の説明 - 式などで表示
   * (@use JSDoc[http://usejsdoc.org/]より)
   * attributionOptions の値の型は、
   * olx.control.AttributionOptions の型を使用。
    */
   collapsible: false // 折りたたみ
  })
 }),
& view: new ol.View({
  // center: [-11158582, 4813697],
  center: [15500000,4210000],
  // デフォルトの中心座標を指定しています。(地質調査総合センター)
  //  zoom: 4
  zoom: 6
 })
});

2 - ol3ex 20a - WMTS example 1

「WMTS example(wmts.html)」を参考に地図を表示してみます。WMTS については、OGC(http://www.opengeospatial.org/) の 「OpenGIS Web Map Tile Service Implementation Standard(http://www.opengeospatial.org/standards/wmts)」に、次ように書かれています。

*****
This Web Map Tile Service (WMTS) Implementation Standard provides a standard based solution to serve digital maps using predefined image tiles.
このウェッブマップタイルサービス(Web Map Tile Service:WMTS)実装標準は、事前定義された画像タイルを使用してデジタル地図サービスを提供するための標準ベースのソリューションを提供します。
The service advertises the tiles it has available through a standardized declaration in the ServiceMetadata document common to all OGC web services.
サービスは、すべてのOGCのWebサービスに共通するServiceMetadata文書内の標準化された宣言を通じて有効であるタイルを提供します。
This declaration defines the tiles available in each layer (i.e. each type of content), in each graphical representation style, in each format, in each coordinate reference system, at each scale, and over each geographic fragment of the total covered area.
この宣言は、各レイヤ(つまり、各種類のコンテンツ)で、各グラフィック表現のスタイルで、各形式で、各座標参照システムで、各スケールで、全カバーエリアの各地理断片の上に、利用可能タイルを定義しています。
The ServiceMetadata document also declares the communication  protocols and encodings through which clients can interact with the server.
ServiceMetadata文書は、クライアントがサーバーと対話可能な通信プロトコルおよびエンコーディングを宣言します。
Clients can interpret the ServiceMetadata document to request specific tiles.
クライアントは、特定のタイルを要求するためにServiceMetadata文書を解釈することができます。
*****

HTML ファイルの作成
a Eclipse のメニューの「ファイル」->「ファイルを開く」をクリックします。





b 「ファイルを開く」ウィンドウで、「user」->「mapsite」->「ol3proj」->「v3.0.0」->「examples」->「wmts.html」をクリックして選択し、「OK」ボタンをクリックします。
同じように「wmts.js」を開きます。





c メニューの「ファイル」->「新規」 -> 「ファイル」をクリックします。



d 「ファイル」ウィンドウで「ol3proj」をクリックして選択し、「ファイル名」を「220-ol3ex.html」と入力し、「次へ」ボタンをクリックします。








e 「File Template」ウィンドウで「HTML 5 Template」をクリックして選択し、「OK」ボタンをクリックします。











f 「wmts.html」の内容をコピーして「220-ol3ex.html」に貼り付け、修正します。
g 同じように、新規に「220-ol3ex.js」ファイルを作成し、「File Template」ウィンドウで「JavaScript Template」をクリックして選択し、「完了」ボタンをクリックして、「wmts.js」の内容をコピーして貼り付け、修正します。「wmts-require.js」も「220-ol3ex-require.js」に貼り付けます。


「220-ol3ex.html」
<!doctype html>
<html lang="en">
 <head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="chrome=1">
  <meta name="viewport" content="initial-scale=1.0, user-scalable=no, width=device-width">
<!--
  <link rel="stylesheet" href="../css/ol.css" type="text/css">
  <link rel="stylesheet" href="../resources/bootstrap/css/bootstrap.min.css" type="text/css">
  <link rel="stylesheet" href="../resources/layout.css" type="text/css">
  <link rel="stylesheet" href="../resources/bootstrap/css/bootstrap-responsive.min.css" type="text/css">
-->
  <!-- ディレクトリ修正 -->
  <link rel="stylesheet" href="v3.0.0/css/ol.css" type="text/css">
  <link rel="stylesheet" href="v3.0.0/resources/bootstrap/css/bootstrap.min.css" type="text/css">
  <link rel="stylesheet" href="v3.0.0/resources/layout.css" type="text/css">
  <link rel="stylesheet" href="v3.0.0/resources/bootstrap/css/bootstrap-responsive.min.css" type="text/css">
  <style>
   /** attribution が2行になるので表示できるように */
   .ol-attribution ul{
    line-height: 15px;
    }
   .ol-attribution.ol-uncollapsible{
    height:2.1em;
    line-height:1em;
   }
  </style>
  <title>WMTS example</title>
 </head>
 <body>
  <!-- 
  bootstrap.min.css, bootstrap-responsive.min.css で設定されたセレクタを使用。
  -->
  <div class="navbar navbar-inverse navbar-fixed-top">
   <div class="navbar-inner">
    <div class="container">
<!--
     <a class="brand" href="./"><img src="../resources/logo.png"> OpenLayers 3 Examples</a>
-->
      <!-- ディレクトリ修正 -->
     <a class="brand" href="v3.0.0/examples/"><img src="v3.0.0/resources/logo.png"> OpenLayers 3 Examples</a>
    </div>
   </div>
  </div>
  <div class="container-fluid">
   <div class="row-fluid">
    <div class="span12">
     <div id="map" class="map"></div>
    </div>
   </div>
   <div class="row-fluid">
    <div class="span12">
     <h4 id="title">WMTS example</h4>
     <p id="shortdesc">Example of a WMTS source.</p>
     <div id="docs">
<!--
      <p>See the <a href="wmts.js" target="_blank">wmts.js source</a> to see how this is done.</p>
-->
       <!-- ファイル修正 -->
      <p>See the <a href="220-ol3ex.js" target="_blank">220-ol3ex.js source</a> to see how this is done.</p>
     </div>
     <div id="tags">wmts</div>
    </div>
   </div>
  </div>
<!--
  <script src="jquery.min.js" type="text/javascript"></script>
  <script src="../resources/example-behaviour.js" type="text/javascript"></script>
-->
  <!-- ディレクトリ修正
   jQuery Minified版と
   example-behaviour.js(Examples用 JSコード[文字コードなど])
  -->
  <script src="v3.0.0/examples/jquery.min.js" type="text/javascript"></script>
  <script src="v3.0.0/resources/example-behaviour.js" type="text/javascript"></script>
<!--
  <script src="loader.js?id=wmts" type="text/javascript"></script>
-->
  <!-- ファイル修正 -->  <!-- ディレクトリ修正 -->
  <script src="loader.js?id=220-ol3ex" type="text/javascript"></script>

 </body>
</html>