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

2015年11月30日月曜日

2 - ol3.11ex 140b - Reprojection with EPSG.io database search 2

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

「2140-ol3ex.js」
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 参照)
  */
  })
 ],
 renderer: common.getRendererFromQueryString(),
// 'common.js' により URL にある renderer を返します
 target: 'map',
 view: new ol.View({
  projection: 'EPSG:3857',
  center: [0, 0],
  zoom: 1
 })
});
var queryInput = document.getElementById('epsg-query');
var searchButton = document.getElementById('epsg-search');
var resultSpan = document.getElementById('epsg-result');
var renderEdgesCheckbox = document.getElementById('render-edges');
function setProjection(code, name, proj4def, bbox) {
 if (code === null || name === null || proj4def === null || bbox === null) {
  resultSpan.innerHTML = 'Nothing usable found, using EPSG:3857...';
  map.setView(new ol.View({
  /** setView(view)
   * Set the view for this map.
   * map の view を設定します。(ol3 API)
   */
   projection: 'EPSG:3857',
   center: [0, 0],
   zoom: 1
  }));
  return;
 }
 resultSpan.innerHTML = '(' + code + ') ' + name;

 var newProjCode = 'EPSG:' + code;
 proj4.defs(newProjCode, proj4def);
 var newProj = ol.proj.get(newProjCode);
 var fromLonLat = ol.proj.getTransform('EPSG:4326', newProj);
/** ol.proj.getTransform(source, destination)
 * Given the projection-like objects, searches for a
 * transformation function to convert a coordinates 
 * array from the source projection to the destination 
 * projection.
 * projection 系オブジェクトを与えられると、変換関数のための
 * 検索は、ソース投影から宛先の投影にの座標の配列に変換します。
 * (ol3 API)
 */
 // very approximate calculation of projection extent
 // 投影範囲のより正確な近似計算
 var extent = ol.extent.applyTransform(
  [bbox[1], bbox[2], bbox[3], bbox[0]], fromLonLat);
 /** ol.extent.applyTransform(extent, transformFn, 
  * opt_extent)
  * Apply a transform function to the extent.
  * 範囲の transform 関数を適用します。(ol3 API)
  */
 newProj.setExtent(extent);
 /** setExtent(extent)
  * Set the validity extent for this projection.
  * この投影の有効範囲を設定します。(ol3 API)
  */
 var newView = new ol.View({
  projection: newProj
 });
 map.setView(newView);
 var size = map.getSize();
 /** getSize()
  * Get the size of this map.
  * Returns: The size in pixels of the map in the DOM.
  * マップのサイズを取得。(ol3 API)
  */
 if (size) {
  newView.fit(extent, size);
 /** fit(geometry, size, 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()。マップアングルに注意してくださ
  * い。
  * (ol3 API[説明は Stable Only のチェックを外すと表示])
  */
 }
}
function search(query) {
 resultSpan.innerHTML = 'Searching...';
 $.ajax({
 /** jQuery.ajax()
  * Perform an asynchronous HTTP (Ajax) request.
  * 非同期 HTTP(Ajax)リエストを実行します。
  * (jQuery[http://api.jquery.com/jquery.ajax/])
  */
 url: 'http://epsg.io/?format=json&q=' + query,
 dataType: 'jsonp',
 success: function(response) {
  if (response) {
   var results = response['results'];
   if (results && results.length > 0) {
    for (var i = 0, ii = results.length; i < ii; i++) {
     var result = results[i];
     if (result) {
      var code = result['code'], name = result['name'],
      proj4def = result['proj4'], bbox = result['bbox'];
      if (code && code.length > 0 && proj4def && proj4def.length > 0 &&
       bbox && bbox.length == 4) {
        setProjection(code, name, proj4def, bbox);
        return;
       }
      }
     }
    }
   }
   setProjection(null, null, null, null);
  }
 });
}
/**
 * @param {Event} e Change event.
 */
/** 「@param」
 * The @param tag provides the name, type, and 
 * description of a function parameter.
 * The @param tag requires you to specify the name of 
 * the parameter you are documenting. You can also 
 * include the parameter's type, enclosed in curly 
 * brackets, and a description of the parameter.
 * @paramタグは、関数パラメータの名前と型、説明を提供します。
 * @paramタグを使用すると、文書化されたパラメータの名前を
 * 指定する必要があります。また、パラメータのタイプと、中括弧
 * で囲まれたおよびパラメータの説明を含めることができます。
 * (@use JSDoc [http://usejsdoc.org/tags-param.html])
 */
