Search in sources :

Example 1 with Punctual

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

the class EsriGeodatabaseXmlRecordWriter method writeDataElement.

private void writeDataElement(final RecordDefinition recordDefinition, final Geometry geometry) {
    final String dataElementType;
    final FieldDefinition geometryField = recordDefinition.getGeometryField();
    boolean hasGeometry = false;
    DataType geometryDataType = null;
    if (geometryField != null) {
        geometryDataType = geometryField.getDataType();
        if (this.fieldTypes.getFieldType(geometryDataType) != null) {
            hasGeometry = true;
            if (geometryDataType.equals(DataTypes.POINT)) {
                this.geometryType = GEOMETRY_TYPE_POINT;
            } else if (geometryDataType.equals(DataTypes.MULTI_POINT)) {
                this.geometryType = GEOMETRY_TYPE_MULTI_POINT;
            } else if (geometryDataType.equals(DataTypes.LINE_STRING)) {
                this.geometryType = GEOMETRY_TYPE_POLYLINE;
            } else if (geometryDataType.equals(DataTypes.MULTI_LINE_STRING)) {
                this.geometryType = GEOMETRY_TYPE_POLYLINE;
            } else if (geometryDataType.equals(DataTypes.POLYGON)) {
                this.geometryType = GEOMETRY_TYPE_POLYGON;
            } else {
                if (geometry instanceof Point) {
                    this.geometryType = GEOMETRY_TYPE_POINT;
                } else if (geometry instanceof Punctual) {
                    this.geometryType = GEOMETRY_TYPE_MULTI_POINT;
                } else if (geometry instanceof Lineal) {
                    this.geometryType = GEOMETRY_TYPE_POLYLINE;
                } else if (geometry instanceof Polygon) {
                    this.geometryType = GEOMETRY_TYPE_POLYGON;
                } else {
                    hasGeometry = false;
                }
            }
        }
    }
    if (hasGeometry) {
        dataElementType = DATA_ELEMENT_FEATURE_CLASS;
        this.datasetType = DATASET_TYPE_FEATURE_CLASS;
    } else {
        dataElementType = DATA_ELEMENT_TABLE;
        this.datasetType = DATASET_TYPE_TABLE;
    }
    this.out.startTag(DATA_ELEMENT);
    this.out.attribute(XsiConstants.TYPE, dataElementType);
    final String path = recordDefinition.getPath();
    final String localName = PathUtil.getName(path);
    this.out.element(CATALOG_PATH, "/FC=" + localName);
    this.out.element(NAME, localName);
    this.out.element(METADATA_RETRIEVED, true);
    this.out.startTag(METADATA);
    this.out.attribute(XsiConstants.TYPE, XML_PROPERTY_SET_TYPE);
    this.out.startTag(XML_DOC);
    this.out.text("<?xml version=\"1.0\"?>");
    this.out.text("<metadata xml:lang=\"en\">");
    this.out.text("<Esri>");
    this.out.text("<MetaID>{");
    this.out.text(UUID.randomUUID().toString().toUpperCase());
    this.out.text("}</MetaID>");
    this.out.text("<CreaDate>");
    final Timestamp date = new Timestamp(System.currentTimeMillis());
    this.out.text(Dates.format("yyyyMMdd", date));
    this.out.text("</CreaDate>");
    this.out.text("<CreaTime>");
    this.out.text(Dates.format("HHmmssSS", date));
    this.out.text("</CreaTime>");
    this.out.text("<SyncOnce>TRUE</SyncOnce>");
    this.out.text("</Esri>");
    this.out.text("</metadata>");
    this.out.endTag(XML_DOC);
    this.out.endTag(METADATA);
    this.out.element(DATASET_TYPE, this.datasetType);
    this.out.element(DSID, this.datasetId++);
    this.out.element(VERSIONED, false);
    this.out.element(CAN_VERSION, false);
    this.out.element(HAS_OID, true);
    this.out.element(OBJECT_ID_FIELD_NAME, "OBJECTID");
    writeFields(recordDefinition);
    this.out.element(CLSID, "{52353152-891A-11D0-BEC6-00805F7C4268}");
    this.out.emptyTag(EXTCLSID);
    this.out.startTag(RELATIONSHIP_CLASS_NAMES);
    this.out.attribute(XsiConstants.TYPE, NAMES_TYPE);
    this.out.endTag(RELATIONSHIP_CLASS_NAMES);
    this.out.element(ALIAS_NAME, localName);
    this.out.emptyTag(MODEL_NAME);
    this.out.element(HAS_GLOBAL_ID, false);
    this.out.emptyTag(GLOBAL_ID_FIELD_NAME);
    this.out.emptyTag(RASTER_FIELD_NAME);
    this.out.startTag(EXTENSION_PROPERTIES);
    this.out.attribute(XsiConstants.TYPE, PROPERTY_SET_TYPE);
    this.out.startTag(PROPERTY_ARRAY);
    this.out.attribute(XsiConstants.TYPE, PROPERTY_ARRAY_TYPE);
    this.out.endTag(PROPERTY_ARRAY);
    this.out.endTag(EXTENSION_PROPERTIES);
    this.out.startTag(CONTROLLER_MEMBERSHIPS);
    this.out.attribute(XsiConstants.TYPE, CONTROLLER_MEMBERSHIPS_TYPE);
    this.out.endTag(CONTROLLER_MEMBERSHIPS);
    if (hasGeometry) {
        this.out.element(FEATURE_TYPE, FEATURE_TYPE_SIMPLE);
        this.out.element(SHAPE_TYPE, this.geometryType);
        this.out.element(SHAPE_FIELD_NAME, geometryField.getName());
        final GeometryFactory geometryFactory = geometryField.getProperty(FieldProperties.GEOMETRY_FACTORY);
        this.out.element(HAS_M, false);
        this.out.element(HAS_Z, geometryFactory.hasZ());
        this.out.element(HAS_SPATIAL_INDEX, false);
        this.out.emptyTag(AREA_FIELD_NAME);
        this.out.emptyTag(LENGTH_FIELD_NAME);
        writeExtent(geometryFactory);
        writeSpatialReference(geometryFactory);
    }
    this.out.endTag(DATA_ELEMENT);
}
Also used : Punctual(com.revolsys.geometry.model.Punctual) GeometryFactory(com.revolsys.geometry.model.GeometryFactory) Lineal(com.revolsys.geometry.model.Lineal) FieldDefinition(com.revolsys.record.schema.FieldDefinition) DataType(com.revolsys.datatype.DataType) Point(com.revolsys.geometry.model.Point) Polygon(com.revolsys.geometry.model.Polygon) Timestamp(java.sql.Timestamp)

