本文整理汇总了Java中org.geotools.geometry.jts.ReferencedEnvelope.expandToInclude方法的典型用法代码示例。如果您正苦于以下问题:Java ReferencedEnvelope.expandToInclude方法的具体用法?Java ReferencedEnvelope.expandToInclude怎么用?Java ReferencedEnvelope.expandToInclude使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.geotools.geometry.jts.ReferencedEnvelope
的用法示例。
在下文中一共展示了ReferencedEnvelope.expandToInclude方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: expandToIncludeEnvelope
import org.geotools.geometry.jts.ReferencedEnvelope; //导入方法依赖的package包/类
private void expandToIncludeEnvelope( ReferencedEnvelope maxExtent, org.opengis.geometry.Envelope envelope ) {
ReferencedEnvelope tmpExtent = new ReferencedEnvelope(envelope.getCoordinateReferenceSystem());
DirectPosition ll = envelope.getLowerCorner();
double[] coordinate = ll.getCoordinate();
tmpExtent.expandToInclude(new Coordinate(coordinate[0], coordinate[1]));
DirectPosition ur = envelope.getUpperCorner();
coordinate = ur.getCoordinate();
tmpExtent.expandToInclude(new Coordinate(coordinate[0], coordinate[1]));
try {
ReferencedEnvelope transformed = tmpExtent.transform(maxExtent.getCoordinateReferenceSystem(), true);
maxExtent.expandToInclude(transformed);
} catch (TransformException | FactoryException e) {
e.printStackTrace();
}
}
示例2: updateFeatureType
import org.geotools.geometry.jts.ReferencedEnvelope; //导入方法依赖的package包/类
void updateFeatureType(FeatureTypeInfo fti, ReferencedEnvelope dirtyRegion) {
log.fine(()->"Updating bounds of "+fti.prefixedName()+" in response to data change");
ReferencedEnvelope bounds = fti.getNativeBoundingBox();
bounds.expandToInclude(dirtyRegion); // CRSes should already match
fti.setNativeBoundingBox(bounds);
catalog.save(fti);
}
示例3: updateLayerGroup
import org.geotools.geometry.jts.ReferencedEnvelope; //导入方法依赖的package包/类
void updateLayerGroup(LayerGroupInfo lgi, ReferencedEnvelope dirtyRegion) {
log.fine(()->"Updating bounds of "+lgi.prefixedName()+" in response to data change");
ReferencedEnvelope bounds = lgi.getBounds();
try {
bounds.expandToInclude(new ReferencedEnvelope(dirtyRegion).transform(bounds.getCoordinateReferenceSystem(), true, 1000));
} catch (MismatchedDimensionException | TransformException | FactoryException ex) {
log.log(Level.WARNING, "Error while transforming changes to coordinate system of layer group "+lgi.prefixedName(), ex);
}
lgi.setBounds(bounds);
catalog.save(lgi);
}
示例4: testAfterTransaction
import org.geotools.geometry.jts.ReferencedEnvelope; //导入方法依赖的package包/类
@Test
public void testAfterTransaction() throws Exception {
Map<Object, Object> extendedProperties = new HashMap<Object, Object>();
ReferencedEnvelope affectedBounds1 = new ReferencedEnvelope(-180, 0, 0, 90, WGS84);
ReferencedEnvelope affectedBounds2 = new ReferencedEnvelope(0, 180, 0, 90, WGS84);
ReferencedEnvelope oldBounds = new ReferencedEnvelope(-90, 0, 0, 45, WGS84);
ReferencedEnvelope newBounds = new ReferencedEnvelope(oldBounds);
newBounds.expandToInclude(affectedBounds1);
newBounds.expandToInclude(affectedBounds2);
LayerInfo layer = mockLayer(featureType1, "layer");
EasyMock.expect(catalog.getFeatureTypeByName(featureTypeName1)).andStubReturn(featureType1);
EasyMock.expect(featureType1.getNativeBoundingBox()).andStubReturn(oldBounds);
// Verify the FT is updated
featureType1.setNativeBoundingBox(EasyMock.eq(newBounds));EasyMock.expectLastCall().once();
catalog.save(featureType1);EasyMock.expectLastCall().once();
EasyMock.expect(catalog.list(EasyMock.eq(LayerGroupInfo.class), EasyMock.anyObject()))
.andStubAnswer(()-> new CloseableIteratorAdapter<LayerGroupInfo>(
Collections.emptyListIterator()));
EasyMock.replay(catalog, featureType1, featureType2, layer);
issueInsert(extendedProperties, affectedBounds1);
issueInsert(extendedProperties, affectedBounds2);
TransactionType request = EasyMock.createNiceMock(TransactionType.class);
TransactionResponseType result = EasyMock.createNiceMock(TransactionResponseType.class);
EasyMock.expect(request.getExtendedProperties()).andReturn(extendedProperties);
EasyMock.replay(request, result);
listener.afterTransaction(request, result, true);
ReferencedEnvelope expectedEnv = new ReferencedEnvelope(affectedBounds1);
expectedEnv.expandToInclude(affectedBounds2);
EasyMock.verify(catalog, featureType1, featureType2, request, result, layer);
}
示例5: testAfterTransactionLayerGroup
import org.geotools.geometry.jts.ReferencedEnvelope; //导入方法依赖的package包/类
@Test
public void testAfterTransactionLayerGroup() throws Exception {
Map<Object, Object> extendedProperties = new HashMap<Object, Object>();
ReferencedEnvelope affectedBounds1 = new ReferencedEnvelope(-180, 0, 0, 90, WGS84);
ReferencedEnvelope affectedBounds2 = new ReferencedEnvelope(0, 180, 0, 90, WGS84);
ReferencedEnvelope oldBounds = new ReferencedEnvelope(-90, 0, 0, 45, WGS84);
ReferencedEnvelope newBounds = new ReferencedEnvelope(oldBounds);
newBounds.expandToInclude(affectedBounds1);
newBounds.expandToInclude(affectedBounds2);
EasyMock.expect(catalog.getFeatureTypeByName(featureTypeName1)).andStubReturn(featureType1);
EasyMock.expect(featureType1.getNativeBoundingBox()).andStubReturn(oldBounds);
LayerInfo layer = mockLayer(featureType1, "layer");
LayerInfo otherLayer = mockLayer(featureType2, "otherLayer");
List<LayerGroupInfo> groups = new ArrayList<>();
LayerGroupInfo direct = mockGroup("direct", oldBounds, otherLayer, layer);
direct.setBounds(EasyMock.eq(newBounds));EasyMock.expectLastCall().once();
catalog.save(direct);EasyMock.expectLastCall().once();
groups.add(direct);
LayerGroupInfo directRoot = mockGroup("directRoot", oldBounds, layer, otherLayer);
directRoot.setBounds(EasyMock.eq(newBounds));EasyMock.expectLastCall().once();
catalog.save(directRoot);EasyMock.expectLastCall().once();
groups.add(directRoot);
LayerGroupInfo unaffected = mockGroup("unaffected", oldBounds, null, otherLayer);
groups.add(unaffected);
mockLayerGroupList(groups);
// Verify the FT is updated
featureType1.setNativeBoundingBox(EasyMock.eq(newBounds));EasyMock.expectLastCall().once();
catalog.save(featureType1);EasyMock.expectLastCall().once();
EasyMock.replay(catalog, featureType1, featureType2, layer, otherLayer);
groups.forEach(EasyMock::replay);
issueInsert(extendedProperties, affectedBounds1);
issueInsert(extendedProperties, affectedBounds2);
TransactionType request = EasyMock.createNiceMock(TransactionType.class);
TransactionResponseType result = EasyMock.createNiceMock(TransactionResponseType.class);
EasyMock.expect(request.getExtendedProperties()).andReturn(extendedProperties);
EasyMock.replay(request, result);
listener.afterTransaction(request, result, true);
ReferencedEnvelope expectedEnv = new ReferencedEnvelope(affectedBounds1);
expectedEnv.expandToInclude(affectedBounds2);
EasyMock.verify(catalog, featureType1, featureType2, request, result, layer, otherLayer);
groups.forEach(EasyMock::verify);
}
示例6: testAfterTransactionLayerGroupRecursive
import org.geotools.geometry.jts.ReferencedEnvelope; //导入方法依赖的package包/类
@Test
public void testAfterTransactionLayerGroupRecursive() throws Exception {
Map<Object, Object> extendedProperties = new HashMap<Object, Object>();
ReferencedEnvelope affectedBounds1 = new ReferencedEnvelope(-180, 0, 0, 90, WGS84);
ReferencedEnvelope affectedBounds2 = new ReferencedEnvelope(0, 180, 0, 90, WGS84);
ReferencedEnvelope oldBounds = new ReferencedEnvelope(-90, 0, 0, 45, WGS84);
ReferencedEnvelope newBounds = new ReferencedEnvelope(oldBounds);
newBounds.expandToInclude(affectedBounds1);
newBounds.expandToInclude(affectedBounds2);
EasyMock.expect(catalog.getFeatureTypeByName(featureTypeName1)).andStubReturn(featureType1);
EasyMock.expect(featureType1.getNativeBoundingBox()).andStubReturn(oldBounds);
LayerInfo layer = mockLayer(featureType1, "layer");
LayerInfo otherLayer = mockLayer(featureType2, "otherLayer");
List<LayerGroupInfo> groups = new ArrayList<>();
LayerGroupInfo direct = mockGroup("direct", oldBounds, otherLayer, layer);
direct.setBounds(EasyMock.eq(newBounds));EasyMock.expectLastCall().once();
catalog.save(direct);EasyMock.expectLastCall().once();
groups.add(direct);
LayerGroupInfo indirect1 = mockGroup("indirect1", oldBounds, otherLayer, direct);
indirect1.setBounds(EasyMock.eq(newBounds));EasyMock.expectLastCall().once();
catalog.save(indirect1);EasyMock.expectLastCall().once();
groups.add(indirect1);
LayerGroupInfo indirect2 = mockGroup("indirect2", oldBounds, otherLayer, indirect1);
indirect2.setBounds(EasyMock.eq(newBounds));EasyMock.expectLastCall().once();
catalog.save(indirect2);EasyMock.expectLastCall().once();
groups.add(indirect2);
mockLayerGroupList(groups);
// Verify the FT is updated
featureType1.setNativeBoundingBox(EasyMock.eq(newBounds));EasyMock.expectLastCall().once();
catalog.save(featureType1);EasyMock.expectLastCall().once();
EasyMock.replay(catalog, featureType1, featureType2, layer, otherLayer);
groups.forEach(EasyMock::replay);
issueInsert(extendedProperties, affectedBounds1);
issueInsert(extendedProperties, affectedBounds2);
TransactionType request = EasyMock.createNiceMock(TransactionType.class);
TransactionResponseType result = EasyMock.createNiceMock(TransactionResponseType.class);
EasyMock.expect(request.getExtendedProperties()).andReturn(extendedProperties);
EasyMock.replay(request, result);
listener.afterTransaction(request, result, true);
ReferencedEnvelope expectedEnv = new ReferencedEnvelope(affectedBounds1);
expectedEnv.expandToInclude(affectedBounds2);
EasyMock.verify(catalog, featureType1, featureType2, request, result, layer, otherLayer);
groups.forEach(EasyMock::verify);
}
示例7: createGridLayer
import org.geotools.geometry.jts.ReferencedEnvelope; //导入方法依赖的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;
}