Complete Note#1 in the http://wiki.osgeo.org/wiki/GEOS_Provenance_Review to get out...
[geos.git] / examples / CustomCoordinateSequenceExample.h
blob38ecd5f5237d8316c1ae72dc6210d8f931341488
1 /**********************************************************************
3 * GEOS - Geometry Engine Open Source
4 * http://geos.osgeo.org
6 * Copyright (C) 2001-2002 Vivid Solutions Inc.
8 * This is free software; you can redistribute and/or modify it under
9 * the terms of the GNU Lesser General Public Licence as published
10 * by the Free Software Foundation.
11 * See the COPYING file for more information.
13 **********************************************************************
14 * $Log$
15 * Revision 1.2 2006/04/04 08:16:46 strk
16 * Changed GEOSException hierarchy to be derived from std::runtime_exception.
17 * Removed the GEOSException::toString redundant method (use ::what() instead)
19 * Revision 1.1 2004/07/08 19:41:27 strk
20 * renamed to reflect JTS API.
22 * Revision 1.8 2004/07/02 13:28:26 strk
23 * Fixed all #include lines to reflect headers layout change.
24 * Added client application build tips in README.
26 * Revision 1.7 2003/11/07 01:23:42 pramsey
27 * Add standard CVS headers licence notices and copyrights to all cpp and h
28 * files.
31 **********************************************************************/
34 #ifndef GEOS_EX2_H
35 #define GEOS_EX2_H
37 #include <geos/platform.h>
38 #include <geos/geom.h>
39 #include <geos/util.h>
41 using namespace std;
42 using namespace geos;
45 * This is an example of how you can create a custom CoordinateSequence class that wraps
46 * your own way of storing lists of coordinates. Depending on your internal storage
47 * format some methods in the wrapper class might not work properly (but have to be
48 * preserved for the interface compatibility. In this example CustomPointCoordinateSequence
49 * wraps an array of point_3d. Since the array is fixed length, methods like 'add' or
50 * 'deleteAt' will not work.
52 class CustomPointCoordinateSequence : public BasicCoordinateSequence {
53 public:
54 CustomPointCoordinateSequence(point_3d *newPts,int newSize);
55 CustomPointCoordinateSequence(const CustomPointCoordinateSequence &cl);
56 bool isEmpty();
57 void add(Coordinate& c); //NoOp (exception)
58 void add(point_3d p); //NoOp (exception)
59 int getSize();
60 Coordinate& getAt(int pos);
61 point_3d getPointAt(int pos);
62 void setAt(Coordinate& c, int pos);
63 void setAt(point_3d p, int pos);
64 void deleteAt(int pos); //NoOp (exception)
65 vector<Coordinate>* toVector();
66 vector<point_3d>* toPointVector();
67 string toString();
68 void setPoints(const vector<Coordinate> &v);
69 void setPoints(const vector<point_3d> &v);
70 private:
71 point_3d *pts;
72 int size;
75 class CPCLException: public GEOSException {
76 public:
77 CPCLException();
78 CPCLException(const string& msg);
79 ~CPCLException();
82 #endif