Search in sources :

Example 1 with ArcLineString

use of com.revolsys.record.io.format.saif.geometry.ArcLineString in project com.revolsys.open by revolsys.

the class ArcConverter method write.

protected void write(final OsnSerializer serializer, final Object object, final boolean writeAttributes) throws IOException {
    if (object instanceof LineString) {
        final LineString line = (LineString) object;
        serializer.startObject(this.geometryType);
        serializer.fieldName("LineString");
        serializer.startCollection("List");
        final LineString points = line;
        final int axisCount = points.getAxisCount();
        for (int i = 0; i < points.getVertexCount(); i++) {
            serializer.startObject(SaifConstants.POINT);
            serializer.fieldName("coords");
            final double x = points.getX(i);
            final double y = points.getY(i);
            final double z = points.getZ(i);
            if (axisCount == 2) {
                serializer.startObject("/Coord2D");
                serializer.attribute("c1", x, true);
                serializer.attribute("c2", y, false);
            } else {
                serializer.startObject("/Coord3D");
                serializer.attribute("c1", x, true);
                serializer.attribute("c2", y, true);
                if (Double.isNaN(z)) {
                    serializer.attribute("c3", 0, false);
                } else {
                    serializer.attribute("c3", z, false);
                }
            }
            serializer.endObject();
            serializer.endAttribute();
            serializer.endObject();
        }
        serializer.endCollection();
        serializer.endAttribute();
        if (writeAttributes && line instanceof ArcLineString) {
            writeAttributes(serializer, (ArcLineString) line);
        }
        serializer.endObject();
    }
}
Also used : ArcLineString(com.revolsys.record.io.format.saif.geometry.ArcLineString) LineString(com.revolsys.geometry.model.LineString) ArcLineString(com.revolsys.record.io.format.saif.geometry.ArcLineString)

Example 2 with ArcLineString

use of com.revolsys.record.io.format.saif.geometry.ArcLineString in project com.revolsys.open by revolsys.

the class ArcConverter method writeAttributes.

protected void writeAttributes(final OsnSerializer serializer, final ArcLineString line) throws IOException {
    final String qualifier = line.getQualifier();
    attributeEnum(serializer, "qualifier", qualifier);
}
Also used : ArcLineString(com.revolsys.record.io.format.saif.geometry.ArcLineString) LineString(com.revolsys.geometry.model.LineString)

Example 3 with ArcLineString

use of com.revolsys.record.io.format.saif.geometry.ArcLineString in project com.revolsys.open by revolsys.

the class ContourConverter method write.

@Override
public void write(final OsnSerializer serializer, final Object object) throws IOException {
    if (object instanceof LineString) {
        final LineString line = (LineString) object;
        serializer.startObject(GEOMETRY_CLASS);
        serializer.fieldName("arc");
        super.write(serializer, object);
        serializer.endAttribute();
        if (line instanceof ContourLineString) {
            final ContourLineString contourLine = (ContourLineString) line;
            final String form = contourLine.getForm();
            attributeEnum(serializer, "form", form);
            super.writeAttributes(serializer, (ArcLineString) line);
            final int value = contourLine.getValue();
            attributeEnum(serializer, "form", Integer.toString(value));
        } else if (line instanceof ArcLineString) {
            super.writeAttributes(serializer, (ArcLineString) line);
        }
        serializer.endObject();
    }
}
Also used : ArcLineString(com.revolsys.record.io.format.saif.geometry.ArcLineString) ContourLineString(com.revolsys.record.io.format.saif.geometry.ContourLineString) LineString(com.revolsys.geometry.model.LineString) ArcLineString(com.revolsys.record.io.format.saif.geometry.ArcLineString) ArcLineString(com.revolsys.record.io.format.saif.geometry.ArcLineString) ContourLineString(com.revolsys.record.io.format.saif.geometry.ContourLineString) LineString(com.revolsys.geometry.model.LineString) ContourLineString(com.revolsys.record.io.format.saif.geometry.ContourLineString)

Example 4 with ArcLineString

use of com.revolsys.record.io.format.saif.geometry.ArcLineString in project com.revolsys.open by revolsys.

the class OrientedArcConverter method write.

@Override
public void write(final OsnSerializer serializer, final Object object) throws IOException {
    if (object instanceof LineString) {
        final LineString line = (LineString) object;
        serializer.startObject(GEOMETRY_CLASS);
        serializer.fieldName("arc");
        super.write(serializer, object, false);
        serializer.endAttribute();
        if (line instanceof ArcLineString) {
            super.writeAttributes(serializer, (ArcLineString) line);
        }
        if (line instanceof OrientedArcLineString) {
            final OrientedArcLineString orientedLine = (OrientedArcLineString) line;
            final String traversalDirection = orientedLine.getTraversalDirection();
            attributeEnum(serializer, "traversalDirection", traversalDirection);
        }
        serializer.endObject();
    }
}
Also used : OrientedArcLineString(com.revolsys.record.io.format.saif.geometry.OrientedArcLineString) ArcLineString(com.revolsys.record.io.format.saif.geometry.ArcLineString) OrientedArcLineString(com.revolsys.record.io.format.saif.geometry.OrientedArcLineString) LineString(com.revolsys.geometry.model.LineString) ArcLineString(com.revolsys.record.io.format.saif.geometry.ArcLineString) OrientedArcLineString(com.revolsys.record.io.format.saif.geometry.OrientedArcLineString) ArcLineString(com.revolsys.record.io.format.saif.geometry.ArcLineString) OrientedArcLineString(com.revolsys.record.io.format.saif.geometry.OrientedArcLineString) LineString(com.revolsys.geometry.model.LineString)

Example 5 with ArcLineString

use of com.revolsys.record.io.format.saif.geometry.ArcLineString in project com.revolsys.open by revolsys.

the class ArcDirectedConverter method writeAttributes.

@Override
protected void writeAttributes(final OsnSerializer serializer, final ArcLineString line) throws IOException {
    if (line instanceof ArcDirectedLineString) {
        final ArcDirectedLineString dirLine = (ArcDirectedLineString) line;
        final String flowDirection = dirLine.getFlowDirection();
        attributeEnum(serializer, "flowDirection", flowDirection);
    }
    super.writeAttributes(serializer, line);
}
Also used : ArcDirectedLineString(com.revolsys.record.io.format.saif.geometry.ArcDirectedLineString) ArcDirectedLineString(com.revolsys.record.io.format.saif.geometry.ArcDirectedLineString) ArcLineString(com.revolsys.record.io.format.saif.geometry.ArcLineString) LineString(com.revolsys.geometry.model.LineString)

Aggregations

LineString (com.revolsys.geometry.model.LineString)5 ArcLineString (com.revolsys.record.io.format.saif.geometry.ArcLineString)5 ArcDirectedLineString (com.revolsys.record.io.format.saif.geometry.ArcDirectedLineString)1 ContourLineString (com.revolsys.record.io.format.saif.geometry.ContourLineString)1 OrientedArcLineString (com.revolsys.record.io.format.saif.geometry.OrientedArcLineString)1