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

2015年3月8日日曜日

2 - ol3.3ex 81b - WMTS Capabilities example 2

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

「WMTSCapabilities.xml」
<?xml version="1.0" encoding="UTF-8"?>
<Capabilities
 xmlns="http://www.opengis.net/wmts/1.0"
 xmlns:ows="http://www.opengis.net/ows/1.1"
 xmlns:xlink="http://www.w3.org/1999/xlink"
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xmlns:gml="http://www.opengis.net/gml"
 xsi:schemaLocation="http://www.opengis.net/wmts/1.0 http://schemas.opengis.net/wmts/1.0/wmtsGetCapabilities_response.xsd"
 version="1.0.0">
 <ows:ServiceIdentification>
  <ows:Title>Web Map Tile Service - GeoWebCache</ows:Title>
  <ows:ServiceType>OGC WMTS</ows:ServiceType>
  <ows:ServiceTypeVersion>1.0.0</ows:ServiceTypeVersion>
 </ows:ServiceIdentification>
 <ows:ServiceProvider>
  <ows:ProviderName>http://sdi.georchestra.org/geoserver/gwc/service/wmts</ows:ProviderName>
  <ows:ProviderSite xlink:href="http://sdi.georchestra.org/geoserver/gwc/service/wmts"/>
  <ows:ServiceContact>
   <ows:IndividualName>GeoWebCache User</ows:IndividualName>
  </ows:ServiceContact>
 </ows:ServiceProvider>
 <ows:OperationsMetadata>
  <ows:Operation name="GetCapabilities">
   <ows:DCP>
    <ows:HTTP>
     <ows:Get xlink:href="http://sdi.georchestra.org/geoserver/gwc/service/wmts?">
      <ows:Constraint name="GetEncoding">
       <ows:AllowedValues>
        <ows:Value>KVP</ows:Value>
       </ows:AllowedValues>
      </ows:Constraint>
     </ows:Get>
    </ows:HTTP>
   </ows:DCP>
  </ows:Operation>
  <ows:Operation name="GetTile">
   <ows:DCP>
    <ows:HTTP>
     <ows:Get xlink:href="http://sdi.georchestra.org/geoserver/gwc/service/wmts?">
      <ows:Constraint name="GetEncoding">
       <ows:AllowedValues>
        <ows:Value>KVP</ows:Value>
       </ows:AllowedValues>
      </ows:Constraint>
     </ows:Get>
    </ows:HTTP>
   </ows:DCP>
  </ows:Operation>
---

「281-ol3ex.js」
var parser = new ol.format.WMTSCapabilities();
/** ol.format.WMTSCapabilities
 * Format for reading WMTS capabilities data
 * WMTS capabilities データを読み込むためのフォーマット。
 * (ol3 API)
 */
var map;
// $.ajax('data/WMTSCapabilities.xml').then(function(response) {
$.ajax('v3.3.0/examples/data/WMTSCapabilities.xml').then(function(response) {
/** jQuery.ajax()
 * Perform an asynchronous HTTP (Ajax) request.
 * 非同期 HTTP(Ajax)リエストを実行します。
 * (jQuery[http://api.jquery.com/jquery.ajax/])
 */
/** deferred.then()
 * Add handlers to be called when the Deferred object is 
 * resolved, rejected, or still in progress. 
 * deferred オブジェクトが resolved、rejected か、まだ処理途中
 * (progress)のとき呼び出されるハンドラを追加します。
 * (juery[http://api.jquery.com/deferred.then/])
 */
 var result = parser.read(response);
 /** read()
  * Read a WMTS capabilities document.
  * (ol3 API[説明は Stable Only のチェックを外すと表示])
  */
 var options = ol.source.WMTS.optionsFromCapabilities(result,
 /** ol.source.WMTS.optionsFromCapabilities
  * Return: WMTS source options object.
  * (ol3 API[説明は Stable Only のチェックを外すと表示])
  */
  {layer: 'layer-7328', matrixSet: 'EPSG:3857'});
 var projection = ol.proj.get('EPSG:3857');
 /** ol.proj.get
  * Fetches a Projection object for the code specified.
  * 指定されたコードのプロジェクション·オブジェクトを取得します。
  * (0l3 API)
  */
 var projectionExtent = projection.getExtent();
 /** getExtent()
  * Get the validity extent for this projection.
  * この投影の有効範囲を取得。(ol3 API)
  */
 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: 1,
    extent: projectionExtent,
    source: new ol.source.WMTS(options)
    /** ol.source.WMTS
     * Layer source for tile data from WMTS servers.
     * WMTSサーバからタイルデータのレイヤソース。(ol3 API)
     */
   })
  ],
  target: 'map',
  view: new ol.View({
   center: [19412406.33, -5050500.21],
   zoom: 5
  })
 });
});