searchButton.onclick = function(e) {
 search(queryInput.value);
 e.preventDefault();
 /** Event.preventDefault()
  * Cancels the event if it is cancelable, without 
  * stopping further propagation of the event.
  * イベントのさらなる伝播を停止させることなく、解約された場合
  * に、イベントをキャンセルします。
  * (MDN[https://developer.mozilla.org/en-US/docs/Web/
  * API/Event/preventDefault])
  */
};
/**
 * @param {Event} e Change event.
 */
renderEdgesCheckbox.onchange = function(e) {
/** GlobalEventHandlers.onchange()
 * The onchange property sets and returns the event handler 
 * for the change event.
 * onchange プロパティは、change イベントに対してイベントハ
 * ンドラを設定、および、返します。
 * (MDN[https://developer.mozilla.org/en-US/docs/Web/
 * API/GlobalEventHandlers/onchange])
 */
 map.getLayers().forEach(function(layer) {
 /** getLayers()
  * Get the collection of layers associated with this 
  * map.
  * このマップと関連するレイヤのコレクションを取得します。
  * (ol3 API)
  */
  if (layer instanceof ol.layer.Tile) {
  /** instanceof
   * instanceof 演算子は、オブジェクトが自身のプロトタイプに
   * コンストラクタの prototype プロパティを持っているかを確
   * 認します。
   * (MDN[https://developer.mozilla.org/ja/docs/
   * JavaScript/Reference/Operators/instanceof])
   */
   var source = layer.getSource();
   /** getSource()
    * Return the associated tilesource of the the layer.
    * タイルレイヤの関連するタイルソースを返します。(ol3 API)
    */
   if (source instanceof ol.source.TileImage) {
   /** ol.source.TileImage 
    * Base class for sources providing images divided into 
    * a tile grid.
    * タイルグリッドに分割された画像を提供するソースの基本クラ
    * ス。(ol3 API)
    */
    source.setRenderReprojectionEdges(renderEdgesCheckbox.checked);
    /** setRenderReprojectionEdges(render)
     * Sets whether to render reprojection edges or not 
     * (usually for debugging).
     * 再投影エッジをレンダリングするかしないか(通常はデバッグ
     * 用)を設定します。
    * (ol3 API[説明は Stable Only のチェックを外すと表示])
     */
   }
  }
 });
};

2 - ol3.11ex 140a - Reprojection with EPSG.io database search 1

「Reprojection with EPSG.io database search (reprojection-by-code.html)」を参考に地図を表示してみます。
説明に次のようにあります。

This example shows client-side raster reprojection capabilities from MapQuest OSM (EPSG:3857) to arbitrary projection by searching in EPSG.io database.
この例では、 EPSG.ioデータベースで検索することにより、MapQuest の OSM(3857 EPSG)から任意の投影へ:クライアント側のラスタ再投影キャパビリティを示しています。

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





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





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




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








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











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

