当前位置: 首页>>代码示例>>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;未经允许,请勿转载。