Search in sources :

Example 1 with DirectionalFields

use of com.revolsys.record.property.DirectionalFields in project com.revolsys.open by revolsys.

the class AbstractRecordLayer method newSplitValues.

protected Map<String, Object> newSplitValues(final LayerRecord oldRecord, final LineString oldLine, final Point splitPoint, final LineString newLine) {
    final DirectionalFields directionalFields = DirectionalFields.getProperty(oldRecord);
    final Map<String, Object> values1 = directionalFields.newSplitValues(oldRecord, oldLine, splitPoint, newLine);
    return values1;
}
Also used : LineString(com.revolsys.geometry.model.LineString) DirectionalFields(com.revolsys.record.property.DirectionalFields)

Example 2 with DirectionalFields

use of com.revolsys.record.property.DirectionalFields in project com.revolsys.open by revolsys.

the class AbstractRecordLayer method actionFlipLineOrientation.

private void actionFlipLineOrientation(final LayerRecord record) {
    final DirectionalFields property = DirectionalFields.getProperty(record);
    property.reverseGeometry(record);
}
Also used : DirectionalFields(com.revolsys.record.property.DirectionalFields)

Example 3 with DirectionalFields

use of com.revolsys.record.property.DirectionalFields in project com.revolsys.open by revolsys.

the class ReverseRecordFieldsUndo method undoDo.

@Override
protected void undoDo() {
    final DirectionalFields property = DirectionalFields.getProperty(this.record);
    property.reverseFieldValues(this.record);
}
Also used : DirectionalFields(com.revolsys.record.property.DirectionalFields)

Example 4 with DirectionalFields

use of com.revolsys.record.property.DirectionalFields in project com.revolsys.open by revolsys.

the class ReverseRecordFieldsUndo method redoDo.

@Override
protected void redoDo() {
    final DirectionalFields property = DirectionalFields.getProperty(this.record);
    property.reverseFieldValues(this.record);
}
Also used : DirectionalFields(com.revolsys.record.property.DirectionalFields)

Example 5 with DirectionalFields

use of com.revolsys.record.property.DirectionalFields in project com.revolsys.open by revolsys.

the class AbstractRecordLayer method getMergedRecord.

/**
 * Get a record containing the values of the two records if they can be
 * merged. The new record is not a layer data object so would need to be
 * added, likewise the old records are not removed so they would need to be
 * deleted.
 *
 * @param point
 * @param record1
 * @param record2
 * @return
 */
public Record getMergedRecord(final Point point, final Record record1, final Record record2) {
    if (record1 == record2) {
        return record1;
    } else {
        final String sourceIdFieldName = getIdFieldName();
        final Object id1 = record1.getValue(sourceIdFieldName);
        final Object id2 = record2.getValue(sourceIdFieldName);
        int compare = 0;
        if (id1 == null) {
            if (id2 != null) {
                compare = 1;
            }
        } else if (id2 == null) {
            compare = -1;
        } else {
            compare = CompareUtil.compare(id1, id2);
        }
        if (compare == 0) {
            final Geometry geometry1 = record1.getGeometry();
            final Geometry geometry2 = record2.getGeometry();
            final double length1 = geometry1.getLength();
            final double length2 = geometry2.getLength();
            if (length1 == length2) {
                compare = Integer.compare(System.identityHashCode(record1), System.identityHashCode(record2));
            } else if (length1 > length2) {
                compare = -1;
            } else {
                compare = 1;
            }
        }
        if (compare > 0) {
            return getMergedRecord(point, record2, record1);
        } else {
            final DirectionalFields property = DirectionalFields.getProperty(getRecordDefinition());
            final Map<String, Object> newValues = property.getMergedMap(point, record1, record2);
            newValues.remove(getIdFieldName());
            return new ArrayRecord(getRecordDefinition(), newValues);
        }
    }
}
Also used : Geometry(com.revolsys.geometry.model.Geometry) ArrayRecord(com.revolsys.record.ArrayRecord) LineString(com.revolsys.geometry.model.LineString) Point(com.revolsys.geometry.model.Point) DirectionalFields(com.revolsys.record.property.DirectionalFields)

Aggregations

DirectionalFields (com.revolsys.record.property.DirectionalFields)8 LineString (com.revolsys.geometry.model.LineString)2 Geometry (com.revolsys.geometry.model.Geometry)1 Point (com.revolsys.geometry.model.Point)1 ArrayRecord (com.revolsys.record.ArrayRecord)1