org.geotools.geometry.jts.ReferencedEnvelope Java Examples
The following examples show how to use
org.geotools.geometry.jts.ReferencedEnvelope.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: GeoWaveEmptyTransaction.java From geowave with Apache License 2.0 | 6 votes |
@Override public void add(final String fid, final SimpleFeature feature) throws IOException { feature.getUserData().put(Hints.USE_PROVIDED_FID, true); if (feature.getUserData().containsKey(Hints.PROVIDED_FID)) { final String providedFid = (String) feature.getUserData().get(Hints.PROVIDED_FID); feature.getUserData().put(Hints.PROVIDED_FID, providedFid); } else { feature.getUserData().put(Hints.PROVIDED_FID, feature.getID()); } components.writeCommit(feature, this); components.getGTstore().getListenerManager().fireFeaturesAdded( components.getAdapter().getFeatureType().getTypeName(), Transaction.AUTO_COMMIT, ReferencedEnvelope.reference(feature.getBounds()), true); }
Example #2
Source File: EnvironmentVariableManagerTest.java From sldeditor with GNU General Public License v3.0 | 6 votes |
/** * Test method for {@link * com.sldeditor.filter.v2.envvar.EnvironmentVariableManager#setWMSEnvVarValues(com.sldeditor.filter.v2.envvar.WMSEnvVarValues)}. */ @Test public void testSetWMSEnvVarValues() { EnvironmentVariableManager.getInstance().setWMSEnvVarValues(null); WMSEnvVarValues wmsEnvVar = new WMSEnvVarValues(); wmsEnvVar.setImageHeight(42); wmsEnvVar.setImageWidth(454); Envelope envelope = new Envelope(1.0, 2.0, 50.0, 51.1); ReferencedEnvelope mapBounds = ReferencedEnvelope.create(envelope, CoordManager.getInstance().getWGS84()); wmsEnvVar.setMapBounds(mapBounds); EnvironmentVariableManager.getInstance().setWMSEnvVarValues(wmsEnvVar); // Update the values again WMSEnvVarValues wmsEnvVar2 = new WMSEnvVarValues(); wmsEnvVar2.setImageHeight(69); wmsEnvVar2.setImageWidth(123); Envelope envelope2 = new Envelope(-1.0, -2.0, 50.0, 51.1); ReferencedEnvelope mapBounds2 = ReferencedEnvelope.create(envelope2, CoordManager.getInstance().getWGS84()); wmsEnvVar2.setMapBounds(mapBounds2); EnvironmentVariableManager.getInstance().setWMSEnvVarValues(wmsEnvVar2); }
Example #3
Source File: RasterUtils.java From geowave with Apache License 2.0 | 6 votes |
public static ReferencedEnvelope getReferenceEnvelope( final GridCoverage gridCoverage, final CoordinateReferenceSystem targetCrs) { final CoordinateReferenceSystem sourceCrs = gridCoverage.getCoordinateReferenceSystem(); final Envelope sampleEnvelope = gridCoverage.getEnvelope(); final ReferencedEnvelope sampleReferencedEnvelope = new ReferencedEnvelope( new org.locationtech.jts.geom.Envelope( sampleEnvelope.getMinimum(0), sampleEnvelope.getMaximum(0), sampleEnvelope.getMinimum(1), sampleEnvelope.getMaximum(1)), gridCoverage.getCoordinateReferenceSystem()); ReferencedEnvelope projectedReferenceEnvelope = sampleReferencedEnvelope; if ((targetCrs != null) && !targetCrs.equals(sourceCrs)) { try { projectedReferenceEnvelope = sampleReferencedEnvelope.transform(targetCrs, true); } catch (TransformException | FactoryException e) { LOGGER.warn("Unable to transform envelope of grid coverage to " + targetCrs.getName(), e); } } return projectedReferenceEnvelope; }
Example #4
Source File: RasterLayerFactory.java From geomajas-project-server with GNU Affero General Public License v3.0 | 6 votes |
public Layer createLayer(MapContext mapContext, ClientLayerInfo clientLayerInfo) throws GeomajasException { if (!(clientLayerInfo instanceof ClientRasterLayerInfo)) { throw new IllegalArgumentException( "RasterLayerFactory.createLayer() should only be called using ClientRasterLayerInfo"); } ClientRasterLayerInfo rasterInfo = (ClientRasterLayerInfo) clientLayerInfo; RasterLayerRasterizingInfo extraInfo = (RasterLayerRasterizingInfo) rasterInfo .getWidgetInfo(RasterLayerRasterizingInfo.WIDGET_KEY); ReferencedEnvelope areaOfInterest = mapContext.getAreaOfInterest(); final RasterLayer layer = configurationService.getRasterLayer(clientLayerInfo.getServerLayerId()); MapViewport port = mapContext.getViewport(); double rasterScale = port.getScreenArea().getWidth() / port.getBounds().getWidth(); List<RasterTile> tiles = rasterLayerService.getTiles(clientLayerInfo.getServerLayerId(), areaOfInterest.getCoordinateReferenceSystem(), areaOfInterest, rasterScale); RasterDirectLayer rasterLayer = new RasterDirectLayer(imageThreadPool, new UrlDownLoader() { @Override public InputStream getStream(String url) throws IOException { return httpService.getStream(url, layer); } }, tiles, layer.getLayerInfo().getTileWidth(), layer.getLayerInfo().getTileHeight(), extraInfo.getCssStyle()); rasterLayer.setTitle(clientLayerInfo.getLabel()); rasterLayer.getUserData().put(USERDATA_KEY_LAYER_ID, layer.getId()); rasterLayer.getUserData().put(USERDATA_KEY_SHOWING, extraInfo.isShowing()); return rasterLayer; }
Example #5
Source File: OmsLasConverter.java From hortonmachine with GNU General Public License v3.0 | 6 votes |
private void createBboxGeometry( CoordinateReferenceSystem crs, File lasFile, SimpleFeatureCollection outGeodata ) throws Exception { final ReferencedEnvelope3D envelope = lasReader.getHeader().getDataEnvelope(); ReferencedEnvelope env2d = new ReferencedEnvelope(envelope); final Polygon polygon = FeatureUtilities.envelopeToPolygon(new Envelope2D(env2d)); final SimpleFeatureTypeBuilder b = new SimpleFeatureTypeBuilder(); b.setName("lasdataenvelope"); b.setCRS(crs); b.add("the_geom", Polygon.class); b.add("id", String.class); final SimpleFeatureType type = b.buildFeatureType(); final SimpleFeatureBuilder builder = new SimpleFeatureBuilder(type); final Object[] values = new Object[]{polygon, lasFile.getName()}; builder.addAll(values); final SimpleFeature feature = builder.buildFeature(null); ((DefaultFeatureCollection) outGeodata).add(feature); OmsVectorWriter.writeVector(outFile, outGeodata); }
Example #6
Source File: DecimationProcess.java From geowave with Apache License 2.0 | 6 votes |
@DescribeResult( name = "result", description = "This is just a pass-through, the key is to provide enough information within invertQuery to perform a map to screen transform") public SimpleFeatureCollection execute( @DescribeParameter( name = "data", description = "Feature collection containing the data") final SimpleFeatureCollection features, @DescribeParameter( name = "outputBBOX", description = "Georeferenced bounding box of the output") final ReferencedEnvelope argOutputEnv, @DescribeParameter( name = "outputWidth", description = "Width of the output raster") final Integer argOutputWidth, @DescribeParameter( name = "outputHeight", description = "Height of the output raster") final Integer argOutputHeight, @DescribeParameter( name = "pixelSize", description = "The pixel size to decimate by") final Double pixelSize) throws ProcessException { // vector-to-vector render transform that is just a pass through - the // key is to add map to screen transform within invertQuery return features; }
Example #7
Source File: DaoGpsLog.java From hortonmachine with GNU General Public License v3.0 | 6 votes |
/** * Get the current data envelope. * * @param connection the db connection. * @return the envelope. * @throws Exception */ public static ReferencedEnvelope getEnvelope( IHMConnection connection ) throws Exception { String query = "SELECT min(" + // GpsLogsDataTableFields.COLUMN_DATA_LON.getFieldName() + "), max(" + // GpsLogsDataTableFields.COLUMN_DATA_LON.getFieldName() + "), min(" + // GpsLogsDataTableFields.COLUMN_DATA_LAT.getFieldName() + "), max(" + // GpsLogsDataTableFields.COLUMN_DATA_LAT.getFieldName() + ") " + // " FROM " + TABLE_GPSLOG_DATA; try (IHMStatement statement = connection.createStatement(); IHMResultSet rs = statement.executeQuery(query);) { if (rs.next()) { double minX = rs.getDouble(1); double maxX = rs.getDouble(2); double minY = rs.getDouble(3); double maxY = rs.getDouble(4); ReferencedEnvelope env = new ReferencedEnvelope(minX, maxX, minY, maxY, DefaultGeographicCRS.WGS84); return env; } } return null; }
Example #8
Source File: MainController.java From hortonmachine with GNU General Public License v3.0 | 6 votes |
private void zoomToSubItems() { if (currentFeaturesList != null) { int size = currentFeaturesList.size(); if (currentFeatureIndex < 0) { currentFeatureIndex = 0; } else if (currentFeatureIndex > size - 1) { currentFeatureIndex = size - 1; } SimpleFeature simpleFeature = currentFeaturesList.get(currentFeatureIndex); Envelope env = ((Geometry) simpleFeature.getDefaultGeometry()).getEnvelopeInternal(); if (env.getWidth() == 0) { env.expandBy(0.1); } else { env.expandBy(env.getWidth() * 0.05); } mapPane.setDisplayArea(new ReferencedEnvelope(env, simpleFeature.getFeatureType().getCoordinateReferenceSystem())); } }
Example #9
Source File: FieldConfigBoundingBox.java From sldeditor with GNU General Public License v3.0 | 6 votes |
/** * Populate field. * * @param value the value */ @Override public void populateField(ReferencedEnvelope value) { xMinTextField.setText(Double.toString(value.getMinX())); xMaxTextField.setText(Double.toString(value.getMaxX())); yMinTextField.setText(Double.toString(value.getMinY())); yMaxTextField.setText(Double.toString(value.getMaxY())); String key = CoordManager.getInstance().getCRSCode(value.getCoordinateReferenceSystem()); crsComboBox.setSelectValueKey(key); if (!FieldConfigBoundingBox.this.isSuppressUndoEvents()) { UndoManager.getInstance() .addUndoEvent(new UndoEvent(this, getFieldId(), oldValueObj, value)); oldValueObj = value; } }
Example #10
Source File: GeoHashGridTest.java From elasticgeo with GNU General Public License v3.0 | 6 votes |
@Test public void testGeoHashGrid() throws Exception { features = TestUtil.createAggregationFeatures(ImmutableList.of( ImmutableMap.of("_aggregation", mapper.writeValueAsBytes(ImmutableMap.of("key",GeoHash.encodeHash(new LatLong(-89.9,-179.9),1),"doc_count",10))) )); ReferencedEnvelope envelope = new ReferencedEnvelope(-180,180,-90,90,DefaultGeographicCRS.WGS84); geohashGrid.initalize(envelope, features); assertEquals(GeoHash.widthDegrees(1), geohashGrid.getCellWidth(), 1e-10); assertEquals(GeoHash.heightDegrees(1), geohashGrid.getCellHeight(), 1e-10); assertEquals(new Envelope(-180+GeoHash.widthDegrees(1)/2.,180-GeoHash.widthDegrees(1)/2.,-90+GeoHash.heightDegrees(1)/2.,90-GeoHash.heightDegrees(1)/2.), geohashGrid.getEnvelope()); int ny = (int) Math.round(180/geohashGrid.getCellHeight()); int nx = (int) Math.round(360/GeoHash.widthDegrees(1)); float[][] expected = new float[ny][nx]; expected[ny-1][0] = 10; assertEquals(ny, geohashGrid.getGrid().length); assertEquals(nx, geohashGrid.getGrid()[0].length); IntStream.range(0, ny).forEach(i-> assertArrayEquals(expected[i], geohashGrid.getGrid()[i], 0.0f)); }
Example #11
Source File: DatabaseLasDataManager.java From hortonmachine with GNU General Public License v3.0 | 6 votes |
@Override public synchronized ReferencedEnvelope getOverallEnvelope() throws Exception { if (referencedEnvelope2D == null) { checkOpen(); List<LasSource> lasSources = LasSourcesTable.getLasSources(spatialDb); ReferencedEnvelope total = new ReferencedEnvelope(crs); for( LasSource lasSource : lasSources ) { Envelope envelopeInternal = lasSource.polygon.getEnvelopeInternal(); total.expandToInclude(envelopeInternal); } referencedEnvelope2D = total; referencedEnvelope2DList.add(referencedEnvelope2D); } return referencedEnvelope2D; }
Example #12
Source File: OmsPointCloudMaximaFinderStream.java From hortonmachine with GNU General Public License v3.0 | 6 votes |
public static void main( String[] args ) throws Exception { String lasPath = "/media/hydrologis/LESTOPLUS/test_lidar_spatialite/las_aurina/uni_bz_44.las"; String outPath = "/home/hydrologis/TMP/tops_2m.asc"; OmsPointCloudMaximaFinderStream s = new OmsPointCloudMaximaFinderStream(); List<LasRecord> dotList = new ArrayList<>(); try (ALasReader reader = ALasReader.getReader(new File(lasPath), null)) { reader.open(); while( reader.hasNextPoint() ) { LasRecord dot = (LasRecord) reader.getNextPoint(); dotList.add(dot); } s.inLas = dotList; ReferencedEnvelope3D dataEnvelope = reader.getHeader().getDataEnvelope(); s.aoi = new ReferencedEnvelope(dataEnvelope); s.pBaseGridResolution = 0.5; s.pMaxRadius = 2; s.process(); OmsRasterWriter.writeRaster(outPath, s.outCoverage); } }
Example #13
Source File: GeohashUtilTest.java From elasticgeo with GNU General Public License v3.0 | 6 votes |
@Test public void testComputePrecision() { assertEquals(1, GeohashUtil.computePrecision(new ReferencedEnvelope(-180,180,-90,90,null), 32, 0.9)); assertEquals(2, GeohashUtil.computePrecision(new ReferencedEnvelope(-180,180,-90,90,null), 1024, 0.9)); assertEquals(3, GeohashUtil.computePrecision(new ReferencedEnvelope(-180,180,-90,90,null), 32768, 0.9)); assertEquals(2, GeohashUtil.computePrecision(new ReferencedEnvelope(-180,180,-90,90,null), 1000, 0.9)); assertEquals(3, GeohashUtil.computePrecision(new ReferencedEnvelope(-180,180,-90,90,null), 1500, 0.9)); assertEquals(1, GeohashUtil.computePrecision(new ReferencedEnvelope(EVERYTHING.getMinX(),EVERYTHING.getMaxX(),EVERYTHING.getMinY(),EVERYTHING.getMaxY(),null), 32, 0.9)); assertEquals(1, GeohashUtil.computePrecision(new ReferencedEnvelope(-1,1,-1,1,null), 0, 0.9)); assertEquals(6, GeohashUtil.computePrecision(new ReferencedEnvelope(-180,180,-90,90,null), (long) 1e9, 0.9)); assertEquals(6, GeohashUtil.computePrecision(new ReferencedEnvelope(-180,180,-90,90,null), 1, 1e9)); assertEquals(1, GeohashUtil.computePrecision(new ReferencedEnvelope(-180,180,-90,90,null), 1, -1e9)); }
Example #14
Source File: SwtMapPane.java From gama with GNU General Public License v3.0 | 6 votes |
public void setCrs(final CoordinateReferenceSystem crs) { try { final ReferencedEnvelope rEnv = getDisplayArea(); final CoordinateReferenceSystem sourceCRS = rEnv.getCoordinateReferenceSystem(); final CoordinateReferenceSystem targetCRS = crs; final MathTransform transform = CRS.findMathTransform(sourceCRS, targetCRS); final com.vividsolutions.jts.geom.Envelope newJtsEnv = JTS.transform(rEnv, transform); final ReferencedEnvelope newEnvelope = new ReferencedEnvelope(newJtsEnv, targetCRS); content.getViewport().setBounds(newEnvelope); fullExtent = null; doSetDisplayArea(newEnvelope); } catch (final Exception e) { e.printStackTrace(); } }
Example #15
Source File: RenderPanelImpl.java From sldeditor with GNU General Public License v3.0 | 6 votes |
/** * Calculate bounds. * * @return the referenced envelope */ private ReferencedEnvelope calculateBounds() { ReferencedEnvelope bounds = null; try { bounds = featureList.getBounds(); if (bounds == null) { // It could be that the above call was too costly! bounds = featureList.getFeatures().getBounds(); } if (bounds.getCoordinateReferenceSystem() == null) { // We need a coordinate reference system set otherwise // transformations fail to render bounds = ReferencedEnvelope.create(bounds, DefaultGeographicCRS.WGS84); } if (bounds != null) { expandEnvelope(bounds); } } catch (IOException e) { ConsoleManager.getInstance().exception(this, e); } return bounds; }
Example #16
Source File: ImageServiceImpl.java From geomajas-project-server with GNU Affero General Public License v3.0 | 6 votes |
private RasterizingContainer callPipeline(ClientMapInfo clientMapInfo, PipelineContext context, String pipelineKey) throws GeomajasException { DefaultMapContext mapContext = new DefaultMapContext(); mapContext.setCoordinateReferenceSystem(geoService.getCrs2(clientMapInfo.getCrs())); MapRasterizingInfo mapInfo = (MapRasterizingInfo) clientMapInfo.getWidgetInfo(MapRasterizingInfo.WIDGET_KEY); mapContext.setAreaOfInterest(new ReferencedEnvelope(dtoConverterService.toInternal(mapInfo.getBounds()), mapContext.getCoordinateReferenceSystem())); RenderingHints renderingHints = new Hints(); renderingHints.put(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); RasterizingContainer response = new RasterizingContainer(); context.put(RasterizingPipelineCode.CLIENT_MAP_INFO_KEY, clientMapInfo); context.put(RasterizingPipelineCode.RENDERING_HINTS, renderingHints); Map<Object, Object> rendererHints = new HashMap<Object, Object>(); if (mapInfo.getDpi() > 0) { rendererHints.put(StreamingRenderer.DPI_KEY, mapInfo.getDpi()); } context.put(RasterizingPipelineCode.RENDERER_HINTS, rendererHints); context.put(RasterizingPipelineCode.MAP_CONTEXT_KEY, mapContext); pipelineService.execute(pipelineKey, null, context, response); mapContext.dispose(); return response; }
Example #17
Source File: ImageMosaicNwwLayer.java From hortonmachine with GNU General Public License v3.0 | 6 votes |
public ImageMosaicNwwLayer( File imageMosaicShpFile, Integer tileSize, GeneralParameterValue[] gp, boolean removeSameColorImages ) throws Exception { super(makeLevels(imageMosaicShpFile, getRenderer(imageMosaicShpFile, gp), tileSize, removeSameColorImages)); this.layerName = FileUtilities.getNameWithoutExtention(imageMosaicShpFile); ReferencedEnvelope envelope = OmsVectorReader.readEnvelope(imageMosaicShpFile.getAbsolutePath()); ReferencedEnvelope envelopeLL = envelope.transform(DefaultGeographicCRS.WGS84, true); double w = envelopeLL.getMinX(); double s = envelopeLL.getMinY(); double e = envelopeLL.getMaxX(); double n = envelopeLL.getMaxY(); double centerX = w + (e - w) / 2.0; double centerY = s + (n - s) / 2.0; centerCoordinate = new Coordinate(centerX, centerY); this.setUseTransparentTextures(true); }
Example #18
Source File: FeatureLayer.java From snap-desktop with GNU General Public License v3.0 | 6 votes |
public FeatureLayer(LayerType layerType, final FeatureCollection<SimpleFeatureType, SimpleFeature> fc, PropertySet configuration) { super(layerType, configuration); crs = fc.getSchema().getGeometryDescriptor().getCoordinateReferenceSystem(); if (crs == null) { // todo - check me! Why can this happen??? (nf) crs = DefaultGeographicCRS.WGS84; } final ReferencedEnvelope envelope = new ReferencedEnvelope(fc.getBounds(), crs); modelBounds = new Rectangle2D.Double(envelope.getMinX(), envelope.getMinY(), envelope.getWidth(), envelope.getHeight()); mapContext = new DefaultMapContext(crs); final Style style = (Style) configuration.getValue(FeatureLayerType.PROPERTY_NAME_SLD_STYLE); mapContext.addLayer(fc, style); renderer = new StreamingRenderer(); workaroundLabelCacheBug(); style.accept(new RetrievingStyleVisitor()); renderer.setContext(mapContext); }
Example #19
Source File: GeoWaveFeatureCollection.java From geowave with Apache License 2.0 | 6 votes |
private Geometry getBBox(final Query query, final ReferencedEnvelope envelope) { if (envelope != null) { return new GeometryFactory().toGeometry(envelope); } final String geomAtrributeName = reader.getComponents().getAdapter().getFeatureType().getGeometryDescriptor().getLocalName(); final ExtractGeometryFilterVisitorResult geoAndCompareOp = ExtractGeometryFilterVisitor.getConstraints( query.getFilter(), reader.getComponents().getAdapter().getFeatureType().getCoordinateReferenceSystem(), geomAtrributeName); if (geoAndCompareOp == null) { return reader.clipIndexedBBOXConstraints(null); } else { return reader.clipIndexedBBOXConstraints(geoAndCompareOp.getGeometry()); } }
Example #20
Source File: GeoWaveEmptyTransaction.java From geowave with Apache License 2.0 | 6 votes |
/** * Record a modification to the indicated fid * * @param fid * @param original the original feature(prior state) * @param updated the update feature replacement feature; null to indicate remove */ @Override public void modify(final String fid, final SimpleFeature original, final SimpleFeature updated) throws IOException { // point move? if (!updated.getBounds().equals(original.getBounds())) { components.remove(original, this); components.writeCommit(updated, new GeoWaveEmptyTransaction(components)); } else { components.writeCommit(updated, new GeoWaveEmptyTransaction(components)); } final ReferencedEnvelope bounds = new ReferencedEnvelope(); bounds.include(updated.getBounds()); bounds.include(original.getBounds()); components.getGTstore().getListenerManager().fireFeaturesChanged( updated.getFeatureType().getTypeName(), Transaction.AUTO_COMMIT, bounds, true); }
Example #21
Source File: GeoHashGridProcessTest.java From elasticgeo with GNU General Public License v3.0 | 5 votes |
@Test public void testBasic() { ReferencedEnvelope envelope = new ReferencedEnvelope(-180,180,-90,90,DefaultGeographicCRS.WGS84); int width = 8; int height = 4; int pixelsPerCell = 1; String strategy = "Basic"; Float scaleMin = 0f; GridCoverage2D coverage = process.execute(features, pixelsPerCell, strategy, null, null, scaleMin, null, false, envelope, width, height, null); checkInternal(coverage, fineDelta); checkEdge(coverage, envelope, fineDelta); }
Example #22
Source File: GeoHashGridProcessTest.java From elasticgeo with GNU General Public License v3.0 | 5 votes |
@Test public void testScaled() { ReferencedEnvelope envelope = new ReferencedEnvelope(-180,180,-90,90,DefaultGeographicCRS.WGS84); int width = 16; int height = 8; int pixelsPerCell = 1; String strategy = "Basic"; Float scaleMin = 0f; GridCoverage2D coverage = process.execute(features, pixelsPerCell, strategy, null, null, scaleMin, null, false, envelope, width, height, null); checkInternal(coverage, fineDelta); checkEdge(coverage, envelope, fineDelta); }
Example #23
Source File: GeoHashGrid.java From elasticgeo with GNU General Public License v3.0 | 5 votes |
private void computeMinLonOffset(ReferencedEnvelope env) { double minLon; if (env.getMinX() > 180) { minLon = env.getMinX() % 360; } else if (env.getMinX() < -180) { minLon = 360 - Math.abs(env.getMinX()) % 360; } else { minLon = env.getMinX() % 360; } if (minLon > 180) { minLon -= 360; } lonOffset = env.getMinX() - minLon; }
Example #24
Source File: WorldPaintableDirectLayerTest.java From geomajas-project-server with GNU Affero General Public License v3.0 | 5 votes |
@Test public void testOneOfEach() throws Exception { ClientWorldPaintableLayerInfo wp = new ClientWorldPaintableLayerInfo(); wp.getPaintables().add(createPoint()); wp.getPaintables().add(createLine()); wp.getPaintables().add(createPolygon()); wp.getPaintables().add(createText()); wp.getPaintables().add(createImage()); wp.getPaintables().add(createEllipse()); wp.getPaintables().add(createRectangle()); ClientMapInfo mapInfo = new ClientMapInfo(); mapInfo.setCrs("EPSG:4326"); MapRasterizingInfo mapRasterizingInfo = new MapRasterizingInfo(); mapRasterizingInfo.setBounds(new Bbox(0, 0, size, size)); mapRasterizingInfo.setScale(1); mapRasterizingInfo.setTransparent(true); mapInfo.getWidgetInfo().put(MapRasterizingInfo.WIDGET_KEY, mapRasterizingInfo); DefaultMapContext mapContext = new DefaultMapContext(); mapContext.setCoordinateReferenceSystem(geoService.getCrs2("EPSG:4326")); mapContext.getViewport().setBounds( new ReferencedEnvelope(0, size, 0, size, mapContext.getCoordinateReferenceSystem())); mapContext.getViewport().setCoordinateReferenceSystem(mapContext.getCoordinateReferenceSystem()); mapContext.getViewport().setScreenArea(new Rectangle(0, 0, size, size)); WorldPaintableDirectLayer layer = (WorldPaintableDirectLayer) layerFactory.createLayer(mapContext, wp); BufferedImage image = new BufferedImage(size, size, BufferedImage.TYPE_4BYTE_ABGR); layer.draw(image.createGraphics(), mapContext, mapContext.getViewport()); new DirectLayerAssert(layer, mapContext).assertEqualImage("worldpaintable-mix.png", writeImages, DELTA); mapContext.dispose(); }
Example #25
Source File: GeoHashGridProcessTest.java From elasticgeo with GNU General Public License v3.0 | 5 votes |
@Test public void testSubCellCropWithSheer() { ReferencedEnvelope envelope = new ReferencedEnvelope(-168.75,168.75,-78.75,78.75,DefaultGeographicCRS.WGS84); int width = 900; int height = 600; int pixelsPerCell = 1; String strategy = "Basic"; Float scaleMin = 0f; GridCoverage2D coverage = process.execute(features, pixelsPerCell, strategy, null, null, scaleMin, null, false, envelope, width, height, null); checkInternal(coverage, fineDelta); }
Example #26
Source File: GeoHashGrid.java From elasticgeo with GNU General Public License v3.0 | 5 votes |
private Envelope computeEnvelope(ReferencedEnvelope outEnvelope, int precision) { final String minHash = GeoHash.encodeHash(Math.max(-90,outEnvelope.getMinY()), outEnvelope.getMinX(), precision); final LatLong minLatLon = GeoHash.decodeHash(minHash); final double minLon = minLatLon.getLon() + lonOffset; final double width = Math.ceil(outEnvelope.getWidth()/cellWidth)*cellWidth; final double maxLon = minLon + width - cellWidth; final String maxHash = GeoHash.encodeHash(Math.min(90, outEnvelope.getMaxY()), maxLon, precision); final LatLong maxLatLon = GeoHash.decodeHash(maxHash); return new Envelope(minLon, maxLon, minLatLon.getLat(), maxLatLon.getLat()); }
Example #27
Source File: GeometryDirectLayerTest.java From geomajas-project-server with GNU Affero General Public License v3.0 | 5 votes |
@Test public void testPolygon() throws Exception { ClientGeometryLayerInfo geo = new ClientGeometryLayerInfo(); geo.getGeometries().add(createPolygon()); geo.setStyle(createPolygonStyle()); geo.setLayerType(LayerType.POLYGON); ClientMapInfo mapInfo = new ClientMapInfo(); mapInfo.setCrs("EPSG:4326"); MapRasterizingInfo mapRasterizingInfo = new MapRasterizingInfo(); mapRasterizingInfo.setBounds(new Bbox(0, 0, 100, 100)); mapRasterizingInfo.setScale(1); mapRasterizingInfo.setTransparent(true); mapInfo.getWidgetInfo().put(MapRasterizingInfo.WIDGET_KEY, mapRasterizingInfo); DefaultMapContext mapContext = new DefaultMapContext(); mapContext.setCoordinateReferenceSystem(geoService.getCrs2("EPSG:4326")); mapContext.getViewport().setBounds( new ReferencedEnvelope(0, 100, 0, 100, mapContext.getCoordinateReferenceSystem())); mapContext.getViewport().setCoordinateReferenceSystem(mapContext.getCoordinateReferenceSystem()); mapContext.getViewport().setScreenArea(new Rectangle(0, 0, 100, 100)); GeometryDirectLayer layer = (GeometryDirectLayer) layerFactory.createLayer(mapContext, geo); BufferedImage image = new BufferedImage(100, 100, BufferedImage.TYPE_4BYTE_ABGR); layer.draw(image.createGraphics(), mapContext, mapContext.getViewport()); new DirectLayerAssert(layer, mapContext).assertEqualImage("polygon.png", writeImages, DELTA); mapContext.dispose(); }
Example #28
Source File: GeoHashGridTest.java From elasticgeo with GNU General Public License v3.0 | 5 votes |
@Test public void testGeoHashGridWithProjectedEnvelope() throws Exception { features = TestUtil.createAggregationFeatures(ImmutableList.of( ImmutableMap.of("_aggregation", mapper.writeValueAsBytes(ImmutableMap.of("key",GeoHash.encodeHash(new LatLong(-89.9,-179.9),1),"doc_count",10))) )); ReferencedEnvelope envelope = new ReferencedEnvelope(-19926188.85,19926188.85,-30240971.96,30240971.96, CRS.decode("EPSG:3857")); geohashGrid.initalize(envelope, features); assertEquals(new ReferencedEnvelope(-180,180,-90,90,DefaultGeographicCRS.WGS84), geohashGrid.getBoundingBox()); }
Example #29
Source File: GeoHashGridTest.java From elasticgeo with GNU General Public License v3.0 | 5 votes |
@Test public void testGeoHashGridWithNoFeatures() throws Exception { features = new DefaultFeatureCollection(); ReferencedEnvelope envelope = new ReferencedEnvelope(-180,180,-90,90,CRS.decode("EPSG:4326")); geohashGrid.initalize(envelope, features); IntStream.range(0, geohashGrid.getGrid().length).forEach(i-> assertArrayEquals(new float[geohashGrid.getGrid()[i].length], geohashGrid.getGrid()[i], 0.0f)); }
Example #30
Source File: GeoHashGridTest.java From elasticgeo with GNU General Public License v3.0 | 5 votes |
@Test public void testGeoHashGridWithNoAggregations() throws Exception { features = TestUtil.createAggregationFeatures(ImmutableList.of( ImmutableMap.of("aString", UUID.randomUUID().toString()) )); ReferencedEnvelope envelope = new ReferencedEnvelope(-180,180,-90,90,CRS.decode("EPSG:4326")); geohashGrid.initalize(envelope, features); IntStream.range(0, geohashGrid.getGrid().length).forEach(i-> assertArrayEquals(new float[geohashGrid.getGrid()[i].length], geohashGrid.getGrid()[i], 0.0f)); }