Search in sources :

Example 36 with Record

use of com.revolsys.record.Record in project com.revolsys.open by revolsys.

the class RecordPseudoNodeRemovalVisitor method mergeEdgePairs.

private void mergeEdgePairs(final Node<Record> node, final List<EdgePair<Record>> edgePairs) {
    if (edgePairs != null) {
        for (final EdgePair<Record> edgePair : edgePairs) {
            final Edge<Record> edge1 = edgePair.getEdge1();
            final Edge<Record> edge2 = edgePair.getEdge2();
            final Record object = edge1.getObject();
            if (mergeEdges(node, edge1, edge2) != null) {
                this.mergedStatistics.addCount(object);
            }
        }
    }
}
Also used : Record(com.revolsys.record.Record)

Example 37 with Record

use of com.revolsys.record.Record in project com.revolsys.open by revolsys.

the class SimpleRecordConveter method convert.

@Override
public Record convert(final Record sourceObject) {
    final Record targetObject = this.factory.newRecord(this.recordDefinition);
    final Geometry sourceGeometry = sourceObject.getGeometry();
    final GeometryFactory geometryFactory = sourceGeometry.getGeometryFactory();
    final Geometry targetGeometry = geometryFactory.geometry(sourceGeometry);
    targetObject.setGeometryValue(targetGeometry);
    for (final SourceToTargetProcess<Record, Record> processor : this.processors) {
        processor.process(sourceObject, targetObject);
    }
    return targetObject;
}
Also used : Geometry(com.revolsys.geometry.model.Geometry) GeometryFactory(com.revolsys.geometry.model.GeometryFactory) Record(com.revolsys.record.Record)

Example 38 with Record

use of com.revolsys.record.Record in project com.revolsys.open by revolsys.

the class SetCodeTableId method process.

@Override
public void process(final Record source, final Record target) {
    final Map<String, Object> codeTableValues = new HashMap<>();
    for (final Entry<String, Converter<Record, Object>> entry : this.codeTableValueConverters.entrySet()) {
        String codeTableFieldName = entry.getKey();
        final Converter<Record, Object> sourceAttributeConverter = entry.getValue();
        Object sourceValue = sourceAttributeConverter.convert(source);
        if (sourceValue != null) {
            final RecordDefinition targetRecordDefinition = target.getRecordDefinition();
            String codeTableValueName = null;
            final int dotIndex = codeTableFieldName.indexOf(".");
            if (dotIndex != -1) {
                codeTableValueName = codeTableFieldName.substring(dotIndex + 1);
                codeTableFieldName = codeTableFieldName.substring(0, dotIndex);
            }
            final CodeTable targetCodeTable = targetRecordDefinition.getCodeTableByFieldName(codeTableFieldName);
            if (targetCodeTable != null) {
                if (codeTableValueName == null) {
                    sourceValue = targetCodeTable.getIdentifier(sourceValue);
                } else {
                    sourceValue = targetCodeTable.getIdentifier(Collections.singletonMap(codeTableValueName, sourceValue));
                }
            }
        }
        codeTableValues.put(codeTableFieldName, sourceValue);
    }
    final Object codeId = this.codeTable.getIdentifier(codeTableValues);
    target.setValue(this.targetFieldName, codeId);
}
Also used : CodeTable(com.revolsys.record.code.CodeTable) HashMap(java.util.HashMap) Converter(org.springframework.core.convert.converter.Converter) Record(com.revolsys.record.Record) RecordDefinition(com.revolsys.record.schema.RecordDefinition)

Example 39 with Record

use of com.revolsys.record.Record in project com.revolsys.open by revolsys.

the class CompareProcessor method processExactLineMatch.

private void processExactLineMatch(final Record sourceObject) {
    final LineString sourceLine = sourceObject.getGeometry();
    final LineEqualIgnoreDirectionFilter lineEqualFilter = new LineEqualIgnoreDirectionFilter(sourceLine, 3);
    final Predicate<Record> geometryFilter = new RecordGeometryFilter<>(lineEqualFilter);
    final Predicate<Record> equalFilter = this.equalFilterFactory.apply(sourceObject);
    final Predicate<Record> filter = equalFilter.and(geometryFilter);
    final Record otherObject = this.otherIndex.queryFirst(sourceObject, filter);
    if (otherObject != null) {
        this.equalStatistics.addCount(sourceObject);
        removeObject(sourceObject);
        removeOtherObject(otherObject);
    }
}
Also used : RecordGeometryFilter(com.revolsys.record.filter.RecordGeometryFilter) LineString(com.revolsys.geometry.model.LineString) LineEqualIgnoreDirectionFilter(com.revolsys.geometry.filter.LineEqualIgnoreDirectionFilter) Record(com.revolsys.record.Record)

Example 40 with Record

use of com.revolsys.record.Record in project com.revolsys.open by revolsys.

the class CompareProcessor method processObjects.

@Override
protected void processObjects(final RecordDefinition recordDefinition, final Channel<Record> out) {
    if (this.otherIndex.size() + this.otherPointMap.size() == 0) {
        if (this.logNotEqualSource) {
            for (final Record object : this.sourceObjects) {
                logError(object, "Source missing in Other", true);
            }
        }
    } else {
        processExactPointMatches();
        processExactLineMatches();
        processPartialMatches();
    }
    for (final Record object : this.otherIndex.getAll()) {
        logError(object, "Other missing in Source", false);
    }
    for (final Record record : this.otherPointMap.getAll()) {
        logError(record, "Other missing in Source", false);
    }
    if (this.logNotEqualSource) {
        for (final Record object : this.sourceObjects) {
            logError(object, "Source missing in Other", true);
        }
    }
    this.sourceObjects.clear();
    this.otherIndex = null;
    this.otherPointMap.clear();
}
Also used : Record(com.revolsys.record.Record)

Aggregations

Record (com.revolsys.record.Record)198 ArrayRecord (com.revolsys.record.ArrayRecord)43 RecordReader (com.revolsys.record.io.RecordReader)34 RecordDefinition (com.revolsys.record.schema.RecordDefinition)34 Geometry (com.revolsys.geometry.model.Geometry)29 LineString (com.revolsys.geometry.model.LineString)21 Point (com.revolsys.geometry.model.Point)20 ChannelWriter (com.revolsys.io.channels.ChannelWriter)19 Identifier (com.revolsys.identifier.Identifier)17 ArrayList (java.util.ArrayList)16 FieldDefinition (com.revolsys.record.schema.FieldDefinition)15 GeometryFactory (com.revolsys.geometry.model.GeometryFactory)14 LayerRecord (com.revolsys.swing.map.layer.record.LayerRecord)13 NoSuchElementException (java.util.NoSuchElementException)13 DataType (com.revolsys.datatype.DataType)10 Query (com.revolsys.record.query.Query)9 HashMap (java.util.HashMap)9 List (java.util.List)8 LinkedHashMap (java.util.LinkedHashMap)7 Edge (com.revolsys.geometry.graph.Edge)6