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

2015年11月30日月曜日

2 - ol3.11ex 138b - Image reprojection example 2

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

「2138-ol3ex.js」
proj4.defs('EPSG:27700', '+proj=tmerc +lat_0=49 +lon_0=-2 +k=0.9996012717 ' +
 '+x_0=400000 +y_0=-100000 +ellps=airy ' +
 '+towgs84=446.448,-125.157,542.06,0.15,0.247,0.842,-20.489 ' +
 '+units=m +no_defs');
var imageExtent = [0, 0, 700000, 1300000];

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.MapQuest({layer: 'osm'})
   /** ol.source.MapQuest
    * Layer source for the MapQuest tile server.
    * MapQuest タイルサーバのレイヤソース。(ol3 API
    * 2 - ol3ex 23b - MapQuest example 2 参照)
    */
  }),
  new ol.layer.Image({
  /** ol.layer.Image
   * Server-rendered images that are available for arbitrary 
   * extents and resolutions. 
   * 任意の範囲と解像度で利用可能な server-rendered イメージ。
   * (ol3 API)
   */
   source: new ol.source.ImageStatic({
   /** source.ImageStatic
    * A layer source for displaying a single, static image.
    * 単一で静的(東映データが付加されていない)画像の表示のため
    * のレイヤソース。(ol3 API)
    */
    url: 'http://upload.wikimedia.org/wikipedia/commons/thumb/1/18/' +
     'British_National_Grid.svg/2000px-British_National_Grid.svg.png',
    crossOrigin: '',
    /** crossOrigin
     * The crossOrigin attribute for loaded images. Note 
     * that you must provide a crossOrigin value if you 
     * are using the WebGL renderer or if you want to 
     * access pixel data with the Canvas renderer. See 
     * https://developer.mozilla.org/en-US/docs/Web/HTML/
     * CORS_enabled_image for more detail.
     * ロードされたイメージの crossOrigin属性。WebGLのレンダ
     * ラーを使用している場合、または、キャンバスレンダラでピ
     * クセルデータにアクセスする場合、crossOrigin 値を提供な
     * ければならないことに注意してください。詳細は 
     * https://developer.mozilla.org/en-US/docs/Web/HTML/
     * CORS_enabled_image を参照してください。(ol3 API)
     */
    projection: 'EPSG:27700',
    imageExtent: imageExtent
    /** imageExtent
     * Extent of the image in map coordinates. This is the 
     * [left, bottom, right, top] map coordinates of your 
     * image. Required.
     * マップ座標の画像の範囲が調整。これは、イメージのマップ座標
     * [左、下、右、上]です。 必須。(ol3 API)
     */
   })
  })
 ],
 renderer: common.getRendererFromQueryString(),
// 'common.js' により URL にある renderer を返します
 target: 'map',
 view: new ol.View({
  center: ol.proj.transform(ol.extent.getCenter(imageExtent),
   'EPSG:27700', '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)
   */
  /** ol.extent.getCenter(extent)
   * Get the center coordinate of an extent.
   * 範囲の中心座標を取得します。(ol3 API)
   */
  zoom: 4
 })
});

2 - ol3.11ex 138a - Image reprojection example 1

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

This example shows client-side reprojection of single image source.この例では、単一イメージ(画像)ソースのクライアント側の再投影を示しています。

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





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





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




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








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











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

「2138-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.11.2/css/ol.css" type="text/css">
  <link rel="stylesheet" href="v3.11.2/examples/resources/layout.css" type="text/css">

  <link rel="stylesheet" href="v3.11.2/examples/resources/prism/prism.css" type="text/css">
  <script src="v3.11.2/examples/resources/zeroclipboard/ZeroClipboard.min.js"></script>
  <script src="http://cdnjs.cloudflare.com/ajax/libs/proj4js/2.3.6/proj4.js">&lt/script>
  <title>Image reprojection 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.11.2/examples/"><img src="v3.11.2/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">Image reprojection example</h4>
     <p id="shortdesc">Demonstrates client-side reprojection 
       of single image source.</p>
     <div id="docs"><p>This example shows client-side 
      reprojection of single image source. </p>
     </div>
     <div id="tags">reprojection, projection, proj4js, 
      mapquest, image, imagestatic</div>
     <div id="api-links">Related API documentation: 
      <ul class="inline">
       <li>
       <!-- <a href="../apidoc/ol.Map.html" title="API documentation for ol.Map">ol.Map</a> -->
        <a href="v3.11.2/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.11.2/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.11.2/apidoc/ol.extent.html" title="API documentation for ol.extent">ol.extent</a>
       </li>,
       <li>
        <!-- <a href="../apidoc/ol.layer.Image.html" title="API documentation for ol.layer.Image">ol.layer.Image</a> -->
        <a href="v3.11.2/apidoc/ol.layer.Image.html" title="API documentation for ol.layer.Image">ol.layer.Image</a>
       </li>,
       <li>
        <!-- <a href="../apidoc/ol.layer.Tile.html" title="API documentation for ol.layer.Tile">ol.layer.Tile</a> -->
        <a href="v3.11.2/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.11.2/apidoc/ol.proj.html" title="API documentation for ol.proj">ol.proj</a>
       </li>,
       <li>
        <!-- <a href="../apidoc/ol.source.ImageStatic.html" title="API documentation for ol.source.ImageStatic">ol.source.ImageStatic</a> -->
        <a href="v3.11.2/apidoc/ol.source.ImageStatic.html" title="API documentation for ol.source.ImageStatic">ol.source.ImageStatic</a>
       </li>
       <li>
        <!-- <a href="../apidoc/ol.source.MapQuest.html" title="API documentation for ol.source.MapQuest">ol.source.MapQuest</a> -->
        <a href="v3.11.2/apidoc/ol.source.MapQuest.html" title="API documentation for ol.source.MapQuest">ol.source.MapQuest</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="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.11.2/examples/resources/common.js"></script>
  <script src="v3.11.2/examples/resources/prism/prism.min.js"></script>
  <!-- 
  <script src="loader.js?id=reprojection-image"></script>
  -->
  <!-- ファイル修正 -->  <!-- ディレクトリ修正 -->
  <script src="loader.js?id=2138-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 のコンテキストメニューが表示されると動作しています。