util.h

00001 /**********************************************************************
00002  * $Id: util.h,v 1.8 2004/11/01 16:43:04 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_UTIL_H
00017 #define GEOS_UTIL_H
00018 
00019 #include <memory>
00020 #include <string>
00021 #include <geos/platform.h>
00022 #include <geos/geom.h>
00023 
00024 using namespace std;
00025 
00026 namespace geos {
00027 
00036 class GEOSException {
00037 public:
00038         GEOSException();
00039 
00040         GEOSException(string msg);
00041 
00043         GEOSException(string nname,string msg);
00044 
00045         virtual ~GEOSException();
00046 
00048         virtual string toString();
00049 
00050         virtual void setName(string nname);
00051         virtual void setMessage(string msg);
00052 protected:
00053         string txt;
00054         string name;
00055 };
00056 
00060 class AssertionFailedException: public GEOSException {
00061 public:
00062         AssertionFailedException();
00063         AssertionFailedException(string msg);
00064         ~AssertionFailedException();
00065 };
00066 
00074 class IllegalArgumentException: public GEOSException {
00075 public:
00076         IllegalArgumentException();
00077         IllegalArgumentException(string msg);
00078         ~IllegalArgumentException();
00079 };
00080 
00088 class TopologyException: public GEOSException {
00089 public:
00090         TopologyException(string msg);
00091         TopologyException(string msg,const Coordinate *newPt);
00092         ~TopologyException();
00093         Coordinate* getCoordinate();
00094 private:
00095         Coordinate *pt;
00096 };
00097 
00106 class UnsupportedOperationException: public GEOSException {
00107 public:
00108         UnsupportedOperationException();
00109         UnsupportedOperationException(string msg);
00110         ~UnsupportedOperationException();
00111 };
00112 
00113 class Coordinate;
00114 class Assert {
00115 public:
00116         static void isTrue(bool assertion);
00117         static void isTrue(bool assertion, string message);
00118 
00119         static void equals(const Coordinate& expectedValue, const Coordinate& actualValue);
00120         static void equals(const Coordinate& expectedValue, const Coordinate& actualValue, string message);
00121 
00122         static void shouldNeverReachHere();
00123         static void shouldNeverReachHere(string message);
00124 };
00125 
00126 class CoordinateArrayFilter:public CoordinateFilter {
00127 public:
00128         CoordinateSequence* pts;
00129         int n;
00130         CoordinateArrayFilter(int size);
00131         virtual ~CoordinateArrayFilter();
00132         virtual const CoordinateSequence* getCoordinates() const;
00133         virtual void filter_ro(const Coordinate &coord);
00134         virtual void filter_rw(Coordinate &coord); // Unsopported
00135 };
00136 
00137 class UniqueCoordinateArrayFilter:public CoordinateFilter {
00138 public:
00139         CoordinateSequence *list;
00140         UniqueCoordinateArrayFilter();
00141         virtual ~UniqueCoordinateArrayFilter();
00142         virtual const CoordinateSequence* getCoordinates() const;
00143         virtual void filter_ro(const Coordinate *coord);
00144         virtual void filter_rw(Coordinate *coord); // Unsupported
00145 };
00146 
00147 
00157 class GeometricShapeFactory {
00158 private:
00159         class Dimensions {
00160         public:
00161                 Dimensions();
00162                 Coordinate base;
00163                 Coordinate centre;
00164                 double width;
00165                 double height;
00166                 void setBase(const Coordinate& newBase);
00167                 void setCentre(const Coordinate& newCentre);
00168                 void setSize(double size);
00169                 void setWidth(double nWidth);
00170                 void setHeight(double nHeight);
00171                 Envelope* getEnvelope();
00172         };
00173         const GeometryFactory* geomFact;
00174         Dimensions dim;
00175         int nPts;
00176 public:
00187         GeometricShapeFactory(const GeometryFactory *factory);
00188 
00189         ~GeometricShapeFactory();
00190 
00196         LineString* createArc(double startAng,double endAng);
00197 
00203         Polygon* createCircle();
00204 
00210         Polygon* createRectangle();
00211 
00220         void setBase(const Coordinate& base);
00221 
00229         void setCentre(const Coordinate& centre);
00230 
00236         void setHeight(double height);
00237 
00241         void setNumPoints(int nNPts);
00242 
00249         void setSize(double size);
00250 
00256         void setWidth(double width);
00257 
00258 };
00259 
00260 }
00261 #endif
00262 
00263 /**********************************************************************
00264  * $Log: util.h,v $
00265  * Revision 1.8  2004/11/01 16:43:04  strk
00266  * Added Profiler code.
00267  * Temporarly patched a bug in DoubleBits (must check drawbacks).
00268  * Various cleanups and speedups.
00269  *
00270  * Revision 1.7  2004/07/16 10:28:41  strk
00271  * Dimesions object allocated on the heap
00272  *
00273  * Revision 1.6  2004/07/14 21:19:35  strk
00274  * GeometricShapeFactory first pass of bug fixes
00275  *
00276  * Revision 1.5  2004/07/08 19:34:49  strk
00277  * Mirrored JTS interface of CoordinateSequence, factory and
00278  * default implementations.
00279  * Added DefaultCoordinateSequenceFactory::instance() function.
00280  *
00281  * Revision 1.4  2004/07/07 10:29:54  strk
00282  * Adjusted exceptions documentation.
00283  *
00284  * Revision 1.3  2004/07/05 14:23:03  strk
00285  * More documentation cleanups.
00286  *
00287  * Revision 1.2  2004/07/05 10:50:21  strk
00288  * deep-dopy construction taken out of Geometry and implemented only
00289  * in GeometryFactory.
00290  * Deep-copy geometry construction takes care of cleaning up copies
00291  * on exception.
00292  * Implemented clone() method for CoordinateSequence
00293  * Changed createMultiPoint(CoordinateSequence) signature to reflect
00294  * copy semantic (by-ref instead of by-pointer).
00295  * Cleaned up documentation.
00296  *
00297  * Revision 1.1  2004/07/02 13:20:42  strk
00298  * Header files moved under geos/ dir.
00299  *
00300  * Revision 1.14  2004/04/10 22:41:25  ybychkov
00301  * "precision" upgraded to JTS 1.4
00302  *
00303  * Revision 1.13  2004/03/18 10:42:44  ybychkov
00304  * "IO" and "Util" upgraded to JTS 1.4
00305  * "Geometry" partially upgraded.
00306  *
00307  * Revision 1.12  2003/11/07 01:23:42  pramsey
00308  * Add standard CVS headers licence notices and copyrights to all cpp and h
00309  * files.
00310  *
00311  *
00312  **********************************************************************/
00313 

Generated on Mon Nov 6 20:45:02 2006 for GEOS by  doxygen 1.5.1