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

util.h

00001 /**********************************************************************
00002  * $Id: util.h,v 1.7 2004/07/16 10:28:41 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  * $Log: util.h,v $
00016  * Revision 1.7  2004/07/16 10:28:41  strk
00017  * Dimesions object allocated on the heap
00018  *
00019  * Revision 1.6  2004/07/14 21:19:35  strk
00020  * GeometricShapeFactory first pass of bug fixes
00021  *
00022  * Revision 1.5  2004/07/08 19:34:49  strk
00023  * Mirrored JTS interface of CoordinateSequence, factory and
00024  * default implementations.
00025  * Added DefaultCoordinateSequenceFactory::instance() function.
00026  *
00027  * Revision 1.4  2004/07/07 10:29:54  strk
00028  * Adjusted exceptions documentation.
00029  *
00030  * Revision 1.3  2004/07/05 14:23:03  strk
00031  * More documentation cleanups.
00032  *
00033  * Revision 1.2  2004/07/05 10:50:21  strk
00034  * deep-dopy construction taken out of Geometry and implemented only
00035  * in GeometryFactory.
00036  * Deep-copy geometry construction takes care of cleaning up copies
00037  * on exception.
00038  * Implemented clone() method for CoordinateSequence
00039  * Changed createMultiPoint(CoordinateSequence) signature to reflect
00040  * copy semantic (by-ref instead of by-pointer).
00041  * Cleaned up documentation.
00042  *
00043  * Revision 1.1  2004/07/02 13:20:42  strk
00044  * Header files moved under geos/ dir.
00045  *
00046  * Revision 1.14  2004/04/10 22:41:25  ybychkov
00047  * "precision" upgraded to JTS 1.4
00048  *
00049  * Revision 1.13  2004/03/18 10:42:44  ybychkov
00050  * "IO" and "Util" upgraded to JTS 1.4
00051  * "Geometry" partially upgraded.
00052  *
00053  * Revision 1.12  2003/11/07 01:23:42  pramsey
00054  * Add standard CVS headers licence notices and copyrights to all cpp and h
00055  * files.
00056  *
00057  *
00058  **********************************************************************/
00059 
00060 
00061 /*
00062 * $Log: util.h,v $
00063 * Revision 1.7  2004/07/16 10:28:41  strk
00064 * Dimesions object allocated on the heap
00065 *
00066 * Revision 1.6  2004/07/14 21:19:35  strk
00067 * GeometricShapeFactory first pass of bug fixes
00068 *
00069 * Revision 1.5  2004/07/08 19:34:49  strk
00070 * Mirrored JTS interface of CoordinateSequence, factory and
00071 * default implementations.
00072 * Added DefaultCoordinateSequenceFactory::instance() function.
00073 *
00074 * Revision 1.4  2004/07/07 10:29:54  strk
00075 * Adjusted exceptions documentation.
00076 *
00077 * Revision 1.3  2004/07/05 14:23:03  strk
00078 * More documentation cleanups.
00079 *
00080 * Revision 1.2  2004/07/05 10:50:21  strk
00081 * deep-dopy construction taken out of Geometry and implemented only
00082 * in GeometryFactory.
00083 * Deep-copy geometry construction takes care of cleaning up copies
00084 * on exception.
00085 * Implemented clone() method for CoordinateSequence
00086 * Changed createMultiPoint(CoordinateSequence) signature to reflect
00087 * copy semantic (by-ref instead of by-pointer).
00088 * Cleaned up documentation.
00089 *
00090 * Revision 1.1  2004/07/02 13:20:42  strk
00091 * Header files moved under geos/ dir.
00092 *
00093 * Revision 1.14  2004/04/10 22:41:25  ybychkov
00094 * "precision" upgraded to JTS 1.4
00095 *
00096 * Revision 1.13  2004/03/18 10:42:44  ybychkov
00097 * "IO" and "Util" upgraded to JTS 1.4
00098 * "Geometry" partially upgraded.
00099 *
00100 * Revision 1.12  2003/11/07 01:23:42  pramsey
00101 * Add standard CVS headers licence notices and copyrights to all cpp and h
00102 * files.
00103 *
00104 * Revision 1.11  2003/10/23 09:12:49  strk
00105 * Made CoordinateArrayFilter destructor virtual.
00106 *
00107 * Revision 1.10  2003/10/16 17:05:07  strk
00108 * Made TopologyException inherit from GEOSException. Adjusted IllegalArgumentException subclassing.
00109 *
00110 */
00111 #ifndef GEOS_UTIL_H
00112 #define GEOS_UTIL_H
00113 
00114 #include <memory>
00115 #include <string>
00116 #include <geos/platform.h>
00117 #include <geos/geom.h>
00118 
00119 using namespace std;
00120 
00121 namespace geos {
00122 
00131 class GEOSException {
00132 public:
00133         GEOSException();
00134 
00135         GEOSException(string msg);
00136 
00138         GEOSException(string nname,string msg);
00139 
00140         virtual ~GEOSException();
00141 
00143         virtual string toString();
00144 
00145         virtual void setName(string nname);
00146         virtual void setMessage(string msg);
00147 protected:
00148         string txt;
00149         string name;
00150 };
00151 
00155 class AssertionFailedException: public GEOSException {
00156 public:
00157         AssertionFailedException();
00158         AssertionFailedException(string msg);
00159         ~AssertionFailedException();
00160 };
00161 
00169 class IllegalArgumentException: public GEOSException {
00170 public:
00171         IllegalArgumentException();
00172         IllegalArgumentException(string msg);
00173         ~IllegalArgumentException();
00174 };
00175 
00183 class TopologyException: public GEOSException {
00184 public:
00185         TopologyException(string msg);
00186         TopologyException(string msg,const Coordinate *newPt);
00187         ~TopologyException();
00188         Coordinate* getCoordinate();
00189 private:
00190         Coordinate *pt;
00191 };
00192 
00201 class UnsupportedOperationException: public GEOSException {
00202 public:
00203         UnsupportedOperationException();
00204         UnsupportedOperationException(string msg);
00205         ~UnsupportedOperationException();
00206 };
00207 
00208 class Coordinate;
00209 class Assert {
00210 public:
00211         static void isTrue(bool assertion);
00212         static void isTrue(bool assertion, string message);
00213 
00214         static void equals(const Coordinate& expectedValue, const Coordinate& actualValue);
00215         static void equals(const Coordinate& expectedValue, const Coordinate& actualValue, string message);
00216 
00217         static void shouldNeverReachHere();
00218         static void shouldNeverReachHere(string message);
00219 };
00220 
00221 class CoordinateArrayFilter:public CoordinateFilter {
00222 public:
00223         CoordinateSequence* pts;
00224         int n;
00225         CoordinateArrayFilter(int size);
00226         virtual ~CoordinateArrayFilter();
00227         virtual const CoordinateSequence* getCoordinates() const;
00228         virtual void filter_ro(const Coordinate &coord);
00229         virtual void filter_rw(Coordinate &coord); // Unsopported
00230 };
00231 
00232 class UniqueCoordinateArrayFilter:public CoordinateFilter {
00233 public:
00234         CoordinateSequence *list;
00235         UniqueCoordinateArrayFilter();
00236         virtual ~UniqueCoordinateArrayFilter();
00237         virtual const CoordinateSequence* getCoordinates() const;
00238         virtual void filter_ro(const Coordinate *coord);
00239         virtual void filter_rw(Coordinate *coord); // Unsupported
00240 };
00241 
00242 
00252 class GeometricShapeFactory {
00253 private:
00254         class Dimensions {
00255         public:
00256                 Dimensions();
00257                 Coordinate base;
00258                 Coordinate centre;
00259                 double width;
00260                 double height;
00261                 void setBase(const Coordinate& newBase);
00262                 void setCentre(const Coordinate& newCentre);
00263                 void setSize(double size);
00264                 void setWidth(double nWidth);
00265                 void setHeight(double nHeight);
00266                 Envelope* getEnvelope();
00267         };
00268         const GeometryFactory* geomFact;
00269         Dimensions dim;
00270         int nPts;
00271 public:
00282         GeometricShapeFactory(const GeometryFactory *factory);
00283 
00284         ~GeometricShapeFactory();
00285 
00291         LineString* createArc(double startAng,double endAng);
00292 
00298         Polygon* createCircle();
00299 
00305         Polygon* createRectangle();
00306 
00315         void setBase(const Coordinate& base);
00316 
00324         void setCentre(const Coordinate& centre);
00325 
00331         void setHeight(double height);
00332 
00336         void setNumPoints(int nNPts);
00337 
00344         void setSize(double size);
00345 
00351         void setWidth(double width);
00352 
00353 };
00354 
00355 }
00356 #endif

Generated on Fri Nov 26 21:30:45 2004 for GEOS by  doxygen 1.3.9.1