「2140-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>Reprojection with EPSG.io database search</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>
    <form class="form-inline">
     <label for="epsg-query">Search projection:</label>
     <input type="text" id="epsg-query" placeholder="4326, 27700, US National Atlas, Swiss, France, ..." class="form-control" size="50" />
     <button id="epsg-search" class="btn">Search</button>
     <span id="epsg-result"></span>
     <div>
      <label for="render-edges"><input type="checkbox" id="render-edges" />Render reprojection edges</label>
     </div>
    </form>
   </div>
   <div class="row-fluid">
    <div class="span12">
     <h4 id="title">Reprojection with EPSG.io database 
      search</h4>
     <p id="shortdesc">Demonstrates client-side raster 
      reprojection of MapQuest OSM to arbitrary 
       projection</p>
     <div id="docs"><p>This example shows client-side 
      raster reprojection capabilities from MapQuest OSM 
      (EPSG:3857) to arbitrary projection by searching in 
      <a href="http://epsg.io/">EPSG.io</a> database.</p>
     </div>
     <div id="tags">reprojection, projection, proj4js, 
      mapquest, epsg.io</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.11.2/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.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.format.WMTSCapabilities.html" title="API documentation for ol.format.WMTSCapabilities">ol.format.WMTSCapabilities</a> -->
        <a href="v3.11.2/apidoc/ol.format.WMTSCapabilities.html" title="API documentation for ol.format.WMTSCapabilities">ol.format.WMTSCapabilities</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.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>,
       <li>
        <!-- <a href="../apidoc/ol.source.TileImage.html" title="API documentation for ol.source.TileImage">ol.source.TileImage</a> -->
        <a href="v3.11.2/apidoc/ol.source.TileImage.html" title="API documentation for ol.source.TileImage">ol.source.TileImage</a>
       </li>,
       <li>
        <!-- <a href="../apidoc/ol.source.TileWMS.html" title="API documentation for ol.source.TileWMS">ol.source.TileWMS</a> -->
        <a href="v3.11.2/apidoc/ol.source.TileWMS.html" title="API documentation for ol.source.TileWMS">ol.source.TileWMS</a>
       </li>,
       <li>
        <!-- <a href="../apidoc/ol.source.WMTS.html" title="API documentation for ol.source.WMTS">ol.source.WMTS</a> -->
        <a href="v3.11.2/apidoc/ol.source.WMTS.html" title="API documentation for ol.source.WMTS">ol.source.WMTS</a>
       </li>,
       <li>
        <!-- <a href="../apidoc/ol.source.XYZ.html" title="API documentation for ol.source.XYZ">ol.source.XYZ</a> -->
        <a href="v3.11.2/apidoc/ol.source.XYZ.html" title="API documentation for ol.source.XYZ">ol.source.XYZ</a>
       </li>,
        <li>
        <!-- <a href="../apidoc/ol.tilegrid.TileGrid.html" title="API documentation for ol.tilegrid.TileGrid">ol.tilegrid.TileGrid</a> -->
        <a href="v3.11.2/apidoc/ol.tilegrid.TileGrid.html" title="API documentation for ol.tilegrid.TileGrid">ol.tilegrid.TileGrid</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"></script>
  -->
  <!-- ファイル修正 -->  <!-- ディレクトリ修正 -->
  <script src="loader.js?id=2140-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 のコンテキストメニューが表示されると動作しています。

2014年10月22日水曜日

2 - ol3ex 19a - EPSG:4326 example 1

