public LinearRing createLinearRing(CoordinateSequence cs) {
    if (cs.getCoordinate(0).equals(cs.getCoordinate(cs.size() - 1)))
      return super.createLinearRing(cs);

    // add a new coordinate to close the ring
    CoordinateSequenceFactory csFact = getCoordinateSequenceFactory();
    CoordinateSequence csNew = csFact.create(cs.size() + 1, cs.getDimension());
    CoordinateSequences.copy(cs, 0, csNew, 0, cs.size());
    CoordinateSequences.copyCoord(csNew, 0, csNew, csNew.size() - 1);
    return super.createLinearRing(csNew);
  }
Esempio n. 2
0
 /**
  * Convenience method which provides standard way of copying {@link CoordinateSequence}s
  *
  * @param seq the sequence to copy
  * @return a deep copy of the sequence
  */
 protected final CoordinateSequence copy(CoordinateSequence seq) {
   return CoordinateSequences.copy(seq);
 }
 private CoordinateSequence readCoordinateSequenceRing(int size) throws IOException {
   CoordinateSequence seq = readCoordinateSequence(size);
   if (isStrict) return seq;
   if (CoordinateSequences.isRing(seq)) return seq;
   return CoordinateSequences.ensureValidRing(csFactory, seq);
 }
 private CoordinateSequence readCoordinateSequenceLineString(int size) throws IOException {
   CoordinateSequence seq = readCoordinateSequence(size);
   if (isStrict) return seq;
   if (seq.size() == 0 || seq.size() >= 2) return seq;
   return CoordinateSequences.extend(csFactory, seq, 2);
 }