Search in sources :

Example 66 with Polygon

use of com.revolsys.geometry.model.Polygon in project com.revolsys.open by revolsys.

the class TestPerfDistanceGeomSet method newCircleRandomLocation.

Geometry newCircleRandomLocation(final int nPts) {
    final SineStarFactory gsf = new SineStarFactory();
    gsf.setCentre(randomLocation());
    gsf.setSize(GEOM_SIZE);
    gsf.setNumPoints(nPts);
    final Polygon g = gsf.newCircle();
    return g;
}
Also used : SineStarFactory(com.revolsys.geometry.model.util.SineStarFactory) Polygon(com.revolsys.geometry.model.Polygon)

Example 67 with Polygon

use of com.revolsys.geometry.model.Polygon in project com.revolsys.open by revolsys.

the class DelaunayTest method testBoundary.

@Test
public void testBoundary() throws ParseException {
    // final Point point = this.geometryFactory.point(0, 0, 0);
    // testBoundaryDo(point);
    final LineString line = this.geometryFactory.lineString(3, 2, 0.0, 0, 0, 10, 10, 0);
    testBoundaryDo(line);
    final Polygon polygon = // 
    this.geometryFactory.polygon(// 
    3, // 
    0, // 
    10, // 
    2, // 
    10, // 
    10, // 
    3, // 
    10, // 
    0, // 
    4, // 
    0.0, // 
    0, // 
    1, // 
    0, // 
    10, // 
    2);
    testBoundaryDo(polygon);
}
Also used : LineString(com.revolsys.geometry.model.LineString) Polygon(com.revolsys.geometry.model.Polygon) Test(org.junit.Test)

Example 68 with Polygon

use of com.revolsys.geometry.model.Polygon in project com.revolsys.open by revolsys.

the class OracleSdoGeometryJdbcFieldDefinition method toPolygon.

private Polygon toPolygon(final ResultSet resultSet, final int columnIndex, final int axisCount) throws SQLException {
    final BigDecimal[] elemInfo = JdbcUtils.getBigDecimalArray(resultSet, columnIndex + 4);
    final BigDecimal[] coordinatesArray = JdbcUtils.getBigDecimalArray(resultSet, columnIndex + 5);
    final List<LinearRing> rings = new ArrayList<>();
    int numInteriorRings = 0;
    for (int elemInfoOffset = 0; elemInfoOffset < elemInfo.length; ) {
        final int offset = elemInfo[elemInfoOffset].intValue();
        final int type = (int) elemInfo[elemInfoOffset + 1].longValue();
        final long interpretation = elemInfo[elemInfoOffset + 2].longValue();
        switch(type) {
            case 1003:
                if (rings.isEmpty()) {
                    elemInfoOffset = addRingSimple(rings, axisCount, elemInfo, type, coordinatesArray, elemInfoOffset, offset, interpretation);
                } else {
                    throw new IllegalArgumentException("Cannot have two exterior rings on a geometry");
                }
                break;
            case 1005:
                if (rings.isEmpty()) {
                    elemInfoOffset = addRingComplex(rings, axisCount, elemInfo, type, coordinatesArray, elemInfoOffset, offset, interpretation);
                } else {
                    throw new IllegalArgumentException("Cannot have two exterior rings on a geometry");
                }
                break;
            case 2003:
                if (numInteriorRings == rings.size()) {
                    throw new IllegalArgumentException("Too many interior rings");
                } else {
                    numInteriorRings++;
                    elemInfoOffset = addRingSimple(rings, axisCount, elemInfo, type, coordinatesArray, elemInfoOffset, offset, interpretation);
                }
                break;
            case 2005:
                if (numInteriorRings == rings.size()) {
                    throw new IllegalArgumentException("Too many interior rings");
                } else {
                    numInteriorRings++;
                    elemInfoOffset = addRingSimple(rings, axisCount, elemInfo, type, coordinatesArray, elemInfoOffset, offset, interpretation);
                }
                break;
            default:
                throw new IllegalArgumentException("Unsupported geometry type " + type);
        }
    }
    final Polygon polygon = this.geometryFactory.polygon(rings);
    return polygon;
}
Also used : ArrayList(java.util.ArrayList) LinearRing(com.revolsys.geometry.model.LinearRing) Polygon(com.revolsys.geometry.model.Polygon) BigDecimal(java.math.BigDecimal) Point(com.revolsys.geometry.model.Point)

Example 69 with Polygon

use of com.revolsys.geometry.model.Polygon in project com.revolsys.open by revolsys.

the class GeometryStyleRenderer method renderGeometry.

