Package com.vividsolutions.jts.geom

Examples of com.vividsolutions.jts.geom.Envelope


  private static final double DELTA = 1e-20;

  @Test
  public void testCombine() throws Exception {
    Envelope e1 = new Envelope(10, 40, 10, 30);
    GetLocationResult glr1 = new GetLocationResult();
    glr1.setEnvelope(e1);
    Envelope e2 = new Envelope(20, 35, 25, 50);
    GetLocationResult glr2 = new GetLocationResult();
    glr2.setEnvelope(e2);
    List<GetLocationResult> list = new ArrayList<GetLocationResult>();
    list.add(glr1);
    list.add(glr2);

    CombineResultService cis = new CombineUnionService();
    Envelope res = cis.combine(list);
    Assert.assertEquals(10.0, res.getMinX(), DELTA);
    Assert.assertEquals(10.0, res.getMinY(), DELTA);
    Assert.assertEquals(40.0, res.getMaxX(), DELTA);
    Assert.assertEquals(50.0, res.getMaxY(), DELTA);
  }
View Full Code Here


  Envelope createBbox() {
    double x1 = getMap().getLocation().x;
    double x2 = x1 + (getBounds().getWidth() / getMap().getPpUnit());
    double y1 = getMap().getLocation().y;
    double y2 = y1 + (getBounds().getHeight() / getMap().getPpUnit());
    return new Envelope(x1, x2, y1, y2);
  }
View Full Code Here

      Bbox transformableBbox) {
    this(id, source, target, mathTransform);
    if (null != transformableBbox) {
      this.transformableBbox = transformableBbox;
      this.transformableEnvelope =
          new Envelope(transformableBbox.getX(), transformableBbox.getMaxX(), transformableBbox.getY(),
              transformableBbox.getMaxY());
      this.transformableGeometry = JTS.toGeometry(transformableEnvelope);
    }
  }
View Full Code Here

  private GeoService geoService;

  @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());
  }
View Full Code Here

  @Test
  public void testPaintToTheSide() throws Exception {
    double equator = TiledRasterLayerService.EQUATOR_IN_METERS;
    List<RasterTile> tiles = osm.paint(osm.getCrs(),
        new Envelope(equator * 2 / 3, (equator * 2 / 3) + 100, 0, 100), ZOOMED_IN_SCALE);
    Assert.assertEquals(0, tiles.size());
  }
View Full Code Here

    Assert.assertEquals("EPSG:900913", osmWrongCrs.getLayerInfo().getCrs());
  }

  @Test
  public void testMaxLevel() throws Exception {
    Envelope envelope = new Envelope(10000, 10002, 5000, 5002);
    RasterTile tile;
    List<RasterTile> tiles;
    tiles = osm.paint(osm.getCrs(), envelope, MAX_LEVEL_SCALE);
    Assert.assertEquals(1, tiles.size());
    tile = tiles.get(0);
View Full Code Here

    Assert.assertEquals("http://a.tile.openstreetmap.org/12/2049/2047.png", tile.getUrl());
  }

  @Test
  public void testConfigUrlStrategy() throws Exception {
    Envelope envelope = new Envelope(10000, 10002, 5000, 5002);
    RasterTile tile;
    List<RasterTile> tiles;
    tiles = osmCycleMap.paint(osmCycleMap.getCrs(), envelope, MAX_LEVEL_SCALE);
    Assert.assertEquals(1, tiles.size());
    tile = tiles.get(0);
View Full Code Here

    Assert.assertEquals("http://c.tile.opencyclemap.org/14/8196/8189.png", tile.getUrl());
  }

  @Test
  public void testNormalOne() throws Exception {
    List<RasterTile> tiles = osm.paint(osm.getCrs(), new Envelope(10000, 10010, 5000, 5010), ZOOMED_IN_SCALE);
    Assert.assertEquals(1, tiles.size());
    RasterTile tile = tiles.get(0);
    Assert.assertEquals("http://a.tile.openstreetmap.org/4/8/7.png", tile.getUrl());
    Assert.assertEquals(4, tile.getCode().getTileLevel());
    Assert.assertEquals(8, tile.getCode().getX());
View Full Code Here

    Assert.assertEquals(250.0, tile.getBounds().getWidth(), DELTA);
  }

  @Test
  public void testNormalSeveral() throws Exception {
    Envelope envelope = new Envelope(10000, 13000, 5000, 8000);
    List<RasterTile> tiles = osm.paint(osm.getCrs(), envelope, MAX_LEVEL_SCALE);
    Assert.assertEquals(4, tiles.size());
    Assert.assertEquals("http://a.tile.openstreetmap.org/14/8196/8188.png", tiles.get(0).getUrl());
    Assert.assertEquals("http://a.tile.openstreetmap.org/14/8196/8189.png", tiles.get(1).getUrl());
    Assert.assertEquals("http://a.tile.openstreetmap.org/14/8197/8188.png", tiles.get(2).getUrl());
View Full Code Here

    Assert.assertEquals(245.0, tile.getBounds().getWidth(), DELTA);
  }

  @Test
  public void testReprojectOne() throws Exception {
    Envelope googleEnvelope = new Envelope(10000, 10010, 5000, 5010);
    // back-transform envelope to latlon
    Crs google = geoService.getCrs2("EPSG:900913");
    Crs latlon = geoService.getCrs2("EPSG:4326");
    Envelope latlonEnvelope = geoService.transform(JTS.toGeometry(googleEnvelope), google, latlon)
        .getEnvelopeInternal();
    // back-transform scale to latlon
    double latlonScale = ZOOMED_IN_SCALE * googleEnvelope.getWidth() / latlonEnvelope.getWidth();
    // paint with reprojection (affine is fine for now...:-)
    List<RasterTile> tiles = osm.paint(latlon, latlonEnvelope, latlonScale);
    Assert.assertEquals(1, tiles.size());
    RasterTile tile = tiles.get(0);
    Assert.assertEquals("http://a.tile.openstreetmap.org/4/8/7.png", tile.getUrl());
View Full Code Here

TOP

Related Classes of com.vividsolutions.jts.geom.Envelope

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.