2 - ol3.3ex 81a - WMTS Capabilities example 1

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

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





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





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



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








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











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


「281-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.3.0/css/ol.css" type="text/css">
  <link rel="stylesheet" href="v3.3.0/resources/bootstrap/css/bootstrap.min.css" type="text/css">
  <link rel="stylesheet" href="v3.3.0/resources/layout.css" type="text/css">
  <link rel="stylesheet" href="v3.3.0/resources/bootstrap/css/bootstrap-responsive.min.css" type="text/css">
  <title>WMTS Layer example from capabilities </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.3.0/examples/"><img src="v3.3.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 Capabilities example</h4>
     <p id="shortdesc">Example of a WMTS source created from 
      a WMTS capabilities document.</p>
     <div id="docs">
      <!--
      <p>See the <a href="wmts-layer-from-capabilities.js" target="_blank">wmts-layer-from-capabilities.js source</a> 
       to see how this is done.</p>
      -->
      <!-- ファイル修正 -->
      <p>See the <a href="281-ol3ex.js" target="_blank">281-ol3ex.js source</a> 
       to see how this is done.</p>
     </div>
     <div id="tags">wmts, capabilities, getcapabilities</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.3.0/resources/jquery.min.js" type="text/javascript"></script>
  <script src="v3.3.0/resources/example-behaviour.js" type="text/javascript"></script>
  <!--
  <script src="loader.js?id=wmts-layer-from-capabilities" type="text/javascript"></script>
  -->
  <!-- ファイル修正 -->  <!-- ディレクトリ修正 -->
  <script src="loader.js?id=281-ol3ex" type="text/javascript"></script>
 </body>
</html>

2015年2月16日月曜日

2 - ol3.2ex 60a - WMTS GetCapabilities parsing example 1

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

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





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





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



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








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











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



「260-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.2.0/css/ol.css" type="text/css">
  <link rel="stylesheet" href="v3.2.0/resources/bootstrap/css/bootstrap.min.css" type="text/css">
  <link rel="stylesheet" href="v3.2.0/resources/layout.css" type="text/css">
  <link rel="stylesheet" href="v3.2.0/resources/bootstrap/css/bootstrap-responsive.min.css" type="text/css">
  <title>WMTS GetCapabilities parsing 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.2.0/examples/"><img src="v3.2.0/resources/logo.png"> OpenLayers 3 Examples</a>
    </div>
   </div>
  </div>
  <div class="container-fluid">
   <div class="row-fluid">
    <div class="span4">
     <h4 id="title">WMTS GetCapabilities parsing example</h4>
     <p id="shortdesc">Example of parsing a WMTS GetCapabilities response.</p>
     <div id="docs">
      <!--
      See the <a href="wmts-capabilities.js" target="_blank">wmts-capabilities.js source</a> to see how this is done.</p>
      -->
      <!-- ファイル修正 -->
      See the <a href="260-ol3ex.js" target="_blank">260-ol3ex.js source</a> to see how this is done.</p>
     </div>
     <div id="tags">wmts, capabilities, getcapabilities</div>
    </div>
    <div class="span8">
     <pre id="log"></pre>
    </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.2.0/resources/jquery.min.js" type="text/javascript"></script>
  <script src="v3.2.0/resources/example-behaviour.js" type="text/javascript"></script>
  <!--
  <script src="loader.js?id=wmts-capabilities" type="text/javascript"></script>
  -->
  <!-- ファイル修正 -->  <!-- ディレクトリ修正 -->
  <script src="loader.js?id=260-ol3ex" type="text/javascript"></script>
 </body>
</html>