public static final void renderGeometry(final Viewport2D viewport, final Graphics2D graphics, final Geometry geometry, final GeometryStyle style) {
    if (geometry != null) {
        final BoundingBox viewExtent = viewport.getBoundingBox();
        if (!viewExtent.isEmpty()) {
            final GeometryFactory viewGeometryFactory = viewport.getGeometryFactory2dFloating();
            for (int i = 0; i < geometry.getGeometryCount(); i++) {
                final Geometry part = geometry.getGeometry(i);
                final BoundingBox partExtent = part.getBoundingBox();
                if (partExtent.intersects(viewExtent)) {
                    final Geometry convertedPart = part.convertGeometry(viewGeometryFactory);
                    if (convertedPart instanceof Point) {
                        final Point point = (Point) convertedPart;
                        MarkerStyleRenderer.renderMarker(viewport, graphics, point, style, 0);
                    } else if (convertedPart instanceof LineString) {
                        final LineString lineString = (LineString) convertedPart;
                        renderLineString(viewport, graphics, lineString, style);
                    } else if (convertedPart instanceof Polygon) {
                        final Polygon polygon = (Polygon) convertedPart;
                        renderPolygon(viewport, graphics, polygon, style);
                    }
                }
            }
        }
    }
}
Also used : Geometry(com.revolsys.geometry.model.Geometry) GeometryFactory(com.revolsys.geometry.model.GeometryFactory) LineString(com.revolsys.geometry.model.LineString) BoundingBox(com.revolsys.geometry.model.BoundingBox) Point(com.revolsys.geometry.model.Point) Polygon(com.revolsys.geometry.model.Polygon) Paint(java.awt.Paint) Point(com.revolsys.geometry.model.Point)

Example 70 with Polygon

use of com.revolsys.geometry.model.Polygon in project com.revolsys.open by revolsys.

the class GeometryStyleRenderer method renderGeometryOutline.

public static final void renderGeometryOutline(final Viewport2D viewport, final Graphics2D graphics, final Geometry geometry, final GeometryStyle style) {
    if (geometry != null) {
        final BoundingBox viewExtent = viewport.getBoundingBox();
        if (!viewExtent.isEmpty()) {
            final GeometryFactory viewGeometryFactory = viewport.getGeometryFactory2dFloating();
            for (int i = 0; i < geometry.getGeometryCount(); i++) {
                final Geometry part = geometry.getGeometry(i);
                final BoundingBox partExtent = part.getBoundingBox();
                if (partExtent.intersects(viewExtent)) {
                    final Geometry convertedPart = part.convertGeometry(viewGeometryFactory);
                    if (convertedPart instanceof Point) {
                        final Point point = (Point) convertedPart;
                        MarkerStyleRenderer.renderMarker(viewport, graphics, point, style, 0);
                    } else if (convertedPart instanceof LineString) {
                        final LineString lineString = (LineString) convertedPart;
                        renderLineString(viewport, graphics, lineString, style);
                    } else if (convertedPart instanceof Polygon) {
                        final Polygon polygon = (Polygon) convertedPart;
                        for (final LinearRing ring : polygon.rings()) {
                            renderLineString(viewport, graphics, ring, style);
                        }
                    }
                }
            }
        }
    }
}
Also used : Geometry(com.revolsys.geometry.model.Geometry) GeometryFactory(com.revolsys.geometry.model.GeometryFactory) LineString(com.revolsys.geometry.model.LineString) BoundingBox(com.revolsys.geometry.model.BoundingBox) Point(com.revolsys.geometry.model.Point) Polygon(com.revolsys.geometry.model.Polygon) LinearRing(com.revolsys.geometry.model.LinearRing) Paint(java.awt.Paint) Point(com.revolsys.geometry.model.Point)

Aggregations

Polygon (com.revolsys.geometry.model.Polygon)147 Point (com.revolsys.geometry.model.Point)66 LinearRing (com.revolsys.geometry.model.LinearRing)54 LineString (com.revolsys.geometry.model.LineString)39 Geometry (com.revolsys.geometry.model.Geometry)34 ArrayList (java.util.ArrayList)30 GeometryFactory (com.revolsys.geometry.model.GeometryFactory)22 Polygonal (com.revolsys.geometry.model.Polygonal)17 BoundingBox (com.revolsys.geometry.model.BoundingBox)14 Punctual (com.revolsys.geometry.model.Punctual)12 Test (org.junit.Test)12 Lineal (com.revolsys.geometry.model.Lineal)11 BaseCloseable (com.revolsys.io.BaseCloseable)7 List (java.util.List)7 PolygonEditor (com.revolsys.geometry.model.editor.PolygonEditor)6 PointDoubleXY (com.revolsys.geometry.model.impl.PointDoubleXY)6 Vertex (com.revolsys.geometry.model.vertex.Vertex)6 CoordinateSystem (com.revolsys.geometry.cs.CoordinateSystem)3 ProjectedCoordinateSystem (com.revolsys.geometry.cs.ProjectedCoordinateSystem)3 Graphics2D (java.awt.Graphics2D)3