當前位置: 首頁>>代碼示例>>Java>>正文


Java Grids類代碼示例

本文整理匯總了Java中org.geotools.grid.Grids的典型用法代碼示例。如果您正苦於以下問題:Java Grids類的具體用法?Java Grids怎麽用?Java Grids使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Grids類屬於org.geotools.grid包,在下文中一共展示了Grids類的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: createGridLayer

import org.geotools.grid.Grids; //導入依賴的package包/類
private Layer createGridLayer(Style style, ReferencedEnvelope gridBounds)
        throws IOException {
    double squareWidth = 20.0;
    double extent = gridBounds.maxExtent();
    double ll = Math.log10(extent);
    if (ll > 0) {
        // there are ll 10's across the map
        while (ll-- > 4) {
            squareWidth *= 10;
        }
    }

    // max distance between vertices
    double vertexSpacing = squareWidth / 20;
    // grow to cover the whole map (and a bit).
    double left = gridBounds.getMinX();
    double bottom = gridBounds.getMinY();

    if (left % squareWidth != 0) {
        if (left > 0.0) { // east
            left -= Math.abs(left % squareWidth);
        } else { // west
            left += Math.abs(left % squareWidth);
        }
    }

    if (bottom % squareWidth != 0) {
        if (bottom > 0.0) {
            bottom -= Math.abs(bottom % squareWidth);
        } else {
            bottom += Math.abs(bottom % squareWidth);
        }
    }

    gridBounds.expandToInclude(left, bottom);
    double right = gridBounds.getMaxX();
    double top = gridBounds.getMaxY();
    if (right % squareWidth != 0) {
        if (right > 0.0) { // east
            right += Math.abs(right % squareWidth) + squareWidth;
        } else { // west
            right -= Math.abs(right % squareWidth) - squareWidth;
        }
    }

    if (top % squareWidth != 0) {
        if (top > 0.0) { // North
            top += Math.abs(top % squareWidth) + squareWidth;
        } else { // South
            top -= Math.abs(top % squareWidth) - squareWidth;
        }
    }

    gridBounds.expandToInclude(right, top);
    SimpleFeatureSource grid = Grids.createSquareGrid(gridBounds, squareWidth,
            vertexSpacing);
    Layer gridLayer = new FeatureLayer(grid.getFeatures(), style);
    return gridLayer;
}
 
開發者ID:ianturton,項目名稱:geotools-cookbook,代碼行數:60,代碼來源:Tissot.java


注:本文中的org.geotools.grid.Grids類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。