Search in sources :

Example 41 with Record

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

the class CompareProcessor method addOtherObject.

@Override
protected void addOtherObject(final Record record) {
    final Geometry geometry = record.getGeometry();
    if (geometry instanceof Point) {
        boolean add = true;
        if (this.cleanDuplicatePoints) {
            final List<Record> objects = this.otherPointMap.getRecords(record);
            if (!objects.isEmpty()) {
                final Predicate<Record> filter = this.equalFilterFactory.apply(record);
                add = !Predicates.matches(objects, filter);
            }
            if (add) {
                this.otherPointMap.addRecord(record);
            } else {
                this.duplicateOtherStatistics.addCount(record);
            }
        }
    } else if (geometry instanceof LineString) {
        this.otherIndex.addRecord(record);
    }
}
Also used : Geometry(com.revolsys.geometry.model.Geometry) LineString(com.revolsys.geometry.model.LineString) Record(com.revolsys.record.Record) Point(com.revolsys.geometry.model.Point)

Example 42 with Record

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

the class CompareProcessor method processPartialMatch.

private void processPartialMatch(final Record sourceObject) {
    final Geometry sourceGeometry = sourceObject.getGeometry();
    if (sourceGeometry instanceof LineString) {
        final LineString sourceLine = (LineString) sourceGeometry;
        final LineIntersectsFilter intersectsFilter = new LineIntersectsFilter(sourceLine);
        final Predicate<Record> geometryFilter = new RecordGeometryFilter<>(intersectsFilter);
        final Predicate<Record> equalFilter = this.equalFilterFactory.apply(sourceObject);
        final Predicate<Record> filter = equalFilter.and(geometryFilter);
        final List<Record> otherObjects = this.otherIndex.queryList(sourceGeometry, filter);
        if (!otherObjects.isEmpty()) {
            final LineMatchGraph<Record> graph = new LineMatchGraph<>(sourceObject, sourceLine);
            for (final Record otherObject : otherObjects) {
                final LineString otherLine = otherObject.getGeometry();
                graph.add(otherLine);
            }
            final Lineal nonMatchedLines = graph.getNonMatchedLines(0);
            if (nonMatchedLines.isEmpty()) {
                removeObject(sourceObject);
            } else {
                removeObject(sourceObject);
                if (nonMatchedLines.getGeometryCount() == 1 && nonMatchedLines.getGeometry(0).getLength() == 1) {
                } else {
                    for (int j = 0; j < nonMatchedLines.getGeometryCount(); j++) {
                        final Geometry newGeometry = nonMatchedLines.getGeometry(j);
                        final Record newObject = Records.copy(sourceObject, newGeometry);
                        addSourceObject(newObject);
                    }
                }
            }
            for (int i = 0; i < otherObjects.size(); i++) {
                final Record otherObject = otherObjects.get(i);
                final Lineal otherNonMatched = graph.getNonMatchedLines(i + 1, 0);
                for (int j = 0; j < otherNonMatched.getGeometryCount(); j++) {
                    final Geometry newGeometry = otherNonMatched.getGeometry(j);
                    final Record newOtherObject = Records.copy(otherObject, newGeometry);
                    addOtherObject(newOtherObject);
                }
                removeOtherObject(otherObject);
            }
        }
    }
}
Also used : Geometry(com.revolsys.geometry.model.Geometry) RecordGeometryFilter(com.revolsys.record.filter.RecordGeometryFilter) Lineal(com.revolsys.geometry.model.Lineal) LineString(com.revolsys.geometry.model.LineString) Record(com.revolsys.record.Record) LineMatchGraph(com.revolsys.geometry.algorithm.linematch.LineMatchGraph) LineIntersectsFilter(com.revolsys.geometry.filter.LineIntersectsFilter) Point(com.revolsys.geometry.model.Point)

Example 43 with Record

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

the class ConverterProcess method process.

@Override
protected void process(final Channel<Record> in, final Channel<Record> out, final Record object) {
    if (this.converter != null) {
        final Record target = this.converter.convert(object);
        out.write(target);
    }
}
Also used : Record(com.revolsys.record.Record)

Example 44 with Record

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

the class CopyProcess method copy.

protected Record copy(final Record object) {
    Record targetObject;
    if (this.recordDefinition == null) {
        targetObject = object;
    } else {
        targetObject = new ArrayRecord(this.recordDefinition);
        for (final String fieldName : this.recordDefinition.getFieldNames()) {
            copyAttribute(object, fieldName, targetObject, fieldName);
        }
        if (this.attributeMap != null) {
            for (final Entry<String, String> mapping : this.attributeMap.entrySet()) {
                final String sourceFieldName = mapping.getKey();
                final String targetFieldName = mapping.getValue();
                copyAttribute(object, sourceFieldName, targetObject, targetFieldName);
            }
        }
    }
    return targetObject;
}
Also used : ArrayRecord(com.revolsys.record.ArrayRecord) Record(com.revolsys.record.Record) ArrayRecord(com.revolsys.record.ArrayRecord)

Example 45 with Record

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

the class CopyProcess method process.

@Override
protected void process(final Channel<Record> in, final Channel<Record> out, final Record object) {
    final Record targetObject = copy(object);
    out.write(targetObject);
}
Also used : Record(com.revolsys.record.Record) ArrayRecord(com.revolsys.record.ArrayRecord)

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