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();
}
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;
}
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;
}
}
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);
}
}
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);
}
}
Aggregations