Search in sources :

Example 16 with Punctual

use of com.revolsys.geometry.model.Punctual 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 17 with Punctual

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

the class MeasureOverlay method paintComponent.

@Override
protected void paintComponent(final Viewport2D viewport, final Graphics2D graphics) {
    if (!this.measureGeometry.isEmpty()) {
        final GeometryFactory geometryFactory = getGeometryFactory2d();
        try (BaseCloseable transformCloseable = viewport.setUseModelCoordinates(graphics, true)) {
            MEASURE_RENDERER.paintSelected(viewport, graphics, geometryFactory, this.measureGeometry);
            if (this.measureGeometry instanceof Polygon) {
                final Polygon polygon = (Polygon) this.measureGeometry;
                GeometryStyleRenderer.renderPolygon(viewport, graphics, polygon, POLYGON_STYLE);
            }
        }
        if (!(this.measureGeometry instanceof Punctual)) {
            final TextStyle measureTextStyle = new TextStyle();
            measureTextStyle.setTextBoxColor(WebColors.Violet);
            measureTextStyle.setTextSize(Quantities.getQuantity(14, CustomUnits.PIXEL));
            measureTextStyle.setTextFaceName(Font.MONOSPACED);
            Point textPoint;
            measureTextStyle.setTextHorizontalAlignment("right");
            if (this.measureDataType == DataTypes.POLYGON && this.measureGeometry instanceof Polygon) {
                measureTextStyle.setTextDx(Quantities.getQuantity(-5, CustomUnits.PIXEL));
                measureTextStyle.setTextPlacementType("vertex(n-1)");
                measureTextStyle.setTextVerticalAlignment("middle");
                textPoint = this.measureGeometry.getToVertex(0, 1);
            } else {
                measureTextStyle.setTextDx(Quantities.getQuantity(-7, CustomUnits.PIXEL));
                measureTextStyle.setTextDy(Quantities.getQuantity(-2, CustomUnits.PIXEL));
                measureTextStyle.setTextPlacementType("vertex(n)");
                measureTextStyle.setTextVerticalAlignment("top");
                textPoint = this.measureGeometry.getToVertex(0);
            }
            TextStyleRenderer.renderText(viewport, graphics, this.measureLabel, textPoint, measureTextStyle);
        }
    }
    drawXorGeometry(graphics);
}
Also used : BaseCloseable(com.revolsys.io.BaseCloseable) GeometryFactory(com.revolsys.geometry.model.GeometryFactory) Punctual(com.revolsys.geometry.model.Punctual) TextStyle(com.revolsys.swing.map.layer.record.style.TextStyle) Point(com.revolsys.geometry.model.Point) Polygon(com.revolsys.geometry.model.Polygon)

Example 18 with Punctual

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

the class MultiPointVertex method next.

@Override
public Vertex next() {
    final Punctual punctual = getPunctual();
    this.partIndex++;
    if (this.partIndex < punctual.getGeometryCount()) {
        return this;
    } else {
        throw new NoSuchElementException();
    }
}
Also used : Punctual(com.revolsys.geometry.model.Punctual) NoSuchElementException(java.util.NoSuchElementException)

Example 19 with Punctual

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

the class ShapefileGeometryHandler method writeMultipoint.

private void writeMultipoint(final EndianOutput out, final Geometry geometry, final int shapeType, final int wordsPerPoint) {
    if (geometry instanceof Punctual) {
        final int vertexCount = geometry.getVertexCount();
        if (this.writeLength) {
            final int recordLength = 20 + wordsPerPoint * vertexCount;
            // (BYTES_IN_INT + 4 * BYTES_IN_DOUBLE + BYTES_IN_INT +
            // (vertexCount * 2 * BYTES_IN_DOUBLE)) / BYTES_IN_SHORT;
            out.writeInt(recordLength);
        }
        out.writeLEInt(shapeType);
        final BoundingBox envelope = geometry.getBoundingBox();
        writeEnvelope(out, envelope);
        out.writeLEInt(vertexCount);
        writeXYCoordinates(out, geometry);
    } else {
        throw new IllegalArgumentException("Expecting Punctual geometry got " + geometry.getGeometryType());
    }
}
Also used : Punctual(com.revolsys.geometry.model.Punctual) BoundingBox(com.revolsys.geometry.model.BoundingBox) Point(com.revolsys.geometry.model.Point)

Example 20 with Punctual

use of com.revolsys.geometry.model.Punctual 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

Punctual (com.revolsys.geometry.model.Punctual)31 Point (com.revolsys.geometry.model.Point)17 LineString (com.revolsys.geometry.model.LineString)11 Lineal (com.revolsys.geometry.model.Lineal)11 Polygon (com.revolsys.geometry.model.Polygon)11 Polygonal (com.revolsys.geometry.model.Polygonal)9 Geometry (com.revolsys.geometry.model.Geometry)8 Test (org.junit.Test)7 BoundingBox (com.revolsys.geometry.model.BoundingBox)6 LinearRing (com.revolsys.geometry.model.LinearRing)6 PunctualEditor (com.revolsys.geometry.model.editor.PunctualEditor)6 GeometryFactory (com.revolsys.geometry.model.GeometryFactory)4 ArrayList (java.util.ArrayList)2 DataType (com.revolsys.datatype.DataType)1 Edge (com.revolsys.geometry.graph.Edge)1 LineStringDouble (com.revolsys.geometry.model.impl.LineStringDouble)1 PointDoubleXY (com.revolsys.geometry.model.impl.PointDoubleXY)1 LineSegment (com.revolsys.geometry.model.segment.LineSegment)1 LineSegmentDoubleGF (com.revolsys.geometry.model.segment.LineSegmentDoubleGF)1 BaseCloseable (com.revolsys.io.BaseCloseable)1