1 /********************************************************************** 2 * 3 * GEOS - Geometry Engine Open Source 4 * http://geos.osgeo.org 5 * 6 * Copyright (C) 2006 Refractions Research Inc. 7 * 8 * This is free software; you can redistribute and/or modify it under 9 * the terms of the GNU Lesser General Public Licence as published 10 * by the Free Software Foundation. 11 * See the COPYING file for more information. 12 * 13 ********************************************************************** 14 * 15 * Last port: geom/CoordinateSequenceFactory.java r591 (JTS-1.12) 16 * 17 **********************************************************************/ 18 19 #ifndef GEOS_GEOM_COORDINATESEQUENCEFACTORY_H 20 #define GEOS_GEOM_COORDINATESEQUENCEFACTORY_H 21 22 23 #include <geos/export.h> 24 #include <memory> 25 #include <vector> 26 27 //#include <geos/geom/Coordinate.h> 28 #include <geos/inline.h> 29 30 // Forward declarations 31 namespace geos { 32 namespace geom { 33 class CoordinateSequence; 34 class Coordinate; 35 } 36 } 37 38 namespace geos { 39 namespace geom { // geos::geom 40 41 /** 42 * \brief 43 * A factory to create concrete instances of {@link CoordinateSequence}s. 44 * 45 * Used to configure {@link GeometryFactory}s 46 * to provide specific kinds of CoordinateSequences. 47 */ 48 class GEOS_DLL CoordinateSequenceFactory { 49 public: 50 51 /** \brief 52 * Returns an empty CoordinateSequence, the dimensions will be autodetected 53 * when it is populated. 54 */ 55 virtual std::unique_ptr<CoordinateSequence> create() const = 0; 56 57 /** \brief 58 * Returns a CoordinateSequence based on the given array. 59 * 60 * Whether the array is copied or simply referenced 61 * is implementation-dependent. 62 * For this reason caller does give up ownership of it. 63 * Implementations that will not copy it will need take care 64 * of deleting it. 65 * 66 * This method must handle null arguments by creating 67 * an empty sequence. 68 * 69 * @param coordinates the coordinates 70 * @param dimension 0, 2 or 3 with 0 indicating unknown at this time. 71 */ 72 virtual std::unique_ptr<CoordinateSequence> create( 73 std::vector<Coordinate>* coordinates, 74 std::size_t dimension = 0) const = 0; 75 76 /** \brief 77 * Returns a CoordinateSequence based on the given array. 78 * 79 * @param coordinates the coordinates 80 * @param dimension 0, 2 or 3 with 0 indicating unknown at this time. 81 */ 82 virtual std::unique_ptr<CoordinateSequence> create( 83 std::vector<Coordinate> && coordinates, 84 std::size_t dimension = 0) const = 0; 85 86 /** \brief 87 * Creates a CoordinateSequence of the specified size and dimension. 88 * 89 * For this to be useful, the CoordinateSequence implementation must 90 * be mutable. 91 * 92 * @param size the number of coordinates in the sequence 93 * @param dimension the dimension of the coordinates in the sequence 94 * (0=unknown, 2, or 3 - ignored if not user specifiable) 95 */ 96 virtual std::unique_ptr<CoordinateSequence> create(std::size_t size, 97 std::size_t dimension = 0) const = 0; 98 99 /** \brief 100 * Creates a CoordinateSequence which is a copy of the given one. 101 * 102 * This method must handle null arguments by creating an empty sequence. 103 * 104 * @param coordSeq the coordinate sequence to copy 105 */ 106 virtual std::unique_ptr<CoordinateSequence> create(const CoordinateSequence& coordSeq) const = 0; 107 108 virtual ~CoordinateSequenceFactory() = default; 109 }; 110 111 } // namespace geos::geom 112 } // namespace geos 113 114 //#ifdef GEOS_INLINE 115 //# include "geos/geom/CoordinateSequenceFactory.inl" 116 //#endif 117 118 #endif // ndef GEOS_GEOM_COORDINATESEQUENCEFACTORY_H 119