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

2014年9月23日火曜日

2 - ol3ex 4b - WMS without client projection example 2

「wms-no-proj.js(204-ol3ex.js)」は、地図を表示するのに必要な javascript です。
(2015.4.20 修正)

「204-ol3ex.js」
var 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.TileWMS({
  /** ol.source.TileWMS
   * Layer source for tile data from WMS servers.
   * WMS サーバからのタイルデータのためのソース。(ol3 API)
   */
 new ol.layer.Image({
  source: new ol.source.ImageWMS({
   attributions: [new ol.Attribution({
   /** ol.Attribution
    * An attribution for a layer source.
    * レイヤソースの属性(ol3 API)
    */
    html: '©' +
    '<a href="http://www.geo.admin.ch/internet/geoportal/' +
    'en/home.html">' +
    'Pixelmap 1:1000000 / geo.admin.ch</a>'
   })],
   crossOrigin: 'anonymous',
   /** 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)
    */
   params: {
    'LAYERS': 'ch.swisstopo.pixelkarte-farbe-pk1000.noscale',
    'FORMAT': 'image/jpeg' // 地図以外の部分が黒くなるため
   },
   url: 'http://wms.geo.admin.ch/',
  })
 }),
 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.ImageWMS({
  /** ol.source.ImageWMS
   * Source for WMS servers providing single, untiled images.
   * 単一、アンタイル(タイル状でない)イメージを提供する WMS 
   * のためのソース。(ol3 API)
   */
   attributions: [new ol.Attribution({
   html: '&copy;' +
   '<a href="http://www.geo.admin.ch/internet/geoportal/' +
   'en/home.html">' +
   'National parks / geo.admin.ch</a>'
   })],
   crossOrigin: 'anonymous',
   params: {'LAYERS': 'ch.bafu.schutzgebiete-paerke_nationaler_bedeutung'},
   serverType: 'mapserver',
   url: 'http://wms.geo.admin.ch/'
  })
 })
];
/** A minimal projection object is configured with only the 
 * SRS code and the map units. No client side coordinate 
 * transforms are possible with such a projection 
 * object.Requesting tiles only needs the code together 
 * with a tile grid of Cartesian coordinates; it does not 
 * matter how those coordinates relate to latitude or 
 * longitude.
 * 最小の投影オブジェクトは、SRS コードおよびマップユニット
 * (units)だけで構成されています。クライアント側座標変換は、投
 * 影オブジェクトで可能です。タイルを要求するには、直交座標のタ
 * イルグリッドと一緒にコードだけ必要とします。それらの座標が緯
 * 度または経度にどのように関連するかは問題ではありません。
 */
var projection = 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: 'EPSG:21781',
 units: 'm'
});
var map = new ol.Map({ 
 layers: layers, 
 renderer: exampleNS.getRendererFromQueryString(),
 //'example-behavior.js' により URL にある renderer を返します
 target: 'map',
 view: new ol.View({
  center: [660000, 190000],
  projection: projection,
  zoom: 9
 })
});


2 - ol3ex 4a - WMS without client projection example 1

「WMS without client projection example(wms-no-proj.html)」を参考に地図を表示してみます。

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





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




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



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








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











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


「204-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">
  <title>WMS without client projection example</title>
 </head>
 <body>

  <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">WMS without client projection example</h4>
     <p id="shortdesc">Example of two WMS layers using the projection EPSG:21781, which is unknown to the client.</p>
     <div id="docs">
<!--
      <p>See the <a href="wms-no-proj.js" target="_blank">wms-no-proj.js source</a> to see how this is done.</p>
-->
       <!-- ファイル修正 -->
      <p>See the <a href="204-ol3ex.js" target="_blank">204-ol3ex.js source</a> to see how this is done.</p>
     </div>
     <div id="tags">wms, projection</div>
    </div>
   </div>
  </div>
<!--
  <script src="jquery.min.js" type="text/javascript"></script>
  <script src="../resources/example-behaviour.js" type="text/javascript"></script>
-->
  <!-- ディレクトリ修正 -->
  <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=wms-no-proj" type="text/javascript"></script>
-->
  <!-- ファイル修正 -->  <!-- ディレクトリ修正 -->
  <script src="loader.js?id=204-ol3ex" type="text/javascript"></script>

 </body>
</html>

2014年6月18日水曜日

2 - ol3-beta.5ex 5b - WMS without client projection example 2

「wms-no-proj.js(205-ol3ex.js)」は、地図を表示するのに必要な javascript です。

