本文整理汇总了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;
}