📄 geom.h
字号:
//CoordinateSequence *createCoordinateSequence() {return new DefaultCoordinateSequence();}; // create an empty DefaultCoordinateSequence with 'size' Coordinate slots //CoordinateSequence* createCoordinateSequence(int size) {return new DefaultCoordinateSequence(size);}; //CoordinateSequence* createCoordinateSequence(const Coordinate& c) {return new DefaultCoordinateSequence(c);}; // create an DefaultCoordinateSequence containing the given Coordinate //CoordinateSequence* createCoordinateSequence(const CoordinateSequence *cl) {return new DefaultCoordinateSequence(cl);}; /** \brief * Returns a DefaultCoordinateSequence based on the given vector * (the vector is not copied - callers give up ownership). */ CoordinateSequence *create(vector<Coordinate> *coords) const; /** \brief * Returns the singleton instance of DefaultCoordinateSequenceFactory */ static const CoordinateSequenceFactory *instance();};/* * \class PointCoordinateSequenceFactory geom.h geos.h * * \brief * Factory for PointCoordinateSequence objects. */class PointCoordinateSequenceFactory: public CoordinateSequenceFactory {public: CoordinateSequence *create(vector<Coordinate> *coords) const;};/* * <code>Geometry</code> classes support the concept of applying a * coordinate filter to every coordinate in the <code>Geometry</code>. A * coordinate filter can either record information about each coordinate or * change the coordinate in some way. Coordinate filters implement the * interface <code>CoordinateFilter</code>. (<code>CoordinateFilter</code> is * an example of the Gang-of-Four Visitor pattern). Coordinate filters can be * used to implement such things as coordinate transformations, centroid and * envelope computation, and many other functions. * */class CoordinateFilter {public: virtual ~CoordinateFilter() {} /** * Performs an operation with or on <code>coord</code>. * *@param coord a <code>Coordinate</code> to which the filter is applied. */ virtual void filter_rw(Coordinate* coord)=0; virtual void filter_ro(const Coordinate* coord)=0;};class Geometry;/* * <code>Geometry</code> classes support the concept of applying * a <code>GeometryComponentFilter</code> * filter to the <code>Geometry</code>. * The filter is applied to every component of the <code>Geometry</code> * which is itself a <code>Geometry</code>. * A <code>GeometryComponentFilter</code> filter can either * record information about the <code>Geometry</code> * or change the <code>Geometry</code> in some way. * <code>GeometryComponentFilter</code> * is an example of the Gang-of-Four Visitor pattern. * */class GeometryComponentFilter {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(Geometry *geom)=0; virtual void filter_rw(Geometry *geom); virtual void filter_ro(const Geometry *geom); // Unsupported};/* * Constants representing the dimensions of a point, a curve and a surface. * Also, constants representing the dimensions of the empty geometry and * non-empty geometries, and a wildcard dimension meaning "any dimension". * */class Dimension {public: enum { DONTCARE=-3, /// Dimension value for any dimension (= {FALSE, TRUE}). True, /// Dimension value of non-empty geometries (= {P, L, A}). False, /// Dimension value of the empty geometry (-1). P, /// Dimension value of a point (0). L, /// Dimension value of a curve (1). A /// Dimension value of a surface (2). }; //static const int P = 0; /// Dimension value of a point (0). //static const int L = 1; /// Dimension value of a curve (1). //static const int A = 2; /// Dimension value of a surface (2). //static const int False = -1; /// Dimension value of the empty geometry (-1). //static const int True = -2; /// Dimension value of non-empty geometries (= {P, L, A}). //static const int DONTCARE = -3; /// Dimension value for any dimension (= {FALSE, TRUE}). static char toDimensionSymbol(int dimensionValue); static int toDimensionValue(char dimensionSymbol);};/** * \class Envelope geom.h geos.h * * \brief * An Envelope defines a rectangulare region of the 2D coordinate plane. * * It is often used to represent the bounding box of a Geometry, * e.g. the minimum and maximum x and y values of the Coordinates. * * Note that Envelopes support infinite or half-infinite regions, by using * the values of <code>Double_POSITIVE_INFINITY</code> and * <code>Double_NEGATIVE_INFINITY</code>. * * When Envelope objects are created or initialized, * the supplies extent values are automatically sorted into the correct order. * */class Envelope {public: Envelope(void); Envelope(double x1, double x2, double y1, double y2); Envelope(const Coordinate& p1, const Coordinate& p2); Envelope(const Coordinate& p); Envelope(const Envelope &env); virtual ~Envelope(void); static bool intersects(const Coordinate& p1,const Coordinate& p2,const Coordinate& q); static bool intersects(const Coordinate& p1,const Coordinate& p2,const Coordinate& q1,const Coordinate& q2); void init(void); void init(double x1, double x2, double y1, double y2); void init(const Coordinate& p1, const Coordinate& p2); void init(const Coordinate& p); void init(Envelope env); void setToNull(void); bool isNull(void) const; double getWidth(void) const; double getHeight(void) const; double getMaxY() const; double getMaxX() const; double getMinY() const; double getMinX() const; void expandToInclude(const Coordinate& p); void expandToInclude(double x, double y); void expandToInclude(const Envelope* other); bool contains(const Coordinate& p) const; bool contains(double x, double y) const; bool contains(const Envelope* other) const; bool overlaps(const Coordinate& p) const; bool overlaps(double x, double y) const; bool overlaps(const Envelope* other) const; bool intersects(const Coordinate& p) const; bool intersects(double x, double y) const; bool intersects(const Envelope* other) const; bool equals(const Envelope* other) const; string toString(void) const; double distance(const Envelope* env) const; int hashCode() const;private: static double distance(double x0,double y0,double x1,double y1); double minx; /// the minimum x-coordinate double maxx; /// the maximum x-coordinate double miny; /// the minimum y-coordinate double maxy; /// the maximum y-coordinate#ifdef INT64_CONST_IS_I64 static const int64 serialVersionUID=5873921885273102420I64;#else static const int64 serialVersionUID=5873921885273102420LL;#endif };class Geometry;class GeometryFilter;class IntersectionMatrix;class CGAlgorithms;class Point;class GeometryFactory;/** * \class Geometry geom.h geos.h * * \brief Basic implementation of Geometry, constructed and * destructed by GeometryFactory. * * <code>clone</code> returns a deep copy of the object. * Use GeometryFactory to construct. * * <H3>Binary Predicates</H3> * Because it is not clear at this time * what semantics for spatial * analysis methods involving <code>GeometryCollection</code>s would be useful, * <code>GeometryCollection</code>s are not supported as arguments to binary * predicates (other than <code>convexHull</code>) or the <code>relate</code> * method. * * <H3>Set-Theoretic Methods</H3> * * The spatial analysis methods will * return the most specific class possible to represent the result. If the * result is homogeneous, a <code>Point</code>, <code>LineString</code>, or * <code>Polygon</code> will be returned if the result contains a single * element; otherwise, a <code>MultiPoint</code>, <code>MultiLineString</code>, * or <code>MultiPolygon</code> will be returned. If the result is * heterogeneous a <code>GeometryCollection</code> will be returned. <P> * * Because it is not clear at this time what semantics for set-theoretic * methods involving <code>GeometryCollection</code>s would be useful, * <code>GeometryCollections</code> * are not supported as arguments to the set-theoretic methods. * * <H4>Representation of Computed Geometries </H4> * * The SFS states that the result * of a set-theoretic method is the "point-set" result of the usual * set-theoretic definition of the operation (SFS 3.2.21.1). However, there are * sometimes many ways of representing a point set as a <code>Geometry</code>. * <P> * * The SFS does not specify an unambiguous representation of a given point set * returned from a spatial analysis method. One goal of JTS is to make this * specification precise and unambiguous. JTS will use a canonical form for * <code>Geometry</code>s returned from spatial analysis methods. The canonical * form is a <code>Geometry</code> which is simple and noded: * <UL> * <LI> Simple means that the Geometry returned will be simple according to * the JTS definition of <code>isSimple</code>. * <LI> Noded applies only to overlays involving <code>LineString</code>s. It * means that all intersection points on <code>LineString</code>s will be * present as endpoints of <code>LineString</code>s in the result. * </UL> * This definition implies that non-simple geometries which are arguments to * spatial analysis methods must be subjected to a line-dissolve process to * ensure that the results are simple. * * <H4> Constructed Points And The Precision Model </H4> * * The results computed by the set-theoretic methods may * contain constructed points which are not present in the input <code>Geometry</code> * s. These new points arise from intersections between line segments in the * edges of the input <code>Geometry</code>s. In the general case it is not * possible to represent constructed points exactly. This is due to the fact * that the coordinates of an intersection point may contain twice as many bits * of precision as the coordinates of the input line segments. In order to * represent these constructed points explicitly, JTS must truncate them to fit * the <code>PrecisionModel</code>. <P> * * Unfortunately, truncating coordinates moves them slightly. Line segments * which would not be coincident in the exact result may become coincident in * the truncated representation. This in turn leads to "topology collapses" -- * situations where a computed element has a lower dimension than it would in * the exact result. <P> * * When JTS detects topology collapses during the computation of spatial * analysis methods, it will throw an exception. If possible the exception will * report the location of the collapse. <P> * * #equals(Object) and #hashCode are not overridden, so that when two * topologically equal Geometries are added to HashMaps and HashSets, they * remain distinct. This behaviour is desired in many cases. * */class Geometry{friend class Unload;public: Geometry(const Geometry &geom); /** \brief * Construct a geometry with the given GeometryFactory. * Will keep a reference to the factory, so don't * delete it until al Geometry objects referring to * it are deleted. */ Geometry(const GeometryFactory *factory); /** Destroy Geometry and all components */ virtual ~Geometry(); /// Make a deep-copy of this Geometry virtual Geometry* clone() const=0; /** * \brief * Gets the factory which contains the context in which this * geometry was created. * * @return the factory for this geometry */ const GeometryFactory* getFactory() const; /** * \brief * A simple scheme for applications to add their own custom data to * a Geometry. * An example use might be to add an object representing a * Coordinate Reference System. * * Note that user data objects are not present in geometries created * by construction methods. * * @param newUserData an object, the semantics for which are * defined by the application using this Geometry */ void setUserData(void* newUserData); /** * \brief * Gets the user data object for this geometry, if any. * * @return the user data object, or <code>null</code> if none set */ void* getUserData(); /* * \brief * Returns the ID of the Spatial Reference System used by the * <code>Geometry</code>. * * GEOS supports Spatial Reference System information in the simple way * defined in the SFS. A Spatial Reference System ID (SRID) is present * in each <code>Geometry</code> object. <code>Geometry</code> * provides basic accessor operations for this field, but no others. * The SRID is represented as an integer. * * @return the ID of the coordinate space in which the * <code>Geometry</code> is defined. * * @deprecated use getUserData instead */ virtual int getSRID() const; /* * Sets the ID of the Spatial Reference System used by the * <code>Geometry</code>. * @deprecated use setUserData instead */ virtual void setSRID(int newSRID); /** * \brief * Get the PrecisionModel used to create this Geometry. */ virtual const PrecisionModel* getPrecisionModel() const; /// Returns a vertex of this Geometry. virtual const Coordinate* getCoordinate() const=0; //Abstract /** * \brief * Returns this Geometry vertices. * Caller takes ownership of the returned object. */ virtual CoordinateSequence* getCoordinates() const=0; //Abstract /// Returns the count of this Geometrys vertices. virtual int getNumPoints() const=0; //Abstract /// Returns false if the Geometry not simple. virtual bool isSimple() const=0; //Abstract /// Return a string representation of this Geometry type virtual string getGeometryType() const=0; //Abstract /// Return an integer representation of this Geometry type virtual GeometryTypeId getGeometryTypeId() const=0; //Abstract /** * \brief Tests the validity of this <code>Geometry</code>. * * Subclasses provide their own definition of "valid". * * @return <code>true</code> if this <code>Geometry</code> is valid * * @see IsValidOp */ virtual bool isValid() const; /// Returns whether or not the set of points in this Geometry is empty. virtual bool isEmpty() const=0; //Abstract /// Returns the dimension of this Geometry (0=point, 1=line, 2=surface) virtual int getDimension() const=0; //Abstract /** * \brief * Returns the boundary, or the empty geometry if this Geometry * is empty. */ virtual Geometry* getBoundary() const=0; //Abstract /// Returns the dimension of this Geometrys inherent boundary. virtual int getBoundaryDimension() const=0; //Abstract /// Returns this Geometrys bounding box.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -