Package org.geomajas.puregwt.client.spatial

Examples of org.geomajas.puregwt.client.spatial.Geometry


  }

  @Test
  public void testTransformPoint() {
    Point point = factory.createPoint(new Coordinate(0, 0));
    Geometry result = viewPort.transform(point, RenderSpace.WORLD, RenderSpace.SCREEN);
    Assert.assertEquals(MAP_WIDTH / 2, ((Point) result).getX(), DELTA);
    Assert.assertEquals(MAP_HEIGHT / 2, ((Point) result).getY(), DELTA);

    result = viewPort.transform(result, RenderSpace.SCREEN, RenderSpace.WORLD);
    Assert.assertEquals(0, ((Point) result).getX(), DELTA);
View Full Code Here


  }

  @Test
  public void testTransformLineString() {
    LineString line = factory.createLineString(new Coordinate[] { new Coordinate(0, 0), new Coordinate(10, 10) });
    Geometry result = viewPort.transform(line, RenderSpace.WORLD, RenderSpace.SCREEN);
    Assert.assertEquals(MAP_WIDTH / 2, result.getCoordinates()[0].getX(), DELTA);
    Assert.assertEquals(MAP_HEIGHT / 2, result.getCoordinates()[0].getY(), DELTA);
    Assert.assertEquals((MAP_WIDTH / 2) + (viewPort.getScale() * 10), result.getCoordinates()[1].getX(), DELTA);
    Assert.assertEquals((MAP_HEIGHT / 2) - (viewPort.getScale() * 10), result.getCoordinates()[1].getY(), DELTA);
  }
View Full Code Here

  public void testTransformMultiPoint() {
    Point point1 = factory.createPoint(new Coordinate(0, 0));
    Point point2 = factory.createPoint(new Coordinate(5, 10));
    MultiPoint multiPoint = factory.createMultiPoint(new Point[] { point1, point2 });

    Geometry result = viewPort.transform(multiPoint, RenderSpace.WORLD, RenderSpace.SCREEN);
    Coordinate coordinate = result.getGeometryN(0).getCoordinate();
    Assert.assertEquals(MAP_WIDTH / 2, coordinate.getX(), DELTA);
    Assert.assertEquals(MAP_HEIGHT / 2, coordinate.getY(), DELTA);
    coordinate = result.getGeometryN(1).getCoordinate();
    Assert.assertEquals((MAP_WIDTH / 2) + (viewPort.getScale() * 5), coordinate.getX(), DELTA);
    Assert.assertEquals((MAP_HEIGHT / 2) - (viewPort.getScale() * 10), coordinate.getY(), DELTA);

    result = viewPort.transform(result, RenderSpace.SCREEN, RenderSpace.WORLD);
    coordinate = result.getGeometryN(0).getCoordinate();
    Assert.assertEquals(0.0, coordinate.getX(), DELTA);
    Assert.assertEquals(0.0, coordinate.getY(), DELTA);
    coordinate = result.getGeometryN(1).getCoordinate();
    Assert.assertEquals(5, coordinate.getX(), DELTA);
    Assert.assertEquals(10, coordinate.getY(), DELTA);
  }
View Full Code Here

  public void testTransformMultiLineString() {
    LineString ls1 = factory.createLineString(new Coordinate[] { new Coordinate(-5, 10), new Coordinate(10, 5) });
    LineString ls2 = factory.createLineString(new Coordinate[] { new Coordinate(5, -10), new Coordinate(-10, -5) });
    MultiLineString mls = factory.createMultiLineString(new LineString[] { ls1, ls2 });

    Geometry result = viewPort.transform(mls, RenderSpace.WORLD, RenderSpace.SCREEN);
    Coordinate coordinate = result.getGeometryN(0).getCoordinates()[0];
    Assert.assertEquals((MAP_WIDTH / 2) - (viewPort.getScale() * 5), coordinate.getX(), DELTA);
    Assert.assertEquals((MAP_HEIGHT / 2) - (viewPort.getScale() * 10), coordinate.getY(), DELTA);
    coordinate = result.getGeometryN(1).getCoordinates()[1];
    Assert.assertEquals((MAP_WIDTH / 2) - (viewPort.getScale() * 10), coordinate.getX(), DELTA);
    Assert.assertEquals((MAP_HEIGHT / 2) + (viewPort.getScale() * 5), coordinate.getY(), DELTA);

    result = viewPort.transform(result, RenderSpace.SCREEN, RenderSpace.WORLD);
    coordinate = result.getGeometryN(0).getCoordinates()[0];
    Assert.assertEquals(-5.0, coordinate.getX(), DELTA);
    Assert.assertEquals(10.0, coordinate.getY(), DELTA);
    coordinate = result.getGeometryN(1).getCoordinates()[1];
    Assert.assertEquals(-10.0, coordinate.getX(), DELTA);
    Assert.assertEquals(-5.0, coordinate.getY(), DELTA);
  }
View Full Code Here

        new Coordinate(-5, 5), new Coordinate(-5, -5) });
    Polygon polygon = factory.createPolygon(shell, new LinearRing[] { hole });
    MultiPolygon mp = factory.createMultiPolygon(new Polygon[] { polygon });

    // World to screen:
    Geometry result = viewPort.transform(mp, RenderSpace.WORLD, RenderSpace.SCREEN);
    Coordinate c = result.getGeometryN(0).getGeometryN(0).getCoordinates()[0];
    Assert.assertEquals((MAP_WIDTH / 2) - (viewPort.getScale() * 10), c.getX(), DELTA);
    Assert.assertEquals((MAP_HEIGHT / 2) + (viewPort.getScale() * 10), c.getY(), DELTA);
    c = result.getGeometryN(0).getGeometryN(0).getCoordinates()[1];
    Assert.assertEquals((MAP_WIDTH / 2) + (viewPort.getScale() * 10), c.getX(), DELTA);
    Assert.assertEquals((MAP_HEIGHT / 2), c.getY(), DELTA);
    c = ((Polygon) result.getGeometryN(0)).getInteriorRingN(0).getCoordinates()[2];
    Assert.assertEquals((MAP_WIDTH / 2) - (viewPort.getScale() * 5), c.getX(), DELTA);
    Assert.assertEquals((MAP_HEIGHT / 2) - (viewPort.getScale() * 5), c.getY(), DELTA);

    // Screen to world:
    result = viewPort.transform(result, RenderSpace.SCREEN, RenderSpace.WORLD);
    c = result.getGeometryN(0).getGeometryN(0).getCoordinates()[0];
    Assert.assertEquals(-10.0, c.getX(), DELTA);
    Assert.assertEquals(-10.0, c.getY(), DELTA);
    c = result.getGeometryN(0).getGeometryN(0).getCoordinates()[1];
    Assert.assertEquals(10, c.getX(), DELTA);
    Assert.assertEquals(0, c.getY(), DELTA);
    c = ((Polygon) result.getGeometryN(0)).getInteriorRingN(0).getCoordinates()[2];
    Assert.assertEquals(-5.0, c.getX(), DELTA);
    Assert.assertEquals(5.0, c.getY(), DELTA);
  }
View Full Code Here

TOP

Related Classes of org.geomajas.puregwt.client.spatial.Geometry

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.