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

geom.h

00001 /**********************************************************************
00002  * $Id: geom.h,v 1.34.2.1 2005/05/23 18:16:40 strk Exp $
00003  *
00004  * GEOS - Geometry Engine Open Source
00005  * http://geos.refractions.net
00006  *
00007  * Copyright (C) 2001-2002 Vivid Solutions Inc.
00008  * Copyright (C) 2005 Refractions Research Inc.
00009  *
00010  * This is free software; you can redistribute and/or modify it under
00011  * the terms of the GNU Lesser General Public Licence as published
00012  * by the Free Software Foundation. 
00013  * See the COPYING file for more information.
00014  *
00015  **********************************************************************/
00016 
00017 #ifndef GEOS_GEOM_H
00018 #define GEOS_GEOM_H
00019 
00020 #include <memory>
00021 #include <iostream>
00022 #include <string>
00023 #include <vector>
00024 #include <algorithm>
00025 #include <map>
00026 #include <cmath>
00027 #include <geos/platform.h>
00028 
00029 using namespace std;
00030 
00034 namespace geos {
00035 
00037 string geosversion();
00038 
00044 string jtsport();
00045 
00047 enum GeometryTypeId {
00049         GEOS_POINT,
00051         GEOS_LINESTRING,
00053         GEOS_LINEARRING,
00055         GEOS_POLYGON,
00057         GEOS_MULTIPOINT,
00059         GEOS_MULTILINESTRING,
00061         GEOS_MULTIPOLYGON,
00063         GEOS_GEOMETRYCOLLECTION
00064 };
00065 
00066 class Coordinate;
00067 
00109 class PrecisionModel {
00110 friend class Unload;
00111 public:
00113         /*
00114         * This class is only for use to support the "enums"
00115         * for the types of precision model.
00116         */
00117         typedef enum {
00118 
00125                 FIXED,
00126 
00132                 FLOATING,
00133 
00139                 FLOATING_SINGLE
00140 
00141         } Type;
00142         
00144         PrecisionModel(void);
00145 
00147 
00152         PrecisionModel(Type nModelType);
00153 
00154         /*
00155          * Creates a <code>PrecisionModel</code> with Fixed precision.
00156          *
00157          * Fixed-precision coordinates are represented as precise internal
00158          * coordinates, which are rounded to the grid defined by the
00159          * scale factor.
00160          *
00161          * @param  scale
00162          *      amount by which to multiply a coordinate after subtracting
00163          *      the offset, to obtain a precise coordinate
00164          * @param  offsetX  not used.
00165          * @param  offsetY  not used.
00166          *
00167          * @deprecated offsets are no longer supported, since internal
00168          * representation is rounded floating point
00169          */
00170         PrecisionModel(double newScale, double newOffsetX, double newOffsetY);
00171 
00183         PrecisionModel(double newScale);
00184 
00185         // copy constructor
00186         PrecisionModel(const PrecisionModel &pm);
00187 
00189         virtual ~PrecisionModel(void);
00190 
00191 
00193 
00198         static const double maximumPreciseValue;
00199 
00201         double makePrecise(double val) const;
00202 
00204         void makePrecise(Coordinate *coord) const;
00205 
00207 
00211         bool isFloating() const;
00212 
00214 
00219         int getMaximumSignificantDigits() const;
00220 
00222 
00225         Type getType() const;
00226 
00228         double getScale() const;
00229 
00230         /*
00231         * Returns the x-offset used to obtain a precise coordinate.
00232         *
00233         * @return the amount by which to subtract the x-coordinate before
00234         *         multiplying by the scale
00235         * @deprecated Offsets are no longer used
00236         */
00237         double getOffsetX() const;
00238 
00239         /*
00240         * Returns the y-offset used to obtain a precise coordinate.
00241         *
00242         * @return the amount by which to subtract the y-coordinate before
00243         *         multiplying by the scale
00244         * @deprecated Offsets are no longer used
00245         */
00246         double getOffsetY() const;
00247 
00248         /*
00249          *  Sets <code>internal</code> to the precise representation of <code>external</code>.
00250          *
00251          * @param external the original coordinate
00252          * @param internal the coordinate whose values will be changed to the
00253          *                 precise representation of <code>external</code>
00254          * @deprecated use makePrecise instead
00255          */
00256         void toInternal(const Coordinate& external, Coordinate* internal) const;
00257 
00258         /*
00259         *  Returns the precise representation of <code>external</code>.
00260         *
00261         *@param  external  the original coordinate
00262         *@return
00263         *       the coordinate whose values will be changed to the precise
00264         *       representation of <code>external</code>
00265         * @deprecated use makePrecise instead
00266         */
00267         Coordinate* toInternal(const Coordinate& external) const;
00268 
00269         /*
00270         *  Returns the external representation of <code>internal</code>.
00271         *
00272         *@param  internal  the original coordinate
00273         *@return           the coordinate whose values will be changed to the
00274         *      external representation of <code>internal</code>
00275         * @deprecated no longer needed, since internal representation is same as external representation
00276         */
00277         Coordinate* toExternal(const Coordinate& internal) const;
00278 
00279         /*
00280         *  Sets <code>external</code> to the external representation of
00281         *  <code>internal</code>.
00282         *
00283         * @param  internal  the original coordinate
00284         * @param  external
00285         *       the coordinate whose values will be changed to the
00286         *       external representation of <code>internal</code>
00287         * @deprecated no longer needed, since internal representation is same as external representation
00288         */
00289         void toExternal(const Coordinate& internal, Coordinate* external) const;
00290 
00291         string toString() const;
00292 
00294 
00308         int compareTo(const PrecisionModel* other) const;
00309 
00310 private:
00311         void setScale(double newScale);
00312         Type modelType;
00313         double scale;
00314 #ifdef INT64_CONST_IS_I64
00315         static const int64 serialVersionUID = 7777263578777803835I64;
00316 #else        
00317         static const int64 serialVersionUID = 7777263578777803835LL;
00318 #endif        
00319 };
00320 
00341 class Coordinate {
00342 public:
00343         //void setNull(void);
00344         //static Coordinate& getNull(void);
00345         virtual ~Coordinate(){};
00346         //Coordinate(double xNew, double yNew, double zNew);
00347         //Coordinate(const Coordinate& c);
00348         //Coordinate(double xNew, double yNew);
00349         //void setCoordinate(Coordinate& other);
00350         //bool equals2D(Coordinate& other);
00351         //int compareTo(Coordinate& other);
00352         //bool equals3D(Coordinate& other);
00353         string toString() const;
00354         //void makePrecise();
00355         //double distance(Coordinate& p);
00356         static Coordinate nullCoord;
00357 
00358         void Coordinate::setNull() {
00359                 x=DoubleNotANumber;
00360                 y=DoubleNotANumber;
00361                 z=DoubleNotANumber;
00362         }
00363 
00364         static Coordinate& Coordinate::getNull() {
00365                 return nullCoord;
00366         }
00367 
00368         Coordinate::Coordinate() {
00369                 x=0.0;
00370                 y=0.0;
00371                 z=DoubleNotANumber;
00372         }
00373 
00374         Coordinate::Coordinate(double xNew, double yNew, double zNew) {
00375                 x=xNew;
00376                 y=yNew;
00377                 z=zNew;
00378         }
00379 
00380         Coordinate::Coordinate(const Coordinate& c){
00381                 x=c.x;
00382                 y=c.y;
00383                 z=c.z;
00384         }
00385 
00386         Coordinate::Coordinate(double xNew, double yNew){
00387                 x=xNew;
00388                 y=yNew;
00389                 z=DoubleNotANumber;
00390         }
00391 
00392         void Coordinate::setCoordinate(const Coordinate& other) {
00393                 x = other.x;
00394                 y = other.y;
00395                 z = other.z;
00396         }
00397 
00398         bool Coordinate::equals2D(const Coordinate& other) const {
00399                 if (x != other.x) {
00400                 return false;
00401                 }
00402                 if (y != other.y) {
00403                 return false;
00404                 }
00405                 return true;
00406         }
00407 
00408         int Coordinate::compareTo(const Coordinate& other) const {
00409                 if (x < other.x) {
00410                 return -1;
00411                 }
00412                 if (x > other.x) {
00413                 return 1;
00414                 }
00415                 if (y < other.y) {
00416                 return -1;
00417                 }
00418                 if (y > other.y) {
00419                 return 1;
00420                 }
00421                 return 0;
00422         }
00423 
00424         bool Coordinate::equals3D(const Coordinate& other) const {
00425                 return (x == other.x) && ( y == other.y) && ((z == other.z)||(ISNAN(z) && ISNAN(other.z)));
00426         }
00427 
00428         void Coordinate::makePrecise(const PrecisionModel *precisionModel) {
00429                 x = precisionModel->makePrecise(x);
00430                 y = precisionModel->makePrecise(y);
00431         }
00432 
00433         double Coordinate::distance(const Coordinate& p) const {
00434                 double dx = x - p.x;
00435                 double dy = y - p.y;
00436                 return sqrt(dx * dx + dy * dy);
00437         }
00438 
00439         int Coordinate::hashCode() {
00440                 //Algorithm from Effective Java by Joshua Bloch [Jon Aquino]
00441                 int result = 17;
00442                 result = 37 * result + hashCode(x);
00443                 result = 37 * result + hashCode(y);
00444                 return result;
00445         }
00446 
00451         static int Coordinate::hashCode(double x) {
00452                 int64 f = (int64)(x);
00453                 return (int)(f^(f>>32));
00454         }
00455 
00456 
00458         double x;
00460         double y;
00462         double z;
00463 
00464 private:
00465 #ifdef INT64_CONST_IS_I64
00466         static const int64 serialVersionUID=6683108902428366910I64;
00467 #else
00468         static const int64 serialVersionUID=6683108902428366910LL;
00469 #endif
00470 
00471 };
00472 
00473 
00474 //* class CoordinateList geom.h geos.h
00475 //*
00476 //* brief A list of Coordinates, which may be set to prevent
00477 //* repeated coordinates from occuring in the list.
00478 //
00479 //class CoordinateList {
00480 //public:
00481 //      ~CoordinateList(){};
00482 //
00483 //      // copy constructor
00484 //      CoordinateList(const CoordinateList &cl);
00485 //
00486 //      // constructor an empty CoordinateList
00487 //      CoordinateList();
00488 //
00489 //      /*
00490 //       * Constructs a new list from a vector of Coordinates.
00491 //       * Caller can specify if repeated points are to be removed.
00492 //       * Default is allowing repeated points.
00493 //       * Will take ownership of coords.
00494 //       */
00495 //      CoordinateList(vector<Coordinate> *coords, bool allowRepeted=false);
00496 //
00497 //      // Get a reference to the nth Coordinate 
00498 //      const Coordinate& getCoordinate(int n) const;
00499 //
00500 //      /*
00501 //       * \brief Add an array of coordinates 
00502 //       * @param vc The coordinates
00503 //       * @param allowRepeated if set to false, repeated coordinates
00504 //       *      are collapsed
00505 //       * @return true (as by general collection contract)
00506 //       */
00507 //      void add(vector<Coordinate>* vc, bool allowRepeated);
00508 //
00509 //      /*
00510 //       * \brief Add an array of coordinates 
00511 //       * @param cl The coordinates
00512 //       * @param allowRepeated if set to false, repeated coordinates
00513 //       * are collapsed
00514 //       * @param direction if false, the array is added in reverse order
00515 //       * @return true (as by general collection contract)
00516 //       */
00517 //      void add(CoordinateList *cl,bool allowRepeated,bool direction);
00518 //
00519 //      /*
00520 //       * \brief Add a coordinate
00521 //       * @param c The coordinate to add
00522 //       * @param allowRepeated if set to false, repeated coordinates
00523 //       * are collapsed
00524 //       * @return true (as by general collection contract)
00525 //       */
00526 //      void add(const Coordinate& c,bool allowRepeated);
00527 //
00528 //      // Add a Coordinate to the list
00529 //      void add(const Coordinate& c);
00530 //
00531 //      // Get vector
00532 //      const vector<Coordinate>* toCoordinateArray() const;
00533 //
00534 //private:
00535 //
00536 //      vector<Coordinate> *vect;
00537 //};
00538 
00558 class CoordinateSequence {
00559 public:
00560         virtual ~CoordinateSequence(){};
00561 
00565         virtual CoordinateSequence *clone() const=0;
00566 
00573         //virtual const Coordinate& getCoordinate(int i) const=0;
00574         virtual const Coordinate& getAt(int i) const=0;
00575 
00580         //virtual int size() const=0;
00581         virtual int getSize() const=0;
00582 
00592         virtual const vector<Coordinate>* toVector() const=0;
00593 
00601         void add(const vector<Coordinate>* vc, bool allowRepeated);
00602 
00603         /* This is here for backward compatibility.. */
00604         void add(CoordinateSequence *cl,bool allowRepeated,bool direction);
00605 
00614         void add(const CoordinateSequence *cl,bool allowRepeated,bool direction);
00615 
00623         void add(const Coordinate& c,bool allowRepeated);
00624 
00626         virtual bool isEmpty() const=0;
00627 
00629         virtual void add(const Coordinate& c)=0;
00630 
00631         // Get number of coordinates
00632         //virtual int getSize() const=0;
00633 
00635         //virtual       const Coordinate& getAt(int pos) const=0;
00636 
00638         virtual void setAt(const Coordinate& c, int pos)=0;
00639 
00641         virtual void deleteAt(int pos)=0;
00642 
00644         virtual string toString() const=0;
00645 
00647         virtual void setPoints(const vector<Coordinate> &v)=0;
00648         
00650         bool hasRepeatedPoints() const;
00651 
00653         const Coordinate* minCoordinate() const;
00654 
00655 
00657         static CoordinateSequence* removeRepeatedPoints(const CoordinateSequence *cl);
00658 
00663         static bool hasRepeatedPoints(const CoordinateSequence *cl);
00664 
00669         static CoordinateSequence* atLeastNCoordinatesOrNothing(int n, CoordinateSequence *c);
00670 
00676         static const Coordinate* minCoordinate(CoordinateSequence *cl);
00677 
00679         static int indexOf(const Coordinate *coordinate, const CoordinateSequence *cl);
00685         static bool equals(CoordinateSequence *cl1, CoordinateSequence *cl2);
00686 
00688         static void scroll(CoordinateSequence *cl, const Coordinate *firstCoordinate);
00689 
00691         static void reverse(CoordinateSequence *cl);
00692 
00693 };
00694 
00700 class DefaultCoordinateSequence : public CoordinateSequence {
00701 public:
00702 
00703         DefaultCoordinateSequence(const DefaultCoordinateSequence &cl);
00704 
00705         CoordinateSequence *clone() const;
00706 
00707         //const Coordinate& getCoordinate(int pos) const;
00708         const Coordinate& getAt(int pos) const;
00709 
00710         //int size() const;
00711         int getSize() const;
00712         const vector<Coordinate>* toVector() const;
00713 
00715         DefaultCoordinateSequence();
00716 
00718         DefaultCoordinateSequence(vector<Coordinate> *coords);
00719 
00721         DefaultCoordinateSequence(int n);
00722 
00723         virtual ~DefaultCoordinateSequence();
00724 
00725         bool isEmpty() const;
00726         void add(const Coordinate& c);
00727         void setAt(const Coordinate& c, int pos);
00728         void deleteAt(int pos);
00729         string toString() const;
00730         void setPoints(const vector<Coordinate> &v);
00731 private:
00732         vector<Coordinate> *vect;
00733 };
00734 
00735 struct point_3d {
00736         double x;
00737         double y;
00738         double z;
00739 };
00740 
00741 class PointCoordinateSequence : public CoordinateSequence {
00742 public:
00743         PointCoordinateSequence();
00744         PointCoordinateSequence(int n);
00745         PointCoordinateSequence(const Coordinate& c);
00746         PointCoordinateSequence(const PointCoordinateSequence &cl);
00747         PointCoordinateSequence(const CoordinateSequence *c);
00748         virtual ~PointCoordinateSequence();
00749         CoordinateSequence *clone() const;
00750         bool isEmpty() const;
00751         void add(const Coordinate& c);
00752         void add(point_3d p);
00753         int getSize() const;
00754         const Coordinate& getAt(int pos) const;
00755         point_3d getPointAt(int pos);
00756         void setAt(const Coordinate& c, int pos);
00757         void setAt(point_3d p, int pos);
00758         void deleteAt(int pos);
00759         const vector<Coordinate>* toVector() const;
00760         vector<point_3d>* toPointVector();
00761         string toString() const;
00762         void setPoints(const vector<Coordinate> &v);
00763         void setPoints(vector<point_3d> &v);
00764 private:
00765         vector<point_3d> *vect;
00766         mutable vector<Coordinate>*cached_vector;
00767 };
00768 
00776 class CoordinateSequenceFactory {
00777 public:
00778         // create an empty CoordinateSequence
00779         //virtual CoordinateSequence* createCoordinateSequence()=0;
00780 
00781         // create an empty CoordinateSequence with 'size' Coordinate slots
00782         //virtual CoordinateSequence* createCoordinateSequence(int size)=0;
00783 
00784         //virtual CoordinateSequence* createCoordinateSequence(const Coordinate& c)=0;
00785         // create an CoordinateSequence containing the given Coordinate 
00786         //virtual CoordinateSequence* createCoordinateSequence(const CoordinateSequence *c)=0;
00787 
00797         virtual CoordinateSequence *create(vector<Coordinate> *coordinates) const=0;
00798 };
00799 
00807 class DefaultCoordinateSequenceFactory: public CoordinateSequenceFactory {
00808 
00809 public:
00810         // create an empty DefaultCoordinateSequence
00811         //CoordinateSequence *createCoordinateSequence() {return new DefaultCoordinateSequence();};
00812         // create an empty DefaultCoordinateSequence with 'size' Coordinate slots
00813         //CoordinateSequence* createCoordinateSequence(int size) {return new DefaultCoordinateSequence(size);};
00814         //CoordinateSequence* createCoordinateSequence(const Coordinate& c) {return new DefaultCoordinateSequence(c);};
00815 
00816         // create an DefaultCoordinateSequence containing the given Coordinate 
00817         //CoordinateSequence* createCoordinateSequence(const CoordinateSequence *cl) {return new DefaultCoordinateSequence(cl);};
00818 
00819 
00824         CoordinateSequence *create(vector<Coordinate> *coords) const;
00825 
00829         static const CoordinateSequenceFactory *instance();
00830 };
00831 
00832 /*
00833  * \class PointCoordinateSequenceFactory geom.h geos.h
00834  *
00835  * \brief
00836  * Factory for PointCoordinateSequence objects.
00837  */
00838 class PointCoordinateSequenceFactory: public CoordinateSequenceFactory {
00839 public:
00840 
00841         CoordinateSequence *create(vector<Coordinate> *coords) const;
00842 };
00843 
00844 /*
00845  * <code>Geometry</code> classes support the concept of applying a
00846  * coordinate filter to every coordinate in the <code>Geometry</code>. A
00847  * coordinate filter can either record information about each coordinate or
00848  * change the coordinate in some way. Coordinate filters implement the
00849  * interface <code>CoordinateFilter</code>. (<code>CoordinateFilter</code> is
00850  * an example of the Gang-of-Four Visitor pattern). Coordinate filters can be
00851  * used to implement such things as coordinate transformations, centroid and
00852  * envelope computation, and many other functions.
00853  *
00854  */
00855 class CoordinateFilter {
00856 public:
00857    virtual ~CoordinateFilter() {}
00863    virtual void filter_rw(Coordinate* coord)=0;
00864    virtual void filter_ro(const Coordinate* coord)=0;
00865 };
00866 
00867 class Geometry;
00868 
00869 /*
00870  *  <code>Geometry</code> classes support the concept of applying
00871  *  a <code>GeometryComponentFilter</code>
00872  *  filter to the <code>Geometry</code>.
00873  *  The filter is applied to every component of the <code>Geometry</code>
00874  *  which is itself a <code>Geometry</code>.
00875  *  A <code>GeometryComponentFilter</code> filter can either
00876  *  record information about the <code>Geometry</code>
00877  *  or change the <code>Geometry</code> in some way.
00878  *  <code>GeometryComponentFilter</code>
00879  *  is an example of the Gang-of-Four Visitor pattern.
00880  *
00881  */
00882 class GeometryComponentFilter {
00883 public:
00889 //      virtual void filter(Geometry *geom)=0;
00890         virtual void filter_rw(Geometry *geom);
00891         virtual void filter_ro(const Geometry *geom); // Unsupported
00892 };
00893 
00894 
00895 /*
00896  * Constants representing the dimensions of a point, a curve and a surface.
00897  * Also, constants representing the dimensions of the empty geometry and
00898  * non-empty geometries, and a wildcard dimension meaning "any dimension".
00899  * 
00900  */
00901 class Dimension {
00902 public:
00903         enum {
00904                 DONTCARE=-3,    
00905                 True,                   
00906                 False,                  
00907                 P,                              
00908                 L,                              
00909                 A                               
00910         };
00911         //static const int P = 0;                       /// Dimension value of a point (0).
00912         //static const int L = 1;                       /// Dimension value of a curve (1).
00913         //static const int A = 2;                       /// Dimension value of a surface (2).
00914         //static const int False = -1;  /// Dimension value of the empty geometry (-1).
00915         //static const int True = -2;           /// Dimension value of non-empty geometries (= {P, L, A}).
00916         //static const int DONTCARE = -3;       /// Dimension value for any dimension (= {FALSE, TRUE}).
00917         static char toDimensionSymbol(int dimensionValue);
00918         static int toDimensionValue(char dimensionSymbol);
00919 };
00920 
00938 class Envelope {
00939 public:
00940         Envelope(void);
00941         Envelope(double x1, double x2, double y1, double y2);
00942         Envelope(const Coordinate& p1, const Coordinate& p2);
00943         Envelope(const Coordinate& p);
00944         Envelope(const Envelope &env);
00945         virtual ~Envelope(void);
00946         static bool intersects(const Coordinate& p1,const Coordinate& p2,const Coordinate& q);
00947         static bool intersects(const Coordinate& p1,const Coordinate& p2,const Coordinate& q1,const Coordinate& q2);
00948         void init(void);
00949         void init(double x1, double x2, double y1, double y2);
00950         void init(const Coordinate& p1, const Coordinate& p2);
00951         void init(const Coordinate& p);
00952         void init(Envelope env);
00953         void setToNull(void);
00954         bool isNull(void) const;
00955         double getWidth(void) const;
00956         double getHeight(void) const;
00957         double getMaxY() const;
00958         double getMaxX() const;
00959         double getMinY() const;
00960         double getMinX() const;
00961         void expandToInclude(const Coordinate& p);
00962         void expandToInclude(double x, double y);
00963         void expandToInclude(const Envelope* other);
00964         bool contains(const Coordinate& p) const;
00965         bool contains(double x, double y) const;
00966         bool contains(const Envelope* other) const;
00967         bool overlaps(const Coordinate& p) const;
00968         bool overlaps(double x, double y) const;
00969         bool overlaps(const Envelope* other) const;
00970         bool intersects(const Coordinate& p) const;
00971         bool intersects(double x, double y) const;
00972         bool intersects(const Envelope* other) const;
00973         bool equals(const Envelope* other) const;
00974         string toString(void) const;
00975         double distance(const Envelope* env) const;
00976         int hashCode() const;
00977 
00978 private:
00979         static double distance(double x0,double y0,double x1,double y1);
00980         double minx;    
00981         double maxx;    
00982         double miny;    
00983         double maxy;    
00984 #ifdef INT64_CONST_IS_I64
00985         static const int64 serialVersionUID=5873921885273102420I64;
00986 #else        
00987         static const int64 serialVersionUID=5873921885273102420LL;
00988 #endif        
00989 };
00990 
00991 class Geometry;
00992 class GeometryFilter;
00993 class IntersectionMatrix;
00994 
00995 
00996 class CGAlgorithms;
00997 class Point;
00998 class GeometryFactory;
00999 
01083 class Geometry{
01084 friend class Unload;
01085 public:
01086 
01087         Geometry(const Geometry &geom);
01088 
01095         Geometry(const GeometryFactory *factory);
01096 
01098         virtual ~Geometry();
01099 
01101         virtual Geometry* clone() const=0;
01102 
01110         const GeometryFactory* getFactory() const;
01111 
01125         void setUserData(void* newUserData);
01126 
01133         void* getUserData();
01134 
01135         /*
01136          * \brief
01137          * Returns the ID of the Spatial Reference System used by the
01138          * <code>Geometry</code>.
01139          *
01140          * GEOS supports Spatial Reference System information in the simple way
01141          * defined in the SFS. A Spatial Reference System ID (SRID) is present
01142          * in each <code>Geometry</code> object. <code>Geometry</code>
01143          * provides basic accessor operations for this field, but no others.
01144          * The SRID is represented as an integer.
01145          *
01146          * @return the ID of the coordinate space in which the
01147          * <code>Geometry</code> is defined.
01148          *
01149          * @deprecated use getUserData instead
01150          */
01151         virtual int getSRID() const;
01152 
01153         /*
01154          * Sets the ID of the Spatial Reference System used by the
01155          * <code>Geometry</code>.
01156          * @deprecated use setUserData instead
01157          */
01158         virtual void setSRID(int newSRID);
01159 
01164         virtual const PrecisionModel* getPrecisionModel() const;
01165 
01167         virtual const Coordinate* getCoordinate() const=0; //Abstract
01168 
01174         virtual CoordinateSequence* getCoordinates() const=0; //Abstract
01175 
01177         virtual int getNumPoints() const=0; //Abstract
01178 
01180         virtual bool isSimple() const=0; //Abstract
01181 
01183         virtual string getGeometryType() const=0; //Abstract
01184 
01186         virtual GeometryTypeId getGeometryTypeId() const=0; //Abstract
01187 
01197         virtual bool isValid() const;
01198 
01200         virtual bool isEmpty() const=0; //Abstract
01201 
01203         virtual int getDimension() const=0; //Abstract
01204 
01210         virtual Geometry* getBoundary() const=0; //Abstract
01211 
01213         virtual int getBoundaryDimension() const=0; //Abstract
01214 
01216         virtual Geometry* getEnvelope() const;
01217 
01222         virtual const Envelope* getEnvelopeInternal() const;
01223 
01229         virtual bool disjoint(const Geometry *other) const;
01230 
01235         virtual bool touches(const Geometry *other) const;
01236 
01238         virtual bool intersects(const Geometry *g) const;
01239 
01246         virtual bool crosses(const Geometry *g) const;
01247 
01252         virtual bool within(const Geometry *g) const;
01253 
01255         virtual bool contains(const Geometry *g) const;
01256 
01262         virtual bool overlaps(const Geometry *g) const;
01263 
01275         virtual bool relate(const Geometry *g, string intersectionPattern) const;
01277         virtual IntersectionMatrix* relate(const Geometry *g) const;
01278 
01284         virtual bool equals(const Geometry *g) const;
01285 
01287         virtual string toString() const;
01288 
01289         virtual string toText() const;
01290         
01292         virtual Geometry* buffer(double distance) const;
01293 
01295         virtual Geometry* buffer(double distance,int quadrantSegments) const;
01296 
01298         virtual Geometry* convexHull() const;
01299 
01304         virtual Geometry* intersection(const Geometry *other) const;
01305 
01310         virtual Geometry* Union(const Geometry *other) const;
01311                 // throw(IllegalArgumentException *, TopologyException *);
01312 
01318         virtual Geometry* difference(const Geometry *other) const;
01319 
01324         virtual Geometry* symDifference(const Geometry *other) const;
01325 
01330         virtual bool equalsExact(const Geometry *other, double tolerance)
01331                 const=0; //Abstract
01332 
01333         virtual void apply_rw(CoordinateFilter *filter)=0; //Abstract
01334         virtual void apply_ro(CoordinateFilter *filter) const=0; //Abstract
01335         virtual void apply_rw(GeometryFilter *filter);
01336         virtual void apply_ro(GeometryFilter *filter) const;
01337         virtual void apply_rw(GeometryComponentFilter *filter);
01338         virtual void apply_ro(GeometryComponentFilter *filter) const;
01339 
01341         virtual void normalize()=0; //Abstract
01342 
01343         virtual int compareTo(const Geometry *geom) const;
01344 
01349         virtual double distance(const Geometry *g) const;
01350 
01352         virtual double getArea() const;
01353 
01355         virtual double getLength() const;
01356 
01361         virtual bool isWithinDistance(const Geometry *geom,double cDistance);
01362 
01364         virtual Point* getCentroid() const;
01365 
01367         virtual Point* getInteriorPoint();
01368 
01369         /*
01370          * \brief
01371          * Notifies this Geometry that its Coordinates have been changed
01372          * by an external party (using a CoordinateFilter, for example).
01373          */
01374         virtual void geometryChanged();
01375 
01376         /*
01377          * \brief
01378          * Notifies this Geometry that its Coordinates have been changed
01379          * by an external party.
01380          */
01381         void geometryChangedAction();
01382 
01383 protected:
01384         mutable Envelope* envelope;
01385         
01387         static bool hasNonEmptyElements(const vector<Geometry *>* geometries);
01388 
01390         static bool hasNullElements(const CoordinateSequence* list);
01391 
01393         static bool hasNullElements(const vector<Geometry *>* lrs);
01394 
01395 //      static void reversePointOrder(CoordinateSequence* coordinates);
01396 //      static Coordinate& minCoordinate(CoordinateSequence* coordinates);
01397 //      static void scroll(CoordinateSequence* coordinates,Coordinate* firstCoordinate);
01398 //      static int indexOf(Coordinate* coordinate,CoordinateSequence* coordinates);
01399 //
01404         virtual bool isEquivalentClass(const Geometry *other) const;
01405 
01406         static void checkNotGeometryCollection(const Geometry *g); // throw(IllegalArgumentException *);
01407         //virtual void checkEqualSRID(Geometry *other);
01408         //virtual void checkEqualPrecisionModel(Geometry *other);
01409         virtual Envelope* computeEnvelopeInternal() const=0; //Abstract
01410         virtual int compareToSameClass(const Geometry *geom) const=0; //Abstract
01411         int compare(vector<Coordinate> a, vector<Coordinate> b) const;
01412         int compare(vector<Geometry *> a, vector<Geometry *> b) const;
01413         bool equal(const Coordinate& a, const Coordinate& b,double tolerance) const;
01414         int SRID;
01415 
01428         Geometry* toInternalGeometry(const Geometry *g) const;
01429         Geometry* fromInternalGeometry(const Geometry *g) const;
01430 private:
01431         virtual int getClassSortIndex() const;
01432         static GeometryComponentFilter geometryChangedFilter;
01433 #ifdef INT64_CONST_IS_I64
01434     static const int64 serialVersionUID = 8763622679187376702I64;
01435 #else
01436     static const int64 serialVersionUID = 8763622679187376702LL;
01437 #endif
01438         const GeometryFactory *factory;
01439         static const GeometryFactory* INTERNAL_GEOMETRY_FACTORY;
01440         void* userData;
01441         Point* createPointFromInternalCoord(const Coordinate* coord,const Geometry *exemplar) const;
01442 };
01443 
01444 /*
01445  * Geometry classes support the concept of applying a Geometry
01446  * filter to the Geometry. In the case of GeometryCollection
01447  * subclasses, the filter is applied to every element Geometry.
01448  * A Geometry filter can either record information about the Geometry
01449  * or change the Geometry in some way.
01450  * Geometry filters implement the interface GeometryFilter.
01451  * (GeometryFilter is an example of the Gang-of-Four Visitor pattern).
01452  */
01453 class GeometryFilter {
01454 public:
01455         /*
01456          * Performs an operation with or on <code>geom</code>.
01457          *
01458          * @param  geom  a <code>Geometry</code> to which the filter
01459          *         is applied.
01460          */
01461         virtual void filter_ro(const Geometry *geom)=0;
01462         virtual void filter_rw(Geometry *geom)=0;
01463 };
01464 
01465 /*
01466  * Represents a line segment defined by two {@link Coordinate}s.
01467  * Provides methods to compute various geometric properties
01468  * and relationships of line segments.
01469  * 
01470  * This class is designed to be easily mutable (to the extent of
01471  * having its contained points public).
01472  * This supports a common pattern of reusing a single LineSegment
01473  * object as a way of computing segment properties on the
01474  * segments defined by arrays or lists of {@link Coordinate}s.
01475  *
01476  */
01477 class LineSegment {
01478 public:
01479         Coordinate p0; 
01480         Coordinate p1; 
01481         LineSegment(void);
01482         LineSegment(const LineSegment &ls);
01483         LineSegment(const Coordinate& c0, const Coordinate& c1);
01484         virtual ~LineSegment(void);
01485         virtual void setCoordinates(const Coordinate& c0, const Coordinate& c1);
01486         virtual const Coordinate& getCoordinate(int i) const;
01487         virtual void setCoordinates(const LineSegment ls);
01488         virtual double getLength() const;
01494         virtual bool isHorizontal() const;
01500         virtual bool isVertical() const;
01520         virtual int orientationIndex(LineSegment *seg) const;
01521         virtual void reverse();
01522         virtual void normalize();
01523         virtual double angle() const;
01524         virtual double distance(const LineSegment ls) const;
01528         virtual double distance(const Coordinate& p) const;
01533         virtual double distancePerpendicular(const Coordinate& p) const;
01534         virtual double projectionFactor(const Coordinate& p) const;
01535         virtual Coordinate* project(const Coordinate& p) const;
01536         virtual LineSegment* project(const LineSegment *seg) const;
01537         virtual Coordinate* closestPoint(const Coordinate& p) const;
01538         virtual int compareTo(const LineSegment other) const;
01539         virtual bool equalsTopo(const LineSegment other) const;
01540 
01547         virtual CoordinateSequence* closestPoints(const LineSegment *line);
01548 
01560         Coordinate* intersection(const LineSegment *line) const;
01561         virtual string toString() const;
01562 private:
01563 #ifdef INT64_CONST_IS_I64
01564   static const int64 serialVersionUID=3252005833466256227I64;
01565 #else
01566   static const int64 serialVersionUID=3252005833466256227LL;
01567 #endif
01568 
01569 };
01570 
01571 class IntersectionMatrix {
01572 public:
01573         IntersectionMatrix();
01574         IntersectionMatrix(string elements);
01575         IntersectionMatrix(const IntersectionMatrix &im);
01576         virtual ~IntersectionMatrix();
01577         static bool matches(int actualDimensionValue, char requiredDimensionSymbol);
01578         static bool matches(string actualDimensionSymbols, string requiredDimensionSymbols);
01579         void add(IntersectionMatrix *im);
01580         void set(int row, int column, int dimensionValue);
01581         void set(string dimensionSymbols);
01582         void setAtLeast(int row, int column, int minimumDimensionValue);
01583         void setAtLeastIfValid(int row, int column, int minimumDimensionValue);
01584         void setAtLeast(string minimumDimensionSymbols);
01585         void setAll(int dimensionValue);
01586         int get(int row, int column);
01587         bool isDisjoint();
01588         bool isIntersects();
01589         bool isTouches(int dimensionOfGeometryA, int dimensionOfGeometryB);
01590         bool isCrosses(int dimensionOfGeometryA, int dimensionOfGeometryB);
01591         bool isWithin();
01592         bool isContains();
01593         bool isEquals(int dimensionOfGeometryA, int dimensionOfGeometryB);
01594         bool isOverlaps(int dimensionOfGeometryA, int dimensionOfGeometryB);
01595         bool matches(string requiredDimensionSymbols);
01596         IntersectionMatrix* transpose();
01597         string toString();
01598 private:
01599         int matrix[3][3];
01600 };
01601 
01602 /*
01603  *  Constants representing the location of a point relative to a geometry. They
01604  *  can also be thought of as the row or column index of a DE-9IM matrix. For a
01605  *  description of the DE-9IM, see the <A
01606  *  HREF="http://www.opengis.org/techno/specs.htm">OpenGIS Simple Features
01607  *  Specification for SQL</A> .
01608  */
01609 class Location {
01610 public:
01611         enum {
01615                 UNDEF=-1,   
01616 
01621                 INTERIOR,
01627                 BOUNDARY,
01633                 EXTERIOR = 2
01634         };
01635         //static const int INTERIOR = 0;
01636         //static const int BOUNDARY = 1;
01637         //static const int EXTERIOR = 2;
01638         //static const int UNDEF = -1;   ///Instead of NULL
01639         static char toLocationSymbol(int locationValue);
01640 };
01641 
01642 
01643 //Operators
01644 bool operator==(const Coordinate& a, const Coordinate& b);
01645 bool operator!=(const Coordinate& a, const Coordinate& b);
01646 bool operator==(const Envelope a, const Envelope b);
01647 bool operator==(const PrecisionModel a, const PrecisionModel b);
01648 bool operator==(const LineSegment a, const LineSegment b);
01649 
01650 bool lessThen(Coordinate& a,Coordinate& b);
01651 bool greaterThen(Geometry *first, Geometry *second);
01652 
01662 class GeometryCollection : public Geometry{
01663 public:
01664         GeometryCollection(const GeometryCollection &gc);
01665 
01690         GeometryCollection(vector<Geometry *> *newGeoms, const GeometryFactory *newFactory);
01691 
01692         virtual Geometry *clone() const;
01693 
01694         virtual ~GeometryCollection();
01695 
01709         virtual CoordinateSequence* getCoordinates() const;
01710 
01711         virtual bool isEmpty() const;
01712 
01718         virtual int getDimension() const;
01719 
01720         virtual Geometry* getBoundary() const;
01721 
01727         virtual int getBoundaryDimension() const;
01728 
01729         virtual int getNumPoints() const;
01730         virtual string getGeometryType() const;
01731         virtual GeometryTypeId getGeometryTypeId() const;
01732         virtual bool isSimple() const;
01733         virtual bool equalsExact(const Geometry *other, double tolerance) const;
01734 
01735         virtual void apply_ro(CoordinateFilter *filter) const;
01736         virtual void apply_rw(CoordinateFilter *filter);
01737         virtual void apply_ro(GeometryFilter *filter) const;
01738         virtual void apply_rw(GeometryFilter *filter);
01739         virtual void apply_ro(GeometryComponentFilter *filter) const;
01740         virtual void apply_rw(GeometryComponentFilter *filter);
01741         virtual void normalize();
01742         virtual const Coordinate* getCoordinate() const;
01744         virtual double getArea() const;
01746         virtual double getLength() const;
01748         virtual int getNumGeometries() const;
01750         virtual const Geometry* getGeometryN(int n) const;
01751 protected:
01752         vector<Geometry *>* geometries;
01753         virtual Envelope* computeEnvelopeInternal() const;
01754         virtual int compareToSameClass(const Geometry *gc) const;
01755 private:
01756 #ifdef INT64_CONST_IS_I64
01757         static const int64 serialVersionUID = -5694727726395021467I64;
01758 #else
01759         static const int64 serialVersionUID = -5694727726395021467LL;
01760 #endif        
01761 };
01762 
01763 class GeometryCollectionIterator {
01764 public:
01765         GeometryCollectionIterator();
01766         GeometryCollectionIterator(const GeometryCollectionIterator &gci);
01767         GeometryCollectionIterator(const GeometryCollection *newParent);
01768         virtual ~GeometryCollectionIterator();
01769         bool hasNext() const;
01770         const Geometry *next();
01771         void remove(); //Not implemented
01772 private:
01773         const GeometryCollection* parent;
01774         bool atStart;
01775         int max;
01776         int index;
01777         GeometryCollectionIterator* subcollectionIterator;
01778 };
01779 
01784 class Point : public Geometry{
01785 public:
01786 
01799         Point(CoordinateSequence *newCoords, const GeometryFactory *newFactory);
01800 
01801         Point(const Point &p); 
01802         virtual ~Point();
01803         Geometry *clone() const;
01804         CoordinateSequence* getCoordinates(void) const;
01805         int getNumPoints() const;
01806         bool isEmpty() const;
01807         bool isSimple() const;
01808         //bool isValid() const;
01809 
01811         int getDimension() const;
01812 
01814         int getBoundaryDimension() const;
01815 
01817         Geometry* getBoundary() const;
01818 
01819         double getX() const;
01820         double getY() const;
01821         const Coordinate* getCoordinate() const;
01822         string getGeometryType() const;
01823         virtual GeometryTypeId getGeometryTypeId() const;
01824         void apply_ro(CoordinateFilter *filter) const;
01825         void apply_rw(CoordinateFilter *filter);
01826         void apply_ro(GeometryFilter *filter) const;
01827         void apply_rw(GeometryFilter *filter);
01828         void apply_rw(GeometryComponentFilter *filter);
01829         void apply_ro(GeometryComponentFilter *filter) const;
01830         bool equalsExact(const Geometry *other, double tolerance) const;
01831         void normalize(void) { };
01832 protected:
01833         Envelope* computeEnvelopeInternal() const;
01834         int compareToSameClass(const Geometry *p) const;
01835 private:
01839         CoordinateSequence *coordinates;
01840 #ifdef INT64_CONST_IS_I64
01841         static const int64 serialVersionUID = 4902022702746614570I64;
01842 #else        
01843         static const int64 serialVersionUID = 4902022702746614570LL;
01844 #endif        
01845 };
01846 
01851 class LineString: public Geometry {
01852 public:
01853         LineString(const LineString &ls);
01854 
01856         LineString(CoordinateSequence *pts, const GeometryFactory *newFactory);
01857 
01858         virtual ~LineString();
01859         virtual Geometry *clone() const;
01860         virtual CoordinateSequence* getCoordinates() const;
01861 
01863         const CoordinateSequence* getCoordinatesRO() const;
01864 
01865         virtual const Coordinate& getCoordinateN(int n) const;
01866 
01868         virtual int getDimension() const;
01869 
01875         virtual int getBoundaryDimension() const;
01876 
01882         virtual Geometry* getBoundary() const;
01883 
01884         virtual bool isEmpty() const;
01885         virtual int getNumPoints() const;
01886         virtual Point* getPointN(int n) const;
01887         virtual Point* getStartPoint() const;
01888         virtual Point* getEndPoint() const;
01889         virtual bool isClosed() const;
01890         virtual bool isRing() const;
01891         virtual string getGeometryType() const;
01892         virtual GeometryTypeId getGeometryTypeId() const;
01893         virtual bool isSimple() const;
01894         virtual bool isCoordinate(Coordinate& pt) const;
01895         virtual bool equalsExact(const Geometry *other, double tolerance) const;
01896         virtual void apply_rw(CoordinateFilter *filter);
01897         virtual void apply_ro(CoordinateFilter *filter) const;
01898         virtual void apply_rw(GeometryFilter *filter);
01899         virtual void apply_ro(GeometryFilter *filter) const;
01900         virtual void apply_rw(GeometryComponentFilter *filter);
01901         virtual void apply_ro(GeometryComponentFilter *filter) const;
01902 
01904         virtual void normalize();
01905 
01906         //was protected
01907         virtual int compareToSameClass(const Geometry *ls) const;
01908         virtual int compareTo(const LineString *ls) const;
01909         virtual const Coordinate* getCoordinate() const;
01910         virtual double getLength() const;
01911 protected:
01912         virtual Envelope* computeEnvelopeInternal() const;
01913         CoordinateSequence* points;
01914 private:
01915 #ifdef INT64_CONST_IS_I64
01916         static const int64 serialVersionUID = 3110669828065365560I64;
01917 #else
01918         static const int64 serialVersionUID = 3110669828065365560LL;
01919 #endif        
01920 };
01921 
01932 class LinearRing : public LineString{
01933 
01934 public:
01935 
01936         LinearRing(const LinearRing &lr);
01937 
01949         LinearRing(CoordinateSequence* points, const GeometryFactory *newFactory);
01950 
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.34.2.1  2005/05/23 18:16:40  strk
02436  * more math.h to cmath conversions
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 Mon Sep 19 20:59:55 2005 for GEOS by  doxygen 1.4.4