pcidsk_vectorsegment.h

00001 /******************************************************************************
00002  *
00003  * Purpose:  PCIDSK Vector Segment public interface. Declaration.
00004  * 
00005  ******************************************************************************
00006  * Copyright (c) 2009
00007  * PCI Geomatics, 50 West Wilmot Street, Richmond Hill, Ont, Canada
00008  *
00009  * Permission is hereby granted, free of charge, to any person obtaining a
00010  * copy of this software and associated documentation files (the "Software"),
00011  * to deal in the Software without restriction, including without limitation
00012  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
00013  * and/or sell copies of the Software, and to permit persons to whom the
00014  * Software is furnished to do so, subject to the following conditions:
00015  *
00016  * The above copyright notice and this permission notice shall be included
00017  * in all copies or substantial portions of the Software.
00018  *
00019  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
00020  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
00021  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
00022  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
00023  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
00024  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
00025  * DEALINGS IN THE SOFTWARE.
00026  ****************************************************************************/
00027 
00028 #ifndef __INCLUDE_PCIDSK_VECTORSEGMENT_H
00029 #define __INCLUDE_PCIDSK_VECTORSEGMENT_H
00030 
00031 #include <string>
00032 #include <vector>
00033 #include <iterator>
00034 #include "pcidsk_shape.h"
00035 
00036 namespace PCIDSK
00037 {
00038     class ShapeIterator;
00039     
00040 /************************************************************************/
00041 /*                         PCIDSKVectorSegment                          */
00042 /************************************************************************/
00043 
00078     class PCIDSK_DLL PCIDSKVectorSegment
00079     {
00080     public:
00081         virtual ~PCIDSKVectorSegment() {}
00082 
00093         virtual std::string GetRst() = 0;
00094 
00095 
00105         virtual std::vector<double> GetProjection( std::string &geosys ) = 0;
00106 
00116         virtual int         GetFieldCount() = 0;
00117 
00124         virtual std::string GetFieldName(int field_index) = 0;
00125 
00132         virtual std::string GetFieldDescription(int field_index) = 0;
00133 
00140         virtual ShapeFieldType GetFieldType(int field_index) = 0;
00141 
00148         virtual std::string GetFieldFormat(int field_index) = 0;
00149 
00156         virtual ShapeField  GetFieldDefault(int field_index) = 0;
00157 
00162         virtual ShapeIterator begin() = 0;
00163 
00168         virtual ShapeIterator end() = 0;
00169 
00174         virtual ShapeId     FindFirst() = 0;
00175 
00181         virtual ShapeId     FindNext(ShapeId id) = 0;
00182         
00183 
00189         virtual int         GetShapeCount() = 0;
00190 
00196         virtual void        GetVertices( ShapeId id, 
00197                                          std::vector<ShapeVertex>& list ) = 0;
00198 
00204         virtual void        GetFields( ShapeId id, 
00205                                        std::vector<ShapeField>& list ) = 0;
00206 
00207 
00216         virtual void        SetProjection(std::string geosys,
00217                                           std::vector<double> parms ) = 0;
00218 
00229         virtual void        AddField( std::string name, ShapeFieldType type,
00230                                       std::string description,
00231                                       std::string format,
00232                                       ShapeField *default_value=NULL ) = 0;
00233 
00244         virtual ShapeId     CreateShape( ShapeId id = NullShapeId ) = 0;
00245 
00254         virtual void        DeleteShape( ShapeId id ) = 0;
00255 
00263         virtual void        SetVertices( ShapeId id, 
00264                                          const std::vector<ShapeVertex> &list ) = 0;
00265 
00266 
00276         virtual void        SetFields( ShapeId id, 
00277                                        const std::vector<ShapeField>& list) = 0;
00278 
00279 // Methods needed 
00280         // DeleteField
00281     };
00282 
00283 /************************************************************************/
00284 /*                            ShapeIterator                             */
00285 /************************************************************************/
00286 
00288 
00289     class ShapeIterator : public std::iterator<std::input_iterator_tag, ShapeId>
00290     {
00291         ShapeId id;
00292         PCIDSKVectorSegment *seg;
00293         
00294     public:
00295         ShapeIterator(PCIDSKVectorSegment *seg_in)
00296                 : seg(seg_in)  { id = seg->FindFirst(); }
00297         ShapeIterator(PCIDSKVectorSegment *seg_in, ShapeId id_in )
00298                 : id(id_in), seg(seg_in)  {}
00299         ShapeIterator(const ShapeIterator& mit) : id(mit.id), seg(mit.seg) {}
00300         ShapeIterator& operator++() { id=seg->FindNext(id); return *this;}
00301         ShapeIterator& operator++(int) { id=seg->FindNext(id); return *this;}
00302         bool operator==(const ShapeIterator& rhs) {return id == rhs.id;}
00303         bool operator!=(const ShapeIterator& rhs) {return id != rhs.id;}
00304         ShapeId& operator*() {return id;}
00305     };
00306 
00307 } // end namespace PCIDSK
00308 
00309 #endif // __INCLUDE_PCIDSK_VECTORSEGMENT_H

Generated on Fri Jul 16 16:01:31 2010 for libpcidsk by  doxygen 1.5.1