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

2019年8月26日月曜日

ol5.3ex 6 - Zoomify

「Zoomify (zoomify.html) 」を参考に地図を表示してみます。

「About Zoomify, Inc.(http://www.zoomify.com/about.htm)」に次のようにあります。

Vision
Zoomify makes high-quality images zoom-and-pan for fast, interactive viewing on the web with just HTML, JPEGs, and JavaScript! Zoomify's products meet the high-resolution imaging needs of creative professionals, image-centric businesses, and digital device developers. Zoomify is revolutionizing digital imaging in commerce, education, entertainment, science, and security. Technologies include HTML5 viewing options, web-based annotation, and more.
Zoomify は、高画質イメージを、素早くズームとパンし、HTML と JPEGs、JavaScrip だけを使ってウェッブ上でインタラクティブビューにします。Zoomify の製品は、創造的なプロフェッショナルの高解像度画像のニーズや画像中心のビジネス、デジタルデバイス開発者にあっています。Zoomify は、商業や教育、エンターテイメント、科学、セキュリティのデジタル画像に革命を起こしています。技術は HTML5 ビューオプションやウェッブベースの注釈などを含んでいます。


説明に次のようにあります。

Zoomify is a format for deep-zooming into high resolution images. This example shows how to use the Zoomify source with a pixel projection. Internet Imaging Protocol (IIP) with JTL extension is also handled.

Zoomify は、高解像度画像にする深いズームのフォーマットです。この例はピクセル投影法で Zoomify ソースを使用する方法を示しています。JTL 拡張でインターネットイメージプロトコルも取り扱えます。

次の内容で index.js を作成します。
user@deb9-vmw:~/new-project$ vim index.js
import 'ol/ol.css';
import Map from 'ol/Map';
import View from 'ol/View';
import TileLayer from 'ol/layer/Tile';
import Zoomify from 'ol/source/Zoomify.js';
var imgWidth = 9911;
var imgHeight = 6100;
var zoomifyUrl = 'http://vips.vtech.fr/cgi-bin/iipsrv.fcgi?zoomify=' +
 '/mnt/MD1/AD00/plan_CHU-4HD-01/FOND.TIF/';
var iipUrl = 'http://vips.vtech.fr/cgi-bin/iipsrv.fcgi?FIF=' + '/mnt/MD1/AD00/plan_CHU-4HD-01/FOND.TIF' + '&JTL={z},{tileIndex}';
var layer = new TileLayer({
/** ol/layer/Tile~TileLayer 
 * For layer sources that provide pre-rendered, tiled 
 * images in grids that are organized by zoom levels for 
 * specific resolutions. 
 * プリレンダリング(事前描画)を提供するレイヤソースのため
 * の、特定の解像度でのズームレベルによって編成されているグ
 * リッドのタイルイメージ。(ol5 API)
 */
 source: new Zoomify({
 /** source [TileLayer(option)]
  * Source for this layer. 
  * レイヤのソース。(ol5 API)
  */
 /** ol/source/Zoomify~Zoomify 
  * Layer source for tile data in Zoomify format (both 
  * Zoomify and Internet Imaging Protocol are supported).
  * Zoomify フォーマット(Zoomify と Internet Imaging 
  * Protocol の両方がサポートされる)タイルサデータのレイヤ
  * ソース。(ol5 API)
  */
  url: zoomifyUrl,
  /** url [Zoomify(option)]
   * URL template or base URL of the Zoomify service. A 
   * base URL is the fixed part of the URL, excluding 
   * the tile group, z, x, and y folder structure, e.g. 
   * http://my.zoomify.info/IMAGE.TIF/. A URL template 
   * must include {TileGroup}, {x}, {y}, and {z} 
   * placeholders, e.g. http://my.zoomify.info/
   * IMAGE.TIF/{TileGroup}/{z}-{x}-{y}.jpg. Internet 
   * Imaging Protocol (IIP) with JTL extension can be  
   * also used with {tileIndex} and {z} placeholders, 
   * e.g. http://my.zoomify.info?FIF=IMAGE.TIF&JTL={z},
   * {tileIndex}. A {?-?} template pattern, for example 
   * subdomain{a-f}.domain.com, may be used instead of 
   * defining each one separately in the urls option.
   * URL テンプレート、または、Zoomify サービスのベース URL。
   * ベース URL は、タイルグループ、x、z、y フォルダ構造を除
   * く、 URLの固定された部分、例えば、
   * http://my.zoomify.info/IMAGE.TIF/、です。URL テン
   * プレートは、{TileGroup}、{x}、{y}、{z} プレースホルダを
   * 含まなければなりません。例えば、http://my.zoomify.info/
   * IMAGE.TIF/{TileGroup}/{z}-{x}-{y}.jpg です。JTL 
   * 拡張子のついたInternet Imaging Protocol (IIP) は、
   * {tileIndex} と {z} プレースホルダをつけて使われます。
   * 例えば、http://my.zoomify.info?FIF=IMAGE.TIF&JTL=
   * {z},{tileIndex} です。{?-?} テンプレートパターン、例え
   * ば subdomain{a-f}.domain.com、は urls オプションで
   * それぞれを別に定義するかわりに使うことができます。
   * (ol5 API)
   */
  size: [imgWidth, imgHeight],
  /** size [Zoomify(option)]
   * Size of the image.
   * 画像のサイズ。
   * (ol5 API)
   */
  crossOrigin: 'anonymous'
  /** crossOrigin [Zoomify(option)]
   * 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 レンダ
   * ラを使用している場合、または、Canvas レンダラでピクセル
   * データにアクセスする場合、crossOrigin 値を提供なければ
   * ならないことに注意してください。詳細は 
   * https://developer.mozilla.org/en-US/docs/Web/HTML/
   * CORS_enabled_image を参照してください。
   * (ol5 API)
   */
 })
});
var extent = [0, -imgHeight, imgWidth, 0];
var map = new Map({
 layers: [layer],
 /** layers [Map(options)]
  * Layers. If this is not defined, a map with no layers 
  * will be rendered. Note that layers are rendered in 
  * the order supplied, so if you want, for example, a 
  * vector layer to appear on top of a tile layer, it 
  * must come after the tile layer.
  * レイヤ(layers)。これが定義されていない場合、レイヤのない
  * マップが描画されます。レイヤは提供された順番に描画されるの
  * で、例えば、ベクタレイヤがタイルレイヤの上に表示するよう望
  * むなら、タイルレイヤの後に来なければならないことに注意して
  * ください。(ol5 API)
  */
 target: 'map',
 /** target [Map(options)]
  * The container for the map, either the element itself 
  * or the id of the element. If not specified at 
  * construction time, module:ol/Map~Map#setTarget must 
  * be called for the map to be rendered.
  * map のコンテナ、(HTML)エレメント自身、または、エレメント
  * の id。構築時に指定されていない場合、描画される map のた
  * めに module:ol/Map~Map#setTarget が呼び出されなけれ
  * ばなりません。
  * (ol5 API)
  */
 view: new View({
 /** view [Map(options)]
  * The map's view. No layer sources will be fetched unless 
  * this is specified at construction time or through 
  * module:ol/Map~Map#setView.
  * map(マップ)の view(ビュー)。これが構築時に指定されて
  * いないか、module:ol/Map~Map#setView を介さなければ、取
  * 得されるレイヤソースはありません。
  * (ol5 API)
  */
  // adjust zoom levels to those provided by the source
  // ソースによって提供されたそれらのためにズームレベルを調整する
  resolutions: layer.getSource().getTileGrid().getResolutions(),
  /** resolutions [View(options)]
   * Resolutions to determine the resolution constraint. 
   * If set the maxResolution, minResolution, minZoom, 
   * maxZoom, and zoomFactor options are ignored.
   * resolution 制約を決定するための resolutions。
   * maxResolution が設定されている場合、inResolution, 
   * minZoom, maxZoom, and zoomFactor は無視されます。
   * (ol5 API)
   */
  /** getSource()
   * Return the associated tilesource of the the layer.
   * タイルレイヤの関連するタイルソースを返します。
   * (ol5 API)
   */
  /** getTileGrid()
   * Return the tile grid of the tile source.
   * タイルソースのタイルグリッドを返します。
   * (ol5 API)
   */
  /** getResolutions()
   * Get the list of resolutions for the tile grid.
   * タイルグリッドの解像度のリストを取得します。
   * (ol5 API)
   */
  // constrain the center: center cannot be set outside 
  // this extent
  // 中心を制約する: 中心をこの範囲の外に設定できません
  extent: extent
  /** extent [View(options)]
   * The extent that constrains the center, in other words, 
   * center cannot be set outside this extent.
   * 中心を制約する範囲、言い換えれば、中心をこの範囲の外に設
   * 定できません。
   * (ol5 API)
   */
 })
});
map.getView().fit(extent);
/** getView()
 * Get the view associated with this map. A view manages 
 * properties such as center and resolution.
 * このマップと関連するビューを取得します。ビューは、中心や解
 * 像度のような属性を管理します。
 * (ol5 API)
 */
/** fit(geometryOrExtent, opt_options)
 * Fit the given geometry or extent based on the given 
 * map size and border. The size is pixel dimensions of 
 * the box to fit the extent into. In most cases you 
 * will want to use the map size, that is map.getSize(). 
 * Takes care of the map angle.
 * 与えられたジオメトリと与えられたマップサイズと境界をもとと
 * した範囲を合わせます。サイズは、範囲内に合わせるために、ボッ
 * クスの単位はピクセルです。ほとんどの場合、マップサイズを使
 * いますが、それは map.getSize() です。マップアングルに気
 * をつけてください。
 * (ol5 API)
 */
var control = document.getElementById('zoomifyProtocol');
/** Document.getElementById()
 * The Document method getElementById() returns an 
 * Element object representing the element whose id 
 * property matches the specified string. Since element 
 * IDs are required to be unique if specified, they're a 
 * useful way to get access to a specific element 
 * quickly.
 * If you need to get access to an element which doesn't 
 * have an ID, you can use querySelector() to find the 
 * element using any selector.
 * Document の getElementById() メソッドは、 id プロパティ
 * が指定された文字列に一致する要素を表す Element オブジェ
 * クトを返します。要素の ID は、指定されていれば固有であるこ
 * とが求められているため、特定の要素にすばやくアクセスする
 * には便利な方法です。
 * ID を持たない要素にアクセスする必要がある場合は、
 * querySelector() で何らかのセレクターを使用して要素を検
 * 索することができます。
 * (MDN[https://developer.mozilla.org/ja/docs/Web/API/
 * Document/getElementById])
 */
control.addEventListener('change', function(event) {
/** EventTarget.addEventListener()
 * The EventTarget method addEventListener() sets up a 
 * function that will be called whenever the specified 
 * event is delivered to the target. Common targets are
 * Element, Document, and Window, but the target may be 
 * any object that supports events (such as 
 * XMLHttpRequest).
 * addEventListener() works by adding a function or an 
 * object that implements EventListener to the list of 
 * event listeners for the specified event type on the 
 * EventTarget on which it's called.
 * EventTarget.addEventListener() メソッドは、指定された
 * イベントがターゲットに渡されるときにはいつでも呼び出される
 * ファンクションを設定します。一般的なターゲットは、Element、
 * Document、Window ですが、ターゲットは(XMLHttpRequest 
 * のような)イベントをサポートするあらゆるオブジェクトです。
 * addEventListener() は、呼び出される EventTarget の指
 * 定されたイベントタイプためのイベントリスナのリストに 
 * EventListener を実装するファンクション、または、オブジェ
 * クトを追加することによって動作します。
 *(MDN[https://developer.mozilla.org/en-US/docs/Web/API/
 * EventTarget.addEventListener])
 */
 var value = event.currentTarget.value;
 /** Event.currentTarget
  * The currentTarget read-only property of the Event 
  * interface identifies the current target for the 
  * event, as the event traverses the DOM. It always 
  * refers to the element to which the event handler has 
  * been attached, as opposed to Event.target, which 
  * identifies the element on which the event occurred 
  * and which may be its direct descendent. 
  * Event インターフェイスの currentTarget 読み取り専用プ
  * ロパティは、イベントの現在のターゲットを識別し、そのため
  * イベントは DOM を横断します。Event.target とは対象的に、
  * イベントハンドラが装着されている要素を常に参照します。
  * イベントが発生した要素を識別し、その直接の子孫です。
  *(MDN[https://developer.mozilla.org/en-US/docs/Web/API/
  * Event/currentTarget])
  */
 if (value === 'iip') {
  layer.setSource(new Zoomify({
  /** setSource(source)
   * Set the layer source.
   * レイヤソースを設定します。
   * (ol5 API)
   */
   url: iipUrl,
   size: [imgWidth, imgHeight],
   crossOrigin: 'anonymous'
  }));
 } else if (value === 'zoomify') {
  layer.setSource(new Zoomify({
   url: zoomifyUrl,
   size: [imgWidth, imgHeight],
   crossOrigin: 'anonymous'
  }));
 }
});
次に index.html を作成します。
user@deb9-vmw:~/new-project$ vim index.html
<!doctype html>
<html>
 <head>
  <meta charset="utf-8">
  <title>Zoomify</title>
  <!-- The line below is only needed for old environments like Internet Explorer and Android 4.x -->
  <script src="https://cdn.polyfill.io/v2/polyfill.min.js?features=requestAnimationFrame,Element.prototype.classList,URL"></script>
 </head>
 <body>
  <div id="map"></div>
  <div class="controls">
   <select id="zoomifyProtocol">
    <option value="zoomify">Zoomify</option>
    <option value="iip">IIP</option>
   </select>
  </div>
  <script src="./index.js"></script>
 <body>
</html>
npm start を実行します。

user@deb9-vmw:~/new-project$ npm start

Webブラウザのアドレス欄に

http://localhost:1234

と入力して Enter キーを押します。



2015年4月13日月曜日

2 - ol3.4ex 110b - Zoomify example 2

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

Zoomify は、

Zoomify
http://www.zoomify.com/

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

Zoomify makes high-quality images of any size zoom-and-pan for fast, interactive viewing on the web. Just HTML, JPEGs, and a small JavaScript file — use it on any website and view it anywhere.
Zoomify は、高速な任意のサイズのズームとパンで高品質な画像をWeb上でインタラクティブに表示します。適切な HTML、JPEG ファイル、および小さい JavaScript ファイルは - すべてのウェブサイト上でそれを使用し、どこでもそれを表示します。

「2110-ol3ex.js」
/** This server does not support CORS, and so is incompatible
 * with WebGL.
 * このサーバは、CORS をサポートしていません。それで、WebGL と共
 * に実行できません。
 */
//var imgWidth = 8001;
//var imgHeight = 6943;
//var url = 'http://mapy.mzk.cz/AA22/0103/';
//var crossOrigin = undefined;
var imgWidth = 9911;
var imgHeight = 6100;
var url = 'http://vips.vtech.fr/cgi-bin/iipsrv.fcgi?zoomify=' +
 '/mnt/MD1/AD00/plan_CHU-4HD-01/FOND.TIF/';
var crossOrigin = 'anonymous';

var imgCenter = [imgWidth / 2, - imgHeight / 2];
/** Maps always need a projection, but Zoomify layers are 
 * not geo-referenced, and are only measured in pixels.  
 * So, we create a fake projection that the map can use to 
 * properly display the layer.
 * マップは常に投影が必要ですが、Zoomify レイヤは地理参照ではな
 * く、ピクセルで測定されるだけです。そこで、マップが適切にレイ
 * ヤーを表示するために使用できる偽の投影を作成します。
 */
var proj = new ol.proj.Projection({
/** ol.proj.Projection
 * Projection definition class. One of these is created 
 * for each projection supported in the application and 
 * stored in the ol.proj namespace. You can use these in 
 * applications, but this is not required, as API params 
 * and options use ol.proj.ProjectionLike which means the 
 * simple string code will suffice.
 * 投影定義クラス。これらの一つは、アプリケーションでサポートさ
 * れ、ol.proj名前空間に格納されている各投影に対して作成されま
 * す。アプリケーションでこれらを使用することができますが、API 
 * のパラメータとオプションは、単純な文字列コードが有能であるこ
 * とを意味する ol.proj.ProjectionLike を使用するので、これは
 * 必要ありません。(ol3 API)
 */
 code: 'ZOOMIFY',
 /** code
  * The SRS identifier code, e.g. EPSG:4326.(ol3 API)
  */
 units: 'pixels',
 /** units
  * Units. Required unless a proj4 projection is defined 
  * for code.
  * units。もし、proj4 プロジェクションがコードとして定義されてい
  * なければ必要です。(ol3 API)
  */
 extent: [0, 0, imgWidth, imgHeight]
 /** extent
  * The validity extent for the SRS.
  * SRS の有効範囲。(ol3 API)
  */
});
var source = new ol.source.Zoomify({
/** ol.source.Zoomify
 * Layer source for tile data in Zoomify format.
 * Zoomify フォーマットのタイルデータのレイヤソース。(ol3 API)
 */
 url: url,
 size: [imgWidth, imgHeight],
 crossOrigin: 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)
  */
});
var map = new ol.Map({
 layers: [
  new ol.layer.Tile({
   source: source
  })
 ],
 renderer: exampleNS.getRendererFromQueryString(),
// 'example-behavior.js' により URL にある renderer を返します
 target: 'map',
 view: new ol.View({
  projection: proj,
  center: imgCenter,
zoom: 0,
  /** constrain the center: center cannot be set outside
   * this extent
   * 中心を強制する: 中心をこの範囲の外に設定できません。
   */
  extent: [0, -imgHeight, imgWidth, 0]
 })
});
 

2 - ol3.4ex 110a - Zoomify example 1

「Zoomify example (zoomify.html)」を参考に地図を表示してみます。

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





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





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



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








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











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

「2110-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>Zoomify 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">Zoomify example</h4>
     <p id="shortdesc">Example of a Zoomify source.</p>
     <div id="docs">
      <!--
      <p>See the <a href="zoomify.js" target="_blank">zoomify.js source</a> to see how this is done.</p>
      -->
      <!-- ファイル修正 -->
      <p>See the <a href="2110-ol3ex.js" target="_blank">2110-ol3ex.js source</a> to see how this is done.</p>
     </div>
     <div id="tags">zoomify</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=zoomify" type="text/javascript"></script>
  -->
  <!-- ファイル修正 -->  <!-- ディレクトリ修正 -->
  <script src="loader.js?id=2110-ol3ex" type="text/javascript"></script>
  </body>
</html>