com.vividsolutions.jts.geom.Envelope Java Examples
The following examples show how to use
com.vividsolutions.jts.geom.Envelope.
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: RestController.java From geomajas-project-server with GNU Affero General Public License v3.0 | 6 votes |
private Filter createBBoxFilter(String layerId, Crs crs, Envelope... bbox) throws GeomajasException { VectorLayer layer = configurationService.getVectorLayer(layerId); Crs layerCrs = geoService.getCrs2(layer.getLayerInfo().getCrs()); CrsTransform transform = geoService.getCrsTransform(crs, layerCrs); for (Envelope envelope : bbox) { if (envelope != null) { try { return filterService.createBboxFilter(layerCrs, geoService.transform(envelope, crs, layerCrs), layer.getFeatureModel().getGeometryAttributeName()); } catch (LayerException e) { throw new RestException(e, RestException.PROBLEM_READING_LAYERSERVICE, layerId); } } } return filterService.createTrueFilter(); }
Example #2
Source File: TransformGeometryCommandTest.java From geomajas-project-server with GNU Affero General Public License v3.0 | 6 votes |
@Test public void testTransformGeometry() throws Exception { TransformGeometryRequest request = new TransformGeometryRequest(); WKTReader reader = new WKTReader(); Geometry origin = converterService.toDto(reader.read("POLYGON((10 30, 20 30,20 40,10 40,10 30))")); request.setGeometry(origin); request.setSourceCrs(MERCATOR); request.setTargetCrs(LONLAT); // execute TransformGeometryResponse response = (TransformGeometryResponse) dispatcher.execute( TransformGeometryRequest.COMMAND, request, null, "en"); Geometry transformed = response.getGeometry(); Envelope bounds = converterService.toInternal(transformed).getEnvelopeInternal(); Assert.assertEquals(8.983152841195215E-5, bounds.getMinX(), DELTA); Assert.assertEquals(2.6949458522981454E-4, bounds.getMinY(), DELTA); Assert.assertEquals(1.796630568239043E-4, bounds.getMaxX(), DELTA); Assert.assertEquals(3.593261136397527E-4, bounds.getMaxY(), DELTA); }
Example #3
Source File: HibernateLayer.java From geomajas-project-server with GNU Affero General Public License v3.0 | 6 votes |
/** * Bounds are calculated locally, can use any filter, but slower than native. * * @param filter * filter which needs to be applied * @return the bounds of the specified features * @throws LayerException * oops */ private Envelope getBoundsLocal(Filter filter) throws LayerException { try { Session session = getSessionFactory().getCurrentSession(); Criteria criteria = session.createCriteria(getFeatureInfo().getDataSourceName()); CriteriaVisitor visitor = new CriteriaVisitor((HibernateFeatureModel) getFeatureModel(), dateFormat); Criterion c = (Criterion) filter.accept(visitor, criteria); if (c != null) { criteria.add(c); } criteria.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY); List<?> features = criteria.list(); Envelope bounds = new Envelope(); for (Object f : features) { Envelope geomBounds = getFeatureModel().getGeometry(f).getEnvelopeInternal(); if (!geomBounds.isNull()) { bounds.expandToInclude(geomBounds); } } return bounds; } catch (HibernateException he) { throw new HibernateLayerException(he, ExceptionCode.HIBERNATE_LOAD_FILTER_FAIL, getFeatureInfo() .getDataSourceName(), filter.toString()); } }
Example #4
Source File: GoogleLayerTest.java From geomajas-project-server with GNU Affero General Public License v3.0 | 6 votes |
@Test public void testSatelliteDs() throws Exception { List<RasterTile> tiles = satelliteDs.paint(satelliteDs.getCrs(), new Envelope(10000, 10010, 4000, 4010), ZOOMED_IN_SCALE); Assert.assertEquals(1, tiles.size()); RasterTile tile = tiles.get(0); if (System.getProperty("java.version").startsWith("1.6")) { Assert.assertEquals("http://maps.googleapis.com/maps/api/staticmap?center=16.731982094003893,16.975000002070733&zoom=4&sensor=false&maptype=satellite&size=640x640", tile.getUrl()); } else { Assert.assertEquals("http://maps.googleapis.com/maps/api/staticmap?center=16.731982094003904,16.975000002070733&zoom=4&sensor=false&maptype=satellite&size=640x640", tile.getUrl()); } Assert.assertEquals(4, tile.getCode().getTileLevel()); Assert.assertEquals(3, tile.getCode().getX()); Assert.assertEquals(3, tile.getCode().getY()); Assert.assertEquals(-124.0, tile.getBounds().getX(), DELTA); Assert.assertEquals(-502.0, tile.getBounds().getY(), DELTA); Assert.assertEquals(626.0, tile.getBounds().getHeight(), DELTA); Assert.assertEquals(626.0, tile.getBounds().getWidth(), DELTA); }
Example #5
Source File: GoogleLayerTest.java From geomajas-project-server with GNU Affero General Public License v3.0 | 6 votes |
@Test public void testNormalDs() throws Exception { List<RasterTile> tiles = googleDs.paint(googleDs.getCrs(), new Envelope(10000, 10010, 4000, 4010), ZOOMED_IN_SCALE); Assert.assertEquals(1, tiles.size()); RasterTile tile = tiles.get(0); if (System.getProperty("java.version").startsWith("1.6")) { Assert.assertEquals("http://maps.googleapis.com/maps/api/staticmap?center=16.731982094003893,16.975000002070733&zoom=4&sensor=false&maptype=roadmap&size=640x640", tile.getUrl()); } else { Assert.assertEquals("http://maps.googleapis.com/maps/api/staticmap?center=16.731982094003904,16.975000002070733&zoom=4&sensor=false&maptype=roadmap&size=640x640", tile.getUrl()); } Assert.assertEquals(4, tile.getCode().getTileLevel()); Assert.assertEquals(3, tile.getCode().getX()); Assert.assertEquals(3, tile.getCode().getY()); Assert.assertEquals(-124.0, tile.getBounds().getX(), DELTA); Assert.assertEquals(-502.0, tile.getBounds().getY(), DELTA); Assert.assertEquals(626.0, tile.getBounds().getHeight(), DELTA); Assert.assertEquals(626.0, tile.getBounds().getWidth(), DELTA); }
Example #6
Source File: GeoServiceImpl.java From geomajas-project-server with GNU Affero General Public License v3.0 | 6 votes |
@Override @edu.umd.cs.findbugs.annotations.SuppressWarnings(value = "REC_CATCH_EXCEPTION") public Envelope transform(Envelope source, CrsTransform crsTransform) { try { if (crsTransform.isTransforming()) { Envelope transformableArea = crsTransform.getTransformableEnvelope(); if (null != transformableArea) { source = source.intersection(transformableArea); } if (source.isNull()) { return source; } else { ReferencedEnvelope refEnvelope = new ReferencedEnvelope(source, crsTransform.getSource()); return refEnvelope.transform(crsTransform.getTarget(), true); } } else { return source; } } catch (Exception e) { // NOSONAR typically TopologyException, TransformException or FactoryException logEnvelopeSuggestCrsTransformInfo(crsTransform.getId(), source, e); return new Envelope(); } }
Example #7
Source File: GamaQuadTree.java From gama with GNU General Public License v3.0 | 6 votes |
public void split() { final double maxx = bounds.getMaxX(); final double minx = bounds.getMinX(); final double miny = bounds.getMinY(); final double maxy = bounds.getMaxY(); nodes = new QuadNode[] { new QuadNode(new Envelope(minx, halfx, miny, halfy)), new QuadNode(new Envelope(halfx, maxx, miny, halfy)), new QuadNode(new Envelope(minx, halfx, halfy, maxy)), new QuadNode(new Envelope(halfx, maxx, halfy, maxy)) }; if (objects != null) { for (final Map.Entry<IAgent, Envelope3D> entry : objects.entrySet()) { final IAgent agent = entry.getKey(); if (agent != null && !agent.dead()) { final IShape g = agent.getGeometry(); if (g.isPoint()) { add((Coordinate) g.getLocation(), agent); } else { add(g.getEnvelope(), agent); } } } objects.clear(); objects = null; } }
Example #8
Source File: GamaQuadTree.java From gama with GNU General Public License v3.0 | 6 votes |
public void findIntersects(final Envelope r, final Collection<IAgent> result) { if (bounds.intersects(r)) { if (objects != null) { for (final Map.Entry<IAgent, Envelope3D> entry : objects.entrySet()) { final Envelope3D env = entry.getValue(); if (env != null && env.intersects(r)) { result.add(entry.getKey()); } } } if (nodes != null) { for (final QuadNode node : nodes) { node.findIntersects(r, result); } } } }
Example #9
Source File: StaticMultiPolygonTest.java From jts with GNU Lesser General Public License v2.1 | 6 votes |
/** * Round Trip test for a single MultiPolygon with lotsa points * @throws ParserConfigurationException * @throws IOException * @throws SAXException */ public void testSingleMultiPolygonManyPointsManyHolesRoundTrip() throws SAXException, IOException, ParserConfigurationException{ PolygonGenerator pgc = new PolygonGenerator(); pgc.setGeometryFactory(geometryFactory); pgc.setGenerationAlgorithm(PolygonGenerator.BOX); pgc.setNumberPoints(100); pgc.setNumberHoles(100); MultiGenerator pg = new MultiGenerator(pgc); pg.setBoundingBox(new Envelope(0,10,0,10)); pg.setNumberGeometries(3); pg.setGeometryFactory(geometryFactory); MultiPolygon pt = (MultiPolygon) pg.create(); // System.out.println((pt==null?"NULL":pt.toString())); checkRoundTrip(pt); }
Example #10
Source File: RestControllerTest.java From geomajas-project-server with GNU Affero General Public License v3.0 | 6 votes |
@Test public void testBboxFilter() throws Exception { MockHttpServletRequest request = new MockHttpServletRequest(); request.setRequestURI("/rest/beans"); request.addParameter("bbox", "4,6,0,3"); request.setMethod("GET"); MockHttpServletResponse response = new MockHttpServletResponse(); ModelAndView mav = adapter.handle(request, response, restController); Object o = mav.getModel().get(RestController.FEATURE_COLLECTION); Assert.assertTrue(o instanceof List<?>); for (Object f : (List<?>) o) { Assert.assertTrue(f instanceof InternalFeature); Assert.assertTrue(new Envelope(4, 6, 0, 3).intersects(((InternalFeature) f).getGeometry() .getEnvelopeInternal())); } }
Example #11
Source File: WmsLayerTileTest.java From geomajas-project-server with GNU Affero General Public License v3.0 | 6 votes |
@Test public void testLowestTileLevel() throws Exception { Crs lambert = geoService.getCrs2(LAMBERT); double x = wms.getLayerInfo().getMaxExtent().getX(); double y = wms.getLayerInfo().getMaxExtent().getY(); ScaleInfo scaleInfo = wms.getLayerInfo().getZoomLevels().get(wms.getLayerInfo().getZoomLevels().size()- 1); Envelope bounds = new Envelope(x - 1, x + 1, y - 1, y + 1); double scale = scaleInfo.getPixelPerUnit(); List<RasterTile> tiles = wms.paint(lambert, bounds, scale); Assert.assertEquals(1, tiles.size()); RasterTile tile = tiles.get(0); double resultX = tile.getBounds().getX() / scale; double resultY = -tile.getBounds().getY() / scale - tile.getBounds().getHeight() / scale; Assert.assertEquals(x, resultX, 0.1); Assert.assertEquals(y, resultY, 0.1); }
Example #12
Source File: StringToEnvelopeConverter.java From geomajas-project-server with GNU Affero General Public License v3.0 | 6 votes |
public Envelope convert(String source) { if (source == null) { return null; } else { String[] args = source.trim().split("[\\s,]+"); if (args.length != 4) { throw new IllegalArgumentException("Cannot parse envelope from " + source + ", expected format is \"xmin,ymin,xmax,ymax\""); } else { double[] coords = new double[4]; try { for (int i = 0; i < coords.length; i++) { coords[i] = Double.parseDouble(args[i]); } return new Envelope(coords[0], coords[1], coords[2], coords[3]); } catch (NumberFormatException nfe) { throw new IllegalArgumentException("Cannot parse envelope from " + source + ", expected format is \"xmin,ymin,xmax,ymax\"", nfe); } } } }
Example #13
Source File: OSMArea.java From traffic-engine with GNU General Public License v3.0 | 6 votes |
public OSMArea(long id, int x, int y, int z, String placeName, Long placePop, long zoneOffset, Envelope env) { this.id = id; this.x = x; this.y = y; this.z = z; this.placeName = placeName; if(placePop != null) this.placePop = placePop; this.zoneOffset = zoneOffset; GeometryFactory gf = new GeometryFactory(); this.env = env; }
Example #14
Source File: StyleConverterServiceImpl.java From geomajas-project-server with GNU Affero General Public License v3.0 | 6 votes |
private Envelope toEnvelope(BoxTypeInfo box) throws LayerException { if (box.ifCoordinates()) { Coordinate[] coords = getCoordinates(box.getCoordinates()); if (coords.length == 2) { return new Envelope(coords[0].x, coords[1].x, coords[0].y, coords[1].y); } else { throw new IllegalArgumentException("Number of coordinates != 2 in box : " + box); } } else { if (box.getCoordList().size() == 2) { CoordTypeInfo coordMin = box.getCoordList().get(0); CoordTypeInfo coordMax = box.getCoordList().get(1); return new Envelope(coordMin.getX().doubleValue(), coordMax.getX().doubleValue(), coordMin.getY() .doubleValue(), coordMax.getY().doubleValue()); } else { throw new IllegalArgumentException("Number of coordinates != 2 in box : " + box); } } }
Example #15
Source File: TmsLayerTest.java From geomajas-project-server with GNU Affero General Public License v3.0 | 6 votes |
@Test @SuppressWarnings("deprecation") public void testPaintLevel1() throws LayerException, GeomajasException { double resolution = 512.0; Envelope maxBounds = new Envelope(18000.0, 259500.250, 152999.75, 244500.0); List<RasterTile> tiles = layer.paint(geoService.getCrs("EPSG:31370"), maxBounds, 1.0 / resolution); Assert.assertEquals(2, tiles.size()); Assert.assertEquals(1, tiles.get(0).getCode().getTileLevel()); Assert.assertEquals(0, tiles.get(0).getCode().getX()); Assert.assertEquals(0, tiles.get(0).getCode().getY()); Assert.assertEquals("http://tms.osgeo.org/1.0.0/landsat2000/" + (int) resolution + "/0/0.png", tiles.get(0) .getUrl()); Assert.assertEquals(1, tiles.get(1).getCode().getTileLevel()); Assert.assertEquals(1, tiles.get(1).getCode().getX()); Assert.assertEquals(0, tiles.get(1).getCode().getY()); Assert.assertEquals("http://tms.osgeo.org/1.0.0/landsat2000/" + (int) resolution + "/1/0.png", tiles.get(1) .getUrl()); }
Example #16
Source File: GeoServiceTest.java From geomajas-project-server with GNU Affero General Public License v3.0 | 5 votes |
@Test public void transformEnvelopeCrsTransformTest() throws Exception { CrsTransform crsTransform = geoService.getCrsTransform(MERCATOR, LONLAT); Envelope envelope = new Envelope(10, 20, 30, 40); Envelope transformed = geoService.transform(envelope, crsTransform); Assert.assertEquals(8.983152841195215E-5, transformed.getMinX(), DELTA); Assert.assertEquals(2.6949458522981454E-4, transformed.getMinY(), DELTA); Assert.assertEquals(1.796630568239043E-4, transformed.getMaxX(), DELTA); Assert.assertEquals(3.593261136397527E-4, transformed.getMaxY(), DELTA); Assert.assertEquals(envelope, geoService.transform(envelope, MERCATOR, MERCATOR)); }
Example #17
Source File: Tile.java From geoar-app with Apache License 2.0 | 5 votes |
public Envelope getEnvelope() { float top = (float) MercatorProj.transformTileYToLat(y, zoom); float bottom = (float) MercatorProj.transformTileYToLat(y + 1, zoom); float left = (float) MercatorProj.transformTileXToLon(x, zoom); float right = (float) MercatorProj.transformTileXToLon(x + 1, zoom); return new Envelope(left, right, top, bottom); }
Example #18
Source File: FPAtlas.java From OpenMapKitAndroid with BSD 3-Clause "New" or "Revised" License | 5 votes |
private void findPage(ILatLng latLng) { Coordinate coord = new Coordinate(latLng.getLongitude(), latLng.getLatitude()); Envelope env = new Envelope(coord); List fpPages = spatialIndex.query(env); for (Object p : fpPages) { FPPage page = (FPPage)p; Geometry pageGeom = page.geometry(); if (pageGeom.contains(GEOMETRY_FACTORY.createPoint(coord))) { foundPage(page); return; } } noPageFound(); }
Example #19
Source File: TiledFeatureService.java From geomajas-project-server with GNU Affero General Public License v3.0 | 5 votes |
/** * Put features in a tile. This will assure all features are only added in one tile. When a feature's unique tile * is different from this one a link is added in the tile. * * @param tile * tile to put features in * @param maxTileExtent * the maximum tile extent * @throws GeomajasException oops */ public void fillTile(InternalTile tile, Envelope maxTileExtent) throws GeomajasException { List<InternalFeature> origFeatures = tile.getFeatures(); tile.setFeatures(new ArrayList<InternalFeature>()); for (InternalFeature feature : origFeatures) { if (!addTileCode(tile, maxTileExtent, feature.getGeometry())) { log.debug("add feature"); tile.addFeature(feature); } } }
Example #20
Source File: OsmLayerTest.java From geomajas-project-server with GNU Affero General Public License v3.0 | 5 votes |
@Test public void testPaintOutOfBounds() throws Exception { double equator = TiledRasterLayerService.EQUATOR_IN_METERS; List<RasterTile> tiles = osm.paint(osm.getCrs(), new Envelope(-equator, equator, -equator, equator), 256 / equator); Assert.assertEquals(1, tiles.size()); Assert.assertEquals("http://a.tile.openstreetmap.org/0/0/0.png", tiles.iterator().next().getUrl()); }
Example #21
Source File: KdTreeTest.java From jts with GNU Lesser General Public License v2.1 | 5 votes |
private void testQuery(KdTree index, Envelope queryEnv, Coordinate[] expectedCoord) { Coordinate[] result = KdTree.toCoordinates(index.query(queryEnv)); Arrays.sort(result); Arrays.sort(expectedCoord); assertTrue("Result count = " + result.length + ", expected count = " + expectedCoord.length, result.length == expectedCoord.length); boolean isMatch = CoordinateArrays.equals(result, expectedCoord); assertTrue("Expected result coordinates not found", isMatch); }
Example #22
Source File: BboxConverterTest.java From geomajas-project-server with GNU Affero General Public License v3.0 | 5 votes |
@Test public void testToDto() { Envelope envelope = new Envelope(10, 20, 30, 40); Bbox bbox = converterService.toDto(envelope); Assert.assertEquals(10, bbox.getX(), ALLOWANCE); Assert.assertEquals(30, bbox.getY(), ALLOWANCE); Assert.assertEquals(20, bbox.getMaxX(), ALLOWANCE); Assert.assertEquals(40, bbox.getMaxY(), ALLOWANCE); }
Example #23
Source File: GeocoderUtilServiceTest.java From geomajas-project-server with GNU Affero General Public License v3.0 | 5 votes |
@Test public void transformEnvelopeTest() throws Exception { CoordinateReferenceSystem source = geoService.getCrs("EPSG:900913"); CoordinateReferenceSystem target = geoService.getCrs("EPSG:4326"); Envelope envelope = new Envelope(10, 20, 30, 40); Envelope transformed = geocoderUtilService.transform(envelope, source, target); Assert.assertEquals(8.983152841195215E-5, transformed.getMinX(), DELTA); Assert.assertEquals(2.6949458522981454E-4, transformed.getMinY(), DELTA); Assert.assertEquals(1.796630568239043E-4, transformed.getMaxX(), DELTA); Assert.assertEquals(3.593261136397527E-4, transformed.getMaxY(), DELTA); }
Example #24
Source File: Envelope3D.java From gama with GNU General Public License v3.0 | 5 votes |
/** * Computes the distance between this and another <code>Envelope</code>. The distance between overlapping Envelopes * is 0. Otherwise, the distance is the Euclidean distance between the closest points. */ @Override public double distance(final Envelope env) { if (intersects(env)) { return 0; } double dx = 0.0; if (getMaxX() < env.getMinX()) { dx = env.getMinX() - getMaxX(); } else if (getMinX() > env.getMaxX()) { dx = getMinX() - env.getMaxX(); } double dy = 0.0; if (getMaxY() < env.getMinY()) { dy = env.getMinY() - getMaxY(); } else if (getMinY() > env.getMaxY()) { dy = getMinY() - env.getMaxY(); } double dz = 0.0; final double otherMinZ = getMinZOf(env); final double otherMaxZ = getMaxZOf(env); if (maxz < otherMinZ) { dz = otherMinZ - maxz; } else if (minz > otherMaxZ) { dz = minz - otherMaxZ; } // if either is zero, the envelopes overlap either vertically or // horizontally if (dx == 0.0 && dz == 0.0) { return dy; } if (dy == 0.0 && dz == 0.0) { return dx; } if (dx == 0.0 && dy == 0.0) { return dz; } return Math.sqrt(dx * dx + dy * dy + dz * dz); }
Example #25
Source File: GetTileFillStep.java From geomajas-project-server with GNU Affero General Public License v3.0 | 5 votes |
public void execute(PipelineContext context, GetTileContainer response) throws GeomajasException { TileMetadata metadata = context.get(PipelineCode.TILE_METADATA_KEY, TileMetadata.class); // Determine the maximum tile extent Envelope maxTileExtent = context.get(PipelineCode.TILE_MAX_EXTENT_KEY, Envelope.class); // fill the tiles tiledFeatureService.fillTile(response.getTile(), maxTileExtent); // clipping of features in tile Coordinate panOrigin = new Coordinate(metadata.getPanOrigin().getX(), metadata.getPanOrigin().getY()); tiledFeatureService.clipTile(response.getTile(), metadata.getScale(), panOrigin); }
Example #26
Source File: GeoServiceTest.java From geomajas-project-server with GNU Affero General Public License v3.0 | 5 votes |
@Test public void transformEnvelopeStringTest() throws Exception { Envelope envelope = new Envelope(10, 20, 30, 40); Envelope transformed = geoService.transform(envelope, MERCATOR, LONLAT); Assert.assertEquals(8.983152841195215E-5, transformed.getMinX(), DELTA); Assert.assertEquals(2.6949458522981454E-4, transformed.getMinY(), DELTA); Assert.assertEquals(1.796630568239043E-4, transformed.getMaxX(), DELTA); Assert.assertEquals(3.593261136397527E-4, transformed.getMaxY(), DELTA); }
Example #27
Source File: VectorLayerServiceTest.java From geomajas-project-server with GNU Affero General Public License v3.0 | 5 votes |
@Test public void testGetBoundsIntersectsFiltered() throws Exception { GeometryFactory factory = new GeometryFactory(); LineString equator = factory.createLineString(new Coordinate[] { new Coordinate(0, 0), new Coordinate(-180, 180) }); Filter filter = filterService.createIntersectsFilter(equator,beanLayer.getLayerInfo().getFeatureInfo().getGeometryType().getName()); Envelope bounds = layerService.getBounds(LAYER_ID, geoService.getCrs2(beanLayer.getLayerInfo().getCrs()), filter); Assert.assertEquals(0, bounds.getMinX(), ALLOWANCE); Assert.assertEquals(0, bounds.getMinY(), ALLOWANCE); Assert.assertEquals(1, bounds.getMaxX(), ALLOWANCE); Assert.assertEquals(1, bounds.getMaxY(), ALLOWANCE); }
Example #28
Source File: NodeBase.java From jts with GNU Lesser General Public License v2.1 | 5 votes |
/** * Gets the index of the subquad that wholly contains the given envelope. * If none does, returns -1. * * @return the index of the subquad that wholly contains the given envelope * or -1 if no subquad wholly contains the envelope */ public static int getSubnodeIndex(Envelope env, double centrex, double centrey) { int subnodeIndex = -1; if (env.getMinX() >= centrex) { if (env.getMinY() >= centrey) subnodeIndex = 3; if (env.getMaxY() <= centrey) subnodeIndex = 1; } if (env.getMaxX() <= centrex) { if (env.getMinY() >= centrey) subnodeIndex = 2; if (env.getMaxY() <= centrey) subnodeIndex = 0; } return subnodeIndex; }
Example #29
Source File: WmsLayer.java From geomajas-project-server with GNU Affero General Public License v3.0 | 5 votes |
private RasterGrid getRasterGrid(Envelope bounds, double width, double height) { Bbox bbox = getLayerInfo().getMaxExtent(); int ymin = (int) Math.floor((bounds.getMinY() - bbox.getY()) / height); int ymax = (int) Math.ceil((bounds.getMaxY() - bbox.getY()) / height); int xmin = (int) Math.floor((bounds.getMinX() - bbox.getX()) / width); int xmax = (int) Math.ceil((bounds.getMaxX() - bbox.getX()) / width); Coordinate lowerLeft = new Coordinate(bbox.getX() + xmin * width, bbox.getY() + ymin * height); return new RasterGrid(lowerLeft, xmin, ymin, xmax, ymax, width, height); }
Example #30
Source File: ShapeInMemFilterTest.java From geomajas-project-server with GNU Affero General Public License v3.0 | 5 votes |
@Test public void bboxFilter() throws LayerException { Envelope bbox = new Envelope(-0.4d, -0.2d, -0.3d, 0.1d); Filter filter = filterService.createBboxFilter("EPSG:4326", bbox, PARAM_GEOMETRY_ATTR); Iterator<?> it = layer.getElements(filter, 0, 0); int t = 0; while (it.hasNext()) { it.next(); t++; } Assert.assertEquals(3, t); }