Search in sources :

Example 21 with Polygonal

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

the class ConnectedInteriorTester method visitShellInteriors.

/**
 * Mark all the edges for the edgeRings corresponding to the shells
 * of the input polygons.
 * Only ONE ring gets marked for each shell - if there are others which remain unmarked
 * this indicates a disconnected interior.
 */
private void visitShellInteriors(final Geometry g, final PlanarGraph graph) {
    if (g instanceof Polygon) {
        final Polygon p = (Polygon) g;
        visitInteriorRing(p.getShell(), graph);
    } else if (g instanceof Polygonal) {
        final Polygonal polygonal = (Polygonal) g;
        for (final Polygon polygon : polygonal.polygons()) {
            visitInteriorRing(polygon.getShell(), graph);
        }
    }
}
Also used : Polygonal(com.revolsys.geometry.model.Polygonal) Polygon(com.revolsys.geometry.model.Polygon)

Example 22 with Polygonal

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

the class GmlGeometryFieldType method geometry.

private void geometry(final XmlWriter out, final Object value, final boolean writeSrsName) {
    if (value instanceof Geometry) {
        final Geometry geometry = (Geometry) value;
        if (geometry instanceof Point) {
            final Point point = (Point) geometry;
            point(out, point, writeSrsName);
        } else if (geometry instanceof LineString) {
            final LineString line = (LineString) geometry;
            lineString(out, line, writeSrsName);
        } else if (geometry instanceof Polygon) {
            final Polygon polygon = (Polygon) geometry;
            polygon(out, polygon, writeSrsName);
        } else if (geometry instanceof Punctual) {
            final Punctual punctual = (Punctual) geometry;
            multiPoint(out, punctual, writeSrsName);
        } else if (geometry instanceof Lineal) {
            final Lineal lineal = (Lineal) geometry;
            multiLineString(out, lineal, writeSrsName);
        } else if (geometry instanceof Polygonal) {
            final Polygonal polygonal = (Polygonal) geometry;
            multiPolygon(out, polygonal, writeSrsName);
        } else if (geometry.isGeometryCollection()) {
            geometryCollection(out, geometry, writeSrsName);
        }
    }
}
Also used : Geometry(com.revolsys.geometry.model.Geometry) Punctual(com.revolsys.geometry.model.Punctual) Lineal(com.revolsys.geometry.model.Lineal) LineString(com.revolsys.geometry.model.LineString) Polygonal(com.revolsys.geometry.model.Polygonal) Point(com.revolsys.geometry.model.Point) Polygon(com.revolsys.geometry.model.Polygon)

Example 23 with Polygonal

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

the class GeometryCoordinatesTableModel method setGeometry.

public void setGeometry(final Geometry geometry) {
    final LayerRecordForm form = this.geometryCoordinatesPanel.getForm();
    final LayerRecord record = form.getRecord();
    final Geometry oldGeometry = record.getGeometry();
    if (oldGeometry != geometry) {
        final AbstractRecordLayer layer = record.getLayer();
        final String geometryFieldName = record.getGeometryFieldName();
        final UndoableEdit setGeometryUndo = layer.newSetFieldUndo(record, geometryFieldName, oldGeometry, geometry);
        final UndoManager undoManager = form.getUndoManager();
        undoManager.addEdit(setGeometryUndo);
    }
    if (this.geometry != geometry) {
        this.geometry = geometry;
        if (geometry == null) {
            this.geometryFactory = GeometryFactory.DEFAULT_3D;
            this.vertexIndexMap = Collections.emptyMap();
            this.vertexIndices = Collections.emptyList();
        } else {
            this.geometryFactory = geometry.getGeometryFactory();
            this.vertexIndexMap = getIndexOfVertices(geometry);
            this.vertexIndices = new ArrayList<>(this.vertexIndexMap.keySet());
        }
        this.axisCount = this.geometryFactory.getAxisCount();
        this.axisNames = new ArrayList<>();
        if (geometry.isGeometryCollection()) {
            this.axisNames.add("P");
        }
        if (geometry instanceof Polygonal) {
            this.axisNames.add("R");
        }
        this.vertexIndexColumn = this.axisNames.size();
        this.axisNames.add("#");
        this.segmentIndexColumn = this.axisNames.size();
        this.axisNames.add("S #");
        this.numIndexItems = this.axisNames.size();
        this.axisNames.add("X");
        this.axisNames.add("Y");
        if (this.axisCount > 2) {
            this.axisNames.add("Z");
        }
        if (this.axisCount > 3) {
            this.axisNames.add("M");
        }
        this.columnCount = this.axisNames.size();
        fireTableStructureChanged();
    }
}
Also used : Geometry(com.revolsys.geometry.model.Geometry) LayerRecordForm(com.revolsys.swing.map.form.LayerRecordForm) UndoManager(com.revolsys.swing.undo.UndoManager) UndoableEdit(javax.swing.undo.UndoableEdit) Polygonal(com.revolsys.geometry.model.Polygonal) AbstractRecordLayer(com.revolsys.swing.map.layer.record.AbstractRecordLayer) LayerRecord(com.revolsys.swing.map.layer.record.LayerRecord)