「EPSG:4326 example(epsg-4326.html)」を参考に地図を表示してみます。EPSG については、OGP(International Association of Oil & Gas Producer)[http://www.ogp.org.uk/]の「About the EPSG Dataset(http://www.epsg.org/)」に説明があります。その一部を引用すると、

*****
The OGP’s EPSG Geodetic Parameter Dataset is a collection of definitions of coordinate reference systems and coordinate transformations which may be global, regional, national or local in application.
OGPのEPSG測地パラメータデータセットは、基準座標系とアプリケーションの、世界、地域、国、地方の座標変換の定義の集合です。

The EPSG Geodetic Parameter Dataset is maintained by the Geodesy Subcommittee of the OGP Geomatics Committee.
EPSG測地パラメータデータセットは、OGP空間情報科学委員会の測地学分科会によって維持されます。
*****

とあります。
EPSG:4326 は、epsg.io の「WGS84-...(http://epsg.io/4326)」に、「WGS84 - World Geodetic System 1984, used in GPS」とあります。
WGS84は、アメリカで管理されている GPS 用の測地系です。内容は以下のようになっています。

*****
Center coordinates
0.00000000 0.00000000
WGS84 bounds:
-180.0 -90.0
180.0 90.0

Attributes
Unit: degree (supplier to define representation)
Geodetic CRS: WGS 84
Datum: World Geodetic System 1984
Ellipsoid: WGS 84
Prime meridian: Greenwich
Data source: OGP
Information source: EPSG. See 3D CRS for original information source.

Revision date: 2007-08-27
*****

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





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





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



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








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











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


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

 </body>
</html>

2008年9月16日火曜日

OpenLayers 10a unitsがddとmeterのレイヤ

OpenLayers 10a units(計測単位) が dd と meter のレイヤを同じ地図に表示します。

OpenLayers 7 で units が meter のレイヤを表示しました。
OpenLayers.Map のオプションを

maxResolution: 'auto',
units: 'meters',
maxExtent: new OpenLayers.Bounds(-83624.557161,-96269.254733,-3366.679476,-36305.074927)

で地図を表示できるようになったので、units が dd(degree) のレイヤもこのオプションで表示できるようにします。

もう一度、神奈川県の基盤地図情報のデータを調べてみましょう。
AdmAreaのデータの概要をみてみます。

user@debian:~/mapdata$ ogrinfo -summary kanagawa AdmArea
INFO: Open of `kanagawa'
using driver `ESRI Shapefile' successful.

Layer name: AdmArea
Geometry: Polygon
Feature Count: 115
Extent: (-83624.557161, -96269.254733) - (-3366.679476, -36305.074927)
Layer SRS WKT:
PROJCS["JGD2000_Japan_Zone_9", <-1
GEOGCS["GCS_JGD_2000",
DATUM["Japanese_Geodetic_Datum_2000",
SPHEROID["GRS_1980",6378137.0,298.257222101]], <-2
PRIMEM["Greenwich",0.0],
UNIT["Degree",0.0174532925199433]],
PROJECTION["Transverse_Mercator"], <-3
PARAMETER["False_Easting",0.0],
PARAMETER["False_Northing",0.0],
PARAMETER["Central_Meridian",139.833333333333], <-4
PARAMETER["Scale_Factor",0.9999],
PARAMETER["Latitude_Of_Origin",36], <-5
UNIT["Meter",1.0]]
ID: String (8.0)
UUID: String (24.0)
PRESENCE: Real (11.0)
FINISHED: Real (11.0)
ORGGILVL: String (8.0)
ORGMDID: String (8.0)
TYPE: String (8.0)
NAME: String (25.0)
CODE: Integer (8.0)


<-番号 はそれぞれ

1 座標系 JGD2000(新日本測地系)ゾーン9
2 楕円体 GRS_1980
3 図法 横メルカトール図法 (tmerc)
4 中央子午線 139.83... (lon_0)
5 原点緯度 36 (lat_0)

を表しています。
/usr/share/proj/epsg から、JGD2000 に関係するコードをみてみます。

user@debian:/usr/share/proj$ grep -A1 JGD2000 epsg
# JGD2000
<4612> +proj=longlat +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +no_defs <>
--
...
# JGD2000 / Japan Plane Rectangular CS IX
<2451> +proj=tmerc +lat_0=36 +lon_0=139.8333333333333 +k=0.9999 +x_0=0 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs <>
...

上は、経緯度表示、下は、平面直角座標系の定義のIXです。
これから、基盤地図情報の神奈川県のEPSGコードは 2451になります。

OpenLayers 10b unitsがddとmeterのレイヤ

国土数値地図の神奈川県の地図をマップの投影をかえて表示してみます。
kanagawa_mlit_pgis.map のマップ(MAP)の PROJECTION を EPSG:2451 にします。
(以前に EPSG:2451 に設定しましたが、EPSG:4612 が正しい設定です。)
コードに合わせて EXTENT を次のように設定します。

MAP
NAME kanagawa_mlit_pgis_map
STATUS ON
SIZE 600 300
# EXTENT 138.91 35.12 139.84 35.68
EXTENT -83624.557161 -96269.254733 -3366.679476 -36305.074927
UNITS dd
IMAGECOLOR 255 255 255
IMAGETYPE png
FONTSET "fonts.txt"
PROJECTION
"init=epsg:2451"
END
---

また、国土数値地図の座標系は JGD2000(新日本測地系)で、EPSGコードは 4612になります。
各レイヤの PROJECTION を EPSG:4612 にします。

---
LAYER
NAME gyoseikai
---
PROJECTION
"init=epsg:4612"
END
TEMPLATE temp_tokyo_shp.html
END

LAYER
NAME gun_seirei
---
PROJECTION
"init=epsg:4612"
END
TEMPLATE temp_tokyo_shp.html
END

LAYER
NAME railroad
---
PROJECTION
"init=epsg:4612"
END
TEMPLATE temp_railroad.html
END

LAYER
NAME public_facilities
---
PROJECTION
"init=epsg:4612"
END
TEMPLATE temp_facilities_pgis.html
END
---

ka-Map で地図を表示します。
地図が表示されないときは、shp2img で試してみてください。

user@debian:~/mapfile$ shp2img -m kanagawa_mlit_pgis.map -o kanagawa_mlit_pgis.png