private LineSegment extractShorelineInterectAndCheckLength( LineSegment transect, double nsd, double sce) { double tl = transect.getLength(); LineSegment shorelineIntersect = new LineSegment(transect.pointAlong(nsd / tl), transect.pointAlong((nsd + sce) / tl)); double shorelineIntersectLength = shorelineIntersect.getLength(); if (minimumLengthMeters > 0 && shorelineIntersectLength < minimumLengthMeters) { double halfRatio = (minimumLengthMeters / shorelineIntersectLength) / 2; shorelineIntersect = new LineSegment( shorelineIntersect.pointAlong(0 - halfRatio), shorelineIntersect.pointAlong(1 + halfRatio)); } return shorelineIntersect; }
private LineSegment extractShorelineInterect(SimpleFeature feature) { Object sceObject = ((Double) feature.getAttribute(Constants.SCE_ATTR)); Object nsdObject = feature.getAttribute(Constants.NSD_ATTR); Geometry geometry = (Geometry) feature.getDefaultGeometry(); Coordinate[] coordinates = geometry.getCoordinates(); LineSegment segment = new LineSegment(coordinates[0], coordinates[1]); double length = segment.getLength(); double sce = sceObject instanceof Number ? ((Number) sceObject).doubleValue() : Double.NaN; double nsd = nsdObject instanceof Number ? ((Number) nsdObject).doubleValue() : Double.NaN; if (sce == sce && nsd == nsd) { return extractShorelineInterectAndCheckLength(segment, nsd, sce); } else { if (sce != sce && nsd != nsd) { return extractShorelineInterectAndCheckLength(segment, 0, length); } if (sce != sce) { sce = length - nsd; } else /* if nsd != nsd */ { nsd = length - sce; } return extractShorelineInterectAndCheckLength(segment, nsd, sce); } }
public void pushSegment(final LineSegment segment) { final double length = segment.getLength(); /* update station of segment points */ m_length1 = m_length2; m_length2 = m_length1 + length; /* update distance at station */ // REMARK: NaN check needed for very first segment m_distance1 = Double.isNaN(m_distance2) ? m_bufferBuilder.getDistance(m_length1) : m_distance2; m_distance2 = m_bufferBuilder.getDistance(m_length2); /* * Only push the segment, if length is greater than the tolerance, the distance is always updated however, in order * to keep the correct stationing of the line */ if (length > m_tolerance) { m_segment0 = m_segment1; m_segment1 = segment; m_buffer0 = m_buffer1; m_buffer1 = calculateBuffer(m_segment1, m_distance1, m_distance2); } addBufferCoordinates(); }