Example 24 with Polygonal

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

the class MultiPolygonVertex method hasNext.

@Override
public boolean hasNext() {
    if (getGeometry().isEmpty()) {
        return false;
    } else {
        final Polygonal polygonal = getPolygonal();
        int partIndex = this.partIndex;
        int ringIndex = this.ringIndex;
        int vertexIndex = this.vertexIndex + 1;
        while (partIndex < polygonal.getGeometryCount()) {
            final Polygon polygon = polygonal.getPolygon(partIndex);
            while (ringIndex < polygon.getRingCount()) {
                final LinearRing ring = polygon.getRing(ringIndex);
                if (vertexIndex < ring.getVertexCount()) {
                    return true;
                } else {
                    ringIndex++;
                    vertexIndex = 0;
                }
            }
            partIndex++;
            ringIndex = 0;
            vertexIndex = 0;
        }
        return false;
    }
}
Also used : Polygonal(com.revolsys.geometry.model.Polygonal) Polygon(com.revolsys.geometry.model.Polygon) LinearRing(com.revolsys.geometry.model.LinearRing)

Example 25 with Polygonal

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

the class EWktWriter method write.

public static void write(final Writer out, final Geometry geometry) {
    if (geometry != null) {
        if (geometry instanceof Point) {
            final Point point = (Point) geometry;
            write(out, point);
        } else if (geometry instanceof Punctual) {
            final Punctual punctual = (Punctual) geometry;
            write(out, punctual);
        } else if (geometry instanceof LinearRing) {
            final LinearRing line = (LinearRing) geometry;
            write(out, line);
        } else if (geometry instanceof LineString) {
            final LineString line = (LineString) geometry;
            write(out, line);
        } else if (geometry instanceof Lineal) {
            final Lineal lineal = (Lineal) geometry;
            write(out, lineal);
        } else if (geometry instanceof Polygon) {
            final Polygon polygon = (Polygon) geometry;
            write(out, polygon);
        } else if (geometry instanceof Polygonal) {
            final Polygonal polygonal = (Polygonal) geometry;
            write(out, polygonal);
        } else if (geometry.isGeometryCollection()) {
            writeGeometryCollection(out, geometry);
        } else {
            throw new IllegalArgumentException("Unknown geometry type" + geometry.getClass());
        }
    }
}
Also used : Punctual(com.revolsys.geometry.model.Punctual) Lineal(com.revolsys.geometry.model.Lineal) LineString(com.revolsys.geometry.model.LineString) Polygonal(com.revolsys.geometry.model.Polygonal) Point(com.revolsys.geometry.model.Point) LinearRing(com.revolsys.geometry.model.LinearRing) Polygon(com.revolsys.geometry.model.Polygon)

Aggregations

Polygonal (com.revolsys.geometry.model.Polygonal)41 Polygon (com.revolsys.geometry.model.Polygon)17 LinearRing (com.revolsys.geometry.model.LinearRing)12 Point (com.revolsys.geometry.model.Point)12 LineString (com.revolsys.geometry.model.LineString)9 Lineal (com.revolsys.geometry.model.Lineal)9 Punctual (com.revolsys.geometry.model.Punctual)9 Geometry (com.revolsys.geometry.model.Geometry)8 GeometryFactory (com.revolsys.geometry.model.GeometryFactory)7 PolygonalEditor (com.revolsys.geometry.model.editor.PolygonalEditor)6 Test (org.junit.Test)6 ArrayList (java.util.ArrayList)4 QuadEdgeDelaunayTinBuilder (com.revolsys.elevation.tin.quadedge.QuadEdgeDelaunayTinBuilder)3 BoundingBox (com.revolsys.geometry.model.BoundingBox)2 PathName (com.revolsys.io.PathName)2 Record (com.revolsys.record.Record)2 NoSuchElementException (java.util.NoSuchElementException)2 LocateFailureException (com.revolsys.elevation.tin.quadedge.LocateFailureException)1 QuadEdgeConformingDelaunayTinBuilder (com.revolsys.elevation.tin.quadedge.QuadEdgeConformingDelaunayTinBuilder)1 IndexedPointInAreaLocator (com.revolsys.geometry.algorithm.locate.IndexedPointInAreaLocator)1