Complete Note#1 in the http://wiki.osgeo.org/wiki/GEOS_Provenance_Review to get out...
[geos.git] / include / geos / noding / OrientedCoordinateArray.h
blobe0dd0d8a1b9d7e3206f4f5e030c78e3f5ef70194
1 /**********************************************************************
3 * GEOS - Geometry Engine Open Source
4 * http://geos.osgeo.org
6 * Copyright (C) 2009 Sandro Santilli <strk@keybit.net>
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.
13 **********************************************************************
15 * Last port: noding/OrientedCoordinateArray.java rev. 1.1 (JTS-1.9)
17 **********************************************************************/
19 #ifndef GEOS_NODING_ORIENTEDCOORDINATEARRAY_H
20 #define GEOS_NODING_ORIENTEDCOORDINATEARRAY_H
22 #include <geos/export.h>
24 //#include <vector>
25 //#include <iostream>
27 //#include <geos/inline.h>
29 // Forward declarations
30 namespace geos {
31 namespace geom {
32 class CoordinateSequence;
34 namespace noding {
35 //class SegmentString;
39 namespace geos {
40 namespace noding { // geos.noding
42 /** \brief
43 * Allows comparing {@link geom::CoordinateSequence}s
44 * in an orientation-independent way.
46 class GEOS_DLL OrientedCoordinateArray
48 public:
50 /**
51 * Creates a new {@link OrientedCoordinateArray}
52 * for the given {@link geom::CoordinateSequence}.
54 * @param pts the coordinates to orient
56 OrientedCoordinateArray(const geom::CoordinateSequence& pts)
58 pts(pts),
59 orientationVar(orientation(pts))
63 /** \brief
64 * Compares two {@link OrientedCoordinateArray}s for their
65 * relative order
67 * @return -1 this one is smaller
68 * @return 0 the two objects are equal
69 * @return 1 this one is greater
71 * In JTS, this is used automatically by ordered lists.
72 * In C++, operator< would be used instead....
74 int compareTo(const OrientedCoordinateArray& o1) const;
77 private:
79 static int compareOriented(const geom::CoordinateSequence& pts1,
80 bool orientation1,
81 const geom::CoordinateSequence& pts2,
82 bool orientation2);
85 /**
86 * Computes the canonical orientation for a coordinate array.
88 * @param pts the array to test
89 * @return <code>true</code> if the points are oriented forwards
90 * @return <code>false</code if the points are oriented in reverse
92 static bool orientation(const geom::CoordinateSequence& pts);
94 /// Externally owned
95 const geom::CoordinateSequence& pts;
97 bool orientationVar;
99 // Declare type as noncopyable
100 OrientedCoordinateArray(const OrientedCoordinateArray& other);
101 OrientedCoordinateArray& operator=(const OrientedCoordinateArray& rhs);
104 } // namespace geos.noding
105 } // namespace geos
108 #endif // GEOS_NODING_ORIENTEDCOORDINATEARRAY_H