「205-ol3ex.js」
var layers = [
// 'ol.layer.Tile' では地図が表示できませんでした
//  new ol.layer.Tile({
//    source: new ol.source.TileWMS({
 new ol.layer.Image({
  source: new ol.source.ImageWMS({
   attributions: [new ol.Attribution({
/*  html: '© ' +
 *   '<a href="http://www.geo.admin.ch/internet/geoportal/' +
 *   'en/home.html">' +
 *   'Pixelmap 1:1000000 / geo.admin.ch</a>'
 */
    html: '基盤地図情報'
   })],
// crossOrigin: 'anonymous',
   params: {
//  'LAYERS': 'ch.swisstopo.pixelkarte-farbe-pk1000.noscale',
    'MAP' : '/home/user/mapfile/nippon_bmi_akiruno_pgis.map',
    'LAYERS': 'akiruno_kukaku',
//  'FORMAT': 'image/jpeg' // 地図以外の部分が黒くなるため
    'VERSION': '1.1.1' // '1.3.0' では地図が表示できませんでした
   },
// url: 'http://wms.geo.admin.ch/',
   url: 'http://localhost/cgi-bin/mapserv?'
  })
 }),
 new ol.layer.Image({
  source: new ol.source.ImageWMS({
   attributions: [new ol.Attribution({
/*
 *  html: '© ' +
 *  '<a href="http://www.geo.admin.ch/internet/geoportal/' +
 *  'en/home.html">' +
 *  'National parks / geo.admin.ch</a>'
 */
    html: '基盤地図情報'
   })],
// crossOrigin: 'anonymous',
// params: {'LAYERS': 'ch.bafu.schutzgebiete-paerke_nationaler_bedeutung'},
   params: {
    'MAP' : '/home/user/mapfile/nippon_bmi_akiruno_pgis.map',
    'LAYERS': 'akiruno_kenchiku',
    'VERSION': '1.1.1'
   },
   serverType: 'mapserver',
// url: 'http://wms.geo.admin.ch/'
   url: 'http://localhost/cgi-bin/mapserv?'
  })
 })
];
// A minimal projection object is configured with only the SRS code and the map
// units. No client side coordinate transforms are possible with such a
// projection object.
var projection = new ol.proj.Projection({
// code: 'EPSG:21781',
  code: 'EPSG:2451',
  units: 'm'
});
var map = new ol.Map({
/* 座標系の設定がないとスケールが表示されません
 * controls: ol.control.defaults().extend([
 *  new ol.control.ScaleLine({
 *   units: 'metric'
 *  })
 * ]),
 */
 layers: layers,
 // 'example-behavior.js' により URL にある renderer を返します
 renderer: exampleNS.getRendererFromQueryString(),
 target: 'map',
 view: new ol.View2D({
// center: [660000, 190000],
  center: [-54250, -29350],
  projection: projection,
// zoom: 9
  zoom: 12 // 座標系の設定がない場合とある場合で数値が違います
 })
});


2 - ol3-beta.5ex 5a - WMS without client projection example 1

「WMS without client projection example
(wms-no-proj.html)」を参考に地図を表示してみます。

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





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




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



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








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











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


「205-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-beta.5/css/ol.css" type="text/css">
  <link rel="stylesheet" href="v3.0.0-beta.5/resources/bootstrap/css/bootstrap.min.css" type="text/css">
  <link rel="stylesheet" href="v3.0.0-beta.5/resources/layout.css" type="text/css">
  <link rel="stylesheet" href="v3.0.0-beta.5/resources/bootstrap/css/bootstrap-responsive.min.css" type="text/css">
  <title>WMS without client projection example</title>
 </head>
 <body>

  <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-beta.5/examples/"><img src="v3.0.0-beta.5/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">WMS without client projection example</h4>
     <p id="shortdesc">Example of two WMS layers using the projection EPSG:21781, which is unknown to the client.</p>
     <div id="docs">
<!--
      <p>See the <a href="wms-no-proj.js" target="_blank">wms-no-proj.js source</a> to see how this is done.</p>
-->
       <!-- ファイル修正 -->
      <p>See the <a href="205-ol3ex.js" target="_blank">205-ol3ex.js source</a> to see how this is done.</p>
     </div>
     <div id="tags">wms, projection</div>
    </div>
   </div>
  </div>
<!--
  <script src="jquery.min.js" type="text/javascript"></script>
  <script src="../resources/example-behaviour.js" type="text/javascript"></script>
-->
  <!-- ディレクトリ修正 -->
  <script src="v3.0.0-beta.5/examples/jquery.min.js" type="text/javascript"></script>
  <script src="v3.0.0-beta.5/resources/example-behaviour.js" type="text/javascript"></script>
<!--
  <script src="loader.js?id=wms-no-proj" type="text/javascript"></script>
-->
  <!-- ファイル修正 -->  <!-- ディレクトリ修正 -->
  <script src="loader.js?id=205-ol3ex" type="text/javascript"></script>

 </body>
</html>