Example 2 with Punctual

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

the class ShapefileGeometryUtil method writeMultipoint.

private void writeMultipoint(final EndianOutput out, final Geometry geometry, final int shapeType, final int wordsPerPoint) throws IOException {
    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 3 with Punctual

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

the class BoundingBoxTest method testMultiPoint.

@Test
public void testMultiPoint() {
    for (final GeometryFactory geometryFactory : GEOMETRY_FACTORIES) {
        final Punctual empty = geometryFactory.punctual();
        final BoundingBox boundingBoxEmpty = empty.getBoundingBox();
        assertBoundingBox(empty, boundingBoxEmpty, geometryFactory, true, 2, NULL_BOUNDS);
        final Punctual geometry1 = geometryFactory.punctual(2, 3.0, 4.0, 1.0, 2.0);
        final BoundingBox boundingBox1 = geometry1.getBoundingBox();
        assertBoundingBox(geometry1, boundingBox1, geometryFactory, false, 2, 1.0, 2.0, 3.0, 4.0);
    }
}
Also used : GeometryFactory(com.revolsys.geometry.model.GeometryFactory) Punctual(com.revolsys.geometry.model.Punctual) BoundingBox(com.revolsys.geometry.model.BoundingBox) Test(org.junit.Test)

Example 4 with Punctual

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

the class GeometryTestUtil method multiPoint.

public static Punctual multiPoint(final GeometryFactory geometryFactory, final int geometryCount, final double delta) {
    final List<Geometry> geometries = new ArrayList<>();
    for (int i = 0; i < geometryCount; i++) {
        final Geometry geometry = point(geometryFactory, delta * i);
        geometries.add(geometry);
    }
    final Punctual multiPoint = geometryFactory.punctual(geometries);
    return multiPoint;
}
Also used : Geometry(com.revolsys.geometry.model.Geometry) Punctual(com.revolsys.geometry.model.Punctual) ArrayList(java.util.ArrayList) Point(com.revolsys.geometry.model.Point)

Example 5 with Punctual

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

the class ConvexHullTest method test6.

public void test6() throws Exception {
    final Punctual inputGeometry = GEOMETRY_FACTORY_1M.punctual(2, 0, 0, 5, 1, 10, 0);
    final Geometry actualGeometry = inputGeometry.convexHull();
    final Geometry expectedGeometry = GEOMETRY_FACTORY_1M.geometry("POLYGON((0 0,5 1,10 0,0 0))");
    assertEquals(expectedGeometry.toString(), actualGeometry.toString());
}
Also used : Geometry(com.revolsys.geometry.model.Geometry) Punctual(com.revolsys.geometry.model.Punctual)

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