📄 geom.h
字号:
virtual Geometry* getEnvelope() const; /** \brief * Returns the minimum and maximum x and y values in this Geometry, * or a null Envelope if this Geometry is empty. */ virtual const Envelope* getEnvelopeInternal() const; /** * \brief * Returns true if the DE-9IM intersection matrix for the * two Geometrys is FF*FF****. */ virtual bool disjoint(const Geometry *other) const; /** \brief * Returns true if the DE-9IM intersection matrix for the two * Geometrys is FT*******, F**T***** or F***T****. */ virtual bool touches(const Geometry *other) const; /// Returns true if disjoint returns false. virtual bool intersects(const Geometry *g) const; /** * \brief * Returns true if the DE-9IM intersection matrix for the two * Geometrys is T*T****** (for a point and a curve, a point and * an area or a line and an area) 0******** (for two curves). */ virtual bool crosses(const Geometry *g) const; /** \brief * Returns true if the DE-9IM intersection matrix for the two * Geometrys is T*F**F***. */ virtual bool within(const Geometry *g) const; /// Returns true if other.within(this) returns true. virtual bool contains(const Geometry *g) const; /** \brief * Returns true if the DE-9IM intersection matrix for the two * Geometrys is T*T***T** (for two points or two surfaces) * 1*T***T** (for two curves). */ virtual bool overlaps(const Geometry *g) const; /** * \brief * Returns true if the elements in the DE-9IM intersection matrix * for the two Geometrys match the elements in intersectionPattern. * * IntersectionPattern elements may be: 0 1 2 T ( = 0, 1 or 2) * F ( = -1) * ( = -1, 0, 1 or 2). * * For more information on the DE-9IM, see the OpenGIS Simple * Features Specification. */ virtual bool relate(const Geometry *g, string intersectionPattern) const; /// Returns the DE-9IM intersection matrix for the two Geometrys. virtual IntersectionMatrix* relate(const Geometry *g) const; /** * \brief * Returns true if the DE-9IM intersection matrix for the two * Geometrys is T*F**FFF*. */ virtual bool equals(const Geometry *g) const; /// Returns the Well-known Text representation of this Geometry. virtual string toString() const; virtual string toText() const; /// Returns a buffer region around this Geometry having the given width. virtual Geometry* buffer(double distance) const; /// Returns a buffer region around this Geometry having the given width and with a specified number of segments used to approximate curves. virtual Geometry* buffer(double distance,int quadrantSegments) const; /// Returns the smallest convex Polygon that contains all the points in the Geometry. virtual Geometry* convexHull() const; /** \brief * Returns a Geometry representing the points shared by * this Geometry and other. */ virtual Geometry* intersection(const Geometry *other) const; /** \brief * Returns a Geometry representing all the points in this Geometry * and other. */ virtual Geometry* Union(const Geometry *other) const; // throw(IllegalArgumentException *, TopologyException *); /** * \brief * Returns a Geometry representing the points making up this * Geometry that do not make up other. */ virtual Geometry* difference(const Geometry *other) const; /** \brief * Returns a set combining the points in this Geometry not in other, * and the points in other not in this Geometry. */ virtual Geometry* symDifference(const Geometry *other) const; /** \brief * Returns true if the two Geometrys are exactly equal, * up to a specified tolerance. */ virtual bool equalsExact(const Geometry *other, double tolerance) const=0; //Abstract virtual void apply_rw(CoordinateFilter *filter)=0; //Abstract virtual void apply_ro(CoordinateFilter *filter) const=0; //Abstract virtual void apply_rw(GeometryFilter *filter); virtual void apply_ro(GeometryFilter *filter) const; virtual void apply_rw(GeometryComponentFilter *filter); virtual void apply_ro(GeometryComponentFilter *filter) const; /// Converts this Geometry to normal form (or canonical form). virtual void normalize()=0; //Abstract virtual int compareTo(const Geometry *geom) const; /** \brief * Returns the minimum distance between this Geometry * and the Geometry g */ virtual double distance(const Geometry *g) const; /// Returns the area of this Geometry. virtual double getArea() const; /// Returns the length of this Geometry. virtual double getLength() const; /** \brief * Tests whether the distance from this Geometry to another * is less than or equal to a specified value. */ virtual bool isWithinDistance(const Geometry *geom,double cDistance); /// Computes the centroid of this Geometry. virtual Point* getCentroid() const; /// Computes an interior point of this Geometry. virtual Point* getInteriorPoint(); /* * \brief * Notifies this Geometry that its Coordinates have been changed * by an external party (using a CoordinateFilter, for example). */ virtual void geometryChanged(); /* * \brief * Notifies this Geometry that its Coordinates have been changed * by an external party. */ void geometryChangedAction();protected: mutable Envelope* envelope; /// Returns true if the array contains any non-empty Geometrys. static bool hasNonEmptyElements(const vector<Geometry *>* geometries); /// Returns true if the CoordinateSequence contains any null elements. static bool hasNullElements(const CoordinateSequence* list); /// Returns true if the vector contains any null elements. static bool hasNullElements(const vector<Geometry *>* lrs);// static void reversePointOrder(CoordinateSequence* coordinates);// static Coordinate& minCoordinate(CoordinateSequence* coordinates);// static void scroll(CoordinateSequence* coordinates,Coordinate* firstCoordinate);// static int indexOf(Coordinate* coordinate,CoordinateSequence* coordinates);// /** \brief * Returns whether the two Geometrys are equal, from the point * of view of the equalsExact method. */ virtual bool isEquivalentClass(const Geometry *other) const; static void checkNotGeometryCollection(const Geometry *g); // throw(IllegalArgumentException *); //virtual void checkEqualSRID(Geometry *other); //virtual void checkEqualPrecisionModel(Geometry *other); virtual Envelope* computeEnvelopeInternal() const=0; //Abstract virtual int compareToSameClass(const Geometry *geom) const=0; //Abstract int compare(vector<Coordinate> a, vector<Coordinate> b) const; int compare(vector<Geometry *> a, vector<Geometry *> b) const; bool equal(const Coordinate& a, const Coordinate& b,double tolerance) const; int SRID; /** * The GEOS algorithms assume that Geometry::getCoordinate() and * #getCoordinates * are fast, which may not be the case if the CoordinateSequence is not a * DefaultCoordinateSequence (e.g. if it were implemented using separate * arrays for the x- and y-values), in which case frequent * construction of Coordinates takes up much space and time. * To solve this performance problem, toInternalGeometry converts the * Geometry to a DefaultCoordinateSequence * implementation before sending it * to the JTS algorithms. */ Geometry* toInternalGeometry(const Geometry *g) const; Geometry* fromInternalGeometry(const Geometry *g) const;private: virtual int getClassSortIndex() const; static GeometryComponentFilter geometryChangedFilter;#ifdef INT64_CONST_IS_I64 static const int64 serialVersionUID = 8763622679187376702I64;#else static const int64 serialVersionUID = 8763622679187376702LL;#endif const GeometryFactory *factory; static const GeometryFactory* INTERNAL_GEOMETRY_FACTORY; void* userData; Point* createPointFromInternalCoord(const Coordinate* coord,const Geometry *exemplar) const;};/* * Geometry classes support the concept of applying a Geometry * filter to the Geometry. In the case of GeometryCollection * subclasses, the filter is applied to every element Geometry. * A Geometry filter can either record information about the Geometry * or change the Geometry in some way. * Geometry filters implement the interface GeometryFilter. * (GeometryFilter is an example of the Gang-of-Four Visitor pattern). */class GeometryFilter {public: /* * Performs an operation with or on <code>geom</code>. * * @param geom a <code>Geometry</code> to which the filter * is applied. */ virtual void filter_ro(const Geometry *geom)=0; virtual void filter_rw(Geometry *geom)=0;};/* * Represents a line segment defined by two {@link Coordinate}s. * Provides methods to compute various geometric properties * and relationships of line segments. * * This class is designed to be easily mutable (to the extent of * having its contained points public). * This supports a common pattern of reusing a single LineSegment * object as a way of computing segment properties on the * segments defined by arrays or lists of {@link Coordinate}s. * */class LineSegment {public: Coordinate p0; /// Segment start Coordinate p1; /// Segemnt end LineSegment(void); LineSegment(const LineSegment &ls); LineSegment(const Coordinate& c0, const Coordinate& c1); virtual ~LineSegment(void); virtual void setCoordinates(const Coordinate& c0, const Coordinate& c1); virtual const Coordinate& getCoordinate(int i) const; virtual void setCoordinates(const LineSegment ls); virtual double getLength() const; /** * Tests whether the segment is horizontal. * * @return <code>true</code> if the segment is horizontal */ virtual bool isHorizontal() const; /** * Tests whether the segment is vertical. * * @return <code>true</code> if the segment is vertical */ virtual bool isVertical() const; /** * Determines the orientation of a LineSegment relative to this segment. * The concept of orientation is specified as follows: * Given two line segments A and L, * <ul * <li>A is to the left of a segment L if A lies wholly in the * closed half-plane lying to the left of L * <li>A is to the right of a segment L if A lies wholly in the * closed half-plane lying to the right of L * <li>otherwise, A has indeterminate orientation relative to L. This * happens if A is collinear with L or if A crosses the line determined by L. * </ul> * * @param seg the LineSegment to compare * * @return 1 if <code>seg</code> is to the left of this segment * @return -1 if <code>seg</code> is to the right of this segment * @return 0 if <code>seg</code> has indeterminate orientation relative to this segment */ virtual int orientationIndex(LineSegment *seg) const; virtual void reverse(); virtual void normalize(); virtual double angle() const; virtual double distance(const LineSegment ls) const; /** * Computes the distance between this line segment and a point. */ virtual double distance(const Coordinate& p) const; /** * Computes the perpendicular distance between the (infinite) line defined * by this line segment and a point. */ virtual double distancePerpendicular(const Coordinate& p) const; virtual double projectionFactor(const Coordinate& p) const; virtual Coordinate* project(const Coordinate& p) const; virtual LineSegment* project(const LineSegment *seg) const; virtual Coordinate* closestPoint(const Coordinate& p) const; virtual int compareTo(const LineSegment other) const; virtual bool equalsTopo(const LineSegment other) const; /** * Computes the closest points on two line segments. * @param p the point to find the closest point to * @return a pair of Coordinates which are the closest points on the line segments * The returned CoordinateList must be deleted by caller */ virtual CoordinateSequence* closestPoints(const LineSegment *line); /** * Computes an intersection point between two segments, if there is one. * There may be 0, 1 or many intersection points between two segments. * If there are 0, null is returned. If there is 1 or more, a single one * is returned (chosen at the discretion of the algorithm). If * more information is required about the details of the intersection, * the {@link RobustLineIntersector} class should be used. * * @param line * @return an intersection point, or <code>null</code> if there is none */ Coordinate* intersection(const LineSegment *line) const; virtual string toString() const;private:#ifdef INT64_CONST_IS_I64 static const int64 serialVersionUID=3252005833466256227I64;#else static const int64 serialVersionUID=3252005833466256227LL;#endif};class IntersectionMatrix {public: IntersectionMatrix(); IntersectionMatrix(string elements); IntersectionMatrix(const IntersectionMatrix &im); virtual ~IntersectionMatrix(); static bool matches(int actualDimensionValue, char requiredDimensionSymbol); static bool matches(string actualDimensionSymbols, string requiredDimensionSymbols); void add(IntersectionMatrix *im); void set(int row, int column, int dimensionValue); void set(string dimensionSymbols); void setAtLeast(int row, int column, int minimumDimensionValue); void setAtLeastIfValid(int row, int column, int minimumDimensionValue); void setAtLeast(string minimumDimensionSymbols); void setAll(int dimensionValue); int get(int row, int column); bool isDisjoint(); bool isIntersects(); bool isTouches(int dimensionOfGeometryA, int dimensionOfGeometryB); bool isCrosses(int dimensionOfGeometryA, int dimensionOfGeometryB); bool isWithin(); bool isContains(); bool isEquals(int dimensionOfGeometryA, int dimensionOfGeometryB); bool isOverlaps(int dimensionOfGeometryA, int dimensionOfGeometryB); bool matches(string requiredDimensionSymbols); IntersectionMatrix* transpose(); string toString();private: int matrix[3][3];};/* * Constants representing the location of a point relative to a geometry. They * can also be thought of as the row or column index of a DE-9IM matrix. For a * description of the DE-9IM, see the <A * HREF="http://www.opengis.org/techno/specs.htm">OpenGIS Simple Features * Specification for SQL</A> . */class Location {public: enum { /** * Used for uninitialized location values. */ UNDEF=-1, ///Instead of NULL /** * DE-9IM row index of the interior of the first geometry and column index of * the interior of the second geometry. Location value for the interior of a * geometry. */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -