| 1 | // types and functions for internal use
|
|---|
| 2 | #ifndef SHAPE_INT_H
|
|---|
| 3 | #define SHAPE_INT_H
|
|---|
| 4 | #include "ruby_min.h"
|
|---|
| 5 |
|
|---|
| 6 | #include <vector>
|
|---|
| 7 |
|
|---|
| 8 | typedef struct _ShpReadContext {
|
|---|
| 9 | size_t readSize;
|
|---|
| 10 | size_t readRecordContentSize;
|
|---|
| 11 | } ShpReadContext;
|
|---|
| 12 |
|
|---|
| 13 | /*interface*/
|
|---|
| 14 | class ShpRecordObject
|
|---|
| 15 | {
|
|---|
| 16 | public:
|
|---|
| 17 | virtual ~ShpRecordObject(){};
|
|---|
| 18 | virtual VALUE toRubyObject() = 0;
|
|---|
| 19 | virtual ShpRecordObject* clone() = 0;
|
|---|
| 20 | virtual es_error_t readFromMainFile(FILE* fp, ShpReadContext& rctx) = 0;
|
|---|
| 21 |
|
|---|
| 22 | int mDebugIndex;
|
|---|
| 23 | };
|
|---|
| 24 |
|
|---|
| 25 | typedef std::vector<ShpRecordObject*> RecordContentList;
|
|---|
| 26 |
|
|---|
| 27 | class IndexedPointList
|
|---|
| 28 | {
|
|---|
| 29 | public:
|
|---|
| 30 | IndexedPointList();
|
|---|
| 31 | virtual ~IndexedPointList();
|
|---|
| 32 | void copyFrom(const IndexedPointList& aSrc);
|
|---|
| 33 | VALUE getPartAsRubyObj(int index);
|
|---|
| 34 |
|
|---|
| 35 | void allocBuffers();
|
|---|
| 36 | void freeBuffers();
|
|---|
| 37 |
|
|---|
| 38 | ESDouble mBounds[4];
|
|---|
| 39 | ESInt32 mNParts;
|
|---|
| 40 | ESInt32 mNPoints;
|
|---|
| 41 |
|
|---|
| 42 | ESInt32* mPartIndexes;
|
|---|
| 43 | ESPointEx* mPoints;
|
|---|
| 44 |
|
|---|
| 45 | ESDouble mZRange[2];
|
|---|
| 46 | ESDouble mMRange[2];
|
|---|
| 47 |
|
|---|
| 48 | es_error_t readFromMainFile(FILE* fp, ShpReadContext& rctx, int option);
|
|---|
| 49 | };
|
|---|
| 50 |
|
|---|
| 51 |
|
|---|
| 52 | #define SHPRECORD_WITH_Z 0x1
|
|---|
| 53 | #define SHPRECORD_WITH_M 0x2
|
|---|
| 54 |
|
|---|
| 55 | class ShpPolygon : public ShpRecordObject
|
|---|
| 56 | {
|
|---|
| 57 | public:
|
|---|
| 58 | ShpPolygon(int option);
|
|---|
| 59 | virtual ~ShpPolygon();
|
|---|
| 60 | virtual VALUE toRubyObject();
|
|---|
| 61 | virtual ShpRecordObject* clone();
|
|---|
| 62 |
|
|---|
| 63 | VALUE getPartAt(int index);
|
|---|
| 64 | VALUE getBoundingBox();
|
|---|
| 65 | int getPartsLength();
|
|---|
| 66 |
|
|---|
| 67 | void markRubyGC();
|
|---|
| 68 |
|
|---|
| 69 | es_error_t readFromMainFile(FILE* fp, ShpReadContext& rctx);
|
|---|
| 70 | private:
|
|---|
| 71 | ESInt32 mType;
|
|---|
| 72 | IndexedPointList mPList;
|
|---|
| 73 | int mOption;
|
|---|
| 74 | };
|
|---|
| 75 |
|
|---|
| 76 | class ShpPolyline : public ShpRecordObject
|
|---|
| 77 | {
|
|---|
| 78 | public:
|
|---|
| 79 | ShpPolyline(int option);
|
|---|
| 80 | virtual ~ShpPolyline();
|
|---|
| 81 | virtual VALUE toRubyObject();
|
|---|
| 82 | virtual ShpRecordObject* clone();
|
|---|
| 83 | VALUE getPartAt(int index);
|
|---|
| 84 | int getPartsLength();
|
|---|
| 85 |
|
|---|
| 86 | es_error_t readFromMainFile(FILE* fp, ShpReadContext& rctx);
|
|---|
| 87 | private:
|
|---|
| 88 | ESInt32 mType;
|
|---|
| 89 | IndexedPointList mPList;
|
|---|
| 90 | int mOption;
|
|---|
| 91 | };
|
|---|
| 92 |
|
|---|
| 93 | class ShpPoint : public ShpRecordObject
|
|---|
| 94 | {
|
|---|
| 95 | public:
|
|---|
| 96 | ShpPoint(int option);
|
|---|
| 97 | ShpPoint(ESDouble x, ESDouble y, ESDouble z, ESDouble m);
|
|---|
| 98 | virtual ~ShpPoint();
|
|---|
| 99 | virtual VALUE toRubyObject();
|
|---|
| 100 | virtual ShpRecordObject* clone();
|
|---|
| 101 |
|
|---|
| 102 | ESDouble getX() const{ return mX; }
|
|---|
| 103 | ESDouble getY() const{ return mY; }
|
|---|
| 104 | ESDouble getZ() const{ return mZ; }
|
|---|
| 105 | ESDouble getM() const{ return mM; }
|
|---|
| 106 |
|
|---|
| 107 | es_error_t readFromMainFile(FILE* fp, ShpReadContext& rctx);
|
|---|
| 108 | private:
|
|---|
| 109 | ESDouble mX;
|
|---|
| 110 | ESDouble mY;
|
|---|
| 111 | ESDouble mZ;
|
|---|
| 112 | ESDouble mM;
|
|---|
| 113 | ESInt32 mType;
|
|---|
| 114 | int mOption;
|
|---|
| 115 | };
|
|---|
| 116 |
|
|---|
| 117 | #endif |
|---|