Package org.geomajas.puregwt.client.spatial

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


  }

  private Path toPath(Polygon polygon) {
    Path path = toPath(polygon.getExteriorRing());
    for (int i = 0; i < polygon.getNumInteriorRing(); i++) {
      LinearRing interiorRing = polygon.getInteriorRingN(i);
      path.moveTo((int) interiorRing.getCoordinate().getX(), (int) interiorRing.getCoordinate().getY());
      for (int j = 1; j < interiorRing.getNumPoints() - 1; j++) {
        Coordinate coordinate = interiorRing.getCoordinateN(j);
        path.lineTo((int) coordinate.getX(), (int) coordinate.getY());
      }
      path.close();
    }
    return path;
View Full Code Here


  private Path toPath(MultiPolygon multiPolygon) {
    Path path = toPath((Polygon) multiPolygon.getGeometryN(0));
    for (int g = 1; g < multiPolygon.getNumGeometries(); g++) {
      Polygon polygon = (Polygon) multiPolygon.getGeometryN(g);

      LinearRing exteriorRing = polygon.getExteriorRing();
      path.moveTo((int) exteriorRing.getCoordinate().getX(), (int) exteriorRing.getCoordinate().getY());
      for (int i = 1; i < exteriorRing.getNumPoints() - 1; i++) {
        Coordinate coordinate = exteriorRing.getCoordinateN(i);
        path.lineTo((int) coordinate.getX(), (int) coordinate.getY());
      }
      path.close();

      for (int i = 0; i < polygon.getNumInteriorRing(); i++) {
        LinearRing interiorRing = polygon.getInteriorRingN(i);
        path.moveTo((int) interiorRing.getCoordinate().getX(), (int) interiorRing.getCoordinate().getY());
        for (int j = 1; j < interiorRing.getNumPoints() - 1; j++) {
          Coordinate coordinate = interiorRing.getCoordinateN(j);
          path.lineTo((int) coordinate.getX(), (int) coordinate.getY());
        }
        path.close();
      }
    }
View Full Code Here

          coordinates[i] = worldToScreen(geometry.getCoordinates()[i]);
        }
        return factory.createLineString(coordinates);
      } else if (geometry instanceof Polygon) {
        Polygon polygon = (Polygon) geometry;
        LinearRing shell = (LinearRing) worldToScreen(polygon.getExteriorRing());
        LinearRing[] holes = new LinearRing[polygon.getNumInteriorRing()];
        for (int n = 0; n < polygon.getNumInteriorRing(); n++) {
          holes[n] = (LinearRing) worldToScreen(polygon.getInteriorRingN(n));
        }
        return factory.createPolygon(shell, holes);
View Full Code Here

          coordinates[i] = screenToWorld(geometry.getCoordinates()[i]);
        }
        return factory.createLineString(coordinates);
      } else if (geometry instanceof Polygon) {
        Polygon polygon = (Polygon) geometry;
        LinearRing shell = (LinearRing) screenToWorld(polygon.getExteriorRing());
        LinearRing[] holes = new LinearRing[polygon.getNumInteriorRing()];
        for (int n = 0; n < polygon.getNumInteriorRing(); n++) {
          holes[n] = (LinearRing) screenToWorld(polygon.getInteriorRingN(n));
        }
        return factory.createPolygon(shell, holes);
View Full Code Here

    } else if (Geometry.LINEAR_RING.equals(geometryType)) {
      gwt = factory.createLinearRing(geometry.getCoordinates());
    } else if (Geometry.LINE_STRING.equals(geometryType)) {
      gwt = factory.createLineString(geometry.getCoordinates());
    } else if (Geometry.POLYGON.equals(geometryType)) {
      LinearRing exteriorRing = (LinearRing) toGwt(geometry.getGeometries()[0]);
      LinearRing[] interiorRings = new LinearRing[geometry.getGeometries().length - 1];
      for (int i = 0; i < interiorRings.length; i++) {
        interiorRings[i] = (LinearRing) toGwt(geometry.getGeometries()[i + 1]);
      }
      gwt = factory.createPolygon(exteriorRing, interiorRings);
View Full Code Here

    Assert.assertEquals((MAP_HEIGHT / 2) - (viewPort.getScale() * 10), result.getCoordinates()[1].getY(), DELTA);
  }

  @Test
  public void testTransformPolygon() {
    LinearRing shell = factory.createLinearRing(new Coordinate[] { new Coordinate(-10, -10), new Coordinate(10, 0),
        new Coordinate(-10, 10), new Coordinate(-10, -10) });
    LinearRing hole = factory.createLinearRing(new Coordinate[] { new Coordinate(-5, -5), new Coordinate(5, 0),
        new Coordinate(-5, 5), new Coordinate(-5, -5) });
    Polygon polygon = factory.createPolygon(shell, new LinearRing[] { hole });

    // World to screen:
    Polygon result = (Polygon) viewPort.transform(polygon, RenderSpace.WORLD, RenderSpace.SCREEN);
View Full Code Here

    Assert.assertEquals(-5.0, coordinate.getY(), DELTA);
  }

  @Test
  public void testTransformMultiPolygon() {
    LinearRing shell = factory.createLinearRing(new Coordinate[] { new Coordinate(-10, -10), new Coordinate(10, 0),
        new Coordinate(-10, 10), new Coordinate(-10, -10) });
    LinearRing hole = factory.createLinearRing(new Coordinate[] { new Coordinate(-5, -5), new Coordinate(5, 0),
        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:
View Full Code Here

TOP

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

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.