Interface CoordinateSequenceFactory

 1 /*
 2  * Copyright (c) 2016 Vivid Solutions.
 3  *
 4  * All rights reserved. This program and the accompanying materials
 5  * are made available under the terms of the Eclipse Public License 2.0
 6  * and Eclipse Distribution License v. 1.0 which accompanies this distribution.
 7  * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v20.html
 8  * and the Eclipse Distribution License is available at
 9  *
10  * http://www.eclipse.org/org/documents/edl-v10.php.
11  */
12 package org.locationtech.jts.geom;
13  
14 /**
15  * A factory to create concrete instances of {@link CoordinateSequence}s.
16  * Used to configure {@link GeometryFactory}s
17  * to provide specific kinds of CoordinateSequences.
18  *
19  * @version 1.7
20  */
21 public interface CoordinateSequenceFactory
22 {
23  
24   /**
25    * Returns a {@link CoordinateSequence} based on the given array.
26    * Whether the array is copied or simply referenced
27    * is implementation-dependent.
28    * This method must handle null arguments by creating an empty sequence.
29    *
30    * @param coordinates the coordinates
31    */
32   CoordinateSequence create(Coordinate[] coordinates);
33  
34   /**
35    * Creates a {@link CoordinateSequence} which is a copy
36    * of the given {@link CoordinateSequence}.
37    * This method must handle null arguments by creating an empty sequence.
38    *
39    * @param coordSeq the coordinate sequence to copy
40    */
41   CoordinateSequence create(CoordinateSequence coordSeq);
42  
43   /**
44    * Creates a {@link CoordinateSequence} of the specified size and dimension.
45    * For this to be useful, the {@link CoordinateSequence} implementation must
46    * be mutable.
47    * <p>
48    * If the requested dimension is larger than the CoordinateSequence implementation
49    * can provide, then a sequence of maximum possible dimension should be created.
50    * An error should not be thrown.
51    *
52    * @param size the number of coordinates in the sequence
53    * @param dimension the dimension of the coordinates in the sequence (if user-specifiable,
54    * otherwise ignored)
55    */
56   CoordinateSequence create(int size, int dimension);
57  
58   /**
59    * Creates a {@link CoordinateSequence} of the specified size and dimension with measure support.
60    * For this to be useful, the {@link CoordinateSequence} implementation must
61    * be mutable.
62    * <p>
63    * If the requested dimension or measures are larger than the CoordinateSequence implementation
64    * can provide, then a sequence of maximum possible dimension should be created.
65    * An error should not be thrown.
66    *
67    * @param size the number of coordinates in the sequence
68    * @param dimension the dimension of the coordinates in the sequence (if user-specifiable,
69    * otherwise ignored)
70    * @param measures the number of measures of the coordinates in the sequence (if user-specifiable,
71    * otherwise ignored)
72    */
73   default CoordinateSequence create(int size, int dimension, int measures) {
74       return create(size, dimension);
75   }
76 }
77