Search in sources :

Example 66 with RecordDefinition

use of com.revolsys.record.schema.RecordDefinition in project com.revolsys.open by revolsys.

the class CloseLocation method toString.

@Override
public String toString() {
    final StringBuilder string = new StringBuilder();
    final String layerPath = getLayerPath();
    if (Property.hasValue(layerPath)) {
        string.append(layerPath);
    }
    if (getRecordDefinition() != null) {
        string.append(", ");
        final RecordDefinition recordDefinition = getRecordDefinition();
        string.append(recordDefinition.getIdFieldName());
        string.append("=");
        final Object id = getId();
        string.append(id);
        string.append(", ");
    }
    string.append(getType());
    int[] index = getVertexId();
    if (index != null) {
        string.append(", index=");
    } else {
        string.append(", index=");
        index = getSegmentId();
    }
    final String indexString = Strings.toString(Lists.arrayToList(index));
    string.append(indexString);
    return string.toString();
}
Also used : RecordDefinition(com.revolsys.record.schema.RecordDefinition)

Example 67 with RecordDefinition

use of com.revolsys.record.schema.RecordDefinition in project com.revolsys.open by revolsys.

the class FileRecordLayer method revertDo.

protected boolean revertDo() {
    if (this.resource == null) {
        return false;
    } else {
        if (this.resource.exists()) {
            try (final RecordReader reader = RecordReader.newRecordReader(this.resource)) {
                if (reader == null) {
                    Logs.error(this, "Cannot find reader for: " + this.resource);
                    return false;
                } else {
                    final Map<String, Object> properties = getProperties();
                    reader.setProperties(properties);
                    final RecordDefinition recordDefinition = reader.getRecordDefinition();
                    setRecordDefinition(recordDefinition);
                    if (recordDefinition == null) {
                        Logs.error(this, "No record definition found for: " + this.url);
                        return false;
                    } else {
                        GeometryFactory geometryFactory = recordDefinition.getGeometryFactory();
                        clearRecords();
                        try (BaseCloseable eventsDisabled = eventsDisabled()) {
                            for (final Record record : reader) {
                                final Geometry geometry = record.getGeometry();
                                if (geometry != null) {
                                    if (geometryFactory == null || !geometryFactory.isHasCoordinateSystem()) {
                                        final GeometryFactory geometryFactory2 = geometry.getGeometryFactory();
                                        if (geometryFactory2.isHasCoordinateSystem()) {
                                            setGeometryFactory(geometryFactory2);
                                            geometryFactory = geometryFactory2;
                                            recordDefinition.setGeometryFactory(geometryFactory2);
                                        }
                                    }
                                }
                                newRecordInternal(record);
                            }
                        }
                    }
                    refreshBoundingBox();
                    initRecordMenu();
                    setExists(true);
                    return true;
                }
            } catch (final RuntimeException e) {
                Logs.error(this, "Error reading: " + this.resource, e);
            } finally {
                refresh();
            }
        } else {
            Logs.error(this, "Cannot find: " + this.url);
        }
    }
    return false;
}
Also used : Geometry(com.revolsys.geometry.model.Geometry) BaseCloseable(com.revolsys.io.BaseCloseable) GeometryFactory(com.revolsys.geometry.model.GeometryFactory) RecordReader(com.revolsys.record.io.RecordReader) Record(com.revolsys.record.Record) RecordDefinition(com.revolsys.record.schema.RecordDefinition)

Example 68 with RecordDefinition

use of com.revolsys.record.schema.RecordDefinition in project com.revolsys.open by revolsys.

the class RecordStoreLayer method newBoundingBoxQuery.

protected Query newBoundingBoxQuery(BoundingBox boundingBox) {
    final RecordDefinition recordDefinition = getInternalRecordDefinition();
    final FieldDefinition geometryField = recordDefinition.getGeometryField();
    boundingBox = convertBoundingBox(boundingBox);
    if (geometryField == null || Property.isEmpty(boundingBox)) {
        return null;
    } else {
        Query query = getQuery();
        query = query.newQuery(recordDefinition);
        query.and(F.envelopeIntersects(geometryField, boundingBox));
        return query;
    }
}
Also used : Query(com.revolsys.record.query.Query) FieldDefinition(com.revolsys.record.schema.FieldDefinition) RecordDefinition(com.revolsys.record.schema.RecordDefinition)

Example 69 with RecordDefinition

use of com.revolsys.record.schema.RecordDefinition in project com.revolsys.open by revolsys.

the class RecordStoreLayer method getRecords.

@Override
public <R extends LayerRecord> List<R> getRecords(final Geometry geometry, final double distance) {
    if (Property.isEmpty(geometry) || !hasGeometryField()) {
        return Collections.emptyList();
    } else {
        final RecordDefinition recordDefinition = getRecordDefinition();
        final FieldDefinition geometryField = getGeometryField();
        final WithinDistance where = F.dWithin(geometryField, geometry, distance);
        final Query query = new Query(recordDefinition, where);
        return getRecords(query);
    }
}
Also used : Query(com.revolsys.record.query.Query) FieldDefinition(com.revolsys.record.schema.FieldDefinition) WithinDistance(com.revolsys.record.query.functions.WithinDistance) RecordDefinition(com.revolsys.record.schema.RecordDefinition)

Example 70 with RecordDefinition

use of com.revolsys.record.schema.RecordDefinition in project com.revolsys.open by revolsys.

the class RecordStoreLayer method setTypePath.

public void setTypePath(final PathName typePath) {
    this.typePath = typePath;
    if (this.typePath != null) {
        if (!Property.hasValue(getName())) {
            setName(this.typePath.getName());
        }
    }
    if (isExists()) {
        final RecordDefinition recordDefinition = getRecordDefinition(typePath);
        setRecordDefinition(recordDefinition);
    }
}
Also used : RecordDefinition(com.revolsys.record.schema.RecordDefinition)

Aggregations

RecordDefinition (com.revolsys.record.schema.RecordDefinition)189 FieldDefinition (com.revolsys.record.schema.FieldDefinition)38 Record (com.revolsys.record.Record)34 Geometry (com.revolsys.geometry.model.Geometry)20 CodeTable (com.revolsys.record.code.CodeTable)19 Query (com.revolsys.record.query.Query)18 LineString (com.revolsys.geometry.model.LineString)17 GeometryFactory (com.revolsys.geometry.model.GeometryFactory)16 PathName (com.revolsys.io.PathName)13 ArrayList (java.util.ArrayList)12 DataType (com.revolsys.datatype.DataType)11 Identifier (com.revolsys.identifier.Identifier)11 RecordReader (com.revolsys.record.io.RecordReader)11 RecordStore (com.revolsys.record.schema.RecordStore)11 HashMap (java.util.HashMap)9 VectorOfWString (com.revolsys.gis.esri.gdb.file.capi.swig.VectorOfWString)8 ArrayRecord (com.revolsys.record.ArrayRecord)8 RecordDefinitionImpl (com.revolsys.record.schema.RecordDefinitionImpl)6 Table (com.revolsys.gis.esri.gdb.file.capi.swig.Table)5 RecordWriter (com.revolsys.record.io.RecordWriter)5