Package org.geomajas.gwt.client.spatial.geometry

Examples of org.geomajas.gwt.client.spatial.geometry.Polygon


    } else if (geometry instanceof LineString) {
      dto = new Geometry(Geometry.LINE_STRING, srid, precision);
      dto.setCoordinates(geometry.getCoordinates());
    } else if (geometry instanceof Polygon) {
      dto = new Geometry(Geometry.POLYGON, srid, precision);
      Polygon polygon = (Polygon) geometry;
      Geometry[] geometries = new Geometry[polygon.getNumInteriorRing() + 1];
      for (int i = 0; i < geometries.length; i++) {
        if (i == 0) {
          geometries[i] = toDto(polygon.getExteriorRing());
        } else {
          geometries[i] = toDto(polygon.getInteriorRingN(i - 1));
        }
      }
      dto.setGeometries(geometries);
    } else if (geometry instanceof MultiPoint) {
      dto = new Geometry(Geometry.MULTI_POINT, srid, precision);
View Full Code Here


        for (int i = 0; i < coordinates.length; i++) {
          coordinates[i] = worldToView(geometry.getCoordinates()[i]);
        }
        return geometry.getGeometryFactory().createLineString(coordinates);
      } else if (geometry instanceof Polygon) {
        Polygon polygon = (Polygon) geometry;
        LinearRing shell = (LinearRing) worldToView(polygon.getExteriorRing());
        LinearRing[] holes = new LinearRing[polygon.getNumInteriorRing()];
        for (int n = 0; n < polygon.getNumInteriorRing(); n++) {
          holes[n] = (LinearRing) worldToView(polygon.getInteriorRingN(n));
        }
        return polygon.getGeometryFactory().createPolygon(shell, holes);
      } else if (geometry instanceof MultiPoint) {
        Point[] points = new Point[geometry.getNumGeometries()];
        for (int n = 0; n < geometry.getNumGeometries(); n++) {
          points[n] = (Point) worldToView(geometry.getGeometryN(n));
        }
View Full Code Here

        for (int i = 0; i < coordinates.length; i++) {
          coordinates[i] = worldToPan(geometry.getCoordinates()[i]);
        }
        return geometry.getGeometryFactory().createLineString(coordinates);
      } else if (geometry instanceof Polygon) {
        Polygon polygon = (Polygon) geometry;
        LinearRing shell = (LinearRing) worldToPan(polygon.getExteriorRing());
        LinearRing[] holes = new LinearRing[polygon.getNumInteriorRing()];
        for (int n = 0; n < polygon.getNumInteriorRing(); n++) {
          holes[n] = (LinearRing) worldToPan(polygon.getInteriorRingN(n));
        }
        return polygon.getGeometryFactory().createPolygon(shell, holes);
      } else if (geometry instanceof MultiPoint) {
        Point[] points = new Point[geometry.getNumGeometries()];
        for (int n = 0; n < geometry.getNumGeometries(); n++) {
          points[n] = (Point) worldToPan(geometry.getGeometryN(n));
        }
View Full Code Here

        for (int i = 0; i < coordinates.length; i++) {
          coordinates[i] = viewToPan(geometry.getCoordinates()[i]);
        }
        return geometry.getGeometryFactory().createLineString(coordinates);
      } else if (geometry instanceof Polygon) {
        Polygon polygon = (Polygon) geometry;
        LinearRing shell = (LinearRing) worldToPan(polygon.getExteriorRing());
        LinearRing[] holes = new LinearRing[polygon.getNumInteriorRing()];
        for (int n = 0; n < polygon.getNumInteriorRing(); n++) {
          holes[n] = (LinearRing) viewToPan(polygon.getInteriorRingN(n));
        }
        return polygon.getGeometryFactory().createPolygon(shell, holes);
      } else if (geometry instanceof MultiPoint) {
        Point[] points = new Point[geometry.getNumGeometries()];
        for (int n = 0; n < geometry.getNumGeometries(); n++) {
          points[n] = (Point) viewToPan(geometry.getGeometryN(n));
        }
View Full Code Here

        for (int i = 0; i < coordinates.length; i++) {
          coordinates[i] = viewToWorld(geometry.getCoordinates()[i]);
        }
        return geometry.getGeometryFactory().createLineString(coordinates);
      } else if (geometry instanceof Polygon) {
        Polygon polygon = (Polygon) geometry;
        LinearRing shell = (LinearRing) viewToWorld(polygon.getExteriorRing());
        LinearRing[] holes = new LinearRing[polygon.getNumInteriorRing()];
        for (int n = 0; n < polygon.getNumInteriorRing(); n++) {
          holes[n] = (LinearRing) viewToWorld(polygon.getInteriorRingN(n));
        }
        return polygon.getGeometryFactory().createPolygon(shell, holes);
      } else if (geometry instanceof MultiPoint) {
        Point[] points = new Point[geometry.getNumGeometries()];
        for (int n = 0; n < geometry.getNumGeometries(); n++) {
          points[n] = (Point) viewToWorld(geometry.getGeometryN(n));
        }
View Full Code Here

        for (int i = 0; i < coordinates.length; i++) {
          coordinates[i] = transform(geometry.getCoordinates()[i], matrix);
        }
        return geometry.getGeometryFactory().createLineString(coordinates);
      } else if (geometry instanceof Polygon) {
        Polygon polygon = (Polygon) geometry;
        LinearRing shell = (LinearRing) transform(polygon.getExteriorRing(), matrix);
        LinearRing[] holes = new LinearRing[polygon.getNumInteriorRing()];
        for (int n = 0; n < polygon.getNumInteriorRing(); n++) {
          holes[n] = (LinearRing) transform(polygon.getInteriorRingN(n), matrix);
        }
        return polygon.getGeometryFactory().createPolygon(shell, holes);
      } else if (geometry instanceof MultiPoint) {
        Point[] points = new Point[geometry.getNumGeometries()];
        for (int n = 0; n < geometry.getNumGeometries(); n++) {
          points[n] = (Point) transform(geometry.getGeometryN(n), matrix);
        }
View Full Code Here

    if (maxBoundsDisplayed) {
      VectorLayer layer = getFeatureTransaction().getLayer();
      GeometryFactory factory = mapWidget.getMapModel().getGeometryFactory();
      LinearRing hole = factory.createLinearRing(new Bbox(layer.getLayerInfo().getMaxExtent()));
      LinearRing shell = factory.createLinearRing(mapWidget.getMapModel().getMapView().getMaxBounds());
      Polygon polygon = factory.createPolygon(shell, new LinearRing[] { hole });

      maxExtent = new GfxGeometry("maxExtent");
      maxExtent.setGeometry(polygon);
      maxExtent.setStyle(new ShapeStyle("#000000", .6f, "#990000", 1, 2));
      mapWidget.registerWorldPaintable(maxExtent);
View Full Code Here

              new Coordinate(getWidth() + 2, getHeight() + 2), new Coordinate(-2, getHeight() + 2) });
      LinearRing hole = getMapModel().getGeometryFactory().createLinearRing(
          new Coordinate[] { new Coordinate(box.getX(), box.getY()),
              new Coordinate(box.getMaxX(), box.getY()), new Coordinate(box.getMaxX(), box.getMaxY()),
              new Coordinate(box.getX(), box.getMaxY()) });
      Polygon polygon = getMapModel().getGeometryFactory().createPolygon(shell, new LinearRing[] { hole });
      targetMaxExtentRectangle.setGeometry(polygon);
      render(targetMaxExtentRectangle, RenderGroup.SCREEN, RenderStatus.ALL);
    } else {
      render(targetMaxExtentRectangle, RenderGroup.SCREEN, RenderStatus.DELETE);
      targetMaxExtentRectangle = null;
View Full Code Here

  // -------------------------------------------------------------------------

  @Test
  public void testLineStringZeroIndex() {
    GeometryOperation op = new RemoveRingOperation(0);
    Polygon result = (Polygon) op.execute(polygon);
    Assert.assertEquals(polygon.getNumInteriorRing() - 1, result.getNumInteriorRing());
    Assert.assertEquals(16.0, result.getInteriorRingN(0).getCoordinate().getX(), TOLERANCE);
  }
View Full Code Here

  }

  @Test
  public void testLineStringBigIndex() {
    GeometryOperation op = new RemoveRingOperation(polygon.getNumInteriorRing());
    Polygon result = (Polygon) op.execute(polygon);
    Assert.assertEquals(polygon.getNumInteriorRing() - 1, result.getNumInteriorRing());
    Assert.assertEquals(12.0, result.getInteriorRingN(0).getCoordinate().getX(), TOLERANCE);
  }
View Full Code Here

TOP

Related Classes of org.geomajas.gwt.client.spatial.geometry.Polygon

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.