Search in sources :

Example 41 with GeometryFactory

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

the class ScaledIntegerPointCloudGeometryWriter method initialize.

private void initialize() throws IOException {
    if (!this.initialized) {
        this.initialized = true;
        final ChannelWriter writer = this.resource.newChannelWriter(this.byteBuffer);
        this.writer = writer;
        final GeometryFactory geometryFactory = this.geometryFactory;
        // File
        writer.putBytes(ScaledIntegerPointCloud.FILE_TYPE_HEADER_BYTES);
        // type
        // version
        writer.putShort(ScaledIntegerPointCloud.VERSION);
        // Flags
        writer.putShort((short) 0);
        geometryFactory.writeOffsetScaled3d(writer);
    }
}
Also used : GeometryFactory(com.revolsys.geometry.model.GeometryFactory) ChannelWriter(com.revolsys.io.channels.ChannelWriter)

Example 42 with GeometryFactory

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

the class ScaledIntegerPointCloudGeometryWriter method write.

public void write(final double x, final double y, final double z) {
    try {
        initialize();
        final ChannelWriter writer = this.writer;
        final GeometryFactory geometryFactory = this.geometryFactory;
        final int xInt = geometryFactory.toIntX(x);
        writer.putInt(xInt);
        final int yInt = geometryFactory.toIntY(y);
        writer.putInt(yInt);
        final int zInt = geometryFactory.toIntZ(z);
        writer.putInt(zInt);
    } catch (final IOException e) {
        throw Exceptions.wrap(e);
    }
}
Also used : GeometryFactory(com.revolsys.geometry.model.GeometryFactory) IOException(java.io.IOException) Point(com.revolsys.geometry.model.Point) ChannelWriter(com.revolsys.io.channels.ChannelWriter)

Example 43 with GeometryFactory

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

the class PointConverter method read.

@Override
public Object read(final OsnIterator iterator) {
    final Map<String, Object> values = new TreeMap<>();
    values.put("type", this.geometryClass);
    Point point = null;
    String fieldName = iterator.nextFieldName();
    while (fieldName != null) {
        if (fieldName.equals("coords")) {
            final String coordTypeName = iterator.nextObjectName();
            if (coordTypeName.equals("/Coord3D")) {
                final double x = iterator.nextDoubleAttribute("c1");
                final double y = iterator.nextDoubleAttribute("c2");
                double z = iterator.nextDoubleAttribute("c3");
                if (z == 2147483648.0) {
                    z = 0;
                }
                final GeometryFactory geometryFactory = this.geometryFactory.convertAxisCount(3);
                point = newPoint(geometryFactory, x, y, z);
            } else if (coordTypeName.equals("/Coord2D")) {
                final double x = iterator.nextDoubleAttribute("c1");
                final double y = iterator.nextDoubleAttribute("c2");
                final GeometryFactory geometryFactory = this.geometryFactory.convertAxisCount(3);
                point = newPoint(geometryFactory, x, y);
            } else {
                iterator.throwParseError("Expecting Coord2D or Coord3D");
            }
            iterator.nextEndObject();
        } else {
            readAttribute(iterator, fieldName, values);
        }
        fieldName = iterator.nextFieldName();
    }
    Property.set(point, values);
    return point;
}
Also used : GeometryFactory(com.revolsys.geometry.model.GeometryFactory) Point(com.revolsys.geometry.model.Point) TreeMap(java.util.TreeMap)

Example 44 with GeometryFactory

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

the class RecordDefinitionImpl method addField.

public synchronized void addField(final FieldDefinition field) {
    final int index = this.fieldNames.size();
    final String name = field.getName();
    String lowerName;
    if (name == null) {
        lowerName = null;
    } else {
        lowerName = name.toLowerCase();
    }
    this.internalFieldNames.add(name);
    this.fieldNames = Lists.unmodifiable(this.internalFieldNames);
    this.fieldNamesSet = Sets.unmodifiableLinked(this.internalFieldNames);
    this.internalFields.add(field);
    this.fields = Lists.unmodifiable(this.internalFields);
    this.fieldMap.put(lowerName, field);
    this.fieldIdMap.put(lowerName, this.fieldIdMap.size());
    final DataType dataType = field.getDataType();
    if (dataType == null) {
        Logs.debug(this, field.toString());
    } else {
        final Class<?> dataClass = dataType.getJavaClass();
        if (Geometry.class.isAssignableFrom(dataClass)) {
            this.geometryFieldDefinitionIndexes.add(index);
            this.geometryFieldDefinitionNames.add(name);
            if (this.geometryFieldDefinitionIndex == -1) {
                this.geometryFieldDefinitionIndex = index;
                final GeometryFactory geometryFactory = field.getProperty(FieldProperties.GEOMETRY_FACTORY);
                if (geometryFactory == null && this.geometryFactory != null) {
                    field.setProperty(FieldProperties.GEOMETRY_FACTORY, this.geometryFactory);
                }
            }
        }
    }
    field.setIndex(index);
    field.setRecordDefinition(this);
    final CodeTable codeTable = field.getCodeTable();
    addFieldCodeTable(name, codeTable);
}
Also used : CodeTable(com.revolsys.record.code.CodeTable) GeometryFactory(com.revolsys.geometry.model.GeometryFactory) DataType(com.revolsys.datatype.DataType)

Example 45 with GeometryFactory

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

the class RecordDefinitionImpl method toMap.

@Override
public MapEx toMap() {
    final MapEx map = new LinkedHashMapEx();
    addTypeToMap(map, "recordDefinition");
    final String path = getPath();
    map.put("path", path);
    final ClockDirection polygonRingDirection = getPolygonRingDirection();
    addToMap(map, "polygonRingDirection", polygonRingDirection, null);
    final GeometryFactory geometryFactory = getGeometryFactory();
    addToMap(map, "geometryFactory", geometryFactory, null);
    final List<FieldDefinition> fields = getFields();
    addToMap(map, "fields", fields);
    return map;
}
Also used : GeometryFactory(com.revolsys.geometry.model.GeometryFactory) MapEx(com.revolsys.collection.map.MapEx) LinkedHashMapEx(com.revolsys.collection.map.LinkedHashMapEx) LinkedHashMapEx(com.revolsys.collection.map.LinkedHashMapEx) ClockDirection(com.revolsys.geometry.model.ClockDirection)

Aggregations

GeometryFactory (com.revolsys.geometry.model.GeometryFactory)360 Point (com.revolsys.geometry.model.Point)142 Geometry (com.revolsys.geometry.model.Geometry)72 BoundingBox (com.revolsys.geometry.model.BoundingBox)70 LineString (com.revolsys.geometry.model.LineString)61 ArrayList (java.util.ArrayList)45 DataType (com.revolsys.datatype.DataType)25 FieldDefinition (com.revolsys.record.schema.FieldDefinition)24 Polygon (com.revolsys.geometry.model.Polygon)22 List (java.util.List)18 RecordDefinition (com.revolsys.record.schema.RecordDefinition)17 Test (org.junit.Test)16 CoordinateSystem (com.revolsys.geometry.cs.CoordinateSystem)15 Vertex (com.revolsys.geometry.model.vertex.Vertex)14 Record (com.revolsys.record.Record)14 IOException (java.io.IOException)13 PathName (com.revolsys.io.PathName)12 LinearRing (com.revolsys.geometry.model.LinearRing)10 PointDoubleXY (com.revolsys.geometry.model.impl.PointDoubleXY)10 QuadEdgeDelaunayTinBuilder (com.revolsys.elevation.tin.quadedge.QuadEdgeDelaunayTinBuilder)8