GeoTools を使用して PostGIS 対応データベースのフィーチャ テーブルから読み取ったいくつかのフィーチャを画像に正しくレンダリングしようとしています。
私の構成:
- PostgreSQL 8.4
- PostGIS 1.5
- 浸透 0.40.1
- OSMembrane ビルド 845
- ジオツール 2.7.4
バウンディング ボックス内の一部のフィーチャのレンダリングは、これまでのところ問題なく機能しています。
問題:次の結果が得られます
- 90°回転 (時計回り)
- y 軸にミラーリング
レンダリングしたい機能はこれに基づいていますCoordinateReferenceSystem
GEOGCS["WGS 84",
DATUM["World Geodetic System 1984",
SPHEROID["WGS 84", 6378137.0, 298.257223563, AUTHORITY["EPSG","7030"]],
AUTHORITY["EPSG","6326"]],
PRIMEM["Greenwich", 0.0, AUTHORITY["EPSG","8901"]],
UNIT["degree", 0.017453292519943295],
AXIS["Geodetic latitude", NORTH],
AXIS["Geodetic longitude", EAST],
AUTHORITY["EPSG","4326"]]
アフィン変換を実行することを認識しているため、次のコードを記述しました。
public void render(final MapContext mapContext, final Graphics2D graphics) throws IOException
{
Rectangle renderingArea = new Rectangle(this.mapWidth, this.mapHeight);
GTRenderer renderer = new StreamingRenderer();
renderer.setContext(mapContext);
//move the result to a visisble area
AffineTransform translate = AffineTransform.getTranslateInstance(mapHeight, mapWidth);
//rotate 180° anti-clockwise
AffineTransform rotate = AffineTransform.getRotateInstance(Math.PI);
//exchange x and y
AffineTransform mirror = new AffineTransform(0, 1, 1, 0, 0, 0);
AffineTransform transform = new AffineTransform(translate);
transform.concatenate(rotate);
transform.concatenate(mirror);
graphics.transform(transform);
renderer.paint(graphics, renderingArea, mapContext.getAreaOfInterest());
}
これは機能し、機能がきれいに見えます! 一方で、これはあまり正しくないと感じます。問題は、オブジェクトに適用したのと同じ変換をgraphics
、レンダラーのメソッドのメソッド パラメーターとして使用できないのはなぜpaint
ですか?
例えば
//move the result to a visisble area
AffineTransform translate = AffineTransform.getTranslateInstance(mapHeight, mapWidth);
//rotate 180° anti-clockwise
AffineTransform rotate = AffineTransform.getRotateInstance(Math.PI);
//exchange x and y
AffineTransform mirror = new AffineTransform(0, 1, 1, 0, 0, 0);
AffineTransform transform = new AffineTransform(translate);
transform.concatenate(rotate);
transform.concatenate(mirror);
renderer.paint(graphics, renderingArea, mapContext.getAreaOfInterest(), transform);
これにより、常に空の画面が表示されます。可視領域外のどこかにレンダリングされていると思います。geotools Web サイトのチュートリアルについては知っていますが、すべてがまとめられている場所が恋しいです。
役立つヒントをお待ちしています。