Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members

geom.h

00001 /**********************************************************************
00002  * $Id: geom.h,v 1.35 2004/12/16 16:27:24 strk Exp $
00003  *
00004  * GEOS - Geometry Engine Open Source
00005  * http://geos.refractions.net
00006  *
00007  * Copyright (C) 2001-2002 Vivid Solutions Inc.
00008  *
00009  * This is free software; you can redistribute and/or modify it under
00010  * the terms of the GNU Lesser General Public Licence as published
00011  * by the Free Software Foundation. 
00012  * See the COPYING file for more information.
00013  *
00014  **********************************************************************/
00015 
00016 #ifndef GEOS_GEOM_H
00017 #define GEOS_GEOM_H
00018 
00019 #include <memory>
00020 #include <iostream>
00021 #include <string>
00022 #include <vector>
00023 #include <algorithm>
00024 #include <map>
00025 #include <math.h>
00026 #include <geos/platform.h>
00027 
00028 using namespace std;
00029 
00033 namespace geos {
00034 
00036 string geosversion();
00037 
00043 string jtsport();
00044 
00046 enum GeometryTypeId {
00048         GEOS_POINT,
00050         GEOS_LINESTRING,
00052         GEOS_LINEARRING,
00054         GEOS_POLYGON,
00056         GEOS_MULTIPOINT,
00058         GEOS_MULTILINESTRING,
00060         GEOS_MULTIPOLYGON,
00062         GEOS_GEOMETRYCOLLECTION
00063 };
00064 
00065 class Coordinate;
00066 
00108 class PrecisionModel {
00109 friend class Unload;
00110 public:
00112         /*
00113         * This class is only for use to support the "enums"
00114         * for the types of precision model.
00115         */
00116         typedef enum {
00117 
00124                 FIXED,
00125 
00131                 FLOATING,
00132 
00138                 FLOATING_SINGLE
00139 
00140         } Type;
00141         
00143         PrecisionModel(void);
00144 
00146 
00151         PrecisionModel(Type nModelType);
00152 
00153         /*
00154          * Creates a <code>PrecisionModel</code> with Fixed precision.
00155          *
00156          * Fixed-precision coordinates are represented as precise internal
00157          * coordinates, which are rounded to the grid defined by the
00158          * scale factor.
00159          *
00160          * @param  scale
00161          *      amount by which to multiply a coordinate after subtracting
00162          *      the offset, to obtain a precise coordinate
00163          * @param  offsetX  not used.
00164          * @param  offsetY  not used.
00165          *
00166          * @deprecated offsets are no longer supported, since internal
00167          * representation is rounded floating point
00168          */
00169         PrecisionModel(double newScale, double newOffsetX, double newOffsetY);
00170 
00182         PrecisionModel(double newScale);
00183 
00184         // copy constructor
00185         PrecisionModel(const PrecisionModel &pm);
00186 
00188         virtual ~PrecisionModel(void);
00189 
00190 
00192 
00197         static const double maximumPreciseValue;
00198 
00200         double makePrecise(double val) const;
00201 
00203         void makePrecise(Coordinate *coord) const;
00204 
00206 
00210         bool isFloating() const;
00211 
00213 
00218         int getMaximumSignificantDigits() const;
00219 
00221 
00224         Type getType() const;
00225 
00227         double getScale() const;
00228 
00229         /*
00230         * Returns the x-offset used to obtain a precise coordinate.
00231         *
00232         * @return the amount by which to subtract the x-coordinate before
00233         *         multiplying by the scale
00234         * @deprecated Offsets are no longer used
00235         */
00236         double getOffsetX() const;
00237 
00238         /*
00239         * Returns the y-offset used to obtain a precise coordinate.
00240         *
00241         * @return the amount by which to subtract the y-coordinate before
00242         *         multiplying by the scale
00243         * @deprecated Offsets are no longer used
00244         */
00245         double getOffsetY() const;
00246 
00247         /*
00248          *  Sets <code>internal</code> to the precise representation of <code>external</code>.
00249          *
00250          * @param external the original coordinate
00251          * @param internal the coordinate whose values will be changed to the
00252          *                 precise representation of <code>external</code>
00253          * @deprecated use makePrecise instead
00254          */
00255         void toInternal(const Coordinate& external, Coordinate* internal) const;
00256 
00257         /*
00258         *  Returns the precise representation of <code>external</code>.
00259         *
00260         *@param  external  the original coordinate
00261         *@return
00262         *       the coordinate whose values will be changed to the precise
00263         *       representation of <code>external</code>
00264         * @deprecated use makePrecise instead
00265         */
00266         Coordinate* toInternal(const Coordinate& external) const;
00267 
00268         /*
00269         *  Returns the external representation of <code>internal</code>.
00270         *
00271         *@param  internal  the original coordinate
00272         *@return           the coordinate whose values will be changed to the
00273         *      external representation of <code>internal</code>
00274         * @deprecated no longer needed, since internal representation is same as external representation
00275         */
00276         Coordinate* toExternal(const Coordinate& internal) const;
00277 
00278         /*
00279         *  Sets <code>external</code> to the external representation of
00280         *  <code>internal</code>.
00281         *
00282         * @param  internal  the original coordinate
00283         * @param  external
00284         *       the coordinate whose values will be changed to the
00285         *       external representation of <code>internal</code>
00286         * @deprecated no longer needed, since internal representation is same as external representation
00287         */
00288         void toExternal(const Coordinate& internal, Coordinate* external) const;
00289 
00290         string toString() const;
00291 
00293 
00307         int compareTo(const PrecisionModel* other) const;
00308 
00309 private:
00310         void setScale(double newScale);
00311         Type modelType;
00312         double scale;
00313 #ifdef INT64_CONST_IS_I64
00314         static const int64 serialVersionUID = 7777263578777803835I64;
00315 #else        
00316         static const int64 serialVersionUID = 7777263578777803835LL;
00317 #endif        
00318 };
00319 
00340 class Coordinate {
00341 public:
00342         //void setNull(void);
00343         //static Coordinate& getNull(void);
00344         virtual ~Coordinate(){};
00345         //Coordinate(double xNew, double yNew, double zNew);
00346         //Coordinate(const Coordinate& c);
00347         //Coordinate(double xNew, double yNew);
00348         //void setCoordinate(Coordinate& other);
00349         //bool equals2D(Coordinate& other);
00350         //int compareTo(Coordinate& other);
00351         //bool equals3D(Coordinate& other);
00352         string toString() const;
00353         //void makePrecise();
00354         //double distance(Coordinate& p);
00355         static Coordinate nullCoord;
00356 
00357         void Coordinate::setNull() {
00358                 x=DoubleNotANumber;
00359                 y=DoubleNotANumber;
00360                 z=DoubleNotANumber;
00361         }
00362 
00363         static Coordinate& Coordinate::getNull() {
00364                 return nullCoord;
00365         }
00366 
00367         Coordinate::Coordinate() {
00368                 x=0.0;
00369                 y=0.0;
00370                 z=DoubleNotANumber;
00371         }
00372 
00373         Coordinate::Coordinate(double xNew, double yNew, double zNew) {
00374                 x=xNew;
00375                 y=yNew;
00376                 z=zNew;
00377         }
00378 
00379         Coordinate::Coordinate(const Coordinate& c){
00380                 x=c.x;
00381                 y=c.y;
00382                 z=c.z;
00383         }
00384 
00385         Coordinate::Coordinate(double xNew, double yNew){
00386                 x=xNew;
00387                 y=yNew;
00388                 z=DoubleNotANumber;
00389         }
00390 
00391         void Coordinate::setCoordinate(const Coordinate& other) {
00392                 x = other.x;
00393                 y = other.y;
00394                 z = other.z;
00395         }
00396 
00397         bool Coordinate::equals2D(const Coordinate& other) const {
00398                 if (x != other.x) {
00399                 return false;
00400                 }
00401                 if (y != other.y) {
00402                 return false;
00403                 }
00404                 return true;
00405         }
00406 
00407         int Coordinate::compareTo(const Coordinate& other) const {
00408                 if (x < other.x) {
00409                 return -1;
00410                 }
00411                 if (x > other.x) {
00412                 return 1;
00413                 }
00414                 if (y < other.y) {
00415                 return -1;
00416                 }
00417                 if (y > other.y) {
00418                 return 1;
00419                 }
00420                 return 0;
00421         }
00422 
00423         bool Coordinate::equals3D(const Coordinate& other) const {
00424                 return (x == other.x) && ( y == other.y) && ((z == other.z)||(ISNAN(z) && ISNAN(other.z)));
00425         }
00426 
00427         void Coordinate::makePrecise(const PrecisionModel *precisionModel) {
00428                 x = precisionModel->makePrecise(x);
00429                 y = precisionModel->makePrecise(y);
00430         }
00431 
00432         double Coordinate::distance(const Coordinate& p) const {
00433                 double dx = x - p.x;
00434                 double dy = y - p.y;
00435                 return sqrt(dx * dx + dy * dy);
00436         }
00437 
00438         int Coordinate::hashCode() {
00439                 //Algorithm from Effective Java by Joshua Bloch [Jon Aquino]
00440                 int result = 17;
00441                 result = 37 * result + hashCode(x);
00442                 result = 37 * result + hashCode(y);
00443                 return result;
00444         }
00445 
00450         static int Coordinate::hashCode(double x) {
00451                 int64 f = (int64)(x);
00452                 return (int)(f^(f>>32));
00453         }
00454 
00455 
00457         double x;
00459         double y;
00461         double z;
00462 
00463 private:
00464 #ifdef INT64_CONST_IS_I64
00465         static const int64 serialVersionUID=6683108902428366910I64;
00466 #else
00467         static const int64 serialVersionUID=6683108902428366910LL;
00468 #endif
00469 
00470 };
00471 
00472 
00473 //* class CoordinateList geom.h geos.h
00474 //*
00475 //* brief A list of Coordinates, which may be set to prevent
00476 //* repeated coordinates from occuring in the list.
00477 //
00478 //class CoordinateList {
00479 //public:
00480 //      ~CoordinateList(){};
00481 //
00482 //      // copy constructor
00483 //      CoordinateList(const CoordinateList &cl);
00484 //
00485 //      // constructor an empty CoordinateList
00486 //      CoordinateList();
00487 //
00488 //      /*
00489 //       * Constructs a new list from a vector of Coordinates.
00490 //       * Caller can specify if repeated points are to be removed.
00491 //       * Default is allowing repeated points.
00492 //       * Will take ownership of coords.
00493 //       */
00494 //      CoordinateList(vector<Coordinate> *coords, bool allowRepeted=false);
00495 //
00496 //      // Get a reference to the nth Coordinate 
00497 //      const Coordinate& getCoordinate(int n) const;
00498 //
00499 //      /*
00500 //       * \brief Add an array of coordinates 
00501 //       * @param vc The coordinates
00502 //       * @param allowRepeated if set to false, repeated coordinates
00503 //       *      are collapsed
00504 //       * @return true (as by general collection contract)
00505 //       */
00506 //      void add(vector<Coordinate>* vc, bool allowRepeated);
00507 //
00508 //      /*
00509 //       * \brief Add an array of coordinates 
00510 //       * @param cl The coordinates
00511 //       * @param allowRepeated if set to false, repeated coordinates
00512 //       * are collapsed
00513 //       * @param direction if false, the array is added in reverse order
00514 //       * @return true (as by general collection contract)
00515 //       */
00516 //      void add(CoordinateList *cl,bool allowRepeated,bool direction);
00517 //
00518 //      /*
00519 //       * \brief Add a coordinate
00520 //       * @param c The coordinate to add
00521 //       * @param allowRepeated if set to false, repeated coordinates
00522 //       * are collapsed
00523 //       * @return true (as by general collection contract)
00524 //       */
00525 //      void add(const Coordinate& c,bool allowRepeated);
00526 //
00527 //      // Add a Coordinate to the list
00528 //      void add(const Coordinate& c);
00529 //
00530 //      // Get vector
00531 //      const vector<Coordinate>* toCoordinateArray() const;
00532 //
00533 //private:
00534 //
00535 //      vector<Coordinate> *vect;
00536 //};
00537 
00557 class CoordinateSequence {
00558 public:
00559         virtual ~CoordinateSequence(){};
00560 
00564         virtual CoordinateSequence *clone() const=0;
00565 
00572         //virtual const Coordinate& getCoordinate(int i) const=0;
00573         virtual const Coordinate& getAt(int i) const=0;
00574 
00579         //virtual int size() const=0;
00580         virtual int getSize() const=0;
00581 
00591         virtual const vector<Coordinate>* toVector() const=0;
00592 
00600         void add(const vector<Coordinate>* vc, bool allowRepeated);
00601 
00602         /* This is here for backward compatibility.. */
00603         void add(CoordinateSequence *cl,bool allowRepeated,bool direction);
00604 
00613         void add(const CoordinateSequence *cl,bool allowRepeated,bool direction);
00614 
00622         void add(const Coordinate& c,bool allowRepeated);
00623 
00625         virtual bool isEmpty() const=0;
00626 
00628         virtual void add(const Coordinate& c)=0;
00629 
00630         // Get number of coordinates
00631         //virtual int getSize() const=0;
00632 
00634         //virtual       const Coordinate& getAt(int pos) const=0;
00635 
00637         virtual void setAt(const Coordinate& c, int pos)=0;
00638 
00640         virtual void deleteAt(int pos)=0;
00641 
00643         virtual string toString() const=0;
00644 
00646         virtual void setPoints(const vector<Coordinate> &v)=0;
00647         
00649         bool hasRepeatedPoints() const;
00650 
00652         const Coordinate* minCoordinate() const;
00653 
00654 
00656         static CoordinateSequence* removeRepeatedPoints(const CoordinateSequence *cl);
00657 
00662         static bool hasRepeatedPoints(const CoordinateSequence *cl);
00663 
00668         static CoordinateSequence* atLeastNCoordinatesOrNothing(int n, CoordinateSequence *c);
00669 
00675         static const Coordinate* minCoordinate(CoordinateSequence *cl);
00676 
00678         static int indexOf(const Coordinate *coordinate, const CoordinateSequence *cl);
00684         static bool equals(CoordinateSequence *cl1, CoordinateSequence *cl2);
00685 
00687         static void scroll(CoordinateSequence *cl, const Coordinate *firstCoordinate);
00688 
00690         static void reverse(CoordinateSequence *cl);
00691 
00692 };
00693 
00699 class DefaultCoordinateSequence : public CoordinateSequence {
00700 public:
00701 
00702         DefaultCoordinateSequence(const DefaultCoordinateSequence &cl);
00703 
00704         CoordinateSequence *clone() const;
00705 
00706         //const Coordinate& getCoordinate(int pos) const;
00707         const Coordinate& getAt(int pos) const;
00708 
00709         //int size() const;
00710         int getSize() const;
00711         const vector<Coordinate>* toVector() const;
00712 
00714         DefaultCoordinateSequence();
00715 
00717         DefaultCoordinateSequence(vector<Coordinate> *coords);
00718 
00720         DefaultCoordinateSequence(int n);
00721 
00722         virtual ~DefaultCoordinateSequence();
00723 
00724         bool isEmpty() const;
00725         void add(const Coordinate& c);
00726         void setAt(const Coordinate& c, int pos);
00727         void deleteAt(int pos);
00728         string toString() const;
00729         void setPoints(const vector<Coordinate> &v);
00730 private:
00731         vector<Coordinate> *vect;
00732 };
00733 
00734 struct point_3d {
00735         double x;
00736         double y;
00737         double z;
00738 };
00739 
00740 class PointCoordinateSequence : public CoordinateSequence {
00741 public:
00742         PointCoordinateSequence();
00743         PointCoordinateSequence(int n);
00744         PointCoordinateSequence(const Coordinate& c);
00745         PointCoordinateSequence(const PointCoordinateSequence &cl);
00746         PointCoordinateSequence(const CoordinateSequence *c);
00747         virtual ~PointCoordinateSequence();
00748         CoordinateSequence *clone() const;
00749         bool isEmpty() const;
00750         void add(const Coordinate& c);
00751         void add(point_3d p);
00752         int getSize() const;
00753         const Coordinate& getAt(int pos) const;
00754         point_3d getPointAt(int pos);
00755         void setAt(const Coordinate& c, int pos);
00756         void setAt(point_3d p, int pos);
00757         void deleteAt(int pos);
00758         const vector<Coordinate>* toVector() const;
00759         vector<point_3d>* toPointVector();
00760         string toString() const;
00761         void setPoints(const vector<Coordinate> &v);
00762         void setPoints(vector<point_3d> &v);
00763 private:
00764         vector<point_3d> *vect;
00765         mutable vector<Coordinate>*cached_vector;
00766 };
00767 
00775 class CoordinateSequenceFactory {
00776 public:
00777         // create an empty CoordinateSequence
00778         //virtual CoordinateSequence* createCoordinateSequence()=0;
00779 
00780         // create an empty CoordinateSequence with 'size' Coordinate slots
00781         //virtual CoordinateSequence* createCoordinateSequence(int size)=0;
00782 
00783         //virtual CoordinateSequence* createCoordinateSequence(const Coordinate& c)=0;
00784         // create an CoordinateSequence containing the given Coordinate 
00785         //virtual CoordinateSequence* createCoordinateSequence(const CoordinateSequence *c)=0;
00786 
00796         virtual CoordinateSequence *create(vector<Coordinate> *coordinates) const=0;
00797 };
00798 
00806 class DefaultCoordinateSequenceFactory: public CoordinateSequenceFactory {
00807 
00808 public:
00809         // create an empty DefaultCoordinateSequence
00810         //CoordinateSequence *createCoordinateSequence() {return new DefaultCoordinateSequence();};
00811         // create an empty DefaultCoordinateSequence with 'size' Coordinate slots
00812         //CoordinateSequence* createCoordinateSequence(int size) {return new DefaultCoordinateSequence(size);};
00813         //CoordinateSequence* createCoordinateSequence(const Coordinate& c) {return new DefaultCoordinateSequence(c);};
00814 
00815         // create an DefaultCoordinateSequence containing the given Coordinate 
00816         //CoordinateSequence* createCoordinateSequence(const CoordinateSequence *cl) {return new DefaultCoordinateSequence(cl);};
00817 
00818 
00823         CoordinateSequence *create(vector<Coordinate> *coords) const;
00824 
00828         static const CoordinateSequenceFactory *instance();
00829 };
00830 
00831 /*
00832  * \class PointCoordinateSequenceFactory geom.h geos.h
00833  *
00834  * \brief
00835  * Factory for PointCoordinateSequence objects.
00836  */
00837 class PointCoordinateSequenceFactory: public CoordinateSequenceFactory {
00838 public:
00839 
00840         CoordinateSequence *create(vector<Coordinate> *coords) const;
00841 };
00842 
00843 /*
00844  * <code>Geometry</code> classes support the concept of applying a
00845  * coordinate filter to every coordinate in the <code>Geometry</code>. A
00846  * coordinate filter can either record information about each coordinate or
00847  * change the coordinate in some way. Coordinate filters implement the
00848  * interface <code>CoordinateFilter</code>. (<code>CoordinateFilter</code> is
00849  * an example of the Gang-of-Four Visitor pattern). Coordinate filters can be
00850  * used to implement such things as coordinate transformations, centroid and
00851  * envelope computation, and many other functions.
00852  *
00853  */
00854 class CoordinateFilter {
00855 public:
00856    virtual ~CoordinateFilter() {}
00862    virtual void filter_rw(Coordinate* coord)=0;
00863    virtual void filter_ro(const Coordinate* coord)=0;
00864 };
00865 
00866 class Geometry;
00867 
00868 /*
00869  *  <code>Geometry</code> classes support the concept of applying
00870  *  a <code>GeometryComponentFilter</code>
00871  *  filter to the <code>Geometry</code>.
00872  *  The filter is applied to every component of the <code>Geometry</code>
00873  *  which is itself a <code>Geometry</code>.
00874  *  A <code>GeometryComponentFilter</code> filter can either
00875  *  record information about the <code>Geometry</code>
00876  *  or change the <code>Geometry</code> in some way.
00877  *  <code>GeometryComponentFilter</code>
00878  *  is an example of the Gang-of-Four Visitor pattern.
00879  *
00880  */
00881 class GeometryComponentFilter {
00882 public:
00888 //      virtual void filter(Geometry *geom)=0;
00889         virtual void filter_rw(Geometry *geom);
00890         virtual void filter_ro(const Geometry *geom); // Unsupported
00891 };
00892 
00893 
00894 /*
00895  * Constants representing the dimensions of a point, a curve and a surface.
00896  * Also, constants representing the dimensions of the empty geometry and
00897  * non-empty geometries, and a wildcard dimension meaning "any dimension".
00898  * 
00899  */
00900 class Dimension {
00901 public:
00902         enum {
00903                 DONTCARE=-3,    
00904                 True,                   
00905                 False,                  
00906                 P,                              
00907                 L,                              
00908                 A                               
00909         };
00910         //static const int P = 0;                       /// Dimension value of a point (0).
00911         //static const int L = 1;                       /// Dimension value of a curve (1).
00912         //static const int A = 2;                       /// Dimension value of a surface (2).
00913         //static const int False = -1;  /// Dimension value of the empty geometry (-1).
00914         //static const int True = -2;           /// Dimension value of non-empty geometries (= {P, L, A}).
00915         //static const int DONTCARE = -3;       /// Dimension value for any dimension (= {FALSE, TRUE}).
00916         static char toDimensionSymbol(int dimensionValue);
00917         static int toDimensionValue(char dimensionSymbol);
00918 };
00919 
00937 class Envelope {
00938 public:
00939         Envelope(void);
00940         Envelope(double x1, double x2, double y1, double y2);
00941         Envelope(const Coordinate& p1, const Coordinate& p2);
00942         Envelope(const Coordinate& p);
00943         Envelope(const Envelope &env);
00944         virtual ~Envelope(void);
00945         static bool intersects(const Coordinate& p1,const Coordinate& p2,const Coordinate& q);
00946         static bool intersects(const Coordinate& p1,const Coordinate& p2,const Coordinate& q1,const Coordinate& q2);
00947         void init(void);
00948         void init(double x1, double x2, double y1, double y2);
00949         void init(const Coordinate& p1, const Coordinate& p2);
00950         void init(const Coordinate& p);
00951         void init(Envelope env);
00952         void setToNull(void);
00953         bool isNull(void) const;
00954         double getWidth(void) const;
00955         double getHeight(void) const;
00956         double getMaxY() const;
00957         double getMaxX() const;
00958         double getMinY() const;
00959         double getMinX() const;
00960         void expandToInclude(const Coordinate& p);
00961         void expandToInclude(double x, double y);
00962         void expandToInclude(const Envelope* other);
00963         bool contains(const Coordinate& p) const;
00964         bool contains(double x, double y) const;
00965         bool contains(const Envelope* other) const;
00966         bool overlaps(const Coordinate& p) const;
00967         bool overlaps(double x, double y) const;
00968         bool overlaps(const Envelope* other) const;
00969         bool intersects(const Coordinate& p) const;
00970         bool intersects(double x, double y) const;
00971         bool intersects(const Envelope* other) const;
00972         bool equals(const Envelope* other) const;
00973         string toString(void) const;
00974         double distance(const Envelope* env) const;
00975         int hashCode() const;
00976 
00977 private:
00978         static double distance(double x0,double y0,double x1,double y1);
00979         double minx;    
00980         double maxx;    
00981         double miny;    
00982         double maxy;    
00983 #ifdef INT64_CONST_IS_I64
00984         static const int64 serialVersionUID=5873921885273102420I64;
00985 #else        
00986         static const int64 serialVersionUID=5873921885273102420LL;
00987 #endif        
00988 };
00989 
00990 class Geometry;
00991 class GeometryFilter;
00992 class IntersectionMatrix;
00993 
00994 
00995 class CGAlgorithms;
00996 class Point;
00997 class GeometryFactory;
00998 
01082 class Geometry{
01083 friend class Unload;
01084 public:
01085 
01086         Geometry(const Geometry &geom);
01087 
01094         Geometry(const GeometryFactory *factory);
01095 
01097         virtual ~Geometry();
01098 
01100         virtual Geometry* clone() const=0;
01101 
01109         const GeometryFactory* getFactory() const;
01110 
01124         void setUserData(void* newUserData);
01125 
01132         void* getUserData();
01133 
01134         /*
01135          * \brief
01136          * Returns the ID of the Spatial Reference System used by the
01137          * <code>Geometry</code>.
01138          *
01139          * GEOS supports Spatial Reference System information in the simple way
01140          * defined in the SFS. A Spatial Reference System ID (SRID) is present
01141          * in each <code>Geometry</code> object. <code>Geometry</code>
01142          * provides basic accessor operations for this field, but no others.
01143          * The SRID is represented as an integer.
01144          *
01145          * @return the ID of the coordinate space in which the
01146          * <code>Geometry</code> is defined.
01147          *
01148          * @deprecated use getUserData instead
01149          */
01150         virtual int getSRID() const;
01151 
01152         /*
01153          * Sets the ID of the Spatial Reference System used by the
01154          * <code>Geometry</code>.
01155          * @deprecated use setUserData instead
01156          */
01157         virtual void setSRID(int newSRID);
01158 
01163         virtual const PrecisionModel* getPrecisionModel() const;
01164 
01166         virtual const Coordinate* getCoordinate() const=0; //Abstract
01167 
01173         virtual CoordinateSequence* getCoordinates() const=0; //Abstract
01174 
01176         virtual int getNumPoints() const=0; //Abstract
01177 
01179         virtual bool isSimple() const=0; //Abstract
01180 
01182         virtual string getGeometryType() const=0; //Abstract
01183 
01185         virtual GeometryTypeId getGeometryTypeId() const=0; //Abstract
01186 
01196         virtual bool isValid() const;
01197 
01199         virtual bool isEmpty() const=0; //Abstract
01200 
01202         virtual int getDimension() const=0; //Abstract
01203 
01209         virtual Geometry* getBoundary() const=0; //Abstract
01210 
01212         virtual int getBoundaryDimension() const=0; //Abstract
01213 
01215         virtual Geometry* getEnvelope() const;
01216 
01221         virtual const Envelope* getEnvelopeInternal() const;
01222 
01228         virtual bool disjoint(const Geometry *other) const;
01229 
01234         virtual bool touches(const Geometry *other) const;
01235 
01237         virtual bool intersects(const Geometry *g) const;
01238 
01245         virtual bool crosses(const Geometry *g) const;
01246 
01251         virtual bool within(const Geometry *g) const;
01252 
01254         virtual bool contains(const Geometry *g) const;
01255 
01261         virtual bool overlaps(const Geometry *g) const;
01262 
01274         virtual bool relate(const Geometry *g, string intersectionPattern) const;
01276         virtual IntersectionMatrix* relate(const Geometry *g) const;
01277 
01283         virtual bool equals(const Geometry *g) const;
01284 
01286         virtual string toString() const;
01287 
01288         virtual string toText() const;
01289         
01291         virtual Geometry* buffer(double distance) const;
01292 
01294         virtual Geometry* buffer(double distance,int quadrantSegments) const;
01295 
01297         virtual Geometry* convexHull() const;
01298 
01303         virtual Geometry* intersection(const Geometry *other) const;
01304 
01309         virtual Geometry* Union(const Geometry *other) const;
01310                 // throw(IllegalArgumentException *, TopologyException *);
01311 
01317         virtual Geometry* difference(const Geometry *other) const;
01318 
01323         virtual Geometry* symDifference(const Geometry *other) const;
01324 
01329         virtual bool equalsExact(const Geometry *other, double tolerance)
01330                 const=0; //Abstract
01331 
01332         virtual void apply_rw(CoordinateFilter *filter)=0; //Abstract
01333         virtual void apply_ro(CoordinateFilter *filter) const=0; //Abstract
01334         virtual void apply_rw(GeometryFilter *filter);
01335         virtual void apply_ro(GeometryFilter *filter) const;
01336         virtual void apply_rw(GeometryComponentFilter *filter);
01337         virtual void apply_ro(GeometryComponentFilter *filter) const;
01338 
01340         virtual void normalize()=0; //Abstract
01341 
01342         virtual int compareTo(const Geometry *geom) const;
01343 
01348         virtual double distance(const Geometry *g) const;
01349 
01351         virtual double getArea() const;
01352 
01354         virtual double getLength() const;
01355 
01360         virtual bool isWithinDistance(const Geometry *geom,double cDistance);
01361 
01363         virtual Point* getCentroid() const;
01364 
01366         virtual Point* getInteriorPoint();
01367 
01368         /*
01369          * \brief
01370          * Notifies this Geometry that its Coordinates have been changed
01371          * by an external party (using a CoordinateFilter, for example).
01372          */
01373         virtual void geometryChanged();
01374 
01375         /*
01376          * \brief
01377          * Notifies this Geometry that its Coordinates have been changed
01378          * by an external party.
01379          */
01380         void geometryChangedAction();
01381 
01382 protected:
01383         mutable Envelope* envelope;
01384         
01386         static bool hasNonEmptyElements(const vector<Geometry *>* geometries);
01387 
01389         static bool hasNullElements(const CoordinateSequence* list);
01390 
01392         static bool hasNullElements(const vector<Geometry *>* lrs);
01393 
01394 //      static void reversePointOrder(CoordinateSequence* coordinates);
01395 //      static Coordinate& minCoordinate(CoordinateSequence* coordinates);
01396 //      static void scroll(CoordinateSequence* coordinates,Coordinate* firstCoordinate);
01397 //      static int indexOf(Coordinate* coordinate,CoordinateSequence* coordinates);
01398 //
01403         virtual bool isEquivalentClass(const Geometry *other) const;
01404 
01405         static void checkNotGeometryCollection(const Geometry *g); // throw(IllegalArgumentException *);
01406         //virtual void checkEqualSRID(Geometry *other);
01407         //virtual void checkEqualPrecisionModel(Geometry *other);
01408         virtual Envelope* computeEnvelopeInternal() const=0; //Abstract
01409         virtual int compareToSameClass(const Geometry *geom) const=0; //Abstract
01410         int compare(vector<Coordinate> a, vector<Coordinate> b) const;
01411         int compare(vector<Geometry *> a, vector<Geometry *> b) const;
01412         bool equal(const Coordinate& a, const Coordinate& b,double tolerance) const;
01413         int SRID;
01414 
01427         Geometry* toInternalGeometry(const Geometry *g) const;
01428         Geometry* fromInternalGeometry(const Geometry *g) const;
01429 private:
01430         virtual int getClassSortIndex() const;
01431         static GeometryComponentFilter geometryChangedFilter;
01432 #ifdef INT64_CONST_IS_I64
01433     static const int64 serialVersionUID = 8763622679187376702I64;
01434 #else
01435     static const int64 serialVersionUID = 8763622679187376702LL;
01436 #endif
01437         const GeometryFactory *factory;
01438         static const GeometryFactory* INTERNAL_GEOMETRY_FACTORY;
01439         void* userData;
01440         Point* createPointFromInternalCoord(const Coordinate* coord,const Geometry *exemplar) const;
01441 };
01442 
01443 /*
01444  * Geometry classes support the concept of applying a Geometry
01445  * filter to the Geometry. In the case of GeometryCollection
01446  * subclasses, the filter is applied to every element Geometry.
01447  * A Geometry filter can either record information about the Geometry
01448  * or change the Geometry in some way.
01449  * Geometry filters implement the interface GeometryFilter.
01450  * (GeometryFilter is an example of the Gang-of-Four Visitor pattern).
01451  */
01452 class GeometryFilter {
01453 public:
01454         /*
01455          * Performs an operation with or on <code>geom</code>.
01456          *
01457          * @param  geom  a <code>Geometry</code> to which the filter
01458          *         is applied.
01459          */
01460         virtual void filter_ro(const Geometry *geom)=0;
01461         virtual void filter_rw(Geometry *geom)=0;
01462 };
01463 
01464 /*
01465  * Represents a line segment defined by two {@link Coordinate}s.
01466  * Provides methods to compute various geometric properties
01467  * and relationships of line segments.
01468  * 
01469  * This class is designed to be easily mutable (to the extent of
01470  * having its contained points public).
01471  * This supports a common pattern of reusing a single LineSegment
01472  * object as a way of computing segment properties on the
01473  * segments defined by arrays or lists of {@link Coordinate}s.
01474  *
01475  */
01476 class LineSegment {
01477 public:
01478         Coordinate p0; 
01479         Coordinate p1; 
01480         LineSegment(void);
01481         LineSegment(const LineSegment &ls);
01482         LineSegment(const Coordinate& c0, const Coordinate& c1);
01483         virtual ~LineSegment(void);
01484         virtual void setCoordinates(const Coordinate& c0, const Coordinate& c1);
01485         virtual const Coordinate& getCoordinate(int i) const;
01486         virtual void setCoordinates(const LineSegment ls);
01487         virtual double getLength() const;
01493         virtual bool isHorizontal() const;
01499         virtual bool isVertical() const;
01519         virtual int orientationIndex(LineSegment *seg) const;
01520         virtual void reverse();
01521         virtual void normalize();
01522         virtual double angle() const;
01523         virtual double distance(const LineSegment ls) const;
01527         virtual double distance(const Coordinate& p) const;
01532         virtual double distancePerpendicular(const Coordinate& p) const;
01533         virtual double projectionFactor(const Coordinate& p) const;
01534         virtual Coordinate* project(const Coordinate& p) const;
01535         virtual LineSegment* project(const LineSegment *seg) const;
01536         virtual Coordinate* closestPoint(const Coordinate& p) const;
01537         virtual int compareTo(const LineSegment other) const;
01538         virtual bool equalsTopo(const LineSegment other) const;
01539 
01546         virtual CoordinateSequence* closestPoints(const LineSegment *line);
01547 
01559         Coordinate* intersection(const LineSegment *line) const;
01560         virtual string toString() const;
01561 private:
01562 #ifdef INT64_CONST_IS_I64
01563   static const int64 serialVersionUID=3252005833466256227I64;
01564 #else
01565   static const int64 serialVersionUID=3252005833466256227LL;
01566 #endif
01567 
01568 };
01569 
01570 class IntersectionMatrix {
01571 public:
01572         IntersectionMatrix();
01573         IntersectionMatrix(string elements);
01574         IntersectionMatrix(const IntersectionMatrix &im);
01575         virtual ~IntersectionMatrix();
01576         static bool matches(int actualDimensionValue, char requiredDimensionSymbol);
01577         static bool matches(string actualDimensionSymbols, string requiredDimensionSymbols);
01578         void add(IntersectionMatrix *im);
01579         void set(int row, int column, int dimensionValue);
01580         void set(string dimensionSymbols);
01581         void setAtLeast(int row, int column, int minimumDimensionValue);
01582         void setAtLeastIfValid(int row, int column, int minimumDimensionValue);
01583         void setAtLeast(string minimumDimensionSymbols);
01584         void setAll(int dimensionValue);
01585         int get(int row, int column);
01586         bool isDisjoint();
01587         bool isIntersects();
01588         bool isTouches(int dimensionOfGeometryA, int dimensionOfGeometryB);
01589         bool isCrosses(int dimensionOfGeometryA, int dimensionOfGeometryB);
01590         bool isWithin();
01591         bool isContains();
01592         bool isEquals(int dimensionOfGeometryA, int dimensionOfGeometryB);
01593         bool isOverlaps(int dimensionOfGeometryA, int dimensionOfGeometryB);
01594         bool matches(string requiredDimensionSymbols);
01595         IntersectionMatrix* transpose();
01596         string toString();
01597 private:
01598         int matrix[3][3];
01599 };
01600 
01601 /*
01602  *  Constants representing the location of a point relative to a geometry. They
01603  *  can also be thought of as the row or column index of a DE-9IM matrix. For a
01604  *  description of the DE-9IM, see the <A
01605  *  HREF="http://www.opengis.org/techno/specs.htm">OpenGIS Simple Features
01606  *  Specification for SQL</A> .
01607  */
01608 class Location {
01609 public:
01610         enum {
01614                 UNDEF=-1,   
01615 
01620                 INTERIOR,
01626                 BOUNDARY,
01632                 EXTERIOR = 2
01633         };
01634         //static const int INTERIOR = 0;
01635         //static const int BOUNDARY = 1;
01636         //static const int EXTERIOR = 2;
01637         //static const int UNDEF = -1;   ///Instead of NULL
01638         static char toLocationSymbol(int locationValue);
01639 };
01640 
01641 
01642 //Operators
01643 bool operator==(const Coordinate& a, const Coordinate& b);
01644 bool operator!=(const Coordinate& a, const Coordinate& b);
01645 bool operator==(const Envelope a, const Envelope b);
01646 bool operator==(const PrecisionModel a, const PrecisionModel b);
01647 bool operator==(const LineSegment a, const LineSegment b);
01648 
01649 bool lessThen(Coordinate& a,Coordinate& b);
01650 bool greaterThen(Geometry *first, Geometry *second);
01651 
01661 class GeometryCollection : public Geometry{
01662 public:
01663         GeometryCollection(const GeometryCollection &gc);
01664 
01689         GeometryCollection(vector<Geometry *> *newGeoms, const GeometryFactory *newFactory);
01690 
01691         virtual Geometry *clone() const;
01692 
01693         virtual ~GeometryCollection();
01694 
01708         virtual CoordinateSequence* getCoordinates() const;
01709 
01710         virtual bool isEmpty() const;
01711 
01717         virtual int getDimension() const;
01718 
01719         virtual Geometry* getBoundary() const;
01720 
01726         virtual int getBoundaryDimension() const;
01727 
01728         virtual int getNumPoints() const;
01729         virtual string getGeometryType() const;
01730         virtual GeometryTypeId getGeometryTypeId() const;
01731         virtual bool isSimple() const;
01732         virtual bool equalsExact(const Geometry *other, double tolerance) const;
01733 
01734         virtual void apply_ro(CoordinateFilter *filter) const;
01735         virtual void apply_rw(CoordinateFilter *filter);
01736         virtual void apply_ro(GeometryFilter *filter) const;
01737         virtual void apply_rw(GeometryFilter *filter);
01738         virtual void apply_ro(GeometryComponentFilter *filter) const;
01739         virtual void apply_rw(GeometryComponentFilter *filter);
01740         virtual void normalize();
01741         virtual const Coordinate* getCoordinate() const;
01743         virtual double getArea() const;
01745         virtual double getLength() const;
01747         virtual int getNumGeometries() const;
01749         virtual const Geometry* getGeometryN(int n) const;
01750 protected:
01751         vector<Geometry *>* geometries;
01752         virtual Envelope* computeEnvelopeInternal() const;
01753         virtual int compareToSameClass(const Geometry *gc) const;
01754 private:
01755 #ifdef INT64_CONST_IS_I64
01756         static const int64 serialVersionUID = -5694727726395021467I64;
01757 #else
01758         static const int64 serialVersionUID = -5694727726395021467LL;
01759 #endif        
01760 };
01761 
01762 class GeometryCollectionIterator {
01763 public:
01764         GeometryCollectionIterator();
01765         GeometryCollectionIterator(const GeometryCollectionIterator &gci);
01766         GeometryCollectionIterator(const GeometryCollection *newParent);
01767         virtual ~GeometryCollectionIterator();
01768         bool hasNext() const;
01769         const Geometry *next();
01770         void remove(); //Not implemented
01771 private:
01772         const GeometryCollection* parent;
01773         bool atStart;
01774         int max;
01775         int index;
01776         GeometryCollectionIterator* subcollectionIterator;
01777 };
01778 
01783 class Point : public Geometry{
01784 public:
01785 
01798         Point(CoordinateSequence *newCoords, const GeometryFactory *newFactory);
01799 
01800         Point(const Point &p); 
01801         virtual ~Point();
01802         Geometry *clone() const;
01803         CoordinateSequence* getCoordinates(void) const;
01804         int getNumPoints() const;
01805         bool isEmpty() const;
01806         bool isSimple() const;
01807         //bool isValid() const;
01808 
01810         int getDimension() const;
01811 
01813         int getBoundaryDimension() const;
01814 
01816         Geometry* getBoundary() const;
01817 
01818         double getX() const;
01819         double getY() const;
01820         const Coordinate* getCoordinate() const;
01821         string getGeometryType() const;
01822         virtual GeometryTypeId getGeometryTypeId() const;
01823         void apply_ro(CoordinateFilter *filter) const;
01824         void apply_rw(CoordinateFilter *filter);
01825         void apply_ro(GeometryFilter *filter) const;
01826         void apply_rw(GeometryFilter *filter);
01827         void apply_rw(GeometryComponentFilter *filter);
01828         void apply_ro(GeometryComponentFilter *filter) const;
01829         bool equalsExact(const Geometry *other, double tolerance) const;
01830         void normalize(void) { };
01831 protected:
01832         Envelope* computeEnvelopeInternal() const;
01833         int compareToSameClass(const Geometry *p) const;
01834 private:
01838         CoordinateSequence *coordinates;
01839 #ifdef INT64_CONST_IS_I64
01840         static const int64 serialVersionUID = 4902022702746614570I64;
01841 #else        
01842         static const int64 serialVersionUID = 4902022702746614570LL;
01843 #endif        
01844 };
01845 
01850 class LineString: public Geometry {
01851 public:
01852         LineString(const LineString &ls);
01853 
01855         LineString(CoordinateSequence *pts, const GeometryFactory *newFactory);
01856 
01857         virtual ~LineString();
01858         virtual Geometry *clone() const;
01859         virtual CoordinateSequence* getCoordinates() const;
01860 
01862         const CoordinateSequence* getCoordinatesRO() const;
01863 
01864         virtual const Coordinate& getCoordinateN(int n) const;
01865 
01867         virtual int getDimension() const;
01868 
01874         virtual int getBoundaryDimension() const;
01875 
01881         virtual Geometry* getBoundary() const;
01882 
01883         virtual bool isEmpty() const;
01884         virtual int getNumPoints() const;
01885         virtual Point* getPointN(int n) const;
01886         virtual Point* getStartPoint() const;
01887         virtual Point* getEndPoint() const;
01888         virtual bool isClosed() const;
01889         virtual bool isRing() const;
01890         virtual string getGeometryType() const;
01891         virtual GeometryTypeId getGeometryTypeId() const;
01892         virtual bool isSimple() const;
01893         virtual bool isCoordinate(Coordinate& pt) const;
01894         virtual bool equalsExact(const Geometry *other, double tolerance) const;
01895         virtual void apply_rw(CoordinateFilter *filter);
01896         virtual void apply_ro(CoordinateFilter *filter) const;
01897         virtual void apply_rw(GeometryFilter *filter);
01898         virtual void apply_ro(GeometryFilter *filter) const;
01899         virtual void apply_rw(GeometryComponentFilter *filter);
01900         virtual void apply_ro(GeometryComponentFilter *filter) const;
01901 
01903         virtual void normalize();
01904 
01905         //was protected
01906         virtual int compareToSameClass(const Geometry *ls) const;
01907         virtual int compareTo(const LineString *ls) const;
01908         virtual const Coordinate* getCoordinate() const;
01909         virtual double getLength() const;
01910 protected:
01911         virtual Envelope* computeEnvelopeInternal() const;
01912         CoordinateSequence* points;
01913 private:
01914 #ifdef INT64_CONST_IS_I64
01915         static const int64 serialVersionUID = 3110669828065365560I64;
01916 #else
01917         static const int64 serialVersionUID = 3110669828065365560LL;
01918 #endif        
01919 };
01920 
01931 class LinearRing : public LineString{
01932 
01933 public:
01934 
01935         LinearRing(const LinearRing &lr);
01936 
01948         LinearRing(CoordinateSequence* points, const GeometryFactory *newFactory);
01949 
01950         virtual Geometry *clone() const;
01951         virtual ~LinearRing();
01952         bool isSimple() const;
01953         string getGeometryType() const;
01954         virtual GeometryTypeId getGeometryTypeId() const;
01955         bool isClosed() const;
01956         void setPoints(CoordinateSequence* cl);
01957 private:
01958 #ifdef INT64_CONST_IS_I64
01959         static const int64 serialVersionUID = -4261142084085851829I64;
01960 #else
01961         static const int64 serialVersionUID = -4261142084085851829LL;
01962 #endif        
01963         void validateConstruction();
01964 };
01965 
01981 class Polygon: public Geometry{
01982 public:
01983         Polygon(const Polygon &p);
01984         virtual ~Polygon();
01985 
02004         Polygon(LinearRing *newShell, vector<Geometry *> *newHoles,
02005                 const GeometryFactory *newFactory);
02006 
02007         virtual Geometry *clone() const;
02008         CoordinateSequence* getCoordinates() const;
02009         int getNumPoints() const;
02010 
02012         int getDimension() const;
02013 
02015         int getBoundaryDimension() const;
02016 
02023         Geometry* getBoundary() const;
02024 
02025         bool isEmpty() const;
02026         bool isSimple() const;
02027         
02029         const LineString* getExteriorRing() const;
02030 
02032         int getNumInteriorRing() const;
02033 
02035         const LineString* getInteriorRingN(int n) const;
02036 
02037         string getGeometryType() const;
02038         virtual GeometryTypeId getGeometryTypeId() const;
02039         bool equalsExact(const Geometry *other, double tolerance) const;
02040         void apply_rw(CoordinateFilter *filter);
02041         void apply_ro(CoordinateFilter *filter) const;
02042         void apply_rw(GeometryFilter *filter);
02043         void apply_ro(GeometryFilter *filter) const;
02044         Geometry* convexHull() const;
02045         void normalize();
02046         int compareToSameClass(const Geometry *p) const; //was protected
02047         const Coordinate* getCoordinate() const;
02048 
02049         double getArea() const;
02050 
02052         double getLength() const;
02053 
02054         void apply_rw(GeometryComponentFilter *filter);
02055         void apply_ro(GeometryComponentFilter *filter) const;
02056 protected:
02057         LinearRing *shell;
02058         vector<Geometry *> *holes; //Actually vector<LinearRing *>
02059         Envelope* computeEnvelopeInternal() const;
02060 private:
02061         void normalize(LinearRing *ring, bool clockwise);
02062 #ifdef INT64_CONST_IS_I64
02063         static const int64 serialVersionUID = -3494792200821764533I64;
02064 #else
02065         static const int64 serialVersionUID = -3494792200821764533LL;
02066 #endif        
02067 };
02068 
02073 class MultiPoint: public GeometryCollection{
02074 public:
02075 
02094         MultiPoint(vector<Geometry *> *newPoints, const GeometryFactory *newFactory);
02095 
02096         virtual ~MultiPoint();
02097 
02099         int getDimension() const;
02100 
02102         int getBoundaryDimension() const;
02103 
02105         Geometry* getBoundary() const;
02106 
02107         string getGeometryType() const;
02108         virtual GeometryTypeId getGeometryTypeId() const;
02109         //bool isValid() const;
02110         bool isSimple() const;
02111         bool equalsExact(const Geometry *other, double tolerance) const;
02112 protected:
02113         const Coordinate* getCoordinate(int n) const;
02114 private:
02115 #ifdef INT64_CONST_IS_I64
02116         static const int64 serialVersionUID = -8048474874175355449I64;
02117 #else
02118         static const int64 serialVersionUID = -8048474874175355449LL;
02119 #endif        
02120 };
02121 
02126 class MultiLineString: public GeometryCollection{
02127 public:
02128 
02148         MultiLineString(vector<Geometry *> *newLines, const GeometryFactory *newFactory);
02149 
02150         virtual ~MultiLineString();
02151 
02153         int getDimension() const;
02154 
02160         int getBoundaryDimension() const;
02161 
02163         Geometry* getBoundary() const;
02164 
02165         string getGeometryType() const;
02166         virtual GeometryTypeId getGeometryTypeId() const;
02167         bool isClosed() const;
02168         bool isSimple() const;
02169         bool equalsExact(const Geometry *other, double tolerance) const;
02170 private:
02171 #ifdef INT64_CONST_IS_I64
02172         static const int64 serialVersionUID = 8166665132445433741I64;
02173 #else
02174         static const int64 serialVersionUID = 8166665132445433741LL;
02175 #endif        
02176 };
02177 
02182 class MultiPolygon: public GeometryCollection {
02183 
02184 public:
02185 
02207         MultiPolygon(vector<Geometry *> *newPolys, const GeometryFactory *newFactory);
02208 
02209         virtual ~MultiPolygon();
02210 
02212         int getDimension() const;
02213 
02215         int getBoundaryDimension() const;
02216 
02222         Geometry* getBoundary() const;
02223 
02224         string getGeometryType() const;
02225         virtual GeometryTypeId getGeometryTypeId() const;
02226         bool isSimple() const;
02227         bool equalsExact(const Geometry *other, double tolerance) const;
02228 private:
02229 #ifdef INT64_CONST_IS_I64
02230         static const int64 serialVersionUID = -551033529766975875I64;
02231 #else
02232         static const int64 serialVersionUID = -551033529766975875LL;
02233 #endif        
02234 };
02235 
02241 class GeometryFactory {
02242 public:
02248         GeometryFactory();
02249 
02256         GeometryFactory(const PrecisionModel *pm, int newSRID, CoordinateSequenceFactory *nCoordinateSequenceFactory);
02257 
02264         GeometryFactory(CoordinateSequenceFactory *nCoordinateSequenceFactory);
02265 
02274         GeometryFactory(const PrecisionModel *pm);
02275 
02285         GeometryFactory(const PrecisionModel* pm, int newSRID);
02286 
02292         GeometryFactory(const GeometryFactory &gf);
02293 
02295         virtual ~GeometryFactory();
02296 
02297 //Skipped a lot of list to array convertors
02298 
02299         Point* createPointFromInternalCoord(const Coordinate* coord, const Geometry *exemplar) const;
02300 
02302         Geometry* toGeometry(const Envelope* envelope) const;
02303 
02305         const PrecisionModel* getPrecisionModel() const;
02306 
02308         Point* createPoint() const;
02309 
02311         Point* createPoint(const Coordinate& coordinate) const;
02312 
02314         Point* createPoint(CoordinateSequence *coordinates) const;
02315 
02317         Point* createPoint(const CoordinateSequence &coordinates) const;
02318 
02320         GeometryCollection* createGeometryCollection() const;
02321 
02323         GeometryCollection* createGeometryCollection(vector<Geometry *> *newGeoms) const;
02324 
02326         GeometryCollection* createGeometryCollection(const vector<Geometry *> &newGeoms) const;
02327 
02329         MultiLineString* createMultiLineString() const;
02330 
02332         MultiLineString* createMultiLineString(vector<Geometry *> *newLines) const;
02333 
02335         MultiLineString* createMultiLineString(const vector<Geometry *> &fromLines) const;
02336 
02338         MultiPolygon* createMultiPolygon() const;
02339 
02341         MultiPolygon* createMultiPolygon(vector<Geometry *> *newPolys) const;
02342 
02344         MultiPolygon* createMultiPolygon(const vector<Geometry *> &fromPolys) const;
02345 
02347         LinearRing* createLinearRing() const;
02348 
02350         LinearRing* createLinearRing(CoordinateSequence* newCoords) const;
02351 
02353         LinearRing* createLinearRing(const CoordinateSequence& coordinates) const;
02354 
02356         MultiPoint* createMultiPoint() const;
02357 
02359         MultiPoint* createMultiPoint(vector<Geometry *> *newPoints) const;
02360 
02362         MultiPoint* createMultiPoint(const vector<Geometry *> &fromPoints) const;
02363 
02365         MultiPoint* createMultiPoint(const CoordinateSequence &fromCoords) const;
02366 
02368         Polygon* createPolygon() const;
02369 
02371         Polygon* createPolygon(LinearRing *shell, vector<Geometry *> *holes) const;
02372 
02374         Polygon* createPolygon(const LinearRing &shell, const vector<Geometry *> &holes) const;
02375 
02377         LineString* createLineString() const;
02378 
02380         LineString* createLineString(CoordinateSequence* coordinates) const;
02381 
02383         LineString* createLineString(const CoordinateSequence& coordinates) const;
02384 
02386         Geometry* buildGeometry(vector<Geometry *> *geoms) const;
02387 
02389         Geometry* buildGeometry(const vector<Geometry *> &geoms) const;
02390         
02391         int getSRID() const {return SRID;};
02392 
02393         const CoordinateSequenceFactory* getCoordinateSequenceFactory() const {return coordinateListFactory;};
02394 
02396         Geometry* createGeometry(const Geometry *g) const;
02397 
02399         void destroyGeometry(Geometry *g) const;
02400 
02401 private:
02402         const PrecisionModel* precisionModel;
02403         int SRID;
02404 #ifdef INT64_CONST_IS_I64
02405         static const int64 serialVersionUID = -6820524753094095635I64;
02406 #else
02407         static const int64 serialVersionUID = -6820524753094095635LL;
02408 #endif        
02409         const CoordinateSequenceFactory *coordinateListFactory;
02410 };
02411 
02412 /*
02413  * Represents a planar triangle, and provides methods for calculating various
02414  * properties of triangles.
02415  */
02416 class Triangle {
02417 public:
02418         Coordinate p0,p1,p2;
02419         Triangle(const Coordinate& nP0,const Coordinate& nP1,const Coordinate& nP2);
02427         Coordinate* inCentre();
02428 };
02429 
02430 } // namespace geos
02431 #endif
02432 
02433 /**********************************************************************
02434  * $Log: geom.h,v $
02435  * Revision 1.35  2004/12/16 16:27:24  strk
02436  * Fixed LinearRing::clone() to return LinearRing instead of LineString
02437  *
02438  * Revision 1.34  2004/12/03 22:52:56  strk
02439  * enforced const return of CoordinateSequence::toVector() method to derivate classes.
02440  *
02441  * Revision 1.33  2004/12/03 16:22:36  frank
02442  * update to use I64 on MSVC for 64 bit integer constants, also toVector chg.
02443  *
02444  * Revision 1.32  2004/11/29 16:05:33  strk
02445  * Fixed a bug in LineIntersector::interpolateZ causing NaN values
02446  * to come out.
02447  * Handled dimensional collapses in ElevationMatrix.
02448  * Added ISNAN macro and changed ISNAN/FINITE macros to avoid
02449  * dispendious isnan() and finite() calls.
02450  *
02451  * Revision 1.31  2004/11/23 16:22:49  strk
02452  * Added ElevationMatrix class and components to do post-processing draping of overlayed geometries.
02453  *
02454  * Revision 1.30  2004/11/17 08:13:16  strk
02455  * Indentation changes.
02456  * Some Z_COMPUTATION activated by default.
02457  *
02458  * Revision 1.29  2004/11/08 10:57:42  strk
02459  * Moved Log lines at the bottom, and cut oldest
02460  *
02461  * Revision 1.28  2004/10/13 10:03:02  strk
02462  * Added missing linemerge and polygonize operation.
02463  * Bug fixes and leaks removal from the newly added modules and
02464  * planargraph (used by them).
02465  * Some comments and indentation changes.
02466  *
02467  * Revision 1.27  2004/09/16 09:48:06  strk
02468  * Added Envelope::equals
02469  *
02470  * Revision 1.26  2004/09/13 12:39:14  strk
02471  * Made Point and MultiPoint subject to Validity tests.
02472  *
02473  * Revision 1.25  2004/09/07 08:29:57  strk
02474  * Fixed doxygen malformed comment for Coordinate class
02475  *
02476  * Revision 1.24  2004/07/27 16:35:46  strk
02477  * Geometry::getEnvelopeInternal() changed to return a const Envelope *.
02478  * This should reduce object copies as once computed the envelope of a
02479  * geometry remains the same.
02480  *
02481  * Revision 1.23  2004/07/26 16:35:19  strk
02482  * Removed dangling MultiPoint::isClosed() method definition.
02483  *
02484  * Revision 1.22  2004/07/22 16:58:01  strk
02485  * runtime version extractor functions split. geos::version() is now
02486  * geos::geosversion() and geos::jtsport()
02487  *
02488  **********************************************************************/

Generated on Tue Apr 19 07:10:17 2005 for GEOS by  doxygen 1.4.2